summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorLuca Abeni <lucabe72@email.it>2007-10-02 14:48:08 +0000
committerLuca Abeni <lucabe72@email.it>2007-10-02 14:48:08 +0000
commite0d21bfe835eec87b8c0efe6e9973ae5f588bc07 (patch)
tree1031f231b2673252dd031b79c9fc7045d3a3d254 /libavformat
parent0d0447eae09dca047412a03d64ac2bfc11a80d35 (diff)
Allow to set the maximum number of frames per RTP packet (and add support for
this in the AAC packetizer) Originally committed as revision 10647 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/rtp.c15
-rw-r--r--libavformat/rtp_aac.c2
-rw-r--r--libavformat/rtp_internal.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index 02d3e7be29..14e9189635 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -747,6 +747,21 @@ static int rtp_write_header(AVFormatContext *s1)
return AVERROR(EIO);
s->max_payload_size = max_packet_size - 12;
+ s->max_frames_per_packet = 0;
+ if (s1->max_delay) {
+ if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+ if (st->codec->frame_size == 0) {
+ av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
+ } else {
+ s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN);
+ }
+ }
+ if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+ /* FIXME: We should round down here... */
+ s->max_frames_per_packet = av_rescale_q(s1->max_delay, AV_TIME_BASE_Q, st->codec->time_base);
+ }
+ }
+
av_set_pts_info(st, 32, 1, 90000);
switch(st->codec->codec_id) {
case CODEC_ID_MP2:
diff --git a/libavformat/rtp_aac.c b/libavformat/rtp_aac.c
index 04dc3cfdda..4cd8e129d2 100644
--- a/libavformat/rtp_aac.c
+++ b/libavformat/rtp_aac.c
@@ -22,7 +22,7 @@
#include "rtp_aac.h"
#include "rtp_internal.h"
-#define MAX_FRAMES_PER_PACKET 5
+#define MAX_FRAMES_PER_PACKET (s->max_frames_per_packet ? s->max_frames_per_packet : 5)
#define MAX_AU_HEADERS_SIZE (2 + 2 * MAX_FRAMES_PER_PACKET)
void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size)
diff --git a/libavformat/rtp_internal.h b/libavformat/rtp_internal.h
index 96477620b3..4bfa4bba62 100644
--- a/libavformat/rtp_internal.h
+++ b/libavformat/rtp_internal.h
@@ -105,6 +105,7 @@ struct RTPDemuxContext {
/* dynamic payload stuff */
DynamicPayloadPacketHandlerProc parse_packet; ///< This is also copied from the dynamic protocol handler structure
void *dynamic_protocol_context; ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
+ int max_frames_per_packet;
};
extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;