...
|
...
|
@@ -114,9 +114,8 @@ static int ftp_get_line(FTPContext *s, char *line, int line_size)
|
114
|
114
|
|
115
|
115
|
/*
|
116
|
116
|
* This routine returns ftp server response code.
|
117
|
|
- * Server may send more than one response for a certain command, following priorities are used:
|
118
|
|
- * - When pref_codes are set then pref_code is return if occurred. (expected result)
|
119
|
|
- * - 0 is returned when no pref_codes or not occurred
|
|
117
|
+ * Server may send more than one response for a certain command.
|
|
118
|
+ * First expected code is returned.
|
120
|
119
|
*/
|
121
|
120
|
static int ftp_status(FTPContext *s, char **line, const int response_codes[])
|
122
|
121
|
{
|
...
|
...
|
@@ -404,7 +403,7 @@ static int ftp_connect_control_connection(URLContext *h)
|
404
|
404
|
return err;
|
405
|
405
|
}
|
406
|
406
|
|
407
|
|
- /* consume all messages from server */
|
|
407
|
+ /* check if server is ready */
|
408
|
408
|
if (ftp_status(s, NULL, connect_codes) != 220) {
|
409
|
409
|
av_log(h, AV_LOG_ERROR, "FTP server not ready for new users\n");
|
410
|
410
|
return AVERROR(EACCES);
|
...
|
...
|
@@ -571,6 +570,7 @@ static int64_t ftp_seek(URLContext *h, int64_t pos, int whence)
|
571
|
571
|
if (h->is_streamed)
|
572
|
572
|
return AVERROR(EIO);
|
573
|
573
|
|
|
574
|
+ /* XXX: Simulate behaviour of lseek in file protocol, which could be treated as a reference */
|
574
|
575
|
new_pos = FFMAX(0, new_pos);
|
575
|
576
|
fake_pos = s->filesize != -1 ? FFMIN(new_pos, s->filesize) : new_pos;
|
576
|
577
|
|
...
|
...
|
@@ -590,6 +590,7 @@ static int ftp_read(URLContext *h, unsigned char *buf, int size)
|
590
|
590
|
av_dlog(h, "ftp protocol read %d bytes\n", size);
|
591
|
591
|
retry:
|
592
|
592
|
if (s->state == DISCONNECTED) {
|
|
593
|
+ /* optimization */
|
593
|
594
|
if (s->position >= s->filesize)
|
594
|
595
|
return 0;
|
595
|
596
|
if ((err = ftp_connect_data_connection(h)) < 0)
|
...
|
...
|
@@ -607,6 +608,7 @@ static int ftp_read(URLContext *h, unsigned char *buf, int size)
|
607
|
607
|
s->position += read;
|
608
|
608
|
if (s->position >= s->filesize) {
|
609
|
609
|
/* server will terminate, but keep current position to avoid madness */
|
|
610
|
+ /* save position to restart from it */
|
610
|
611
|
int64_t pos = s->position;
|
611
|
612
|
if (ftp_abort(h) < 0) {
|
612
|
613
|
s->position = pos;
|