- Some concepts of States
- States defined in gstreamer
- GST_STATE_VOID_PENDING: the state of an element is not set.
- GST_STATE_NULL: initial state of an element.
- GST_STATE_READY: all sources are ready and can go to pause.
- GST_STATE_PAUSE: ready to accept and process data.
- GST_STATE_PLAYING: the GstClock is running and the data is flowing.
- Variables in GstElement
- current_state: the current state of an element.
- next_state: the next state of an element.
- pending_state: the final state the element should go to.
- target_state: last state the element we set.
- last_return: the last return value of an element state change.
- The states switch
- States defined in gstreamer
- Create a simple pipe to understand what are states
$ gst-launch-0.10 alsasrc ! audiorate ! filesink location=test.wav
- At the beginning, gstreamer core how to initialize each element
- Use funtion gst_element_factory_make("alsasrc", "sound") to create alsasrc element
- When create instance of alsasrc(sound), gst_element_init() will initial state of the element.
GST_STATE_TARGET (element) = GST_STATE_NULL; //target_state
GST_STATE_NEXT (element) = GST_STATE_VOID_PENDING; //next_state
GST_STATE_PENDING (element) = GST_STATE_VOID_PENDING; //pending_state
GST_STATE_RETURN (element) = GST_STATE_CHANGE_SUCCESS; //last_return
GST_STATE (element) = GST_STATE_NULL; //current_state
- Use function gst_bin_add_many to add elements to pipeline. Just add each element to GstBin->children, didn't change state of element
- After link success I want to change state of pipeline from GST_STATE_NULL to GST_STATE_PLAYING
- Now the state of element is GST_STATE_NULL, first change the state to GST_STATE_READY. All elements are added in GstBin->cheldren, when we change the state of pipeline to GST_STATE_READY, pipeline will call gst_bin_change_state_func to find child elemnt to change state to GST_STATE_READY. each child element will call plugin->change_state which defined by ourselves.
- If state change to GST_STATE_READY successfully, update state of element, then try to change state of pipeline from GST_STATE_READY to GST_STATE_PAUSE. Alsa call gst_bin_change_state_func, the same as step 1.
- If state change to GST_STATE_PAUSE successfully, update state of element, then try to change state of pipeline from GST_STATE_PAUSE to GST_STATE_READY. Alsa call gst_bin_change_state_func, the same as step 1.
- When accept message GST_MESSAGE_EOS, try to change the state of pipeline from GST_STATE_PLAYING to GST_STATE_NULL
搜尋此網誌
2011年1月14日 星期五
Gstreamer State Change
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言