<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Trying to write a player using gstreamer and the playbin element. I'm creating a pipeline, adding a bus watch and waiting for messages on the bus. I then set the uri on the pipeline and wait for it to go to playing state. The code is something like this (checks and cleanup removed):<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>//when user selects a resource<o:p></o:p></p><p class=MsoNormal>m_pipeline = gst_element_factory_make("playbin", "playbin0");<o:p></o:p></p><p class=MsoNormal>GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));<o:p></o:p></p><p class=MsoNormal>m_busWatchId = gst_bus_add_watch (bus, IPlayer::s_busCallback, this);<o:p></o:p></p><p class=MsoNormal>gst_object_unref(bus); <o:p></o:p></p><p class=MsoNormal>g_object_set(G_OBJECT (m_pipeline), "uri", m_uri.c_str(), NULL);<o:p></o:p></p><p class=MsoNormal>gst_element_set_state(m_pipeline, GST_STATE_PAUSED);<o:p></o:p></p><p class=MsoNormal>//when user presses 'play'<o:p></o:p></p><p class=MsoNormal>gst_element_set_state(m_pipeline, GST_STATE_PLAYING);<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>In my bus callback I then look for GST_MESSAGE_STATE_CHANGED in order to know when the pipeline starts playing. Sometimes this works as expected, I get: NULL->READY, READY->PAUSED, PAUSED->PLAYING.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sometimes I only get first: NULL->READY. The video starts playing anyway however, so something is working but my application just has no idea that playback has started.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This is just on application startup, so preconditions should be the same for all runs. I'm guessing something is racing but cannot figure out what. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>My only vague guess is that it’s somehow not allowed to set GST_STATE_PLAYING before the first full transition from NULL to PAUSED (via READY) has completed. But I cannot find documentation that confirms this, and it would take a lot of code to queue up my state changes like that, so I’d rather not do it unless it’s totally necessary. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Here are some logs obtained by setting GST_DEBUG to 4.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When I get the state change:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>0:00:02.918974302 7028 0DF19EC0 INFO GST_STATES gstelement.c:2277:_priv_gst_element_state_changed: notifying about state-changed PAUSED to PLAYING (VOID_PENDING pending) <o:p></o:p></p><p class=MsoNormal>0:00:02.919185366 7028 06452D20 FIXME bin gstbin.c:4144:gst_bin_query: implement duration caching in GstBin again <o:p></o:p></p><p class=MsoNormal>0:00:02.919405213 7028 06452D20 FIXME bin gstbin.c:4144:gst_bin_query: implement duration caching in GstBin again <o:p></o:p></p><p class=MsoNormal>0:00:02.919624475 7028 06452D20 FIXME bin gstbin.c:4144:gst_bin_query: implement duration caching in GstBin again <o:p></o:p></p><p class=MsoNormal>0:00:02.919882670 7028 06452D20 FIXME bin gstbin.c:4144:gst_bin_query: implement duration caching in GstBin again [Media] <o:p></o:p></p><p class=MsoNormal>IPlayer.cpp:555 gst_element_query_duration 85542000000ns [Media] <o:p></o:p></p><p class=MsoNormal>IPlayer.cpp:152 Pipeline playbin0 changed state from PAUSED to PLAYING pending VOID_PENDING. Duration 85542ms<o:p></o:p></p><p class=MsoNormal>0:00:02.926384105 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.927016128 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.927645809 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.929138777 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.929487722 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.929740355 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.931064998 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.931415992 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.932754686 7028 06452D20 INFO GST_STATES gstbin.c:1915:gst_bin_get_state_func: getting state<o:p></o:p></p><p class=MsoNormal>0:00:02.933954622 7028 06452D20 INFO default gstdebugutils.c:811:gst_debug_bin_to_dot_file: wrote bin graph to : 'dot\IPlayer-PLAYING.dot'<o:p></o:p></p><p class=MsoNormal>0:00:02.950122584 7028 0DEB5920 INFO videodecoder gstvideodecoder.c:1432:gst_video_decoder_sink_event_default: upstream tags: taglist, video-codec=(string)"H.264\ \(Main\ Profile\)", bitrate=(uint)2981313, minimum-bitrate=(uint)281200, maximum-bitrate=(uint)1461000;<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>When I don't get the state change:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>0:00:02.947089811 11792 0D369EC0 INFO GST_STATES gstelement.c:2277:_priv_gst_element_state_changed: notifying about state-changed PAUSED to PLAYING (VOID_PENDING pending) <o:p></o:p></p><p class=MsoNormal>0:00:02.981495398 11792 0D307920 INFO videodecoder gstvideodecoder.c:1432:gst_video_decoder_sink_event_default: upstream tags: taglist, video-codec=(string)"H.264\ \(Main\ Profile\)", bitrate=(uint)2981313, minimum-bitrate=(uint)281200, maximum-bitrate=(uint)1461000; <o:p></o:p></p><p class=MsoNormal>0:00:03.020488493 11792 0D307920 INFO videodecoder gstvideodecoder.c:1432:gst_video_decoder_sink_event_default: upstream tags: taglist, video-codec=(string)"H.264\ \(Main\ Profile\)", bitrate=(uint)2981313, minimum-bitrate=(uint)281200, maximum-bitrate=(uint)3918800;<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Of course the logs are a lot longer, but I'm assuming this is the relevant place. The IPlayer.cpp stuff is my application, so this is only when I get the callback. When I add/remove certain printf's I can no longer reproduce the problem.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’m using gstreamer 1.8.1 on windows7.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Best Regards,<o:p></o:p></p><p class=MsoNormal>Henning<o:p></o:p></p></div></body></html>