After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 108301 - source element synchronization (clock)
source element synchronization (clock)
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins
git master
Other All
: Normal major
: 0.6.x
Assigned To: Ronald Bultje
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-03-13 14:43 UTC by Ronald Bultje
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
this simple patch adds clocking support to osssrc. It doesn't check whether it's the master yet. (3.45 KB, patch)
2003-03-30 16:54 UTC, Ronald Bultje
none Details | Review
try #2 - also redoes state changing a bit (4.27 KB, patch)
2003-03-30 21:14 UTC, Ronald Bultje
none Details | Review
Example patch to add clock synchronization to v4lsrc (14.93 KB, patch)
2003-04-14 14:22 UTC, Ronald Bultje
none Details | Review
Fix the above bugs... (17.37 KB, patch)
2003-04-20 16:01 UTC, Ronald Bultje
none Details | Review
same changes for v4lmjpegsrc (17.59 KB, patch)
2003-04-20 16:38 UTC, Ronald Bultje
none Details | Review
same change for v4l2src (14.81 KB, patch)
2003-04-20 18:09 UTC, Ronald Bultje
none Details | Review

Description Ronald Bultje 2003-03-13 14:43:12 UTC
Video and audio (realtime) source elements should syncornize themselves to
the GstClock that's leading the element.

Let's assume a situation where we want the audio to be master and the video
slave (i.e. audio sets the clock, video synchronizes according to it),
osssrc (or alsasrc, or ...) should set the clock. Besides that (in case
this fails!), it should also test whether the clock was actually set and if
not, it should resample internally to make sure that it reaches the
requested audio playback rate. v4l*src should drop/insert frames to reach
the requested fps (25/PAL or 29.97/NTSC) and should also correct for lost
frames. QoS might also be used here (FIXME: how?).

Billy (vektor) disagrees here, btw, he thinks video should be the master.
Another option here is to just set a different framerate (tell the
following elements that we're actually 25.02 fps or so) and not drop/insert
frames at all... this might get messy, though, most files 'just' set 25fps
and you want to try to reach that framerate yourself too...

All of this together means, though, that the output framerate/samplerate of
v4l*src/audio*src, the timestamps used on the buffers and the one given in
the caps/_convert() functions should match, which currently is not the case.
Comment 1 Ronald Bultje 2003-03-30 16:54:41 UTC
Created attachment 15312 [details] [review]
this simple patch adds clocking support to osssrc. It doesn't check whether it's the master yet.
Comment 2 Ronald Bultje 2003-03-30 21:14:25 UTC
Created attachment 15316 [details] [review]
try #2 - also redoes state changing a bit
Comment 3 Ronald Bultje 2003-04-02 14:21:46 UTC
Now that audio is done, here's what's to be done for video:

<BBB> I make a property use_fixed_fps
<BBB> (boolean)
<BBB> if TRUE, we try to drop/insert frames to keep as close to the
framerate that we're supposed to give out (25fps/29.97fps) and report
that framerate on _convert() and _query()
<BBB> if FALSE, we just insert frames for lost ones (to prevent sudden
glitches) and don't do any further processing (so no framedrops) and
report the framerate at which we're actually giving out frames
<BBB> in the first case, the timestamp is just num_frames * GST_SECOND
/ fps
<BBB> the fps is fps
<BBB> in the second case, this is tricky
<BBB> we do gst_clock_get_time() and substract the time when we went
from PAUSED->PLAYING (this gets even more tricky when we go from
PLAYING->PAUSED and back, but that should be fixable too)
<BBB> the fps is num_frames * GST_SECOND / that
Comment 4 Ronald Bultje 2003-04-14 14:22:05 UTC
Created attachment 15712 [details] [review]
Example patch to add clock synchronization to v4lsrc
Comment 5 Ronald Bultje 2003-04-14 21:06:02 UTC
The above patch doesn't actually look at the need_writes for
requeueing the buffer. This means that:
*) if the buffer is not used, the buffer is never requeued
*) if the buffer is used more than once, it's requeued multiple times
To fix this, we need to keep a log of which buffers are used how many
times (we can probably us the is_queued[]-array for that).
Comment 6 Ronald Bultje 2003-04-20 16:01:19 UTC
Created attachment 15864 [details] [review]
Fix the above bugs...
Comment 7 Ronald Bultje 2003-04-20 16:38:03 UTC
Created attachment 15865 [details] [review]
same changes for v4lmjpegsrc
Comment 8 Ronald Bultje 2003-04-20 18:09:35 UTC
Created attachment 15867 [details] [review]
same change for v4l2src