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 748055 - avfvideosrc: get connection and input clock early
avfvideosrc: get connection and input clock early
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal enhancement
: git master
Assigned To: Ilya Konstantinov
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-04-17 13:53 UTC by Ilya Konstantinov
Modified: 2015-06-12 15:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
avfvideosrc: get connection and input clock early (2.44 KB, patch)
2015-04-17 13:53 UTC, Ilya Konstantinov
none Details | Review
avfvideosrc: set sample buffer delegate last (1.46 KB, patch)
2015-06-12 15:37 UTC, Ilya Konstantinov
none Details | Review

Description Ilya Konstantinov 2015-04-17 13:53:14 UTC
Created attachment 301840 [details] [review]
avfvideosrc: get connection and input clock early

Slight refactoring. Will also be useful as a base for exposing any other properties that are controlled through the connection, e.g. orientation and mirroring.
Comment 1 Alessandro Decina 2015-04-17 14:34:03 UTC
commit a02a948a5dbdda949f2aa818981eb2fc96e03b76
Author: Ilya Konstantinov <ilya.konstantinov@gmail.com>
Date:   Fri Apr 17 05:12:10 2015 +0300

    avfvideosrc: get connection and input clock early
Comment 2 Ilya Konstantinov 2015-06-12 15:37:24 UTC
Created attachment 305157 [details] [review]
avfvideosrc: set sample buffer delegate last

Oops, the previous patch would cause this sporadic error:

(<unknown>:1161): GStreamer-CRITICAL **: _gst_util_uint64_scale: assertion 'denom != 0' failed

occurring in:

    now = CMClockGetTime(inputClock); // <-- inputClock == nil
    // ^ now == 0
    input_clock_now = gst_util_uint64_scale (GST_SECOND,
        now.value, now.timescale); // <-- critical error

The problem is caused by:

    [output setSampleBufferDelegate:self
                              queue:workerQueue];
    [session addOutput:output];

    ...
    // ERROR: At this point, inputClock == nil
    //        and the delegate can be called already
    inputClock = ((AVCaptureInputPort *)connection.inputPorts[0]).clock;

The solution is simple -- postpone setting sample buffer delegate to the end.
Comment 3 Ilya Konstantinov 2015-06-12 15:51:00 UTC
Actually, I take it back -- this issue doesn't affect avfvideosrc as-is.

It affects my avfvideosrc because it has another (not yet submitted) patch which allows setting an external session (i.e. a session shared with the user's app). In this case, the (externally-set) session is already running, so the delegate will be called as soon as:

    [output setSampleBufferDelegate:self
                              queue:workerQueue];
    [session addOutput:output];

is performed, triggering the above problem.