mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
audio-info: Allow from_caps() with encoded audio format
Similar to gst_video_info_from_caps() which allows encoded video format, don't error gst_audio_info_from_caps() with encoded audio format. Because gst_audio_info_set_format() supports encoded format, current behavior does not seem to be consistent.
This commit is contained in:
parent
2bc1b38825
commit
2f89c3aff1
1 changed files with 31 additions and 23 deletions
|
@ -193,13 +193,14 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstStructure *str;
|
GstStructure *str;
|
||||||
const gchar *s;
|
const gchar *s;
|
||||||
GstAudioFormat format;
|
GstAudioFormat format = GST_AUDIO_FORMAT_UNKNOWN;
|
||||||
gint rate, channels;
|
gint rate = 0;
|
||||||
guint64 channel_mask;
|
gint channels = 0;
|
||||||
|
guint64 channel_mask = 0;
|
||||||
gint i;
|
gint i;
|
||||||
GstAudioChannelPosition position[64];
|
GstAudioChannelPosition position[64];
|
||||||
GstAudioFlags flags;
|
GstAudioFlags flags;
|
||||||
GstAudioLayout layout;
|
GstAudioLayout layout = GST_AUDIO_LAYOUT_INTERLEAVED;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, FALSE);
|
g_return_val_if_fail (info != NULL, FALSE);
|
||||||
g_return_val_if_fail (caps != NULL, FALSE);
|
g_return_val_if_fail (caps != NULL, FALSE);
|
||||||
|
@ -211,28 +212,35 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
|
||||||
|
|
||||||
str = gst_caps_get_structure (caps, 0);
|
str = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
if (!gst_structure_has_name (str, "audio/x-raw"))
|
if (gst_structure_has_name (str, "audio/x-raw")) {
|
||||||
|
if (!(s = gst_structure_get_string (str, "format")))
|
||||||
|
goto no_format;
|
||||||
|
|
||||||
|
format = gst_audio_format_from_string (s);
|
||||||
|
if (format == GST_AUDIO_FORMAT_UNKNOWN)
|
||||||
|
goto unknown_format;
|
||||||
|
} else if (g_str_has_prefix (gst_structure_get_name (str), "audio/")) {
|
||||||
|
format = GST_AUDIO_FORMAT_ENCODED;
|
||||||
|
} else {
|
||||||
goto wrong_name;
|
goto wrong_name;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(s = gst_structure_get_string (str, "format")))
|
if (format != GST_AUDIO_FORMAT_ENCODED) {
|
||||||
goto no_format;
|
if (!(s = gst_structure_get_string (str, "layout")))
|
||||||
|
goto no_layout;
|
||||||
|
if (g_str_equal (s, "interleaved"))
|
||||||
|
layout = GST_AUDIO_LAYOUT_INTERLEAVED;
|
||||||
|
else if (g_str_equal (s, "non-interleaved"))
|
||||||
|
layout = GST_AUDIO_LAYOUT_NON_INTERLEAVED;
|
||||||
|
else
|
||||||
|
goto unknown_layout;
|
||||||
|
}
|
||||||
|
|
||||||
format = gst_audio_format_from_string (s);
|
if (!gst_structure_get_int (str, "rate", &rate) &&
|
||||||
if (format == GST_AUDIO_FORMAT_UNKNOWN)
|
format != GST_AUDIO_FORMAT_ENCODED)
|
||||||
goto unknown_format;
|
|
||||||
|
|
||||||
if (!(s = gst_structure_get_string (str, "layout")))
|
|
||||||
goto no_layout;
|
|
||||||
if (g_str_equal (s, "interleaved"))
|
|
||||||
layout = GST_AUDIO_LAYOUT_INTERLEAVED;
|
|
||||||
else if (g_str_equal (s, "non-interleaved"))
|
|
||||||
layout = GST_AUDIO_LAYOUT_NON_INTERLEAVED;
|
|
||||||
else
|
|
||||||
goto unknown_layout;
|
|
||||||
|
|
||||||
if (!gst_structure_get_int (str, "rate", &rate))
|
|
||||||
goto no_rate;
|
goto no_rate;
|
||||||
if (!gst_structure_get_int (str, "channels", &channels))
|
if (!gst_structure_get_int (str, "channels", &channels) &&
|
||||||
|
format != GST_AUDIO_FORMAT_ENCODED)
|
||||||
goto no_channels;
|
goto no_channels;
|
||||||
|
|
||||||
if (!gst_structure_get (str, "channel-mask", GST_TYPE_BITMASK, &channel_mask,
|
if (!gst_structure_get (str, "channel-mask", GST_TYPE_BITMASK, &channel_mask,
|
||||||
|
@ -242,7 +250,7 @@ gst_audio_info_from_caps (GstAudioInfo * info, const GstCaps * caps)
|
||||||
} else if (channels == 2) {
|
} else if (channels == 2) {
|
||||||
position[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
|
position[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
|
||||||
position[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
|
position[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
|
||||||
} else {
|
} else if (format != GST_AUDIO_FORMAT_ENCODED) {
|
||||||
goto no_channel_mask;
|
goto no_channel_mask;
|
||||||
}
|
}
|
||||||
} else if (channel_mask == 0) {
|
} else if (channel_mask == 0) {
|
||||||
|
|
Loading…
Reference in a new issue