Hi all!
I would like to know what the correct way to wait for a state change in gstreamer. I'm using a typical code doing a polling after the 'gst_element_set_state' call but sometimes, with the machine under a heavy load, I get a timeout but gstreamer is still working and finally changes the state.
Is there a better way? Is it possible to wait without timeout and look for some error trying to change the state? What timeout is considered safe?
The code waiting for a state change with a 10 seconds timeout
bool poll_for_state_change( GstState new_state )
{ GTimeVal tfthen, tfnow; GstClockTimeDiff diff; GstStateChangeReturn result = GST_STATE_CHANGE_FAILURE; GstState current; gint32 timeescap = 0; gst_element_get_state( pipeline, ¤t, NULL, GST_SECOND ); printf( "%s - change state from %s to %s\n", __FUNCTION__, gst_element_state_get_name( current ), gst_element_state_get_name( new_state ) ); if( current == new_state ) return true; g_get_current_time( &tfthen ); result = gst_element_set_state( pipeline, new_state ); if( result == GST_STATE_CHANGE_FAILURE ) return false; while( 1 ) { gst_element_get_state( pipeline, ¤t, NULL, GST_SECOND ); g_get_current_time( &tfnow ); diff = GST_TIMEVAL_TO_TIME( tfnow ) - GST_TIMEVAL_TO_TIME( tfthen ); diff /= (1000 * 1000); timeescap = (unsigned int) diff; if( new_state == current ) break; if( timeescap > 10000 ) { printf( "%s - Time out in state transferring from %s to %s\n", __FUNCTION__, gst_element_state_get_name( current ), gst_element_state_get_name( new_state ) ); return false; } } return true; }
Thanks! Jorge
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi, you should create a listener for the message bus. Every element posts its state changed message on the bus. When complete, the pipeline also posts a state changed
message on the bus. There are examples in the user manual Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Jorge Fernandez Monteagudo Hi all! I would like to know what the correct way to wait for a state change in gstreamer. I'm using a typical code doing a polling after the 'gst_element_set_state' call but sometimes, with the machine under a heavy load, I get a timeout but gstreamer is still working and finally changes the state. Is there a better way? Is it possible to wait without timeout and look for some error trying to change the state? What timeout is considered safe? The code waiting for a state change with a 10 seconds timeout bool poll_for_state_change( GstState new_state ) Thanks! Jorge _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi!
Thanks for your answer! And is there any way to check if the state change has hit an error? Maybe capturing the 'GST_MESSAGE_ERROR' event? I supposse I have to wait until the pipeline has change its state, isn't it? De: gstreamer-devel <[hidden email]> en nombre de Thornton, Keith <[hidden email]>
Enviado: martes, 4 de abril de 2017 14:30:31 Para: Discussion of the development of and with GStreamer Asunto: AW: gst_element_set_state question Hi, you should create a listener for the message bus. Every element posts its state changed message on the bus. When complete, the pipeline also posts a state changed
message on the bus. There are examples in the user manual Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Jorge Fernandez Monteagudo Hi all! I would like to know what the correct way to wait for a state change in gstreamer. I'm using a typical code doing a polling after the 'gst_element_set_state' call but sometimes, with the machine under a heavy load, I get a timeout but gstreamer is still working and finally changes the state. Is there a better way? Is it possible to wait without timeout and look for some error trying to change the state? What timeout is considered safe? The code waiting for a state change with a 10 seconds timeout bool poll_for_state_change( GstState new_state ) Thanks! Jorge _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Yes, do both.
Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Jorge Fernandez Monteagudo Hi! Thanks for your answer! And is there any way to check if the state change has hit an error? Maybe capturing the 'GST_MESSAGE_ERROR' event? I supposse I have to wait until the pipeline has change its state, isn't it? De: gstreamer-devel <[hidden email]>
en nombre de Thornton, Keith <[hidden email]> Hi, you should create a listener for the message bus. Every element posts its state changed message on the bus. When complete, the pipeline also posts a state changed
message on the bus. There are examples in the user manual Von: gstreamer-devel [[hidden email]]
Im Auftrag von Jorge Fernandez Monteagudo Hi all! I would like to know what the correct way to wait for a state change in gstreamer. I'm using a typical code doing a polling after the 'gst_element_set_state' call but sometimes, with the machine under a heavy load, I get a timeout but gstreamer is still working and finally changes the state. Is there a better way? Is it possible to wait without timeout and look for some error trying to change the state? What timeout is considered safe? The code waiting for a state change with a 10 seconds timeout bool poll_for_state_change( GstState new_state ) Thanks! Jorge _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |