aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mmst.c
diff options
context:
space:
mode:
authorZhentan Feng <spyfeng@gmail.com>2010-08-04 22:34:43 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2010-08-04 22:34:43 +0000
commitaaa91aa00edddb097cce7fa769db6643de37df11 (patch)
treeec6bd0258447f76b57326a64d5e475789456b2e5 /libavformat/mmst.c
parent05fc9a1bcf21d36e61fdc20e15e105777f05a111 (diff)
downloadffmpeg-aaa91aa00edddb097cce7fa769db6643de37df11.tar.gz
Move read_mms_packet() code to be inlined in the calling function.
Patch by Zhentan Feng <spyfeng gmail com>. Originally committed as revision 24700 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mmst.c')
-rw-r--r--libavformat/mmst.c93
1 files changed, 43 insertions, 50 deletions
diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index 4233845a97..26975f524a 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -544,55 +544,6 @@ static int read_data(MMSContext *mms, uint8_t *buf, const int buf_size)
return read_size;
}
-/** Read at most one media packet (or a whole header). */
-static int read_mms_packet(MMSContext *mms, uint8_t *buf, int buf_size)
-{
- int result = 0;
- int size_to_copy;
-
- do {
- if(mms->asf_header_read_size < mms->asf_header_size) {
- /* Read from ASF header buffer */
- size_to_copy= FFMIN(buf_size,
- mms->asf_header_size - mms->asf_header_read_size);
- memcpy(buf, mms->asf_header + mms->asf_header_read_size, size_to_copy);
- mms->asf_header_read_size += size_to_copy;
- result += size_to_copy;
- dprintf(NULL, "Copied %d bytes from stored header. left: %d\n",
- size_to_copy, mms->asf_header_size - mms->asf_header_read_size);
- if (mms->asf_header_size == mms->asf_header_read_size) {
- av_freep(&mms->asf_header);
- }
- } else if(mms->remaining_in_len) {
- /* Read remaining packet data to buffer.
- * the result can not be zero because remaining_in_len is positive.*/
- result = read_data(mms, buf, buf_size);
- } else {
- /* Read from network */
- int err = mms_safe_send_recv(mms, NULL, SC_PKT_ASF_MEDIA);
- if (err == 0) {
- if(mms->remaining_in_len>mms->asf_packet_len) {
- av_log(NULL, AV_LOG_ERROR,
- "Incoming pktlen %d is larger than ASF pktsize %d\n",
- mms->remaining_in_len, mms->asf_packet_len);
- result= AVERROR_IO;
- } else {
- // copy the data to the packet buffer.
- result = read_data(mms, buf, buf_size);
- if (result == 0) {
- dprintf(NULL, "read asf media paket size is zero!\n");
- break;
- }
- }
- } else {
- dprintf(NULL, "read packet error!\n");
- break;
- }
- }
- } while(!result); // only return one packet.
- return result;
-}
-
static int send_close_packet(MMSContext *mms)
{
start_command_packet(mms, CS_PKT_STREAM_CLOSE);
@@ -721,8 +672,50 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
{
/* TODO: see tcp.c:tcp_read() about a possible timeout scheme */
MMSContext *mms = h->priv_data;
+ int result = 0;
+ int size_to_copy;
- return read_mms_packet(mms, buf, size);
+ do {
+ if(mms->asf_header_read_size < mms->asf_header_size) {
+ /* Read from ASF header buffer */
+ size_to_copy= FFMIN(size,
+ mms->asf_header_size - mms->asf_header_read_size);
+ memcpy(buf, mms->asf_header + mms->asf_header_read_size, size_to_copy);
+ mms->asf_header_read_size += size_to_copy;
+ result += size_to_copy;
+ dprintf(NULL, "Copied %d bytes from stored header. left: %d\n",
+ size_to_copy, mms->asf_header_size - mms->asf_header_read_size);
+ if (mms->asf_header_size == mms->asf_header_read_size) {
+ av_freep(&mms->asf_header);
+ }
+ } else if(mms->remaining_in_len) {
+ /* Read remaining packet data to buffer.
+ * the result can not be zero because remaining_in_len is positive.*/
+ result = read_data(mms, buf, size);
+ } else {
+ /* Read from network */
+ int err = mms_safe_send_recv(mms, NULL, SC_PKT_ASF_MEDIA);
+ if (err == 0) {
+ if(mms->remaining_in_len>mms->asf_packet_len) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Incoming pktlen %d is larger than ASF pktsize %d\n",
+ mms->remaining_in_len, mms->asf_packet_len);
+ result= AVERROR_IO;
+ } else {
+ // copy the data to the packet buffer.
+ result = read_data(mms, buf, size);
+ if (result == 0) {
+ dprintf(NULL, "read asf media paket size is zero!\n");
+ break;
+ }
+ }
+ } else {
+ dprintf(NULL, "read packet error!\n");
+ break;
+ }
+ }
+ } while(!result); // only return one packet.
+ return result;
}
URLProtocol mmst_protocol = {