mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 10:25:33 +00:00
Generate timestamps even if the stream is not seekable
Original commit message from CVS: Generate timestamps even if the stream is not seekable
This commit is contained in:
parent
5de9552512
commit
c5b5e78223
1 changed files with 44 additions and 10 deletions
|
@ -192,12 +192,14 @@ gst_vorbisfile_init (VorbisFile * vorbisfile)
|
||||||
{
|
{
|
||||||
vorbisfile->sinkpad = gst_pad_new_from_template (dec_sink_template, "sink");
|
vorbisfile->sinkpad = gst_pad_new_from_template (dec_sink_template, "sink");
|
||||||
gst_element_add_pad (GST_ELEMENT (vorbisfile), vorbisfile->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (vorbisfile), vorbisfile->sinkpad);
|
||||||
|
gst_pad_set_convert_function (vorbisfile->sinkpad, NULL);
|
||||||
|
|
||||||
gst_element_set_loop_function (GST_ELEMENT (vorbisfile), gst_vorbisfile_loop);
|
gst_element_set_loop_function (GST_ELEMENT (vorbisfile), gst_vorbisfile_loop);
|
||||||
vorbisfile->srcpad = gst_pad_new_from_template (dec_src_template, "src");
|
vorbisfile->srcpad = gst_pad_new_from_template (dec_src_template, "src");
|
||||||
gst_element_add_pad (GST_ELEMENT (vorbisfile), vorbisfile->srcpad);
|
gst_element_add_pad (GST_ELEMENT (vorbisfile), vorbisfile->srcpad);
|
||||||
gst_pad_set_query_function (vorbisfile->srcpad, gst_vorbisfile_src_query);
|
gst_pad_set_query_function (vorbisfile->srcpad, gst_vorbisfile_src_query);
|
||||||
gst_pad_set_event_function (vorbisfile->srcpad, gst_vorbisfile_src_event);
|
gst_pad_set_event_function (vorbisfile->srcpad, gst_vorbisfile_src_event);
|
||||||
|
gst_pad_set_convert_function (vorbisfile->srcpad, NULL);
|
||||||
|
|
||||||
vorbisfile->convsize = 4096;
|
vorbisfile->convsize = 4096;
|
||||||
vorbisfile->total_out = 0;
|
vorbisfile->total_out = 0;
|
||||||
|
@ -444,11 +446,19 @@ gst_vorbisfile_loop (GstElement *element)
|
||||||
}
|
}
|
||||||
|
|
||||||
vorbisfile->may_eos = TRUE;
|
vorbisfile->may_eos = TRUE;
|
||||||
if (vorbisfile->vf.seekable) {
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = (gint64) (ov_time_tell (&vorbisfile->vf) * GST_SECOND);
|
{
|
||||||
|
GstFormat format;
|
||||||
|
gint64 value;
|
||||||
|
|
||||||
|
format = GST_FORMAT_TIME;
|
||||||
|
gst_vorbisfile_src_query (vorbisfile->srcpad, GST_PAD_QUERY_POSITION, &format, &value);
|
||||||
|
|
||||||
|
GST_BUFFER_TIMESTAMP (outbuf) = value;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = 0;
|
if (!vorbisfile->vf.seekable) {
|
||||||
|
vorbisfile->total_bytes += GST_BUFFER_SIZE (outbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_pad_push (vorbisfile->srcpad, outbuf);
|
gst_pad_push (vorbisfile->srcpad, outbuf);
|
||||||
|
@ -461,24 +471,36 @@ gst_vorbisfile_src_query (GstPad *pad, GstPadQueryType type,
|
||||||
{
|
{
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
VorbisFile *vorbisfile;
|
VorbisFile *vorbisfile;
|
||||||
|
vorbis_info *vi;
|
||||||
|
|
||||||
vorbisfile = GST_VORBISFILE (gst_pad_get_parent (pad));
|
vorbisfile = GST_VORBISFILE (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
|
vi = ov_info (&vorbisfile->vf, -1);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GST_PAD_QUERY_TOTAL:
|
case GST_PAD_QUERY_TOTAL:
|
||||||
{
|
{
|
||||||
switch (*format) {
|
switch (*format) {
|
||||||
case GST_FORMAT_UNITS:
|
case GST_FORMAT_UNITS:
|
||||||
|
if (vorbisfile->vf.seekable)
|
||||||
*value = ov_pcm_total (&vorbisfile->vf, -1);
|
*value = ov_pcm_total (&vorbisfile->vf, -1);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_BYTES:
|
case GST_FORMAT_BYTES:
|
||||||
res = FALSE;
|
if (vorbisfile->vf.seekable)
|
||||||
|
*value = ov_pcm_total (&vorbisfile->vf, -1) * vi->channels * 2;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_DEFAULT:
|
case GST_FORMAT_DEFAULT:
|
||||||
*format = GST_FORMAT_TIME;
|
*format = GST_FORMAT_TIME;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
|
if (vorbisfile->vf.seekable)
|
||||||
*value = (gint64) (ov_time_total (&vorbisfile->vf, -1) * GST_SECOND);
|
*value = (gint64) (ov_time_total (&vorbisfile->vf, -1) * GST_SECOND);
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
|
@ -492,10 +514,22 @@ gst_vorbisfile_src_query (GstPad *pad, GstPadQueryType type,
|
||||||
*format = GST_FORMAT_TIME;
|
*format = GST_FORMAT_TIME;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
|
if (vorbisfile->vf.seekable)
|
||||||
*value = (gint64) (ov_time_tell (&vorbisfile->vf) * GST_SECOND);
|
*value = (gint64) (ov_time_tell (&vorbisfile->vf) * GST_SECOND);
|
||||||
|
else
|
||||||
|
*value = vorbisfile->total_bytes * GST_SECOND / (vi->rate * vi->channels * 2);
|
||||||
|
break;
|
||||||
|
case GST_FORMAT_BYTES:
|
||||||
|
if (vorbisfile->vf.seekable)
|
||||||
|
*value = ov_pcm_tell (&vorbisfile->vf) * vi->channels * 2;
|
||||||
|
else
|
||||||
|
*value = vorbisfile->total_bytes;
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_UNITS:
|
case GST_FORMAT_UNITS:
|
||||||
|
if (vorbisfile->vf.seekable)
|
||||||
*value = ov_pcm_tell (&vorbisfile->vf);
|
*value = ov_pcm_tell (&vorbisfile->vf);
|
||||||
|
else
|
||||||
|
*value = vorbisfile->total_bytes / (vi->channels * 2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
|
|
Loading…
Reference in a new issue