History

Allow the ASF header to be transferred split over multiple packets, as some servers happen to do. For this, we also move several header-size-related variables to the MMSTContext.

Patch by Zhentan Feng <spyfeng gmail com>. Originally committed as revision 24363 to svn://svn.ffmpeg.org/ffmpeg/trunk

Zhentan Feng committed 16 years ago

Commit e4a28be1 parent d6cc1121 file · +13 −12Browse files

Unified · Split

libavformat/mmst.c+13−12
@@ -120,6 +120,7 @@ typedef struct { · 119 unmodified lines
120120 int asf_header_size; ///< Size of stored ASF header.
121121 int header_parsed; ///< The header has been received and parsed.
122122 int asf_packet_len;
123+ int asf_header_read_size;
123124 /*@}*/
124125
125126 int stream_num; ///< stream numbers.
@@ -302,8 +303,6 @@ static MMSSCPacketType get_tcp_server_response(MMSContext *mms) · 176 unmodified lines
302303 int packet_id_type;
303304 int tmp;
304305
305− assert(mms->remaining_in_len==0);
306−
307306 // note we cache the first 8 bytes,
308307 // then fill up the buffer with the others
309308 tmp = AV_RL16(mms->in_buffer + 6);
@@ -344,6 +343,9 @@ static MMSSCPacketType get_tcp_server_response(MMSContext *mms) · 34 unmodified lines
344343 mms->remaining_in_len);
345344 mms->asf_header_size += mms->remaining_in_len;
346345 }
346+ // 0x04 means asf header is sent in multiple packets.
347+ if (mms->incoming_flags == 0x04)
348+ continue;
347349 } else if(packet_id_type == mms->packet_id) {
348350 packet_type = SC_PKT_ASF_MEDIA;
349351 } else {
@@ -440,15 +442,14 @@ static int asf_header_parser(MMSContext *mms) · 90 unmodified lines
440442 {
441443 uint8_t *p = mms->asf_header;
442444 uint8_t *end;
443− int flags, stream_id, real_header_size;
445+ int flags, stream_id;
444446 mms->stream_num = 0;
445447
446448 if (mms->asf_header_size < sizeof(ff_asf_guid) * 2 + 22 ||
447449 memcmp(p, ff_asf_header, sizeof(ff_asf_guid)))
448450 return -1;
449451
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;
452453
453454 p += sizeof(ff_asf_guid) + 14;
454455 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
519520 /** Read at most one media packet (or a whole header). */
520521 static int read_mms_packet(MMSContext *mms, uint8_t *buf, int buf_size)
521522 {
522− int result = 0, read_header_size = 0;
523+ int result = 0;
523524 int size_to_copy;
524525
525526 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) {
527528 /* Read from ASF header buffer */
528529 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;
532533 result += size_to_copy;
533534 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) {
536537 av_freep(&mms->asf_header);
537538 mms->is_playing = 1;
538539 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t