Fix endian issues with metadata. Some Cleanups too

Original commit message from CVS:
Fix endian issues with metadata. Some Cleanups too
This commit is contained in:
Wim Taymans 2003-02-02 23:48:30 +00:00
parent 37afd27681
commit 9314894ee3

View file

@ -412,7 +412,7 @@ gst_avi_demux_metadata (GstAviDemux *avi_demux, gint len)
{ {
guint32 got_bytes; guint32 got_bytes;
GstByteStream *bs = avi_demux->bs; GstByteStream *bs = avi_demux->bs;
gst_riff_chunk *chunk; gst_riff_chunk *temp_chunk, chunk;
gchar *name, *type; gchar *name, *type;
GstProps *props; GstProps *props;
GstPropsEntry *entry; GstPropsEntry *entry;
@ -420,24 +420,29 @@ gst_avi_demux_metadata (GstAviDemux *avi_demux, gint len)
props = gst_props_empty_new (); props = gst_props_empty_new ();
while (len > 0) { while (len > 0) {
got_bytes = gst_bytestream_peek_bytes(bs, (guint8**)&chunk, sizeof(gst_riff_chunk)); got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&temp_chunk, sizeof (gst_riff_chunk));
gst_bytestream_flush(bs, sizeof(gst_riff_chunk));
if (got_bytes != sizeof(gst_riff_chunk)) /* fixup for our big endian friends */
chunk.id = GUINT32_FROM_LE (temp_chunk->id);
chunk.size = GUINT32_FROM_LE (temp_chunk->size);
gst_bytestream_flush (bs, sizeof (gst_riff_chunk));
if (got_bytes != sizeof (gst_riff_chunk))
return; return;
len -= sizeof(gst_riff_chunk); len -= sizeof (gst_riff_chunk);
/* don't care about empty entries - move on */ /* don't care about empty entries - move on */
if (chunk->size == 0) if (chunk.size == 0)
continue; continue;
got_bytes = gst_bytestream_peek_bytes(bs, (guint8**)&name, chunk->size); got_bytes = gst_bytestream_peek_bytes (bs, (guint8**)&name, chunk.size);
gst_bytestream_flush(bs, (chunk->size + 1) &~ 1); gst_bytestream_flush (bs, (chunk.size + 1) & ~1);
if (got_bytes != chunk->size) if (got_bytes != chunk.size)
return; return;
len -= ((chunk->size + 1) &~ 1); len -= ((chunk.size + 1) & ~1);
/* we now have an info string in 'name' of type 'chunk.id' - find 'type' */ /* we now have an info string in 'name' of type 'chunk.id' - find 'type' */
switch (chunk->id) { switch (chunk.id) {
case GST_RIFF_INFO_IARL: case GST_RIFF_INFO_IARL:
type = "Location"; type = "Location";
break; break;
@ -514,16 +519,17 @@ gst_avi_demux_metadata (GstAviDemux *avi_demux, gint len)
if (type) { if (type) {
/* create props entry */ /* create props entry */
entry = gst_props_entry_new(type, GST_PROPS_STRING(name)); entry = gst_props_entry_new (type, GST_PROPS_STRING (name));
gst_props_add_entry (props, entry); gst_props_add_entry (props, entry);
} }
} }
gst_props_debug(props); gst_props_debug(props);
avi_demux->metadata = gst_caps_new("avi_metadata", gst_caps_replace_sink (&avi_demux->metadata,
"application/x-gst-metadata", gst_caps_new("avi_metadata",
props); "application/x-gst-metadata",
props));
g_object_notify(G_OBJECT(avi_demux), "metadata"); g_object_notify(G_OBJECT(avi_demux), "metadata");
} }
@ -537,9 +543,10 @@ gst_avi_demux_streaminfo (GstAviDemux *avi_demux)
/* compression formats are added later - a bit hacky */ /* compression formats are added later - a bit hacky */
avi_demux->streaminfo = gst_caps_new("avi_streaminfo", gst_caps_replace_sink (&avi_demux->streaminfo,
"application/x-gst-streaminfo", gst_caps_new("avi_streaminfo",
props); "application/x-gst-streaminfo",
props));
/*g_object_notify(G_OBJECT(avi_demux), "streaminfo");*/ /*g_object_notify(G_OBJECT(avi_demux), "streaminfo");*/
} }
@ -1700,14 +1707,8 @@ gst_avi_demux_change_state (GstElement *element)
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
gst_bytestream_destroy (avi_demux->bs); gst_bytestream_destroy (avi_demux->bs);
if (avi_demux->metadata) { gst_caps_replace (&avi_demux->metadata, NULL);
gst_caps_unref(avi_demux->metadata); gst_caps_replace (&avi_demux->streaminfo, NULL);
avi_demux->metadata = NULL;
}
if (avi_demux->streaminfo) {
gst_caps_unref(avi_demux->streaminfo);
avi_demux->streaminfo = NULL;
}
break; break;
case GST_STATE_READY_TO_NULL: case GST_STATE_READY_TO_NULL:
break; break;