Patch by Zhentan Feng <spyfeng gmail com>. Originally committed as revision 24363 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -120,6 +120,7 @@ typedef struct { · 119 unmodified lines | ||
| 120 | 120 | int asf_header_size; ///< Size of stored ASF header. |
| 121 | 121 | int header_parsed; ///< The header has been received and parsed. |
| 122 | 122 | int asf_packet_len; |
| 123 | + int asf_header_read_size; | |
| 123 | 124 | /*@}*/ |
| 124 | 125 | |
| 125 | 126 | int stream_num; ///< stream numbers. |
| @@ -302,8 +303,6 @@ static MMSSCPacketType get_tcp_server_response(MMSContext *mms) · 176 unmodified lines | ||
| 302 | 303 | int packet_id_type; |
| 303 | 304 | int tmp; |
| 304 | 305 | |
| 305 | − assert(mms->remaining_in_len==0); | |
| 306 | − | |
| 307 | 306 | // note we cache the first 8 bytes, |
| 308 | 307 | // then fill up the buffer with the others |
| 309 | 308 | tmp = AV_RL16(mms->in_buffer + 6); |
| @@ -344,6 +343,9 @@ static MMSSCPacketType get_tcp_server_response(MMSContext *mms) · 34 unmodified lines | ||
| 344 | 343 | mms->remaining_in_len); |
| 345 | 344 | mms->asf_header_size += mms->remaining_in_len; |
| 346 | 345 | } |
| 346 | + // 0x04 means asf header is sent in multiple packets. | |
| 347 | + if (mms->incoming_flags == 0x04) | |
| 348 | + continue; | |
| 347 | 349 | } else if(packet_id_type == mms->packet_id) { |
| 348 | 350 | packet_type = SC_PKT_ASF_MEDIA; |
| 349 | 351 | } else { |
| @@ -440,15 +442,14 @@ static int asf_header_parser(MMSContext *mms) · 90 unmodified lines | ||
| 440 | 442 | { |
| 441 | 443 | uint8_t *p = mms->asf_header; |
| 442 | 444 | uint8_t *end; |
| 443 | − int flags, stream_id, real_header_size; | |
| 445 | + int flags, stream_id; | |
| 444 | 446 | mms->stream_num = 0; |
| 445 | 447 | |
| 446 | 448 | if (mms->asf_header_size < sizeof(ff_asf_guid) * 2 + 22 || |
| 447 | 449 | memcmp(p, ff_asf_header, sizeof(ff_asf_guid))) |
| 448 | 450 | return -1; |
| 449 | 451 | |
| 450 | − real_header_size = AV_RL64(p + sizeof(ff_asf_guid)); | |
| 451 | − end = mms->asf_header + real_header_size; | |
| 452 | + end = mms->asf_header + mms->asf_header_size; | |
| 452 | 453 | |
| 453 | 454 | p += sizeof(ff_asf_guid) + 14; |
| 454 | 455 | while(end - p >= sizeof(ff_asf_guid) + 8) { |
| @@ -519,20 +520,20 @@ static int read_data(MMSContext *mms, uint8_t *buf, const int buf_size) · 64 unmodified lines | ||
| 519 | 520 | /** Read at most one media packet (or a whole header). */ |
| 520 | 521 | static int read_mms_packet(MMSContext *mms, uint8_t *buf, int buf_size) |
| 521 | 522 | { |
| 522 | − int result = 0, read_header_size = 0; | |
| 523 | + int result = 0; | |
| 523 | 524 | int size_to_copy; |
| 524 | 525 | |
| 525 | 526 | do { |
| 526 | − if(read_header_size < mms->asf_header_size && !mms->is_playing) { | |
| 527 | + if(mms->asf_header_read_size < mms->asf_header_size && !mms->is_playing) { | |
| 527 | 528 | /* Read from ASF header buffer */ |
| 528 | 529 | size_to_copy= FFMIN(buf_size, |
| 529 | − mms->asf_header_size - read_header_size); | |
| 530 | − memcpy(buf, mms->asf_header + read_header_size, size_to_copy); | |
| 531 | − read_header_size += size_to_copy; | |
| 530 | + mms->asf_header_size - mms->asf_header_read_size); | |
| 531 | + memcpy(buf, mms->asf_header + mms->asf_header_read_size, size_to_copy); | |
| 532 | + mms->asf_header_read_size += size_to_copy; | |
| 532 | 533 | result += size_to_copy; |
| 533 | 534 | dprintf(NULL, "Copied %d bytes from stored header. left: %d\n", |
| 534 | − size_to_copy, mms->asf_header_size - read_header_size); | |
| 535 | − if (mms->asf_header_size == read_header_size) { | |
| 535 | + size_to_copy, mms->asf_header_size - mms->asf_header_read_size); | |
| 536 | + if (mms->asf_header_size == mms->asf_header_read_size) { | |
| 536 | 537 | av_freep(&mms->asf_header); |
| 537 | 538 | mms->is_playing = 1; |
| 538 | 539 | } |