gst/matroska/matroska-demux.c: Fix duration query; fix basetime in newsegment event after seek; fix duration in initi...

Original commit message from CVS:
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_handle_src_query),
(gst_matroska_demux_handle_seek_event),
(gst_matroska_demux_loop_stream_parse_id):
Fix duration query; fix basetime in newsegment event after
seek; fix duration in initial newsegment event.
* gst/matroska/matroska-mux.c:
(gst_matroska_mux_audio_pad_setcaps), (gst_matroska_mux_start):
Extract number of channels and samplerate from vorbis headers;
add some debug messages when querying the durations of the
input streams.
This commit is contained in:
Tim-Philipp Müller 2005-10-20 19:14:27 +00:00
parent 57bcc588e4
commit a7e0b7d6b5
3 changed files with 42 additions and 18 deletions

View file

@ -1,3 +1,18 @@
2005-10-20 Tim-Philipp Müller <tim at centricular dot net>
* gst/matroska/matroska-demux.c:
(gst_matroska_demux_handle_src_query),
(gst_matroska_demux_handle_seek_event),
(gst_matroska_demux_loop_stream_parse_id):
Fix duration query; fix basetime in newsegment event after
seek; fix duration in initial newsegment event.
* gst/matroska/matroska-mux.c:
(gst_matroska_mux_audio_pad_setcaps), (gst_matroska_mux_start):
Extract number of channels and samplerate from vorbis headers;
add some debug messages when querying the durations of the
input streams.
2005-10-20 Wim Taymans <wim@fluendo.com>
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),

View file

@ -990,7 +990,7 @@ gst_matroska_demux_handle_src_query (GstPad * pad, GstQuery * query)
{
GstFormat format;
gst_query_parse_position (query, &format, NULL);
gst_query_parse_duration (query, &format, NULL);
if (format != GST_FORMAT_TIME) {
GST_DEBUG ("only query duration on TIME is supported");
@ -1196,7 +1196,7 @@ gst_matroska_demux_handle_seek_event (GstMatroskaDemux * demux,
}
newsegment_event = gst_event_new_newsegment (FALSE, demux->segment_rate,
GST_FORMAT_TIME, entry->time, demux->segment_stop, 0);
GST_FORMAT_TIME, entry->time, demux->segment_stop, entry->time);
GST_UNLOCK (demux);
@ -2730,7 +2730,8 @@ gst_matroska_demux_loop_stream_parse_id (GstMatroskaDemux * demux,
/* send initial discont */
gst_matroska_demux_send_event (demux,
gst_event_new_newsegment (FALSE, 1.0,
GST_FORMAT_TIME, 0, demux->duration, 0));
GST_FORMAT_TIME, 0,
(demux->duration > 0) ? demux->duration : -1, 0));
GST_DEBUG_OBJECT (demux, "signaling no more pads");
gst_element_no_more_pads (GST_ELEMENT (demux));

View file

@ -603,7 +603,7 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
GstMatroskaPad *collect_pad;
GstMatroskaMux *mux = GST_MATROSKA_MUX (gst_pad_get_parent (pad));
const gchar *mimetype;
gint samplerate, channels;
gint samplerate = 0, channels = 0;
GstStructure *structure;
/* find context */
@ -671,10 +671,12 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
gint endianness, width, depth;
gboolean signedness;
gst_structure_get_int (structure, "endianness", &endianness);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "depth", &depth);
gst_structure_get_int (structure, "signed", &signedness);
if (!gst_structure_get_int (structure, "endianness", &endianness) ||
!gst_structure_get_int (structure, "width", &width) ||
!gst_structure_get_int (structure, "depth", &depth) ||
!gst_structure_get_int (structure, "signed", &signedness))
return FALSE;
if (width != depth ||
(width == 8 && signedness) || (width == 16 && !signedness))
return FALSE;
@ -747,6 +749,13 @@ gst_matroska_mux_audio_pad_setcaps (GstPad * pad, GstCaps * caps)
GST_BUFFER_SIZE (buf[i]));
offset += GST_BUFFER_SIZE (buf[i]);
}
if (memcmp (GST_BUFFER_DATA (buf[0]) + 1, "vorbis", 6) == 0) {
guint8 *hdr = GST_BUFFER_DATA (buf[0]) + 1 + 6 + 4;
audiocontext->channels = GST_READ_UINT8 (hdr);
audiocontext->samplerate = GST_READ_UINT32_LE (hdr + 1);
}
} else {
GST_WARNING_OBJECT (mux, "Vorbis header does not contain "
"three buffers (found %d buffers), Ignoring.", bufarr->len);
@ -1027,25 +1036,24 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
for (collected = mux->collect->data; collected;
collected = g_slist_next (collected)) {
GstMatroskaPad *collect_pad;
GstPad *thepad;
GstQuery *query;
GstFormat format = GST_FORMAT_TIME;
GstPad *thepad, *peerpad;
gint64 trackduration;
collect_pad = (GstMatroskaPad *) collected->data;
thepad = collect_pad->collect.pad;
/* Query the total length of the track. */
query = gst_query_new_duration (GST_FORMAT_TIME);
if (gst_pad_query (GST_PAD_PEER (thepad), query)) {
GstFormat format;
gint64 trackduration;
gst_query_parse_duration (query, &format, &trackduration);
peerpad = gst_pad_get_peer (thepad);
GST_DEBUG ("Querying duration on pad %s:%s", GST_DEBUG_PAD_NAME (thepad));
if (gst_pad_query_duration (peerpad, &format, &trackduration)) {
GST_DEBUG ("%s:%s - duration: %" GST_TIME_FORMAT,
GST_DEBUG_PAD_NAME (thepad), GST_TIME_ARGS (trackduration));
if ((gdouble) trackduration > duration) {
duration = (gdouble) trackduration;
}
}
gst_query_unref (query);
gst_object_unref (peerpad);
}
gst_ebml_write_float (ebml, GST_MATROSKA_ID_DURATION,
duration / mux->time_scale);