]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rtpdec_mpeg4.c
In av_close_input_stream(), flush the packet queue before to actually
[ffmpeg] / libavformat / rtpdec_mpeg4.c
index cf1e7fa819d5f9b972c5bf734649427cc9648ad9..137dbd2613e48255b22ab42fc6486e5a70e08e13 100644 (file)
@@ -27,7 +27,8 @@
  * @author Romain Degez
  */
 
-#include "rtpdec_mpeg4.h"
+#include "rtpdec_formats.h"
+#include "internal.h"
 #include "libavutil/avstring.h"
 #include "libavcodec/get_bits.h"
 #include <strings.h>
@@ -60,35 +61,6 @@ struct PayloadContext
     int cur_au_index;
 };
 
-/* return the length and optionally the data */
-static int hex_to_data(uint8_t *data, const char *p)
-{
-    int c, len, v;
-
-    len = 0;
-    v = 1;
-    for (;;) {
-        p += strspn(p, SPACE_CHARS);
-        if (*p == '\0')
-            break;
-        c = toupper((unsigned char) *p++);
-        if (c >= '0' && c <= '9')
-            c = c - '0';
-        else if (c >= 'A' && c <= 'F')
-            c = c - 'A' + 10;
-        else
-            break;
-        v = (v << 4) | c;
-        if (v & 0x100) {
-            if (data)
-                data[len] = v;
-            len++;
-            v = 1;
-        }
-    }
-    return len;
-}
-
 typedef struct {
     const char *str;
     uint16_t    type;
@@ -138,14 +110,14 @@ static void free_context(PayloadContext * data)
 static int parse_fmtp_config(AVCodecContext * codec, char *value)
 {
     /* decode the hexa encoded parameter */
-    int len = hex_to_data(NULL, value);
+    int len = ff_hex_to_data(NULL, value);
     if (codec->extradata)
         av_free(codec->extradata);
     codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!codec->extradata)
         return AVERROR(ENOMEM);
     codec->extradata_size = len;
-    hex_to_data(codec->extradata, value);
+    ff_hex_to_data(codec->extradata, value);
     return 0;
 }
 
@@ -225,28 +197,28 @@ static int parse_fmtp(AVStream *stream, PayloadContext *data,
     AVCodecContext *codec = stream->codec;
     int res, i;
 
-            if (!strcmp(attr, "config")) {
-                res = parse_fmtp_config(codec, value);
+    if (!strcmp(attr, "config")) {
+        res = parse_fmtp_config(codec, value);
 
-                if (res < 0)
-                    return res;
-            }
+        if (res < 0)
+            return res;
+    }
 
-            if (codec->codec_id == CODEC_ID_AAC) {
-                /* Looking for a known attribute */
-                for (i = 0; attr_names[i].str; ++i) {
-                    if (!strcasecmp(attr, attr_names[i].str)) {
-                        if (attr_names[i].type == ATTR_NAME_TYPE_INT) {
-                            *(int *)((char *)data+
-                                attr_names[i].offset) = atoi(value);
-                        } else if (attr_names[i].type == ATTR_NAME_TYPE_STR)
-                            *(char **)((char *)data+
-                                attr_names[i].offset) = av_strdup(value);
-                    }
-                }
+    if (codec->codec_id == CODEC_ID_AAC) {
+        /* Looking for a known attribute */
+        for (i = 0; attr_names[i].str; ++i) {
+            if (!strcasecmp(attr, attr_names[i].str)) {
+                if (attr_names[i].type == ATTR_NAME_TYPE_INT) {
+                    *(int *)((char *)data+
+                        attr_names[i].offset) = atoi(value);
+                } else if (attr_names[i].type == ATTR_NAME_TYPE_STR)
+                    *(char **)((char *)data+
+                        attr_names[i].offset) = av_strdup(value);
             }
-    return 0;
         }
+    }
+    return 0;
+}
 
 static int parse_sdp_line(AVFormatContext *s, int st_index,
                           PayloadContext *data, const char *line)