summaryrefslogtreecommitdiffstats
path: root/gst/matroska
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2008-11-10 16:44:45 +0000
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2008-11-10 16:44:45 +0000
commite8a21443f1ce716a956a8bb161470fa662436a94 (patch)
tree88041a596c954a032e76b0683b5e6480808ffe66 /gst/matroska
parent9aecda0d08a558cbdd5da235d74e470dea734a86 (diff)
gst/matroska/matroska-mux.c: Fix mapping AAC profile to Matroska codec id.
Original commit message from CVS: * gst/matroska/matroska-mux.c: (aac_codec_data_to_codec_id), (gst_matroska_mux_audio_pad_setcaps): Fix mapping AAC profile to Matroska codec id.
Diffstat (limited to 'gst/matroska')
-rw-r--r--gst/matroska/matroska-mux.c62
1 files changed, 58 insertions, 4 deletions
diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c
index 0b24c543..ccf3ca04 100644
--- a/gst/matroska/matroska-mux.c
+++ b/gst/matroska/matroska-mux.c
@@ -1053,6 +1053,42 @@ flac_streamheader_to_codecdata (const GValue * streamheader,
return TRUE;
}
+static gchar *
+aac_codec_data_to_codec_id (const GstBuffer * buf)
+{
+ gchar *result;
+ gint profile;
+
+ /* default to MAIN */
+ profile = 1;
+
+ if (GST_BUFFER_SIZE (buf) >= 2) {
+ profile = GST_READ_UINT8 (GST_BUFFER_DATA (buf));
+ profile >>= 3;
+ }
+
+ switch (profile) {
+ case 1:
+ result = "MAIN";
+ break;
+ case 2:
+ result = "LC";
+ break;
+ case 3:
+ result = "SSR";
+ break;
+ case 4:
+ result = "LTP";
+ break;
+ default:
+ GST_WARNING ("unknown AAC profile, defaulting to MAIN");
+ result = "MAIN";
+ break;
+ }
+
+ return result;
+}
+
/**
* gst_matroska_mux_audio_pad_setcaps:
* @pad: Pad which got the caps.
@@ -1102,6 +1138,12 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
if (!strcmp (mimetype, "audio/mpeg")) {
gint mpegversion = 0;
+ const GValue *codec_data;
+ const GstBuffer *buf = NULL;
+
+ codec_data = gst_structure_get_value (structure, "codec_data");
+ if (codec_data)
+ buf = gst_value_get_buffer (codec_data);
gst_structure_get_int (structure, "mpegversion", &mpegversion);
switch (mpegversion) {
@@ -1146,12 +1188,24 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
break;
}
case 2:
- context->codec_id =
- g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2 "MAIN");
+ if (buf) {
+ context->codec_id =
+ g_strdup_printf (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2 "%s",
+ aac_codec_data_to_codec_id (buf));
+ } else {
+ GST_DEBUG_OBJECT (mux, "no AAC codec_data; not packetized");
+ return FALSE;
+ }
break;
case 4:
- context->codec_id =
- g_strdup (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4 "MAIN");
+ if (buf) {
+ context->codec_id =
+ g_strdup_printf (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4 "%s",
+ aac_codec_data_to_codec_id (buf));
+ } else {
+ GST_DEBUG_OBJECT (mux, "no AAC codec_data; not packetized");
+ return FALSE;
+ }
break;
default:
return FALSE;