| OLD | NEW |
| 1 /* | 1 /* |
| 2 * MMS protocol over TCP | 2 * MMS protocol over TCP |
| 3 * Copyright (c) 2006,2007 Ryan Martell | 3 * Copyright (c) 2006,2007 Ryan Martell |
| 4 * Copyright (c) 2007 Björn Axelsson | 4 * Copyright (c) 2007 Björn Axelsson |
| 5 * Copyright (c) 2010 Zhentan Feng <spyfeng at gmail dot com> | 5 * Copyright (c) 2010 Zhentan Feng <spyfeng at gmail dot com> |
| 6 * | 6 * |
| 7 * This file is part of FFmpeg. | 7 * This file is part of FFmpeg. |
| 8 * | 8 * |
| 9 * FFmpeg is free software; you can redistribute it and/or | 9 * FFmpeg is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if(AV_RL32(mms->in_buffer + 4)==0xb00bface) { | 251 if(AV_RL32(mms->in_buffer + 4)==0xb00bface) { |
| 252 mms->incoming_flags= mms->in_buffer[3]; | 252 mms->incoming_flags= mms->in_buffer[3]; |
| 253 read_result= url_read_complete(mms->mms_hd, mms->in_buffer+8, 4)
; | 253 read_result= url_read_complete(mms->mms_hd, mms->in_buffer+8, 4)
; |
| 254 if(read_result == 4) { | 254 if(read_result == 4) { |
| 255 int length_remaining= AV_RL32(mms->in_buffer+8) + 4; | 255 int length_remaining= AV_RL32(mms->in_buffer+8) + 4; |
| 256 | 256 |
| 257 dprintf(NULL, "Length remaining is %d\n", length_remaining); | 257 dprintf(NULL, "Length remaining is %d\n", length_remaining); |
| 258 // read the rest of the packet. | 258 // read the rest of the packet. |
| 259 if (length_remaining < 0 | 259 if (length_remaining < 0 |
| 260 || length_remaining > sizeof(mms->in_buffer) - 12) { | 260 || length_remaining > sizeof(mms->in_buffer) - 12) { |
| 261 dprintf("Incoming message len %d exceeds buffer len %d\n
", | 261 dprintf(NULL, "Incoming message len %d exceeds buffer le
n %d\n", |
| 262 length_remaining, sizeof(mms->in_buffer) - 12); | 262 length_remaining, sizeof(mms->in_buffer) - 12); |
| 263 return -1; | 263 return -1; |
| 264 } | 264 } |
| 265 read_result = url_read_complete(mms->mms_hd, mms->in_buffer
+ 12, | 265 read_result = url_read_complete(mms->mms_hd, mms->in_buffer
+ 12, |
| 266 length_remaining) ; | 266 length_remaining) ; |
| 267 if (read_result == length_remaining) { | 267 if (read_result == length_remaining) { |
| 268 packet_type= AV_RL16(mms->in_buffer+36); | 268 packet_type= AV_RL16(mms->in_buffer+36); |
| 269 } else { | 269 } else { |
| 270 dprintf(NULL, "read for packet type failed%d!\n", read_r
esult); | 270 dprintf(NULL, "read for packet type failed%d!\n", read_r
esult); |
| 271 return -1; | 271 return -1; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 284 // note we cache the first 8 bytes, | 284 // note we cache the first 8 bytes, |
| 285 // then fill up the buffer with the others | 285 // then fill up the buffer with the others |
| 286 tmp = AV_RL16(mms->in_buffer + 6); | 286 tmp = AV_RL16(mms->in_buffer + 6); |
| 287 length_remaining = (tmp - 8) & 0xffff; | 287 length_remaining = (tmp - 8) & 0xffff; |
| 288 mms->incoming_packet_seq = AV_RL32(mms->in_buffer); | 288 mms->incoming_packet_seq = AV_RL32(mms->in_buffer); |
| 289 packet_id_type = mms->in_buffer[4]; | 289 packet_id_type = mms->in_buffer[4]; |
| 290 mms->incoming_flags = mms->in_buffer[5]; | 290 mms->incoming_flags = mms->in_buffer[5]; |
| 291 | 291 |
| 292 if (length_remaining < 0 | 292 if (length_remaining < 0 |
| 293 || length_remaining > sizeof(mms->in_buffer) - 8) { | 293 || length_remaining > sizeof(mms->in_buffer) - 8) { |
| 294 dprintf("Incoming data len %d exceeds buffer len %d\n", | 294 dprintf(NULL, "Incoming data len %d exceeds buffer len %d\n"
, |
| 295 length_remaining, sizeof(mms->in_buffer)); | 295 length_remaining, sizeof(mms->in_buffer)); |
| 296 return -1; | 296 return -1; |
| 297 } | 297 } |
| 298 mms->remaining_in_len = length_remaining; | 298 mms->remaining_in_len = length_remaining; |
| 299 mms->read_in_ptr = mms->in_buffer; | 299 mms->read_in_ptr = mms->in_buffer; |
| 300 read_result= url_read_complete(mms->mms_hd, mms->in_buffer, leng
th_remaining); | 300 read_result= url_read_complete(mms->mms_hd, mms->in_buffer, leng
th_remaining); |
| 301 if(read_result != length_remaining) { | 301 if(read_result != length_remaining) { |
| 302 dprintf(NULL, "read_bytes result: %d asking for %d\n", | 302 dprintf(NULL, "read_bytes result: %d asking for %d\n", |
| 303 read_result, length_remaining); | 303 read_result, length_remaining); |
| 304 return -1; | 304 return -1; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 memcmp(p, ff_asf_header, sizeof(ff_asf_guid))) | 424 memcmp(p, ff_asf_header, sizeof(ff_asf_guid))) |
| 425 return -1; | 425 return -1; |
| 426 | 426 |
| 427 real_header_size = AV_RL64(p + sizeof(ff_asf_guid)); | 427 real_header_size = AV_RL64(p + sizeof(ff_asf_guid)); |
| 428 end = mms->asf_header + real_header_size; | 428 end = mms->asf_header + real_header_size; |
| 429 | 429 |
| 430 p += sizeof(ff_asf_guid) + 14; | 430 p += sizeof(ff_asf_guid) + 14; |
| 431 while(end - p >= sizeof(ff_asf_guid) + 8) { | 431 while(end - p >= sizeof(ff_asf_guid) + 8) { |
| 432 uint64_t chunksize = AV_RL64(p + sizeof(ff_asf_guid)); | 432 uint64_t chunksize = AV_RL64(p + sizeof(ff_asf_guid)); |
| 433 if (!chunksize || chunksize > end - p) { | 433 if (!chunksize || chunksize > end - p) { |
| 434 dprintf("chunksize is exceptional value:%d!\n", chunksize); | 434 dprintf(NULL, "chunksize is exceptional value:%d!\n", chunksize); |
| 435 return -1; | 435 return -1; |
| 436 } | 436 } |
| 437 if (!memcmp(p, ff_asf_file_header, sizeof(ff_asf_guid))) { | 437 if (!memcmp(p, ff_asf_file_header, sizeof(ff_asf_guid))) { |
| 438 /* read packet size */ | 438 /* read packet size */ |
| 439 if (end - p > sizeof(ff_asf_guid) * 2 + 68) { | 439 if (end - p > sizeof(ff_asf_guid) * 2 + 68) { |
| 440 mms->asf_packet_len = AV_RL32(p + sizeof(ff_asf_guid) * 2 + 64); | 440 mms->asf_packet_len = AV_RL32(p + sizeof(ff_asf_guid) * 2 + 64); |
| 441 if (mms->asf_packet_len <= 0 || mms->asf_packet_len > sizeof(mms
->in_buffer)) { | 441 if (mms->asf_packet_len <= 0 || mms->asf_packet_len > sizeof(mms
->in_buffer)) { |
| 442 dprintf(NULL,"Too large packet len:%d" | 442 dprintf(NULL,"Too large packet len:%d" |
| 443 " may overwrite in_buffer when padding", mms->asf_packet
_len); | 443 " may overwrite in_buffer when padding", mms->asf_packet
_len); |
| 444 return -1; | 444 return -1; |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 } else if (!memcmp(p, ff_asf_stream_header, sizeof(ff_asf_guid))) { | 447 } else if (!memcmp(p, ff_asf_stream_header, sizeof(ff_asf_guid))) { |
| 448 flags = AV_RL16(p + sizeof(ff_asf_guid)*3 + 24); | 448 flags = AV_RL16(p + sizeof(ff_asf_guid)*3 + 24); |
| 449 stream_id = flags & 0x7F; | 449 stream_id = flags & 0x7F; |
| 450 //The second condition is for checking CS_PKT_STREAM_ID_REQUEST pack
et size, | 450 //The second condition is for checking CS_PKT_STREAM_ID_REQUEST pack
et size, |
| 451 //we can calcuate the packet size by stream_num. | 451 //we can calcuate the packet size by stream_num. |
| 452 //Please see function send_stream_selection_request(). | 452 //Please see function send_stream_selection_request(). |
| 453 if (mms->stream_num < MAX_STREAMS && | 453 if (mms->stream_num < MAX_STREAMS && |
| 454 46 + mms->stream_num * 6 < sizeof(mms->out_buffer)) { | 454 46 + mms->stream_num * 6 < sizeof(mms->out_buffer)) { |
| 455 mms->streams[mms->stream_num].id = stream_id; | 455 mms->streams[mms->stream_num].id = stream_id; |
| 456 mms->stream_num++; | 456 mms->stream_num++; |
| 457 } else { | 457 } else { |
| 458 dprintf("Too many streams.\n"); | 458 dprintf(NULL, "Too many streams.\n"); |
| 459 return -1; | 459 return -1; |
| 460 } | 460 } |
| 461 } | 461 } |
| 462 p += chunksize; | 462 p += chunksize; |
| 463 } | 463 } |
| 464 | 464 |
| 465 return 0; | 465 return 0; |
| 466 } | 466 } |
| 467 | 467 |
| 468 /** Send MMST stream selection command based on the AVStream->discard values. */ | 468 /** Send MMST stream selection command based on the AVStream->discard values. */ |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } | 681 } |
| 682 | 682 |
| 683 URLProtocol mmst_protocol = { | 683 URLProtocol mmst_protocol = { |
| 684 "mmst", | 684 "mmst", |
| 685 mms_open, | 685 mms_open, |
| 686 mms_read, | 686 mms_read, |
| 687 NULL, // write | 687 NULL, // write |
| 688 NULL, // seek | 688 NULL, // seek |
| 689 mms_close, | 689 mms_close, |
| 690 }; | 690 }; |
| OLD | NEW |