最近在搞 ffmpeg RTP 向RTMP的转换,所以顺便把ffmpeg相关的源码看了一下
没在rtpdec.c中找到找到 rtp demuxer的定义,却在rtsp.c中找到了,而且还找到了sdp demuxer
下面给出定义
ff_sdp_demuxer 和 ff_rtp_demuxer 的定义 位于 rtsp.c中
AVInputFormat ff_sdp_demuxer = {
.name = "sdp",
.long_name = NULL_IF_CONFIG_SMALL("SDP"),
.priv_data_size = sizeof(RTSPState),
.read_probe = sdp_probe,
.read_header = sdp_read_header,
.read_packet = ff_rtsp_fetch_packet,
.read_close = sdp_read_close,
.priv_class = &sdp_demuxer_class,
};
AVInputFormat ff_rtp_demuxer = {
.name = "rtp",
.long_name = NULL_IF_CONFIG_SMALL("RTP input"),
.priv_data_size = sizeof(RTSPState),
.read_probe = rtp_probe,
.read_header = rtp_read_header,
.read_packet = ff_rtsp_fetch_packet,
.read_close = sdp_read_close,
.flags = AVFMT_NOFILE,
.priv_class = &rtp_demuxer_class,
};
可以看到在读取包的方法上两个demuxer都是通过ff_rtsp_fetch_packet来读取包
而ff_rtsp_demuxer读取包的方法rtsp_read_packet也是调用这一方法来实现的
ff_rtp_muxer 的定义位于 rtpenc.c中
AVOutputFormat ff_rtp_muxer = {
.name = "rtp",
.long_name = NULL_IF_CONFIG_SMALL("RTP output"),
.priv_data_size = sizeof(RTPMuxContext),
.audio_codec = AV_CODEC_ID_PCM_MULAW,
.video_codec = AV_CODEC_ID_MPEG4,
.write_header = rtp_write_header,
.write_packet = rtp_write_packet,
.write_trailer = rtp_write_trailer,
.priv_class = &rtp_muxer_class,
.flags = AVFMT_TS_NONSTRICT,
};