* RTP output format
* Copyright (c) 2002 Fabrice Bellard
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "mpegts.h"
#include "internal.h"
+#include "libavutil/mathematics.h"
#include "libavutil/random_seed.h"
+#include "libavutil/opt.h"
#include "rtpenc.h"
//#define DEBUG
+static const AVOption options[] = {
+ FF_RTP_FLAG_OPTS(RTPMuxContext, flags),
+ { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM },
+ { NULL },
+};
+
+static const AVClass rtp_muxer_class = {
+ .class_name = "RTP muxer",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
#define RTCP_SR_SIZE 28
static int is_supported(enum CodecID id)
return -1;
}
- s->payload_type = ff_rtp_get_payload_type(st->codec);
if (s->payload_type < 0)
- s->payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == AVMEDIA_TYPE_AUDIO);
-
+ s->payload_type = ff_rtp_get_payload_type(s1, st->codec);
s->base_timestamp = av_get_random_seed();
s->timestamp = s->base_timestamp;
s->cur_timestamp = 0;
s->first_rtcp_ntp_time = (s1->start_time_realtime / 1000) * 1000 +
NTP_OFFSET_US;
- max_packet_size = url_fget_max_packet_size(s1->pb);
+ max_packet_size = s1->pb->max_packet_size;
if (max_packet_size <= 12)
return AVERROR(EIO);
s->buf = av_malloc(max_packet_size);
avio_wb32(s1->pb, rtp_ts);
avio_wb32(s1->pb, s->packet_count);
avio_wb32(s1->pb, s->octet_count);
- put_flush_packet(s1->pb);
+ avio_flush(s1->pb);
}
/* send an rtp packet. sequence number is incremented, but the caller
avio_wb32(s1->pb, s->ssrc);
avio_write(s1->pb, buf1, len);
- put_flush_packet(s1->pb);
+ avio_flush(s1->pb);
s->seq++;
s->octet_count += len;
ff_rtp_send_mpegvideo(s1, pkt->data, size);
break;
case CODEC_ID_AAC:
- ff_rtp_send_aac(s1, pkt->data, size);
+ if (s->flags & FF_RTP_FLAG_MP4A_LATM)
+ ff_rtp_send_latm(s1, pkt->data, size);
+ else
+ ff_rtp_send_aac(s1, pkt->data, size);
break;
case CODEC_ID_AMR_NB:
case CODEC_ID_AMR_WB:
}
AVOutputFormat ff_rtp_muxer = {
- "rtp",
- NULL_IF_CONFIG_SMALL("RTP output format"),
- NULL,
- NULL,
- sizeof(RTPMuxContext),
- CODEC_ID_PCM_MULAW,
- CODEC_ID_NONE,
- rtp_write_header,
- rtp_write_packet,
- rtp_write_trailer,
+ .name = "rtp",
+ .long_name = NULL_IF_CONFIG_SMALL("RTP output format"),
+ .priv_data_size = sizeof(RTPMuxContext),
+ .audio_codec = CODEC_ID_PCM_MULAW,
+ .video_codec = CODEC_ID_NONE,
+ .write_header = rtp_write_header,
+ .write_packet = rtp_write_packet,
+ .write_trailer = rtp_write_trailer,
+ .priv_class = &rtp_muxer_class,
};