static GstStateChangeReturn change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstOmxBaseSink *self; self = GST_OMX_BASE_SINK (element); GST_LOG_OBJECT (self, "begin"); GST_INFO_OBJECT (self, "changing state %s - %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: if (!self->initialized) { if (!omx_init (self)) return GST_PAD_LINK_REFUSED; self->initialized = TRUE; } g_omx_core_prepare (self->gomx); break; case GST_STATE_CHANGE_READY_TO_PAUSED: g_omx_core_start (self->gomx); break; case GST_STATE_CHANGE_PAUSED_TO_READY: g_omx_port_finish (self->in_port); break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (ret == GST_STATE_CHANGE_FAILURE) goto leave; switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: g_omx_port_pause (self->in_port); break; case GST_STATE_CHANGE_PAUSED_TO_READY: g_omx_core_stop (self->gomx); break; case GST_STATE_CHANGE_READY_TO_NULL: g_omx_core_unload (self->gomx); break; default: break; } leave: GST_LOG_OBJECT (self, "end"); return ret; }
static GstStateChangeReturn gst_camerabin_image_change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstCameraBinImage *img = GST_CAMERABIN_IMAGE (element); GST_DEBUG_OBJECT (element, "changing state: %s -> %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: if (!gst_camerabin_image_create_elements (img)) { return GST_STATE_CHANGE_FAILURE; } /* Allow setting filename when image bin in READY state */ gst_element_set_locked_state (img->sink, TRUE); GST_INFO_OBJECT (img, "locking imagebin->sink state to %s", gst_element_state_get_name (GST_STATE (img->sink))); break; case GST_STATE_CHANGE_READY_TO_PAUSED: if (!g_str_equal (img->filename->str, "")) { GST_INFO_OBJECT (img, "preparing image with filename: %s", img->filename->str); gst_element_set_locked_state (img->sink, FALSE); } else { GST_INFO_OBJECT (img, "keep sink locked, we have no filename yet"); } break; case GST_STATE_CHANGE_PAUSED_TO_READY: /* Set sink to NULL in order to write the file _now_ */ GST_INFO_OBJECT (img, "write image with filename: %s", img->filename->str); gst_element_set_locked_state (img->sink, TRUE); gst_element_set_state (img->sink, GST_STATE_NULL); g_string_assign (img->filename, ""); break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_PLAYING: /* Write debug graph to file */ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (GST_ELEMENT_PARENT (img)), GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS, "imagebin.playing"); break; case GST_STATE_CHANGE_READY_TO_NULL: gst_camerabin_image_destroy_elements (img); break; default: break; } GST_DEBUG_OBJECT (element, "changed state: %s -> %s = %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)), gst_element_state_change_return_get_name (ret)); return ret; }
static GstStateChangeReturn change_state (GstElement *element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstOmxBaseFilter *self; GOmxCore *core; self = GST_OMX_BASE_FILTER (element); core = self->gomx; GST_LOG_OBJECT (self, "begin"); GST_INFO_OBJECT (self, "changing state %s - %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: g_omx_core_init (core, self->omx_library, self->omx_component); if (core->omx_state != OMX_StateLoaded) { ret = GST_STATE_CHANGE_FAILURE; goto leave; } break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (ret == GST_STATE_CHANGE_FAILURE) goto leave; switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: g_mutex_lock (self->ready_lock); if (self->ready) { /* unlock */ g_omx_port_finish (self->in_port); g_omx_port_finish (self->out_port); g_omx_core_stop (core); g_omx_core_unload (core); self->ready = FALSE; } g_mutex_unlock (self->ready_lock); if (core->omx_state != OMX_StateLoaded && core->omx_state != OMX_StateInvalid) { ret = GST_STATE_CHANGE_FAILURE; goto leave; } break; case GST_STATE_CHANGE_READY_TO_NULL: g_omx_core_deinit (core); break; default: break; } leave: GST_LOG_OBJECT (self, "end"); return ret; }
static GstStateChangeReturn change_state (GstElement *element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstOmxBaseFilter *self; self = GST_OMX_BASE_FILTER (element); GST_LOG_OBJECT (self, "begin"); GST_INFO_OBJECT (self, "changing state %s - %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: g_omx_core_init (self->gomx, self->omx_library, self->omx_component); if (self->gomx->omx_error) return GST_STATE_CHANGE_FAILURE; break; case GST_STATE_CHANGE_PAUSED_TO_READY: if (self->initialized) { g_omx_port_finish (self->in_port); g_omx_port_finish (self->out_port); } break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (ret == GST_STATE_CHANGE_FAILURE) return ret; switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_READY: if (self->initialized) { g_omx_core_finish (self->gomx); self->initialized = FALSE; } break; case GST_STATE_CHANGE_READY_TO_NULL: g_omx_core_deinit (self->gomx); if (self->gomx->omx_error) return GST_STATE_CHANGE_FAILURE; break; default: break; } GST_LOG_OBJECT (self, "end"); return ret; }
static GstStateChangeReturn gst_glimage_sink_change_state (GstElement * element, GstStateChange transition) { GstGLImageSink *glimage_sink; GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GST_DEBUG ("changing state: %s => %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); glimage_sink = GST_GLIMAGE_SINK (element); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: break; case GST_STATE_CHANGE_READY_TO_PAUSED: g_atomic_int_set (&glimage_sink->to_quit, 0); if (!glimage_sink->display) { if (!gst_gl_ensure_display (glimage_sink, &glimage_sink->display)) return GST_STATE_CHANGE_FAILURE; } break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (ret == GST_STATE_CHANGE_FAILURE) return ret; switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_READY: { /* mark the redisplay_texture as unavailable (=0) * to avoid drawing */ GST_GLIMAGE_SINK_LOCK (glimage_sink); glimage_sink->redisplay_texture = 0; if (glimage_sink->stored_buffer) { gst_buffer_unref (glimage_sink->stored_buffer); glimage_sink->stored_buffer = NULL; } GST_GLIMAGE_SINK_UNLOCK (glimage_sink); if (glimage_sink->upload) { gst_object_unref (glimage_sink->upload); glimage_sink->upload = NULL; } glimage_sink->window_id = 0; //but do not reset glimage_sink->new_window_id if (glimage_sink->pool) { gst_buffer_pool_set_active (glimage_sink->pool, FALSE); gst_object_unref (glimage_sink->pool); glimage_sink->pool = NULL; } GST_VIDEO_SINK_WIDTH (glimage_sink) = 1; GST_VIDEO_SINK_HEIGHT (glimage_sink) = 1; if (glimage_sink->context) { GstGLWindow *window = gst_gl_context_get_window (glimage_sink->context); gst_gl_window_send_message (window, GST_GL_WINDOW_CB (gst_glimage_sink_cleanup_glthread), glimage_sink); gst_gl_window_set_resize_callback (window, NULL, NULL, NULL); gst_gl_window_set_draw_callback (window, NULL, NULL, NULL); gst_gl_window_set_close_callback (window, NULL, NULL, NULL); gst_object_unref (window); gst_object_unref (glimage_sink->context); glimage_sink->context = NULL; } if (glimage_sink->display) { gst_object_unref (glimage_sink->display); glimage_sink->display = NULL; } break; } case GST_STATE_CHANGE_READY_TO_NULL: break; default: break; } return ret; }
static GstStateChangeReturn change_state (GstElement *element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstOmxBaseFilter21 *self; GOmxCore *core; int i; self = GST_OMX_BASE_FILTER21(element); core = self->gomx; printf("begin: changing state %s -> %s\n", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); GST_INFO_OBJECT (self, "begin: changing state %s -> %s", gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)), gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition))); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: g_omx_core_init (core); if (core->omx_state != OMX_StateLoaded) { ret = GST_STATE_CHANGE_FAILURE; goto leave; } break; case GST_STATE_CHANGE_READY_TO_PAUSED: gst_collect_pads_start(self->collectpads); break; case GST_STATE_CHANGE_PAUSED_TO_READY: gst_collect_pads_stop(self->collectpads); break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (ret == GST_STATE_CHANGE_FAILURE) goto leave; switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: printf("Paused to ready\n"); g_mutex_lock (self->ready_lock); if (self->ready) { /* unlock */ for (i = 0; i < NUM_INPUTS; i++){ g_omx_port_finish (self->in_port[i]); } g_omx_port_finish (self->out_port); g_omx_core_stop (core); g_omx_core_unload (core); self->ready = FALSE; } g_mutex_unlock (self->ready_lock); if (core->omx_state != OMX_StateLoaded && core->omx_state != OMX_StateInvalid) { ret = GST_STATE_CHANGE_FAILURE; goto leave; } break; case GST_STATE_CHANGE_READY_TO_NULL: g_omx_core_deinit (core); break; default: break; } leave: GST_LOG_OBJECT (self, "end"); return ret; }