[7/8] movenc: Add an AVOption for enabling LATM in the RTP hinting

Message ID 1305893640-56569-8-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö May 20, 2011, 12:13 p.m.
---
 libavformat/movenc.c |   34 ++++++++++++++++++++++++++++++++++
 libavformat/movenc.h |    3 +++
 2 files changed, 37 insertions(+), 0 deletions(-)

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 2d9460c..0b78744 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -32,10 +32,41 @@ 
 #include "libavcodec/put_bits.h"
 #include "internal.h"
 #include "libavutil/avstring.h"
+#include "libavutil/opt.h"
 
 #undef NDEBUG
 #include <assert.h>
 
+static const AVOption options[] = {
+    { "latm", "Use MP4A-LATM RTP packetization instead of MPEG4-GENERIC for AAC", offsetof(MOVMuxContext, rtp_mp4a_latm), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+    { NULL },
+};
+
+#if CONFIG_MOV_MUXER
+static const AVClass mov_muxer_class = {
+    .class_name = "MOV muxer",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+#endif
+#if CONFIG_TGP_MUXER
+static const AVClass tgp_muxer_class = {
+    .class_name = "3GP muxer",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+#endif
+#if CONFIG_MP4_MUXER
+static const AVClass mp4_muxer_class = {
+    .class_name = "MP4 muxer",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+#endif
+
 //FIXME support 64 bit variant with wide placeholders
 static int64_t updateSize(AVIOContext *pb, int64_t pos)
 {
@@ -2285,6 +2316,7 @@  AVOutputFormat ff_mov_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
 #if CONFIG_TGP_MUXER
@@ -2301,6 +2333,7 @@  AVOutputFormat ff_tgp_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
+    .priv_class = &tgp_muxer_class,
 };
 #endif
 #if CONFIG_MP4_MUXER
@@ -2317,6 +2350,7 @@  AVOutputFormat ff_mp4_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
+    .priv_class = &mp4_muxer_class,
 };
 #endif
 #if CONFIG_PSP_MUXER
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 0cc1eb8..a861324 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -101,6 +101,7 @@  typedef struct MOVIndex {
 } MOVTrack;
 
 typedef struct MOVMuxContext {
+    const AVClass *av_class;
     int     mode;
     int64_t time;
     int     nb_streams;
@@ -108,6 +109,8 @@  typedef struct MOVMuxContext {
     int64_t mdat_pos;
     uint64_t mdat_size;
     MOVTrack *tracks;
+
+    int rtp_mp4a_latm;
 } MOVMuxContext;
 
 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);