From 6674b029e405e01a495e0b3f3a3e57a9a6648be3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 6 Feb 2012 15:52:36 +0100 Subject: [PATCH] flv: fix caps --- gst/flv/Makefile.am | 2 +- gst/flv/gstflvdemux.c | 18 ++++++++++++------ gst/flv/gstflvmux.c | 37 ++++++++++++++++--------------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/gst/flv/Makefile.am b/gst/flv/Makefile.am index d4124a9..be7657a 100644 --- a/gst/flv/Makefile.am +++ b/gst/flv/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgstflv.la libgstflv_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) -libgstflv_la_LIBADD = -lgstpbutils-@GST_MAJORMINOR@ \ +libgstflv_la_LIBADD = -lgstpbutils-@GST_MAJORMINOR@ -lgstaudio-@GST_MAJORMINOR@\ $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) libgstflv_la_LDFLAGS = ${GST_PLUGIN_LDFLAGS} libgstflv_la_SOURCES = gstflvdemux.c gstflvmux.c diff --git a/gst/flv/gstflvdemux.c b/gst/flv/gstflvdemux.c index af51773..f454a5e 100644 --- a/gst/flv/gstflvdemux.c +++ b/gst/flv/gstflvdemux.c @@ -41,6 +41,7 @@ #include #include #include +#include /* FIXME: don't rely on own GstIndex */ #include "gstindex.c" @@ -64,8 +65,7 @@ static GstStaticPadTemplate audio_src_template = "audio/mpeg, mpegversion = (int) 1, layer = (int) 3, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 22050, 44100 }, parsed = (boolean) TRUE; " "audio/mpeg, mpegversion = (int) 4, framed = (boolean) TRUE; " "audio/x-nellymoser, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 16000, 22050, 44100 }; " - "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 8, depth = (int) 8, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) FALSE; " - "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 16, depth = (int) 16, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) TRUE; " + "audio/x-raw, format = (string) { U8, S16LE }, layout = (string) interleaved, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; " "audio/x-alaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; " "audio/x-mulaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; " "audio/x-speex, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 };") @@ -646,14 +646,20 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag, break; case 0: case 3: + { + GstAudioFormat format; + /* Assuming little endian for 0 (aka endianness of the * system on which the file was created) as most people * are probably using little endian machines */ - caps = gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, - "signed", G_TYPE_BOOLEAN, (width == 8) ? FALSE : TRUE, - "width", G_TYPE_INT, width, "depth", G_TYPE_INT, width, NULL); + format = gst_audio_format_build_integer ((width == 8) ? FALSE : TRUE, + G_LITTLE_ENDIAN, width, width); + + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, gst_audio_format_to_string (format), + "layout", G_TYPE_STRING, "interleaved", NULL); break; + } case 4: case 5: case 6: diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c index 79dd0f6..a4d7eae 100644 --- a/gst/flv/gstflvmux.c +++ b/gst/flv/gstflvmux.c @@ -38,6 +38,8 @@ #include #include +#include + #include "gstflvmux.h" #include "amfdefs.h" @@ -76,8 +78,7 @@ static GstStaticPadTemplate audiosink_templ = GST_STATIC_PAD_TEMPLATE ("audio", "audio/mpeg, mpegversion = (int) 1, layer = (int) 3, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 22050, 44100 }, parsed = (boolean) TRUE; " "audio/mpeg, mpegversion = (int) { 2, 4 }, framed = (boolean) TRUE; " "audio/x-nellymoser, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 16000, 22050, 44100 }; " - "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 8, depth = (int) 8, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) FALSE; " - "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 16, depth = (int) 16, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) TRUE; " + "audio/x-raw, format = (string) { U8, S16LE}, layout = (string) interleaved, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; " "audio/x-alaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; " "audio/x-mulaw, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; " "audio/x-speex, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 };") @@ -425,13 +426,19 @@ gst_flv_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps) } else { cpad->audio_codec = 6; } - } else if (strcmp (gst_structure_get_name (s), "audio/x-raw-int") == 0) { - gint endianness; + } else if (strcmp (gst_structure_get_name (s), "audio/x-raw") == 0) { + GstAudioInfo info; - if (gst_structure_get_int (s, "endianness", &endianness) - && endianness == G_LITTLE_ENDIAN) + if (gst_audio_info_from_caps (&info, caps)) { cpad->audio_codec = 3; - else + + if (GST_AUDIO_INFO_WIDTH (&info) == 8) + cpad->width = 0; + else if (GST_AUDIO_INFO_WIDTH (&info) == 16) + cpad->width = 1; + else + ret = FALSE; + } else ret = FALSE; } else if (strcmp (gst_structure_get_name (s), "audio/x-alaw") == 0) { cpad->audio_codec = 7; @@ -444,7 +451,7 @@ gst_flv_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps) } if (ret) { - gint rate, channels, width; + gint rate, channels; if (gst_structure_get_int (s, "rate", &rate)) { if (cpad->audio_codec == 10) @@ -491,20 +498,8 @@ gst_flv_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps) ret = FALSE; } - if (gst_structure_get_int (s, "width", &width)) { - if (cpad->audio_codec != 3) - cpad->width = 1; - else if (width == 8) - cpad->width = 0; - else if (width == 16) - cpad->width = 1; - else - ret = FALSE; - } else if (cpad->audio_codec != 3) { + if (cpad->audio_codec != 3) cpad->width = 1; - } else { - ret = FALSE; - } } if (ret && gst_structure_has_field (s, "codec_data")) { -- 2.7.4