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

spyfeng subversion at mplayerhq.hu
Sun Aug 1 10:46:51 CEST 2010


Author: spyfeng
Date: Sun Aug  1 10:46:50 2010
New Revision: 5882

Log:
extract common code as ff_read_header() 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 10:28:01 2010	(r5881)
+++ mms/mms.c	Sun Aug  1 10:46:50 2010	(r5882)
@@ -24,6 +24,21 @@
 #include "asf.h"
 #include "libavutil/intreadwrite.h"
 
+int ff_read_header(MMSContext *mms, uint8_t *buf, int size)
+{
+    char *pos;
+    int size_to_copy;
+    int remaining_size = mms->asf_header_size - mms->asf_header_read_size;
+    size_to_copy = FFMIN(size, remaining_size);
+    pos = mms->asf_header + mms->asf_header_read_size;
+    memcpy(buf, pos, size_to_copy);
+    if (mms->asf_header_read_size == mms->asf_header_size) {
+        av_freep(&mms->asf_header); // which contains asf header
+    }
+    mms->asf_header_read_size += size_to_copy;
+    return size_to_copy;
+}
+
 int ff_read_data(MMSContext *mms, uint8_t *buf, const int buf_size)
 {
     int read_size;

Modified: mms/mms.h
==============================================================================
--- mms/mms.h	Sun Aug  1 10:28:01 2010	(r5881)
+++ mms/mms.h	Sun Aug  1 10:46:50 2010	(r5882)
@@ -58,4 +58,5 @@ typedef struct {
 
 int ff_asf_header_parser(MMSContext * mms);
 int ff_read_data(MMSContext *mms, uint8_t *buf, const int buf_size);
+int ff_read_header(MMSContext * mms, uint8_t * buf, int size);
 #endif

Modified: mms/mmsh.c
==============================================================================
--- mms/mmsh.c	Sun Aug  1 10:28:01 2010	(r5881)
+++ mms/mmsh.c	Sun Aug  1 10:46:50 2010	(r5882)
@@ -347,17 +347,7 @@ static int mmsh_read(URLContext *h, uint
     do{
         if (mms->asf_header_read_size < mms->asf_header_size) {
             // copy asf header into buffer
-            char *pos;
-            int size_to_copy;
-            int remaining_size = mms->asf_header_size - mms->asf_header_read_size;
-            size_to_copy = FFMIN(size, remaining_size);
-            pos = mms->asf_header + mms->asf_header_read_size;
-            memcpy(buf, pos, size_to_copy);
-            mms->asf_header_read_size += size_to_copy;
-            res = size_to_copy;
-            if (mms->asf_header_read_size == mms->asf_header_size) {
-                av_freep(&mms->asf_header); // which contains asf header
-            }
+            res = ff_read_header(mms, buf, size);
         } else if (mms->remaining_in_len){
             res = ff_read_data(mms, buf, size);
         } else {

Modified: mms/mmst.c
==============================================================================
--- mms/mmst.c	Sun Aug  1 10:28:01 2010	(r5881)
+++ mms/mmst.c	Sun Aug  1 10:46:50 2010	(r5882)
@@ -593,21 +593,10 @@ static int mms_read(URLContext *h, uint8
     /* TODO: see tcp.c:tcp_read() about a possible timeout scheme */
     MMSTContext *mmst_ctx = h->priv_data;
     int result = 0;
-    int size_to_copy;
     MMSContext *mms = mmst_ctx->ff_ctx;
     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);
-            }
+           result =  ff_read_header(mms, buf, size);
         } else if(mms->remaining_in_len) {
             /* Read remaining packet data to buffer.
              * the result can not be zero because remaining_in_len is positive.*/


More information about the FFmpeg-soc mailing list