MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / sdp_parse_rtpmap

Function sdp_parse_rtpmap

libavformat/rtsp.c:314–383  ·  view source on GitHub ↗

parse the rtpmap description: / [/ ] */

Source from the content-addressed store, hash-verified

312
313/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
314static int sdp_parse_rtpmap(AVFormatContext *s,
315 AVStream *st, RTSPStream *rtsp_st,
316 int payload_type, const char *p)
317{
318 AVCodecParameters *par = st->codecpar;
319 char buf[256];
320 int i;
321 const AVCodecDescriptor *desc;
322 const char *c_name;
323
324 /* See if we can handle this kind of payload.
325 * The space should normally not be there but some Real streams or
326 * particular servers ("RealServer Version 6.1.3.970", see issue 1658)
327 * have a trailing space. */
328 get_word_sep(buf, sizeof(buf), "/ ", &p);
329 if (payload_type < RTP_PT_PRIVATE) {
330 /* We are in a standard case
331 * (from http://www.iana.org/assignments/rtp-parameters). */
332 par->codec_id = ff_rtp_codec_id(buf, par->codec_type);
333 }
334
335 if (par->codec_id == AV_CODEC_ID_NONE) {
336 const RTPDynamicProtocolHandler *handler =
337 ff_rtp_handler_find_by_name(buf, par->codec_type);
338 init_rtp_handler(handler, rtsp_st, st);
339 /* If no dynamic handler was found, check with the list of standard
340 * allocated types, if such a stream for some reason happens to
341 * use a private payload type. This isn't handled in rtpdec.c, since
342 * the format name from the rtpmap line never is passed into rtpdec. */
343 if (!rtsp_st->dynamic_handler)
344 par->codec_id = ff_rtp_codec_id(buf, par->codec_type);
345 }
346
347 desc = avcodec_descriptor_get(par->codec_id);
348 if (desc && desc->name)
349 c_name = desc->name;
350 else
351 c_name = "(null)";
352
353 get_word_sep(buf, sizeof(buf), "/", &p);
354 i = atoi(buf);
355 switch (par->codec_type) {
356 case AVMEDIA_TYPE_AUDIO:
357 av_log(s, AV_LOG_DEBUG, "audio codec set to: %s\n", c_name);
358 par->sample_rate = RTSP_DEFAULT_AUDIO_SAMPLERATE;
359 par->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
360 if (i > 0) {
361 par->sample_rate = i;
362 avpriv_set_pts_info(st, 32, 1, par->sample_rate);
363 get_word_sep(buf, sizeof(buf), "/", &p);
364 i = atoi(buf);
365 if (i > 0)
366 av_channel_layout_default(&par->ch_layout, i);
367 }
368 av_log(s, AV_LOG_DEBUG, "audio samplerate set to: %i\n",
369 par->sample_rate);
370 av_log(s, AV_LOG_DEBUG, "audio channels set to: %i\n",
371 par->ch_layout.nb_channels);

Callers 1

sdp_parse_lineFunction · 0.85

Calls 9

get_word_sepFunction · 0.85
ff_rtp_codec_idFunction · 0.85
init_rtp_handlerFunction · 0.85
avcodec_descriptor_getFunction · 0.85
av_logFunction · 0.85
avpriv_set_pts_infoFunction · 0.85

Tested by

no test coverage detected