[FFmpeg-soc] [soc]: r5877 - in mms: mms.c mms.h mmsh.c mmst.c

spyfeng subversion at mplayerhq.hu
Sun Aug 1 09:51:58 CEST 2010


Author: spyfeng
Date: Sun Aug  1 09:51:58 2010
New Revision: 5877

Log:
extract common function read_data() into mms.c.

Modified:
   mms/mms.c
   mms/mms.h
   mms/mmsh.c
   mms/mmst.c

Modified: mms/mms.c
==============================================================================
--- mms/mms.c	Sun Aug  1 09:41:56 2010	(r5876)
+++ mms/mms.c	Sun Aug  1 09:51:58 2010	(r5877)
@@ -24,6 +24,16 @@
 #include "asf.h"
 #include "libavutil/intreadwrite.h"
 
+int ff_read_data(MMSContext *mms, uint8_t *buf, const int buf_size)
+{
+    int read_size;
+    read_size = FFMIN(buf_size, mms->remaining_in_len);
+    memcpy(buf, mms->read_in_ptr, read_size);
+    mms->remaining_in_len -= read_size;
+    mms->read_in_ptr      += read_size;
+    return read_size;
+}
+
 int ff_asf_header_parser(MMSContext *mms)
 {
     uint8_t *p = mms->asf_header;

Modified: mms/mms.h
==============================================================================
--- mms/mms.h	Sun Aug  1 09:41:56 2010	(r5876)
+++ mms/mms.h	Sun Aug  1 09:51:58 2010	(r5877)
@@ -57,4 +57,5 @@ typedef struct {
 } MMSContext;
 
 int ff_asf_header_parser(MMSContext * mms);
+int ff_read_data(MMSContext *mms, uint8_t *buf, const int buf_size);
 #endif

Modified: mms/mmsh.c
==============================================================================
--- mms/mmsh.c	Sun Aug  1 09:41:56 2010	(r5876)
+++ mms/mmsh.c	Sun Aug  1 09:51:58 2010	(r5877)
@@ -306,17 +306,6 @@ static int mmsh_open(URLContext *h, cons
     return 0;
 }
 
-static int read_data(MMSHContext *mmsh_ctx, char *buf, int size)
-{
-    MMSContext *mms = mmsh_ctx->ff_ctx;
-    int read_size;
-    read_size = FFMIN(size, mms->remaining_in_len);
-    memcpy(buf, mms->read_in_ptr, read_size);
-    mms->remaining_in_len -= read_size;
-    mms->read_in_ptr      += read_size;
-    return read_size;
-}
-
 static int handle_chunk_type(MMSHContext *mmsh_ctx)
 {
     MMSContext *mms = mmsh_ctx->ff_ctx;
@@ -370,12 +359,12 @@ static int mmsh_read(URLContext *h, uint
                 av_freep(&mms->asf_header); // which contains asf header
             }
         } else if (mms->remaining_in_len){
-            res =read_data(mmsh_ctx, buf, size);
+            res = ff_read_data(mms, buf, size);
         } else {
              // read data packet from network
             res = handle_chunk_type(mmsh_ctx);
             if (res == 0) {
-                res = read_data(mmsh_ctx, buf, size);
+                res = ff_read_data(mms, buf, size);
             } else {
                 dprintf(NULL, "other situation!\n");
             }

Modified: mms/mmst.c
==============================================================================
--- mms/mmst.c	Sun Aug  1 09:41:56 2010	(r5876)
+++ mms/mmst.c	Sun Aug  1 09:51:58 2010	(r5877)
@@ -454,17 +454,6 @@ static int send_stream_selection_request
     return send_command_packet(mmst_ctx);
 }
 
-static int read_data(MMSTContext *mmst_ctx, uint8_t *buf, const int buf_size)
-{
-    int read_size;
-    MMSContext *mms = mmst_ctx->ff_ctx;
-    read_size = FFMIN(buf_size, mms->remaining_in_len);
-    memcpy(buf, mms->read_in_ptr, read_size);
-    mms->remaining_in_len -= read_size;
-    mms->read_in_ptr      += read_size;
-    return read_size;
-}
-
 /** Read at most one media packet (or a whole header). */
 static int read_mms_packet(MMSTContext *mmst_ctx, uint8_t *buf, int buf_size)
 {
@@ -488,7 +477,7 @@ static int read_mms_packet(MMSTContext *
         } 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(mmst_ctx, buf, buf_size);
+            result = ff_read_data(mms, buf, buf_size);
         } else {
             /* Read from network */
             int err = mms_safe_send_recv(mmst_ctx, NULL, SC_PKT_ASF_MEDIA);
@@ -500,7 +489,7 @@ static int read_mms_packet(MMSTContext *
                     result= AVERROR_IO;
                 } else {
                     // copy the data to the packet buffer.
-                    result = read_data(mmst_ctx, buf, buf_size);
+                    result = ff_read_data(mms, buf, buf_size);
                     if (result == 0) {
                         dprintf(NULL, "read asf media paket size is zero!\n");
                         break;


More information about the FFmpeg-soc mailing list