From 5733068b37d3bf0d5370e19f409fb2640dcd9a89 Mon Sep 17 00:00:00 2001
From: Josh Allmann <joshua.allmann@gmail.com>
Date: Fri, 25 Jun 2010 15:10:49 -0700
Subject: [PATCH 4/7] Clean up FMTP parsing code in H.264 RTP depacketizer.

---
 libavformat/rtpdec_h264.c |   19 ++++---------------
 1 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index a6e0de8..3ecbf42 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -69,10 +69,11 @@ struct PayloadContext {
 #define DEAD_COOKIE (0xdeaddead)        ///< Cookie for the extradata; once it is freed.
 
 /* ---------------- private code */
-static int sdp_parse_fmtp_config_h264(AVStream * stream,
+static int sdp_parse_fmtp_config_h264(AVFormatContext *s, int st_index,
                                        PayloadContext * h264_data,
                                        char *attr, char *value)
 {
+    AVStream *stream = s->streams[st_index];
     AVCodecContext *codec = stream->codec;
     assert(codec->codec_id == CODEC_ID_H264);
     assert(h264_data != NULL);
@@ -385,20 +386,8 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
         codec->height = atoi(p + 1); // skip the -
         codec->pix_fmt = PIX_FMT_YUV420P;
     } else if (av_strstart(p, "fmtp:", &p)) {
-        char attr[256];
-        char value[4096];
-
-        // remove the protocol identifier..
-        while (*p && *p == ' ') p++; // strip spaces.
-        while (*p && *p != ' ') p++; // eat protocol identifier
-        while (*p && *p == ' ') p++; // strip trailing spaces.
-
-        /* loop on each attribute */
-        while (ff_rtsp_next_attr_and_value
-               (&p, attr, sizeof(attr), value, sizeof(value))) {
-            /* grab the codec extra_data from the config parameter of the fmtp line */
-            sdp_parse_fmtp_config_h264(stream, h264_data, attr, value);
-        }
+        return ff_parse_fmtp(s, st_index, h264_data, p,
+                      &sdp_parse_fmtp_config_h264);
     } else if (av_strstart(p, "cliprect:", &p)) {
         // could use this if we wanted.
     }
-- 
1.7.0.4

