static int mpegts_init(AVFormatContext *ctx, int st_index, PayloadContext *data) { data->ts = ff_mpegts_parse_open(ctx); if (!data->ts) return AVERROR(ENOMEM); return 0; }
/** * open a new RTP parse context for stream 'st'. 'st' can be NULL for * MPEG2-TS streams to indicate that they should be demuxed inside the * rtp demux (otherwise AV_CODEC_ID_MPEG2TS packets are returned) */ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size) { RTPDemuxContext *s; s = av_mallocz(sizeof(RTPDemuxContext)); if (!s) return NULL; s->payload_type = payload_type; s->last_rtcp_ntp_time = AV_NOPTS_VALUE; s->first_rtcp_ntp_time = AV_NOPTS_VALUE; s->ic = s1; s->st = st; s->queue_size = queue_size; rtp_init_statistics(&s->statistics, 0); // do we know the initial sequence from sdp? if (!strcmp(ff_rtp_enc_name(payload_type), "MP2T")) { s->ts = ff_mpegts_parse_open(s->ic); if (s->ts == NULL) { av_free(s); return NULL; } } else if (st) { switch (st->codec->codec_id) { case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP3: case AV_CODEC_ID_MPEG4: case AV_CODEC_ID_H263: case AV_CODEC_ID_H264: st->need_parsing = AVSTREAM_PARSE_FULL; break; case AV_CODEC_ID_VORBIS: st->need_parsing = AVSTREAM_PARSE_HEADERS; break; case AV_CODEC_ID_ADPCM_G722: /* According to RFC 3551, the stream clock rate is 8000 * even if the sample rate is 16000. */ if (st->codec->sample_rate == 8000) st->codec->sample_rate = 16000; break; default: break; } } // needed to send back RTCP RR in RTSP sessions s->rtp_ctx = rtpc; gethostname(s->hostname, sizeof(s->hostname)); return s; }
/** * open a new RTP parse context for stream 'st'. 'st' can be NULL for * MPEG2TS streams to indicate that they should be demuxed inside the * rtp demux (otherwise CODEC_ID_MPEG2TS packets are returned) * TODO: change this to not take rtp_payload data, and use the new dynamic payload system. */ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data) { RTPDemuxContext *s; s = av_mallocz(sizeof(RTPDemuxContext)); if (!s) return NULL; s->payload_type = payload_type; s->last_rtcp_ntp_time = AV_NOPTS_VALUE; s->first_rtcp_ntp_time = AV_NOPTS_VALUE; s->ic = s1; s->st = st; s->rtp_payload_data = rtp_payload_data; rtp_init_statistics(&s->statistics, 0); // do we know the initial sequence from sdp? if (!strcmp(ff_rtp_enc_name(payload_type), "MP2T")) { s->ts = ff_mpegts_parse_open(s->ic); if (s->ts == NULL) { av_free(s); return NULL; } } else { av_set_pts_info(st, 32, 1, 90000); switch(st->codec->codec_id) { case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: case CODEC_ID_MP2: case CODEC_ID_MP3: case CODEC_ID_MPEG4: case CODEC_ID_H263: case CODEC_ID_H264: st->need_parsing = AVSTREAM_PARSE_FULL; break; default: if (st->codec->codec_type == CODEC_TYPE_AUDIO) { av_set_pts_info(st, 32, 1, st->codec->sample_rate); } break; } } // needed to send back RTCP RR in RTSP sessions s->rtp_ctx = rtpc; gethostname(s->hostname, sizeof(s->hostname)); return s; }