[FFmpeg-cvslog] rtpdec: pass an AVFormatContext to ff_parse_fmtp()
Anton Khirnov
git at videolan.org
Wed Jul 9 23:45:45 CEST 2014
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Jul 5 07:01:07 2014 +0000| [0307cc2253e76772b1c645ac6117d08da87a147c] | committer: Anton Khirnov
rtpdec: pass an AVFormatContext to ff_parse_fmtp()
Use it for logging, instead of NULL or the stream codec context.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0307cc2253e76772b1c645ac6117d08da87a147c
---
libavformat/rtpdec.c | 8 +++++---
libavformat/rtpdec.h | 6 ++++--
libavformat/rtpdec_amr.c | 9 +++++----
libavformat/rtpdec_h264.c | 15 ++++++++-------
libavformat/rtpdec_ilbc.c | 7 ++++---
libavformat/rtpdec_latm.c | 7 ++++---
libavformat/rtpdec_mpeg4.c | 5 +++--
libavformat/rtpdec_xiph.c | 11 ++++++-----
8 files changed, 39 insertions(+), 29 deletions(-)
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 3984489..308a48a 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -826,8 +826,10 @@ void ff_rtp_parse_close(RTPDemuxContext *s)
av_free(s);
}
-int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
- int (*parse_fmtp)(AVStream *stream,
+int ff_parse_fmtp(AVFormatContext *s,
+ AVStream *stream, PayloadContext *data, const char *p,
+ int (*parse_fmtp)(AVFormatContext *s,
+ AVStream *stream,
PayloadContext *data,
char *attr, char *value))
{
@@ -852,7 +854,7 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
while (ff_rtsp_next_attr_and_value(&p,
attr, sizeof(attr),
value, value_size)) {
- res = parse_fmtp(stream, data, attr, value);
+ res = parse_fmtp(s, stream, data, attr, value);
if (res < 0 && res != AVERROR_PATCHWELCOME) {
av_free(value);
return res;
diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h
index 6b16117..46b08ce 100644
--- a/libavformat/rtpdec.h
+++ b/libavformat/rtpdec.h
@@ -200,8 +200,10 @@ RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id,
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size,
char *value, int value_size);
-int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
- int (*parse_fmtp)(AVStream *stream,
+int ff_parse_fmtp(AVFormatContext *s,
+ AVStream *stream, PayloadContext *data, const char *p,
+ int (*parse_fmtp)(AVFormatContext *s,
+ AVStream *stream,
PayloadContext *data,
char *attr, char *value));
diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c
index fd18ff2..86348bb 100644
--- a/libavformat/rtpdec_amr.c
+++ b/libavformat/rtpdec_amr.c
@@ -139,7 +139,8 @@ static int amr_handle_packet(AVFormatContext *ctx, PayloadContext *data,
return 0;
}
-static int amr_parse_fmtp(AVStream *stream, PayloadContext *data,
+static int amr_parse_fmtp(AVFormatContext *s,
+ AVStream *stream, PayloadContext *data,
char *attr, char *value)
{
/* Some AMR SDP configurations contain "octet-align", without
@@ -147,8 +148,8 @@ static int amr_parse_fmtp(AVStream *stream, PayloadContext *data,
* interpret it as "1".
*/
if (!strcmp(value, "")) {
- av_log(NULL, AV_LOG_WARNING, "AMR fmtp attribute %s had "
- "nonstandard empty value\n", attr);
+ av_log(s, AV_LOG_WARNING, "AMR fmtp attribute %s had "
+ "nonstandard empty value\n", attr);
strcpy(value, "1");
}
if (!strcmp(attr, "octet-align"))
@@ -177,7 +178,7 @@ static int amr_parse_sdp_line(AVFormatContext *s, int st_index,
* separated key/value pairs.
*/
if (av_strstart(line, "fmtp:", &p)) {
- ret = ff_parse_fmtp(s->streams[st_index], data, p, amr_parse_fmtp);
+ ret = ff_parse_fmtp(s, s->streams[st_index], data, p, amr_parse_fmtp);
if (!data->octet_align || data->crc ||
data->interleaving || data->channels != 1) {
av_log(s, AV_LOG_ERROR, "Unsupported RTP/AMR configuration!\n");
diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c
index 982eb72..abf1f39 100644
--- a/libavformat/rtpdec_h264.c
+++ b/libavformat/rtpdec_h264.c
@@ -64,7 +64,8 @@ struct PayloadContext {
static const uint8_t start_sequence[] = { 0, 0, 0, 1 };
-static int sdp_parse_fmtp_config_h264(AVStream *stream,
+static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
+ AVStream *stream,
PayloadContext *h264_data,
char *attr, char *value)
{
@@ -73,7 +74,7 @@ static int sdp_parse_fmtp_config_h264(AVStream *stream,
assert(h264_data != NULL);
if (!strcmp(attr, "packetization-mode")) {
- av_log(codec, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value));
+ av_log(s, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value));
h264_data->packetization_mode = atoi(value);
/*
* Packetization Mode:
@@ -83,7 +84,7 @@ static int sdp_parse_fmtp_config_h264(AVStream *stream,
* and 29 (FU-B) are allowed.
*/
if (h264_data->packetization_mode > 1)
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Interleaved RTP mode is not supported yet.\n");
} else if (!strcmp(attr, "profile-level-id")) {
if (strlen(value) == 6) {
@@ -104,7 +105,7 @@ static int sdp_parse_fmtp_config_h264(AVStream *stream,
buffer[1] = value[5];
level_idc = strtol(buffer, NULL, 16);
- av_log(codec, AV_LOG_DEBUG,
+ av_log(s, AV_LOG_DEBUG,
"RTP Profile IDC: %x Profile IOP: %x Level: %x\n",
profile_idc, profile_iop, level_idc);
h264_data->profile_idc = profile_idc;
@@ -137,7 +138,7 @@ static int sdp_parse_fmtp_config_h264(AVStream *stream,
codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!dest) {
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Unable to allocate memory for extradata!\n");
return AVERROR(ENOMEM);
}
@@ -157,7 +158,7 @@ static int sdp_parse_fmtp_config_h264(AVStream *stream,
codec->extradata_size += sizeof(start_sequence) + packet_size;
}
}
- av_log(codec, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!\n",
+ av_log(s, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!\n",
codec->extradata, codec->extradata_size);
}
return 0;
@@ -385,7 +386,7 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
codec->width = atoi(buf1);
codec->height = atoi(p + 1); // skip the -
} else if (av_strstart(p, "fmtp:", &p)) {
- return ff_parse_fmtp(stream, h264_data, p, sdp_parse_fmtp_config_h264);
+ return ff_parse_fmtp(s, stream, h264_data, p, sdp_parse_fmtp_config_h264);
} else if (av_strstart(p, "cliprect:", &p)) {
// could use this if we wanted.
}
diff --git a/libavformat/rtpdec_ilbc.c b/libavformat/rtpdec_ilbc.c
index 2e99734..bff47c7 100644
--- a/libavformat/rtpdec_ilbc.c
+++ b/libavformat/rtpdec_ilbc.c
@@ -23,7 +23,8 @@
#include "rtpdec_formats.h"
#include "libavutil/avstring.h"
-static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
+static int ilbc_parse_fmtp(AVFormatContext *s,
+ AVStream *stream, PayloadContext *data,
char *attr, char *value)
{
if (!strcmp(attr, "mode")) {
@@ -36,7 +37,7 @@ static int ilbc_parse_fmtp(AVStream *stream, PayloadContext *data,
stream->codec->block_align = 50;
break;
default:
- av_log(NULL, AV_LOG_ERROR, "Unsupported iLBC mode %d\n", mode);
+ av_log(s, AV_LOG_ERROR, "Unsupported iLBC mode %d\n", mode);
return AVERROR(EINVAL);
}
}
@@ -54,7 +55,7 @@ static int ilbc_parse_sdp_line(AVFormatContext *s, int st_index,
st = s->streams[st_index];
if (av_strstart(line, "fmtp:", &p)) {
- int ret = ff_parse_fmtp(st, data, p, ilbc_parse_fmtp);
+ int ret = ff_parse_fmtp(s, st, data, p, ilbc_parse_fmtp);
if (ret < 0)
return ret;
if (!st->codec->block_align) {
diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c
index 050595c..6ab3f78 100644
--- a/libavformat/rtpdec_latm.c
+++ b/libavformat/rtpdec_latm.c
@@ -145,7 +145,8 @@ end:
return ret;
}
-static int parse_fmtp(AVStream *stream, PayloadContext *data,
+static int parse_fmtp(AVFormatContext *s,
+ AVStream *stream, PayloadContext *data,
char *attr, char *value)
{
int res;
@@ -157,7 +158,7 @@ static int parse_fmtp(AVStream *stream, PayloadContext *data,
} else if (!strcmp(attr, "cpresent")) {
int cpresent = atoi(value);
if (cpresent != 0)
- avpriv_request_sample(NULL,
+ avpriv_request_sample(s,
"RTP MP4A-LATM with in-band configuration");
}
@@ -173,7 +174,7 @@ static int latm_parse_sdp_line(AVFormatContext *s, int st_index,
return 0;
if (av_strstart(line, "fmtp:", &p))
- return ff_parse_fmtp(s->streams[st_index], data, p, parse_fmtp);
+ return ff_parse_fmtp(s, s->streams[st_index], data, p, parse_fmtp);
return 0;
}
diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c
index bec5c7d..4aedeea 100644
--- a/libavformat/rtpdec_mpeg4.c
+++ b/libavformat/rtpdec_mpeg4.c
@@ -210,7 +210,8 @@ static int aac_parse_packet(AVFormatContext *ctx, PayloadContext *data,
return 0;
}
-static int parse_fmtp(AVStream *stream, PayloadContext *data,
+static int parse_fmtp(AVFormatContext *s,
+ AVStream *stream, PayloadContext *data,
char *attr, char *value)
{
AVCodecContext *codec = stream->codec;
@@ -248,7 +249,7 @@ static int parse_sdp_line(AVFormatContext *s, int st_index,
return 0;
if (av_strstart(line, "fmtp:", &p))
- return ff_parse_fmtp(s->streams[st_index], data, p, parse_fmtp);
+ return ff_parse_fmtp(s, s->streams[st_index], data, p, parse_fmtp);
return 0;
}
diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c
index 2049e4f..9e4fbc5 100644
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@ -306,7 +306,8 @@ parse_packed_headers(const uint8_t * packed_headers,
return 0;
}
-static int xiph_parse_fmtp_pair(AVStream* stream,
+static int xiph_parse_fmtp_pair(AVFormatContext *s,
+ AVStream* stream,
PayloadContext *xiph_data,
char *attr, char *value)
{
@@ -321,7 +322,7 @@ static int xiph_parse_fmtp_pair(AVStream* stream,
} else if (!strcmp(value, "YCbCr-4:4:4")) {
codec->pix_fmt = AV_PIX_FMT_YUV444P;
} else {
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Unsupported pixel format %s\n", attr);
return AVERROR_INVALIDDATA;
}
@@ -360,12 +361,12 @@ static int xiph_parse_fmtp_pair(AVStream* stream,
(decoded_packet, decoded_packet + packet_size, codec,
xiph_data);
} else {
- av_log(codec, AV_LOG_ERROR,
+ av_log(s, AV_LOG_ERROR,
"Out of memory while decoding SDP configuration.\n");
result = AVERROR(ENOMEM);
}
} else {
- av_log(codec, AV_LOG_ERROR, "Packet too large\n");
+ av_log(s, AV_LOG_ERROR, "Packet too large\n");
result = AVERROR_INVALIDDATA;
}
av_free(decoded_packet);
@@ -382,7 +383,7 @@ static int xiph_parse_sdp_line(AVFormatContext *s, int st_index,
return 0;
if (av_strstart(line, "fmtp:", &p)) {
- return ff_parse_fmtp(s->streams[st_index], data, p,
+ return ff_parse_fmtp(s, s->streams[st_index], data, p,
xiph_parse_fmtp_pair);
}
More information about the ffmpeg-cvslog
mailing list