Commit 940807b7 authored by Sebastian Dröge's avatar Sebastian Dröge

isomp4: Port to the new audio caps

Still needs to handle the channel positions/masks and
channel reordering.
parent c97ac83d
......@@ -117,6 +117,7 @@
#include <gst/gst.h>
#include <gst/base/gstcollectpads.h>
#include <gst/audio/audio.h>
#include <gst/video/video.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.bytes_per_sample = 2;
ext_atom = build_amr_extension ();
} else if (strcmp (mimetype, "audio/x-raw-int") == 0) {
gint width;
gint depth;
gint endianness;
gboolean sign;
} else if (strcmp (mimetype, "audio/x-raw") == 0) {
GstAudioInfo info;
if (!gst_structure_get_int (structure, "width", &width) ||
!gst_structure_get_int (structure, "depth", &depth) ||
!gst_structure_get_boolean (structure, "signed", &sign)) {
GST_DEBUG_OBJECT (qtmux, "broken caps, width/depth/signed field missing");
gst_audio_info_init (&info);
if (!gst_audio_info_from_caps (&info, 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 */
if (width != depth) {
if (info.finfo->width != info.finfo->depth) {
GST_DEBUG_OBJECT (qtmux, "width must be same as depth!");
goto refuse_caps;
}
if (sign) {
if (endianness == G_LITTLE_ENDIAN)
if ((info.finfo->flags & GST_AUDIO_FORMAT_FLAG_SIGNED)) {
if (info.finfo->endianness == G_LITTLE_ENDIAN)
entry.fourcc = FOURCC_sowt;
else if (endianness == G_BIG_ENDIAN)
else if (info.finfo->endianness == G_BIG_ENDIAN)
entry.fourcc = FOURCC_twos;
/* maximum backward compatibility; only new version for > 16 bit */
if (depth <= 16)
if (info.finfo->depth <= 16)
entry.version = 0;
/* not compressed in any case */
entry.compression_id = 0;
/* QT spec says: max at 16 bit even if sample size were actually larger,
* however, most players (e.g. QuickTime!) seem to disagree, so ... */
entry.sample_size = depth;
entry.bytes_per_sample = depth / 8;
entry.sample_size = info.finfo->depth;
entry.bytes_per_sample = info.finfo->depth / 8;
entry.samples_per_packet = 1;
entry.bytes_per_packet = depth / 8;
entry.bytes_per_frame = entry.bytes_per_packet * channels;
entry.bytes_per_packet = info.finfo->depth / 8;
entry.bytes_per_frame = entry.bytes_per_packet * info.channels;
} else {
if (width == 8 && depth == 8) {
if (info.finfo->width == 8 && info.finfo->depth == 8) {
/* fall back to old 8-bit version */
entry.fourcc = FOURCC_raw_;
entry.version = 0;
......@@ -2832,7 +2820,7 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * 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) {
entry.fourcc = FOURCC_alaw;
entry.samples_per_packet = 1023;
......
......@@ -85,32 +85,25 @@
"rate = (int) [ 1, " G_STRINGIFY (r) " ]"
#define PCM_CAPS \
"audio/x-raw-int, " \
"width = (int) 8, " \
"depth = (int) 8, " \
COMMON_AUDIO_CAPS (2, MAX) ", " \
"signed = (boolean) { true, false }; " \
"audio/x-raw-int, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
COMMON_AUDIO_CAPS (2, MAX) ", " \
"signed = (boolean) true " \
"audio/x-raw, " \
"format = (string) { S8, U8 }, " \
"layout = (string) interleaved, " \
COMMON_AUDIO_CAPS (2, MAX) "; " \
"audio/x-raw, " \
"format = (string) { S16LE, S16BE }, " \
"layout = (string) interleaved, " \
COMMON_AUDIO_CAPS (2, MAX)
#define PCM_CAPS_FULL \
PCM_CAPS "; " \
"audio/x-raw-int, " \
"width = (int) 24, " \
"depth = (int) 24, " \
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
COMMON_AUDIO_CAPS (2, MAX) ", " \
"signed = (boolean) true; " \
"audio/x-raw-int, " \
"width = (int) 32, " \
"depth = (int) 32, " \
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
COMMON_AUDIO_CAPS (2, MAX) ", " \
"signed = (boolean) true "
"audio/x-raw, " \
"format = (string) { S24LE, S24BE }, " \
"layout = (string) interleaved, " \
COMMON_AUDIO_CAPS (2, MAX) "; " \
"audio/x-raw, " \
"format = (string) { S32LE, S32BE }, " \
"layout = (string) interleaved, " \
COMMON_AUDIO_CAPS (2, MAX)
#define MP3_CAPS \
"audio/mpeg, " \
......
......@@ -5117,6 +5117,7 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux,
gst_pad_new_from_static_template (&gst_qtdemux_audiosrc_template, name);
g_free (name);
if (stream->caps) {
/* FIXME: Need to set channel-mask here and maybe reorder */
gst_caps_set_simple (stream->caps,
"rate", G_TYPE_INT, (int) stream->rate,
"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),
headerbuf, &header, &extra)) {
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,
header, extra, NULL, NULL);
header, extra, NULL, NULL, NULL);
if (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 */
s = gst_caps_get_structure (caps, 0);
name = gst_structure_get_name (s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment