mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-25 16:48:11 +00:00
isomp4: Port to the new audio caps
Still needs to handle the channel positions/masks and channel reordering.
This commit is contained in:
parent
c97ac83d66
commit
940807b79b
3 changed files with 44 additions and 52 deletions
|
@ -117,6 +117,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstcollectpads.h>
|
#include <gst/base/gstcollectpads.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
#include <gst/tag/xmpwriter.h>
|
#include <gst/tag/xmpwriter.h>
|
||||||
|
|
||||||
|
@ -2777,51 +2778,38 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
entry.samples_per_packet = 320;
|
entry.samples_per_packet = 320;
|
||||||
entry.bytes_per_sample = 2;
|
entry.bytes_per_sample = 2;
|
||||||
ext_atom = build_amr_extension ();
|
ext_atom = build_amr_extension ();
|
||||||
} else if (strcmp (mimetype, "audio/x-raw-int") == 0) {
|
} else if (strcmp (mimetype, "audio/x-raw") == 0) {
|
||||||
gint width;
|
GstAudioInfo info;
|
||||||
gint depth;
|
|
||||||
gint endianness;
|
|
||||||
gboolean sign;
|
|
||||||
|
|
||||||
if (!gst_structure_get_int (structure, "width", &width) ||
|
gst_audio_info_init (&info);
|
||||||
!gst_structure_get_int (structure, "depth", &depth) ||
|
if (!gst_audio_info_from_caps (&info, caps))
|
||||||
!gst_structure_get_boolean (structure, "signed", &sign)) {
|
|
||||||
GST_DEBUG_OBJECT (qtmux, "broken caps, width/depth/signed field missing");
|
|
||||||
goto refuse_caps;
|
goto refuse_caps;
|
||||||
}
|
|
||||||
|
|
||||||
if (depth <= 8) {
|
|
||||||
endianness = G_BYTE_ORDER;
|
|
||||||
} else if (!gst_structure_get_int (structure, "endianness", &endianness)) {
|
|
||||||
GST_DEBUG_OBJECT (qtmux, "broken caps, endianness field missing");
|
|
||||||
goto refuse_caps;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* spec has no place for a distinction in these */
|
/* spec has no place for a distinction in these */
|
||||||
if (width != depth) {
|
if (info.finfo->width != info.finfo->depth) {
|
||||||
GST_DEBUG_OBJECT (qtmux, "width must be same as depth!");
|
GST_DEBUG_OBJECT (qtmux, "width must be same as depth!");
|
||||||
goto refuse_caps;
|
goto refuse_caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sign) {
|
if ((info.finfo->flags & GST_AUDIO_FORMAT_FLAG_SIGNED)) {
|
||||||
if (endianness == G_LITTLE_ENDIAN)
|
if (info.finfo->endianness == G_LITTLE_ENDIAN)
|
||||||
entry.fourcc = FOURCC_sowt;
|
entry.fourcc = FOURCC_sowt;
|
||||||
else if (endianness == G_BIG_ENDIAN)
|
else if (info.finfo->endianness == G_BIG_ENDIAN)
|
||||||
entry.fourcc = FOURCC_twos;
|
entry.fourcc = FOURCC_twos;
|
||||||
/* maximum backward compatibility; only new version for > 16 bit */
|
/* maximum backward compatibility; only new version for > 16 bit */
|
||||||
if (depth <= 16)
|
if (info.finfo->depth <= 16)
|
||||||
entry.version = 0;
|
entry.version = 0;
|
||||||
/* not compressed in any case */
|
/* not compressed in any case */
|
||||||
entry.compression_id = 0;
|
entry.compression_id = 0;
|
||||||
/* QT spec says: max at 16 bit even if sample size were actually larger,
|
/* QT spec says: max at 16 bit even if sample size were actually larger,
|
||||||
* however, most players (e.g. QuickTime!) seem to disagree, so ... */
|
* however, most players (e.g. QuickTime!) seem to disagree, so ... */
|
||||||
entry.sample_size = depth;
|
entry.sample_size = info.finfo->depth;
|
||||||
entry.bytes_per_sample = depth / 8;
|
entry.bytes_per_sample = info.finfo->depth / 8;
|
||||||
entry.samples_per_packet = 1;
|
entry.samples_per_packet = 1;
|
||||||
entry.bytes_per_packet = depth / 8;
|
entry.bytes_per_packet = info.finfo->depth / 8;
|
||||||
entry.bytes_per_frame = entry.bytes_per_packet * channels;
|
entry.bytes_per_frame = entry.bytes_per_packet * info.channels;
|
||||||
} else {
|
} else {
|
||||||
if (width == 8 && depth == 8) {
|
if (info.finfo->width == 8 && info.finfo->depth == 8) {
|
||||||
/* fall back to old 8-bit version */
|
/* fall back to old 8-bit version */
|
||||||
entry.fourcc = FOURCC_raw_;
|
entry.fourcc = FOURCC_raw_;
|
||||||
entry.version = 0;
|
entry.version = 0;
|
||||||
|
@ -2832,7 +2820,7 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
|
||||||
goto refuse_caps;
|
goto refuse_caps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
constant_size = (depth / 8) * channels;
|
constant_size = (info.finfo->depth / 8) * info.channels;
|
||||||
} else if (strcmp (mimetype, "audio/x-alaw") == 0) {
|
} else if (strcmp (mimetype, "audio/x-alaw") == 0) {
|
||||||
entry.fourcc = FOURCC_alaw;
|
entry.fourcc = FOURCC_alaw;
|
||||||
entry.samples_per_packet = 1023;
|
entry.samples_per_packet = 1023;
|
||||||
|
|
|
@ -85,32 +85,25 @@
|
||||||
"rate = (int) [ 1, " G_STRINGIFY (r) " ]"
|
"rate = (int) [ 1, " G_STRINGIFY (r) " ]"
|
||||||
|
|
||||||
#define PCM_CAPS \
|
#define PCM_CAPS \
|
||||||
"audio/x-raw-int, " \
|
"audio/x-raw, " \
|
||||||
"width = (int) 8, " \
|
"format = (string) { S8, U8 }, " \
|
||||||
"depth = (int) 8, " \
|
"layout = (string) interleaved, " \
|
||||||
COMMON_AUDIO_CAPS (2, MAX) ", " \
|
COMMON_AUDIO_CAPS (2, MAX) "; " \
|
||||||
"signed = (boolean) { true, false }; " \
|
"audio/x-raw, " \
|
||||||
"audio/x-raw-int, " \
|
"format = (string) { S16LE, S16BE }, " \
|
||||||
"width = (int) 16, " \
|
"layout = (string) interleaved, " \
|
||||||
"depth = (int) 16, " \
|
COMMON_AUDIO_CAPS (2, MAX)
|
||||||
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
|
|
||||||
COMMON_AUDIO_CAPS (2, MAX) ", " \
|
|
||||||
"signed = (boolean) true " \
|
|
||||||
|
|
||||||
#define PCM_CAPS_FULL \
|
#define PCM_CAPS_FULL \
|
||||||
PCM_CAPS "; " \
|
PCM_CAPS "; " \
|
||||||
"audio/x-raw-int, " \
|
"audio/x-raw, " \
|
||||||
"width = (int) 24, " \
|
"format = (string) { S24LE, S24BE }, " \
|
||||||
"depth = (int) 24, " \
|
"layout = (string) interleaved, " \
|
||||||
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
|
COMMON_AUDIO_CAPS (2, MAX) "; " \
|
||||||
COMMON_AUDIO_CAPS (2, MAX) ", " \
|
"audio/x-raw, " \
|
||||||
"signed = (boolean) true; " \
|
"format = (string) { S32LE, S32BE }, " \
|
||||||
"audio/x-raw-int, " \
|
"layout = (string) interleaved, " \
|
||||||
"width = (int) 32, " \
|
COMMON_AUDIO_CAPS (2, MAX)
|
||||||
"depth = (int) 32, " \
|
|
||||||
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
|
|
||||||
COMMON_AUDIO_CAPS (2, MAX) ", " \
|
|
||||||
"signed = (boolean) true "
|
|
||||||
|
|
||||||
#define MP3_CAPS \
|
#define MP3_CAPS \
|
||||||
"audio/mpeg, " \
|
"audio/mpeg, " \
|
||||||
|
|
|
@ -5117,6 +5117,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
|
||||||
gst_pad_new_from_static_template (&gst_qtdemux_audiosrc_template, name);
|
gst_pad_new_from_static_template (&gst_qtdemux_audiosrc_template, name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
if (stream->caps) {
|
if (stream->caps) {
|
||||||
|
/* FIXME: Need to set channel-mask here and maybe reorder */
|
||||||
gst_caps_set_simple (stream->caps,
|
gst_caps_set_simple (stream->caps,
|
||||||
"rate", G_TYPE_INT, (int) stream->rate,
|
"rate", G_TYPE_INT, (int) stream->rate,
|
||||||
"channels", G_TYPE_INT, stream->n_channels, NULL);
|
"channels", G_TYPE_INT, stream->n_channels, NULL);
|
||||||
|
@ -7216,8 +7217,9 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux),
|
if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux),
|
||||||
headerbuf, &header, &extra)) {
|
headerbuf, &header, &extra)) {
|
||||||
gst_caps_unref (stream->caps);
|
gst_caps_unref (stream->caps);
|
||||||
|
/* FIXME: Need to do something with the channel reorder map */
|
||||||
stream->caps = gst_riff_create_audio_caps (header->format, NULL,
|
stream->caps = gst_riff_create_audio_caps (header->format, NULL,
|
||||||
header, extra, NULL, NULL);
|
header, extra, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (extra)
|
if (extra)
|
||||||
gst_buffer_unref (extra);
|
gst_buffer_unref (extra);
|
||||||
|
@ -9661,6 +9663,15 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (caps) {
|
||||||
|
GstCaps *templ_caps =
|
||||||
|
gst_static_pad_template_get_caps (&gst_qtdemux_audiosrc_template);
|
||||||
|
GstCaps *intersection = gst_caps_intersect (caps, templ_caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
gst_caps_unref (templ_caps);
|
||||||
|
caps = intersection;
|
||||||
|
}
|
||||||
|
|
||||||
/* enable clipping for raw audio streams */
|
/* enable clipping for raw audio streams */
|
||||||
s = gst_caps_get_structure (caps, 0);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
name = gst_structure_get_name (s);
|
name = gst_structure_get_name (s);
|
||||||
|
|
Loading…
Reference in a new issue