mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-05 09:00:54 +00:00
aacparse: set channels and rate on output caps, and keep codec_data
Create output caps from input caps, so we maintain any fields we might get on the input caps, such as codec_data or rate and channels. Set channels and rate on the output caps if we don't have input caps or they don't contain such fields. We do this partly because we can, but also because some muxers need this information. Tagreadbin will also be happy about this.
This commit is contained in:
parent
7f82fe3b46
commit
f5a03ec2a6
2 changed files with 41 additions and 15 deletions
|
@ -213,17 +213,27 @@ gst_aacparse_finalize (GObject * object)
|
|||
static gboolean
|
||||
gst_aacparse_set_src_caps (GstAacParse * aacparse)
|
||||
{
|
||||
GstCaps *src_caps = NULL;
|
||||
gchar *caps_str = NULL;
|
||||
GstStructure *s;
|
||||
GstCaps *sink_caps, *src_caps = NULL;
|
||||
gboolean res = FALSE;
|
||||
|
||||
src_caps = gst_caps_new_simple ("audio/mpeg",
|
||||
"framed", G_TYPE_BOOLEAN, TRUE,
|
||||
sink_caps = GST_PAD_CAPS (GST_BASE_PARSE (aacparse)->sinkpad);
|
||||
GST_DEBUG_OBJECT (aacparse, "sink caps: %" GST_PTR_FORMAT, sink_caps);
|
||||
if (sink_caps)
|
||||
src_caps = gst_caps_copy (sink_caps);
|
||||
else
|
||||
src_caps = gst_caps_new_simple ("audio/mpeg", NULL);
|
||||
|
||||
gst_caps_set_simple (src_caps, "framed", G_TYPE_BOOLEAN, TRUE,
|
||||
"mpegversion", G_TYPE_INT, aacparse->mpegversion, NULL);
|
||||
|
||||
caps_str = gst_caps_to_string (src_caps);
|
||||
GST_DEBUG_OBJECT (aacparse, "setting srcpad caps: %s", caps_str);
|
||||
g_free (caps_str);
|
||||
s = gst_caps_get_structure (src_caps, 0);
|
||||
if (!gst_structure_has_field (s, "rate") && aacparse->sample_rate > 0)
|
||||
gst_structure_set (s, "rate", G_TYPE_INT, aacparse->sample_rate, NULL);
|
||||
if (!gst_structure_has_field (s, "channels") && aacparse->channels > 0)
|
||||
gst_structure_set (s, "channels", G_TYPE_INT, aacparse->channels, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (aacparse, "setting src caps: %" GST_PTR_FORMAT, src_caps);
|
||||
|
||||
gst_pad_use_fixed_caps (GST_BASE_PARSE (aacparse)->srcpad);
|
||||
res = gst_pad_set_caps (GST_BASE_PARSE (aacparse)->srcpad, src_caps);
|
||||
|
|
|
@ -29,9 +29,12 @@
|
|||
#define SRC_CAPS_CDATA "audio/mpeg, framed=(boolean)false, codec_data=(buffer)1190"
|
||||
#define SRC_CAPS_TMPL "audio/mpeg, framed=(boolean)false, mpegversion=(int){2,4}"
|
||||
|
||||
#define SINK_CAPS "audio/mpeg, framed=(boolean)true"
|
||||
#define SINK_CAPS_MPEG2 "audio/mpeg, framed=(boolean)true, mpegversion=2"
|
||||
#define SINK_CAPS_MPEG4 "audio/mpeg, framed=(boolean)true, mpegversion=4"
|
||||
#define SINK_CAPS \
|
||||
"audio/mpeg, framed=(boolean)true"
|
||||
#define SINK_CAPS_MPEG2 \
|
||||
"audio/mpeg, framed=(boolean)true, mpegversion=2, rate=48000, channels=2"
|
||||
#define SINK_CAPS_MPEG4 \
|
||||
"audio/mpeg, framed=(boolean)true, mpegversion=4, rate=96000, channels=2"
|
||||
#define SINK_CAPS_TMPL "audio/mpeg, framed=(boolean)true, mpegversion=(int){2,4}"
|
||||
|
||||
GList *buffers;
|
||||
|
@ -130,6 +133,8 @@ buffer_verify_adts (void *buffer, void *user_data)
|
|||
gchar *bcaps = gst_caps_to_string (GST_BUFFER_CAPS (buffer));
|
||||
g_free (bcaps);
|
||||
|
||||
GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?",
|
||||
GST_BUFFER_CAPS (buffer), vdata->caps);
|
||||
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), vdata->caps));
|
||||
}
|
||||
|
||||
|
@ -226,6 +231,7 @@ GST_START_TEST (test_parse_adif_normal)
|
|||
/* For ADIF parser assumes that data is always version 4 */
|
||||
scaps = gst_caps_from_string (SINK_CAPS_MPEG4);
|
||||
sinkcaps = gst_pad_get_negotiated_caps (sinkpad);
|
||||
GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?", sinkcaps, scaps);
|
||||
fail_unless (gst_caps_is_equal (sinkcaps, scaps));
|
||||
gst_caps_unref (sinkcaps);
|
||||
gst_caps_unref (scaps);
|
||||
|
@ -413,6 +419,7 @@ GST_START_TEST (test_parse_adts_detect_mpeg_version)
|
|||
|
||||
/* Check that the negotiated caps are as expected */
|
||||
sinkcaps = gst_pad_get_negotiated_caps (sinkpad);
|
||||
GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT "?", sinkcaps, vdata.caps);
|
||||
fail_unless (gst_caps_is_equal (sinkcaps, vdata.caps));
|
||||
gst_caps_unref (sinkcaps);
|
||||
|
||||
|
@ -425,7 +432,10 @@ GST_START_TEST (test_parse_adts_detect_mpeg_version)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
#define structure_get_int(s,f) \
|
||||
(g_value_get_int(gst_structure_get_value(s,f)))
|
||||
#define fail_unless_structure_field_int_equals(s,field,num) \
|
||||
fail_unless_equals_int (structure_get_int(s,field), num)
|
||||
/*
|
||||
* Test if the parser handles raw stream and codec_data info properly.
|
||||
*/
|
||||
|
@ -433,7 +443,8 @@ GST_START_TEST (test_parse_handle_codec_data)
|
|||
{
|
||||
GstElement *aacparse;
|
||||
GstBuffer *buffer;
|
||||
GstCaps *scaps, *sinkcaps;
|
||||
GstCaps *sinkcaps;
|
||||
GstStructure *s;
|
||||
guint datasum = 0;
|
||||
guint i;
|
||||
|
||||
|
@ -449,11 +460,16 @@ GST_START_TEST (test_parse_handle_codec_data)
|
|||
|
||||
/* Check that the negotiated caps are as expected */
|
||||
/* When codec_data is present, parser assumes that data is version 4 */
|
||||
scaps = gst_caps_from_string (SINK_CAPS_MPEG4);
|
||||
sinkcaps = gst_pad_get_negotiated_caps (sinkpad);
|
||||
fail_unless (gst_caps_is_equal (sinkcaps, scaps));
|
||||
GST_LOG ("aac output caps: %" GST_PTR_FORMAT, sinkcaps);
|
||||
s = gst_caps_get_structure (sinkcaps, 0);
|
||||
fail_unless (gst_structure_has_name (s, "audio/mpeg"));
|
||||
fail_unless_structure_field_int_equals (s, "mpegversion", 4);
|
||||
fail_unless_structure_field_int_equals (s, "channels", 2);
|
||||
fail_unless_structure_field_int_equals (s, "rate", 48000);
|
||||
fail_unless (gst_structure_has_field (s, "codec_data"));
|
||||
|
||||
gst_caps_unref (sinkcaps);
|
||||
gst_caps_unref (scaps);
|
||||
|
||||
g_list_foreach (buffers, buffer_count_size, &datasum);
|
||||
fail_unless_equals_int (datasum, 10 * 100);
|
||||
|
|
Loading…
Reference in a new issue