aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-12-05 19:41:09 +0000
committerMartin Storsjö <martin@martin.st>2010-12-05 19:41:09 +0000
commit003eb6421783793f8e856edb2f84fdff679c85ec (patch)
treedfe6bb453d4c3eb5f3b3e1ddd6c737a869c64527
parent1e515c4280acb70c615e8fe562fa6b463f1d8bed (diff)
downloadffmpeg-003eb6421783793f8e856edb2f84fdff679c85ec.tar.gz
rtsp: Factorize code for initializing the rtp payload handler
Originally committed as revision 25892 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/rtsp.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 643fde3de4..8afedddd1c 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -122,6 +122,17 @@ static int get_sockaddr(const char *buf, struct sockaddr_storage *sock)
}
#if CONFIG_RTPDEC
+static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
+ RTSPStream *rtsp_st, AVCodecContext *codec)
+{
+ if (!handler)
+ return;
+ codec->codec_id = handler->codec_id;
+ rtsp_st->dynamic_handler = handler;
+ if (handler->open)
+ rtsp_st->dynamic_protocol_context = handler->open();
+}
+
/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
static int sdp_parse_rtpmap(AVFormatContext *s,
AVCodecContext *codec, RTSPStream *rtsp_st,
@@ -139,18 +150,9 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
* have a trailing space. */
get_word_sep(buf, sizeof(buf), "/ ", &p);
if (payload_type >= RTP_PT_PRIVATE) {
- RTPDynamicProtocolHandler *handler;
- for (handler = RTPFirstDynamicPayloadHandler;
- handler; handler = handler->next) {
- if (!strcasecmp(buf, handler->enc_name) &&
- codec->codec_type == handler->codec_type) {
- codec->codec_id = handler->codec_id;
- rtsp_st->dynamic_handler = handler;
- if (handler->open)
- rtsp_st->dynamic_protocol_context = handler->open();
- break;
- }
- }
+ RTPDynamicProtocolHandler *handler =
+ ff_rtp_handler_find_by_name(buf, codec->codec_type);
+ init_rtp_handler(handler, rtsp_st, codec);
/* If no dynamic handler was found, check with the list of standard
* allocated types, if such a stream for some reason happens to
* use a private payload type. This isn't handled in rtpdec.c, since