GNOME Bugzilla – Bug 679611
ClutterGstVideoTexture: clutter_media_get_duration() fails after setting uri more than once
Last modified: 2013-01-03 18:19:56 UTC
Created attachment 218316 [details] Minimal example. Please see comment inside the file. I attempt to play two video files in a row using the same ClutterGstVideoTexture. During playback of the first video file, clutter_media_get_duration() returns the correct duration. After EOS I call clutter_media_set_uri() a second time (with a different video). Subsequently calling clutter_media_set_playing() works as intended (the video is being played back) but clutter_media_get_duration() keeps returning 0 from now on. See the attached file for an attempt at a minimal example to reproduce the observed behavior. See the comment in the file for instructions on how to compile and invoke. Tested on Ubunte 12.04 with libclutter-gst 1.5.4-0ubuntu2 libclutter 1.10.6-1~precise1 libgstreamer 0.10.36-1ubuntu1
I have researched this bug more extensively, mostly by bisecting the git tree. I can definitely say now that the bug is in clutter-gst. Specifically, up to commit a28be3c3 the above mentioned issue does not occur. In the subsequent commits I observed different behaviors when running the attached test program. 1. Starting with commit ac0dc977, clutter_media_get_duration() always returns 0. The eos signal, however still triggers as it should. 2. Interestingly, bba94be5 reverts these changes again, fixing the issue. 3. Starting with 6b96154a, clutter_media_get_duration() returns 0 on the second attempt as described in the original bug report. Also, after playback of the second video file the eos signal does not trigger anymore. 4. The bug is present at least until 1.6.0. After that, I couldn't compile clutter-gst anymore, because I don't have a recent enough libclutter at hand. 5. Also, I had to remove "-DCOGL_ENABLE_EXPERIMENTAL_2_0_API" from Makefile.am. Otherwise, it wouldn't compile on my system. Judging from 6b96154a I would say that the new "autocluttersink" element causes the trouble. Apparently, "cluttersink" which was used before, behaved correctly.
Created attachment 224428 [details] [review] Patch for the clutter-gst-1.6 branch This resolves the issue in the 1.6 branch. I cannot compile the master branch right now as I don't have gstreamer 1.0 running. However, I suspect that by simply replacing GST_ELEMENT_IS_SINK by GST_ELEMENT_FLAG_SINK this patch should work on the master branch just fine.
Maybe a little explanation is in order: The ClutterGstAutoVideoSink sets its GST_ELEMENT_IS_SINK flag in its init method. However, in contrast to the ClutterGstVideoSink, this class is not based on GstBaseSink but on GstBin instead. The problem is that GstBin automatically sets its GST_ELEMENT_IS_SINK flag whenever a sink is added. It also automatically unsets it whenever the last sink is removed from the bin. Now, after the first video clip is finished and the pipeline leaves the PLAYING state, the encapsulated ClutterGstVideoSink is removed from the ClutterGstAutoVideoSink leaving it without any sinks and thus making it lose its GST_ELEMENT_IS_SINK flag. Apparently this happens even before the EOS signal is broadcast in the pipeline. Interestingly, the ClutterGstAutoVideoSink does receive the EOS signal and forwards it to its parent, the vbin of the playsink. But the vbin ignores the signal because in bin_do_eos (gstbin.c) the is_eos check fails. This check, in turn, fails because the bin_element_is_sink check fails on its child, the ClutterGstAutoVideoSink (because its GST_ELEMENT_IS_SINK flag isn't set anymore). It seriously took me well over 30 hours to get to the root of all this. (It might have been solvable in less time if I have had any prior experience with the glib object model or with all the gstreamer intricacies.) :-)
Hi, Thanks a lot for your quest to fix this, yes, the explanation was needed :). I used it as the commit message as that's exactly how commit messages should be, explanatory! Also ported your patch to the master branch which a few changes ( s/IS_SINK/FLAG_SINK/ and a couple of cosmetic changes) but retaining your authorship. Sorry for the long delay, I try to make a few releases per GNOME cycle, don't really have time for more.