summaryrefslogtreecommitdiffstats
path: root/gst/avi/gstavimux.c
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2007-10-02 10:49:03 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2007-10-02 10:49:03 +0000
commitce6f5264bd604ce7bfc174846d97996e1618a927 (patch)
tree1b0119f210b50ac1c280a447c03e6b33f209fe95 /gst/avi/gstavimux.c
parentb36ce655d8ebc55998a4a0feae12fb966c2654a4 (diff)
gst/avi/gstavimux.*: Also save codec data for audio streams. Fixes #482495.
Original commit message from CVS: * gst/avi/gstavimux.c: * gst/avi/gstavimux.h: Also save codec data for audio streams. Fixes #482495.
Diffstat (limited to 'gst/avi/gstavimux.c')
-rw-r--r--gst/avi/gstavimux.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/gst/avi/gstavimux.c b/gst/avi/gstavimux.c
index 66aeea89..44c132fb 100644
--- a/gst/avi/gstavimux.c
+++ b/gst/avi/gstavimux.c
@@ -335,6 +335,11 @@ gst_avi_mux_pad_reset (GstAviPad * avipad, gboolean free)
} else {
GstAviAudioPad *audpad = (GstAviAudioPad *) avipad;
+ if (audpad->auds_codec_data) {
+ gst_buffer_unref (audpad->auds_codec_data);
+ audpad->auds_codec_data = NULL;
+ }
+
memset (&(audpad->auds), 0, sizeof (gst_riff_strf_auds));
}
}
@@ -580,6 +585,7 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
GstAviCollectData *collect_pad;
GstStructure *structure;
const gchar *mimetype;
+ const GValue *codec_data;
gint channels, rate;
avimux = GST_AVI_MUX (gst_pad_get_parent (pad));
@@ -607,6 +613,15 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
avipad->auds.channels = channels;
avipad->auds.rate = rate;
+ /* codec initialization data, if any */
+ codec_data = gst_structure_get_value (structure, "codec_data");
+ if (codec_data) {
+ avipad->auds_codec_data = gst_value_get_buffer (codec_data);
+ gst_buffer_ref (avipad->auds_codec_data);
+ /* keep global track of size */
+ avimux->codec_data_size += GST_BUFFER_SIZE (avipad->auds_codec_data);
+ }
+
if (!strcmp (mimetype, "audio/x-raw-int")) {
gint width, depth;
@@ -650,6 +665,7 @@ gst_avi_mux_audsink_set_caps (GstPad * pad, GstCaps * vscaps)
break;
}
case 4:
+ GST_WARNING ("AAC");
avipad->auds.format = GST_RIFF_WAVE_FORMAT_AAC;
break;
}
@@ -895,8 +911,9 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
/* allocate the buffer, starting with some wild/safe upper bound */
size += avimux->codec_data_size + 100 + sizeof (gst_riff_avih)
- + (g_slist_length (avimux->sinkpads) *
- (100 + sizeof (gst_riff_strh) + sizeof (gst_riff_strf_vids)
+ + (g_slist_length (avimux->sinkpads) * (100 + sizeof (gst_riff_strh)
+ + sizeof (gst_riff_strf_vids)
+ + sizeof (gst_riff_strf_auds)
+ ODML_SUPERINDEX_SIZE));
buffer = gst_buffer_new_and_alloc (size);
buffdata = GST_BUFFER_DATA (buffer);
@@ -949,9 +966,12 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
codec_size = GST_BUFFER_SIZE (vidpad->vids_codec_data);
strl_size = sizeof (gst_riff_strh) + sizeof (gst_riff_strf_vids)
+ codec_size + 4 * 5 + ODML_SUPERINDEX_SIZE;
- } else
+ } else {
+ if (audpad->auds_codec_data)
+ codec_size = GST_BUFFER_SIZE (audpad->auds_codec_data);
strl_size = sizeof (gst_riff_strh) + sizeof (gst_riff_strf_auds)
- + 4 * 5 + ODML_SUPERINDEX_SIZE;
+ + codec_size + 4 * 5 + ODML_SUPERINDEX_SIZE;
+ }
/* stream list metadata */
memcpy (buffdata + 0, "LIST", 4);
@@ -1005,7 +1025,8 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
} else {
/* the audio header */
memcpy (buffdata + 68, "strf", 4);
- GST_WRITE_UINT32_LE (buffdata + 72, sizeof (gst_riff_strf_auds));
+ GST_WRITE_UINT32_LE (buffdata + 72,
+ sizeof (gst_riff_strf_auds) + codec_size);
/* the actual header */
GST_WRITE_UINT16_LE (buffdata + 76, audpad->auds.format);
GST_WRITE_UINT16_LE (buffdata + 78, audpad->auds.channels);
@@ -1015,6 +1036,15 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
GST_WRITE_UINT16_LE (buffdata + 90, audpad->auds.size);
buffdata += 92;
highmark += 92;
+
+ /* include codec data, if any */
+ if (codec_size) {
+ memcpy (buffdata, GST_BUFFER_DATA (audpad->auds_codec_data),
+ codec_size);
+
+ buffdata += codec_size;
+ highmark += codec_size;
+ }
}
/* odml superindex chunk */