Autodetect Asterisk raw pcm with extension "sln".
authorCarl Eugen Hoyos <cehoyos@ag.or.at>
Thu, 22 May 2014 13:15:04 +0000 (15:15 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Thu, 22 May 2014 13:15:04 +0000 (15:15 +0200)
libavformat/allformats.c
libavformat/pcmdec.c

index 0e7feea..30e5d30 100644 (file)
@@ -265,6 +265,7 @@ void av_register_all(void)
     REGISTER_MUXER   (SEGMENT,          stream_segment);
     REGISTER_DEMUXER (SHORTEN,          shorten);
     REGISTER_DEMUXER (SIFF,             siff);
+    REGISTER_DEMUXER (SLN,              sln);
     REGISTER_DEMUXER (SMACKER,          smacker);
     REGISTER_MUXDEMUX(SMJPEG,           smjpeg);
     REGISTER_MUXER   (SMOOTHSTREAMING,  smoothstreaming);
index f4264d9..2584c33 100644 (file)
@@ -144,3 +144,29 @@ PCMDEF(alaw, "PCM A-law",
 
 PCMDEF(mulaw, "PCM mu-law",
        "ul", AV_CODEC_ID_PCM_MULAW)
+
+static const AVOption sln_options[] = {
+    { "sample_rate", "", offsetof(PCMAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.i64 = 8000}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { "channels",    "", offsetof(PCMAudioDemuxerContext, channels),    AV_OPT_TYPE_INT, {.i64 = 1}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { NULL },
+};
+
+static const AVClass sln_demuxer_class = {
+    .class_name = "sln demuxer",
+    .item_name  = av_default_item_name,
+    .option     = sln_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_sln_demuxer = {
+    .name           = "sln",
+    .long_name      = NULL_IF_CONFIG_SMALL("Asterisk raw pcm"),
+    .priv_data_size = sizeof(PCMAudioDemuxerContext),
+    .read_header    = pcm_read_header,
+    .read_packet    = ff_pcm_read_packet,
+    .read_seek      = ff_pcm_read_seek,
+    .flags          = AVFMT_GENERIC_INDEX,
+    .extensions     = "sln",
+    .raw_codec_id   = AV_CODEC_ID_PCM_S16LE,
+    .priv_class     = &sln_demuxer_class,
+};