G_MODULE_EXPORT gboolean preview_draw_cb( GtkWidget *widget, cairo_t *cr, signal_user_data_t *ud) { #if defined(_ENABLE_GST) #if GST_CHECK_VERSION(1, 0, 0) if (ud->preview->live_enabled && ud->preview->state == PREVIEW_STATE_LIVE) { if (GST_STATE(ud->preview->play) >= GST_STATE_PAUSED) { GstElement *vsink; GstVideoOverlay *vover; g_object_get(ud->preview->play, "video-sink", &vsink, NULL); if (GST_IS_BIN(vsink)) vover = GST_VIDEO_OVERLAY(gst_bin_get_by_interface( GST_BIN(vsink), GST_TYPE_VIDEO_OVERLAY)); else vover = GST_VIDEO_OVERLAY(vsink); gst_video_overlay_expose(vover); // For some reason, the exposed region doesn't always get // cleaned up here. But a delayed gst_x_overlay_expose() // takes care of it. g_idle_add((GSourceFunc)delayed_expose_cb, ud); } return FALSE; } #else if (ud->preview->live_enabled && ud->preview->state == PREVIEW_STATE_LIVE) { if (GST_STATE(ud->preview->play) >= GST_STATE_PAUSED) { GstElement *vsink; GstXOverlay *xover; g_object_get(ud->preview->play, "video-sink", &vsink, NULL); if (GST_IS_BIN(vsink)) xover = GST_X_OVERLAY(gst_bin_get_by_interface( GST_BIN(vsink), GST_TYPE_X_OVERLAY)); else xover = GST_X_OVERLAY(vsink); gst_x_overlay_expose(xover); // For some reason, the exposed region doesn't always get // cleaned up here. But a delayed gst_x_overlay_expose() // takes care of it. g_idle_add((GSourceFunc)delayed_expose_cb, ud); } return FALSE; } #endif #endif if (ud->preview->pix != NULL) { _draw_pixbuf(cr, ud->preview->pix); } return FALSE; }
void BasePlatformInterface::PrepareVideoWindow(GstMessage *aMessage) { GstElement *element = NULL; GstXOverlay *xoverlay = NULL; if (GST_IS_BIN (mVideoSink)) { /* Get the actual implementing object from the bin */ element = gst_bin_get_by_interface(GST_BIN (mVideoSink), GST_TYPE_X_OVERLAY); } else { element = mVideoSink; } if (GST_IS_X_OVERLAY (element)) { xoverlay = GST_X_OVERLAY (element); LOG(("xoverlay interface found, setting video window")); } else { LOG(("No xoverlay interface found, cannot set video window")); return; } SetXOverlayWindowID(xoverlay); ResizeToWindow(); }
static gboolean gst_wrapper_camera_bin_src_set_mode (GstBaseCameraSrc * bcamsrc, GstCameraBinMode mode) { GstPhotography *photography = (GstPhotography *) gst_bin_get_by_interface (GST_BIN_CAST (bcamsrc), GST_TYPE_PHOTOGRAPHY); GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (bcamsrc); if (self->output_selector) { if (mode == MODE_IMAGE) { self->image_renegotiate = TRUE; g_object_set (self->output_selector, "active-pad", self->outsel_imgpad, NULL); } else { self->video_renegotiate = TRUE; g_object_set (self->output_selector, "active-pad", self->outsel_vidpad, NULL); } } self->mode = mode; if (photography) { if (g_object_class_find_property (G_OBJECT_GET_CLASS (photography), "capture-mode")) { g_object_set (G_OBJECT (photography), "capture-mode", mode, NULL); } } else { GstCaps *anycaps = gst_caps_new_any (); gst_wrapper_camera_bin_reset_video_src_caps (self, anycaps); gst_caps_unref (anycaps); } return TRUE; }
/* * Method: get_child(index) * Method: get_child(name, recurse=false) * Method: get_child(interface) * index: an index. * name: a name. * recurse: search recursively. * interface: an interface (Ruby class). * * 1st: Gets the index-th element. * * 2nd: Gets the element with the given name from the * bin, as a reference to a Gst::Element object. If the * element is not found and recurse is true, a recursion is * performed on the parent bin. * * 3nd: Looks for the first element inside the bin that implements the * given interface. If such an element is found, it returns the element. * If you want all elements that implement the interface, use * Gst::Bin#get_all_by_interface. The method recurses bins inside bins. * * Returns: a Gst::Element reference, or nil if the bin does not contain * an element with the given name nor implementing the interface. */ static VALUE rb_gst_bin_get(int argc, VALUE *argv, VALUE self) { VALUE index_or_name_or_interface, recurse; GstElement *element = NULL; rb_scan_args(argc, argv, "11", &index_or_name_or_interface, &recurse); if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_name_or_interface, rb_cInteger))) { int index; GList *node; index = NUM2INT(index_or_name_or_interface); node = g_list_nth(GST_BIN_CHILDREN(SELF(self)), index); if (node) element = node->data; } else if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_name_or_interface, rb_cString))) { char *name; name = RVAL2CSTR(index_or_name_or_interface); if (RVAL2CBOOL(recurse)) { element = gst_bin_get_by_name_recurse_up(SELF(self), name); } else { element = gst_bin_get_by_name(SELF(self), name); } } else { GType iface; iface = CLASS2GTYPE(index_or_name_or_interface); element = gst_bin_get_by_interface(SELF(self), iface); } return GST_ELEMENT2RVAL(element); }
/* Main method for the native code. This is executed on its own thread. */ static void *app_function (void *userdata) { JavaVMAttachArgs args; GstBus *bus; CustomData *data = (CustomData *)userdata; GSource *bus_source; GError *error = NULL; GST_DEBUG ("Creating pipeline in CustomData at %p", data); /* Create our own GLib Main Context and make it the default one */ data->context = g_main_context_new (); g_main_context_push_thread_default(data->context); /* Build pipeline */ data->pipeline = gst_parse_launch("videotestsrc ! warptv ! videoconvert ! autovideosink", &error); if (error) { gchar *message = g_strdup_printf("Unable to build pipeline: %s", error->message); g_clear_error (&error); set_ui_message(message, data); g_free (message); return NULL; } /* Set the pipeline to READY, so it can already accept a window handle, if we have one */ gst_element_set_state(data->pipeline, GST_STATE_READY); data->video_sink = gst_bin_get_by_interface(GST_BIN(data->pipeline), GST_TYPE_VIDEO_OVERLAY); if (!data->video_sink) { GST_ERROR ("Could not retrieve video sink"); return NULL; } /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ bus = gst_element_get_bus (data->pipeline); bus_source = gst_bus_create_watch (bus); g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL); g_source_attach (bus_source, data->context); g_source_unref (bus_source); g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, data); g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, data); gst_object_unref (bus); /* Create a GLib Main Loop and set it to run */ GST_DEBUG ("Entering main loop... (CustomData:%p)", data); data->main_loop = g_main_loop_new (data->context, FALSE); check_initialization_complete (data); g_main_loop_run (data->main_loop); GST_DEBUG ("Exited main loop"); g_main_loop_unref (data->main_loop); data->main_loop = NULL; /* Free resources */ g_main_context_pop_thread_default(data->context); g_main_context_unref (data->context); gst_element_set_state (data->pipeline, GST_STATE_NULL); gst_object_unref (data->video_sink); gst_object_unref (data->pipeline); return NULL; }
void _bp_dvd_find_navigation (BansheePlayer *player) { GstElement *video_sink = NULL; GstElement *navigation = NULL; GstNavigation *previous_navigation; previous_navigation = player->navigation; g_object_get (player->playbin, "video-sink", &video_sink, NULL); if (video_sink == NULL) { player->navigation = NULL; if (previous_navigation != NULL) { gst_object_unref (previous_navigation); } } navigation = GST_IS_BIN (video_sink) ? gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_NAVIGATION) : video_sink; player->navigation = GST_IS_NAVIGATION (navigation) ? GST_NAVIGATION (navigation) : NULL; if (previous_navigation != NULL) { gst_object_unref (previous_navigation); } gst_object_unref (video_sink); }
void empathy_video_src_set_channel (GstElement *src, EmpathyGstVideoSrcChannel channel, guint percent) { GstElement *color; GstColorBalance *balance; const GList *channels; GList *l; /* Find something supporting GstColorBalance */ color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); if (color == NULL) return; balance = GST_COLOR_BALANCE (color); channels = gst_color_balance_list_channels (balance); for (l = (GList *) channels; l != NULL; l = g_list_next (l)) { GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data); if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0) { gst_color_balance_set_value (balance, c, ((c->max_value - c->min_value) * percent)/100 + c->min_value); break; } } g_object_unref (color); }
/* TODO: use video overlay in the proper way (like suggested in docs, see gtkvideooverlay example) */ static gboolean expose_cb (GtkWidget * widget, gpointer data) { GstVideoOverlay *overlay = GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (data), GST_TYPE_VIDEO_OVERLAY)); gst_video_overlay_set_gtk_window (overlay, widget); return FALSE; }
bool CGstPlayback::SetWindow(void *window) { returnb_assert(m_playbin); g_print("%s, get GST_TYPE_VIDEO_OVERLAY", __func__); m_video_sink = gst_bin_get_by_interface(GST_BIN(m_playbin), GST_TYPE_VIDEO_OVERLAY); returnb_assert(m_video_sink); g_print("%s, set native window=(%x)", __func__, window); gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (m_video_sink), (guintptr)window); return true; }
static gboolean start_image_capture (GstWrapperCameraBinSrc * self) { GstBaseCameraSrc *bcamsrc = GST_BASE_CAMERA_SRC (self); GstPhotography *photography = (GstPhotography *) gst_bin_get_by_interface (GST_BIN_CAST (bcamsrc), GST_TYPE_PHOTOGRAPHY); gboolean ret = FALSE; GstCaps *caps; GST_DEBUG_OBJECT (self, "Starting image capture"); gst_element_set_state (self->src_vid_src, GST_STATE_READY); if (self->image_renegotiate) { /* clean capsfilter caps so they don't interfere here */ g_object_set (self->src_filter, "caps", NULL, NULL); if (self->src_zoom_filter) g_object_set (self->src_zoom_filter, "caps", NULL, NULL); caps = gst_pad_get_allowed_caps (self->imgsrc); gst_caps_replace (&self->image_capture_caps, caps); gst_caps_unref (caps); /* FIXME - do we need to update basecamerasrc width/height somehow here? * if not, i think we need to do something about _when_ they get updated * to be sure that set_element_zoom doesn't use the wrong values */ /* We caught this event in the src pad event handler and now we want to * actually push it upstream */ gst_pad_send_event (self->outsel_imgpad, gst_event_new_reconfigure ()); self->image_renegotiate = FALSE; } if (photography) { gst_element_set_state (self->src_vid_src, GST_STATE_PLAYING); GST_DEBUG_OBJECT (self, "prepare image capture caps %" GST_PTR_FORMAT, self->image_capture_caps); ret = gst_photography_prepare_for_capture (photography, (GstPhotographyCapturePrepared) img_capture_prepared, self->image_capture_caps, self); } else { g_mutex_unlock (&bcamsrc->capturing_mutex); gst_wrapper_camera_bin_reset_video_src_caps (self, self->image_capture_caps); g_mutex_lock (&bcamsrc->capturing_mutex); ret = TRUE; gst_element_set_state (self->src_vid_src, GST_STATE_PLAYING); } return ret; }
static gboolean bp_video_find_xoverlay (BansheePlayer *player) { GstElement *video_sink = NULL; GstElement *xoverlay; GstXOverlay *previous_xoverlay; gboolean found_xoverlay; g_object_get (player->playbin, "video-sink", &video_sink, NULL); g_mutex_lock (player->video_mutex); previous_xoverlay = player->xoverlay; if (video_sink == NULL) { player->xoverlay = NULL; if (previous_xoverlay != NULL) { gst_object_unref (previous_xoverlay); } g_mutex_unlock (player->video_mutex); return FALSE; } xoverlay = GST_IS_BIN (video_sink) ? gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_X_OVERLAY) : video_sink; player->xoverlay = GST_IS_X_OVERLAY (xoverlay) ? GST_X_OVERLAY (xoverlay) : NULL; if (previous_xoverlay != NULL) { gst_object_unref (previous_xoverlay); } #if !defined(GDK_WINDOWING_WIN32) // We can't rely on aspect ratio from dshowvideosink if (player->xoverlay != NULL && g_object_class_find_property ( G_OBJECT_GET_CLASS (player->xoverlay), "force-aspect-ratio")) { g_object_set (G_OBJECT (player->xoverlay), "force-aspect-ratio", TRUE, NULL); } #endif if (player->xoverlay != NULL && g_object_class_find_property ( G_OBJECT_GET_CLASS (player->xoverlay), "handle-events")) { g_object_set (G_OBJECT (player->xoverlay), "handle-events", FALSE, NULL); } gst_object_unref (video_sink); found_xoverlay = (player->xoverlay != NULL) ? TRUE : FALSE; g_mutex_unlock (player->video_mutex); return found_xoverlay; }
static void gst_gl_sink_bin_overlay_expose (GstVideoOverlay * overlay) { GstGLSinkBin *self = GST_GL_SINK_BIN (overlay); GstVideoOverlay *overlay_element = NULL; overlay_element = GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_VIDEO_OVERLAY)); if (overlay_element) { gst_video_overlay_expose (overlay_element); gst_object_unref (overlay_element); } }
static void gst_gl_sink_bin_color_balance_set_value (GstColorBalance * balance, GstColorBalanceChannel * channel, gint value) { GstGLSinkBin *self = GST_GL_SINK_BIN (balance); GstColorBalance *balance_element = NULL; balance_element = GST_COLOR_BALANCE (gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_COLOR_BALANCE)); if (balance_element) { gst_color_balance_set_value (balance_element, channel, value); gst_object_unref (balance_element); } }
static void gst_gl_sink_bin_overlay_set_render_rectangle (GstVideoOverlay * overlay, gint x, gint y, gint width, gint height) { GstGLSinkBin *self = GST_GL_SINK_BIN (overlay); GstVideoOverlay *overlay_element = NULL; overlay_element = GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_VIDEO_OVERLAY)); if (overlay_element) { gst_video_overlay_set_render_rectangle (overlay_element, x, y, width, height); gst_object_unref (overlay_element); } }
/** * gst_base_camera_src_get_photography: * @self: the camerasrc bin * * Get object implementing photography interface, if there is one. Otherwise * returns NULL. */ GstPhotography * gst_base_camera_src_get_photography (GstBaseCameraSrc * self) { GstElement *elem; if (GST_IS_PHOTOGRAPHY (self)) { elem = GST_ELEMENT (self); } else { elem = gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_PHOTOGRAPHY); } if (elem) { return GST_PHOTOGRAPHY (self); } return NULL; }
/** * gst_base_camera_src_get_colorbalance: * @self: the camerasrc bin * * Get object implementing colorbalance interface, if there is one. Otherwise * returns NULL. */ GstColorBalance * gst_base_camera_src_get_color_balance (GstBaseCameraSrc * self) { GstElement *elem; if (GST_IS_COLOR_BALANCE (self)) { elem = GST_ELEMENT (self); } else { elem = gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_COLOR_BALANCE); } if (elem) { return GST_COLOR_BALANCE (self); } return NULL; }
static const GList * gst_gl_sink_bin_color_balance_list_channels (GstColorBalance * balance) { GstGLSinkBin *self = GST_GL_SINK_BIN (balance); GstColorBalance *balance_element = NULL; const GList *list = NULL; balance_element = GST_COLOR_BALANCE (gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_COLOR_BALANCE)); if (balance_element) { list = gst_color_balance_list_channels (balance_element); gst_object_unref (balance_element); } return list; }
static GstColorBalanceType gst_gl_sink_bin_color_balance_get_balance_type (GstColorBalance * balance) { GstGLSinkBin *self = GST_GL_SINK_BIN (balance); GstColorBalance *balance_element = NULL; GstColorBalanceType type = 0; balance_element = GST_COLOR_BALANCE (gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_COLOR_BALANCE)); if (balance_element) { type = gst_color_balance_get_balance_type (balance_element); gst_object_unref (balance_element); } return type; }
static void gst_gl_sink_bin_navigation_send_event (GstNavigation * navigation, GstStructure * structure) { GstGLSinkBin *self = GST_GL_SINK_BIN (navigation); GstElement *nav = gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_NAVIGATION); if (nav) { gst_navigation_send_event (GST_NAVIGATION (nav), structure); structure = NULL; gst_object_unref (nav); } else { GstEvent *event = gst_event_new_navigation (structure); structure = NULL; gst_element_send_event (GST_ELEMENT (self), event); } }
static gboolean start_image_capture (GstWrapperCameraBinSrc * self) { GstBaseCameraSrc *bcamsrc = GST_BASE_CAMERA_SRC (self); GstPhotography *photography = (GstPhotography *) gst_bin_get_by_interface (GST_BIN_CAST (bcamsrc), GST_TYPE_PHOTOGRAPHY); gboolean ret = FALSE; GstCaps *caps; GST_DEBUG_OBJECT (self, "Starting image capture"); if (self->image_renegotiate) { /* clean capsfilter caps so they don't interfere here */ g_object_set (self->src_filter, "caps", NULL, NULL); if (self->src_zoom_filter) g_object_set (self->src_zoom_filter, "caps", NULL, NULL); caps = gst_pad_get_allowed_caps (self->imgsrc); gst_caps_replace (&self->image_capture_caps, caps); gst_caps_unref (caps); self->image_renegotiate = FALSE; } if (photography) { GST_DEBUG_OBJECT (self, "prepare image capture caps %" GST_PTR_FORMAT, self->image_capture_caps); ret = gst_photography_prepare_for_capture (photography, (GstPhotoCapturePrepared) img_capture_prepared, self->image_capture_caps, self); } else { g_mutex_unlock (bcamsrc->capturing_mutex); gst_wrapper_camera_bin_reset_video_src_caps (self, self->image_capture_caps); g_mutex_lock (bcamsrc->capturing_mutex); ret = TRUE; } return ret; }
static GstColorBalance * dup_color_balance (GstElement *src) { GstElement *color; /* Find something supporting GstColorBalance */ color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); if (color == NULL) return NULL; /* colorbalance is wrapped by GstImplementsInterface, we * need to check if it is actually supported for this instance * in its current state before trying to use it */ if (!GST_IS_COLOR_BALANCE (color)) { g_object_unref (color); return NULL; } return GST_COLOR_BALANCE (color); }
guint empathy_video_src_get_supported_channels (GstElement *src) { GstElement *color; GstColorBalance *balance; const GList *channels; GList *l; guint result = 0; /* Find something supporting GstColorBalance */ color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); if (color == NULL) goto out; balance = GST_COLOR_BALANCE (color); channels = gst_color_balance_list_channels (balance); for (l = (GList *) channels; l != NULL; l = g_list_next (l)) { GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (l->data); int i; for (i = 0; i < NR_EMPATHY_GST_VIDEO_SRC_CHANNELS; i++) { if (g_ascii_strcasecmp (channel->label, channel_names[i]) == 0) { result |= (1 << i); break; } } } g_object_unref (color); out: return result; }
G_MODULE_EXPORT gboolean delayed_expose_cb(signal_user_data_t *ud) { GstElement *vsink; GstXOverlay *xover; if (!ud->preview->live_enabled) return FALSE; g_object_get(ud->preview->play, "video-sink", &vsink, NULL); if (vsink == NULL) return FALSE; if (GST_IS_BIN(vsink)) xover = GST_X_OVERLAY(gst_bin_get_by_interface( GST_BIN(vsink), GST_TYPE_X_OVERLAY)); else xover = GST_X_OVERLAY(vsink); gst_x_overlay_expose(xover); // This function is initiated by g_idle_add. Must return false // so that it is not called again return FALSE; }
/* Main method for the native code. This is executed on its own thread. */ static void *app_function (void *userdata) { JavaVMAttachArgs args; GstBus *bus; CustomData *data = (CustomData *)userdata; GSource *bus_source; GError *error = NULL; GST_DEBUG ("Creating pipeline in CustomData at %p", data); /* Create our own GLib Main Context and make it the default one */ data->context = g_main_context_new (); g_main_context_push_thread_default(data->context); /* Build pipeline */ //char caps[1000]="caps = \"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\\\"Z2QAHqyyAUB7YCIAAAMAAgAAAwBlHixckA\\\\=\\\\=\\\\,aOvBssiw\\\", payload=(int)96, ssrc=(uint)226114972, timestamp-offset=(uint)497630140, seqnum-offset=(uint)4095\""; //data->pipeline = gst_parse_launch("udpsrc port=5010 caps = \"application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\\\"Z2QAHqyyAUB7YCIAAAMAAgAAAwB5HixckA\\\\=\\\\=\\\\,aOvBssiw\\\", payload=(int)96, ssrc=(uint)1750089033, timestamp-offset=(uint)1121294972, seqnum-offset=(uint)31049\" ! rtph264depay ! avdec_h264 ! autovideosink sync=false", &error); data->pipeline = gst_parse_launch(pipeline_path, &error); if (error) { gchar *message = g_strdup_printf("Unable to build pipeline: %s", error->message); g_clear_error (&error); set_ui_message(message, data); g_free (message); return NULL; } /* Set the pipeline to READY, so it can already accept a window handle, if we have one */ gst_element_set_state(data->pipeline, GST_STATE_READY); data->video_sink = gst_bin_get_by_interface(GST_BIN(data->pipeline), GST_TYPE_VIDEO_OVERLAY); if (!data->video_sink) { GST_ERROR ("Could not retrieve video sink"); return NULL; } /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ bus = gst_element_get_bus (data->pipeline); bus_source = gst_bus_create_watch (bus); g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL); g_source_attach (bus_source, data->context); g_source_unref (bus_source); g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, data); g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, data); gst_object_unref (bus); /* Create a GLib Main Loop and set it to run */ GST_DEBUG ("Entering main loop... (CustomData:%p)", data); data->main_loop = g_main_loop_new (data->context, FALSE); check_initialization_complete (data); g_main_loop_run (data->main_loop); GST_DEBUG ("Exited main loop"); g_main_loop_unref (data->main_loop); data->main_loop = NULL; /* Free resources */ g_main_context_pop_thread_default(data->context); g_main_context_unref (data->context); gst_element_set_state (data->pipeline, GST_STATE_NULL); gst_object_unref (data->video_sink); gst_object_unref (data->pipeline); return NULL; }
ElementPtr Bin::getElementByInterface(QGlib::Type interfaceType) const { return ElementPtr::wrap(gst_bin_get_by_interface(object<GstBin>(), interfaceType), false); }
static gboolean start_image_capture (GstWrapperCameraBinSrc * self) { GstBaseCameraSrc *bcamsrc = GST_BASE_CAMERA_SRC (self); GstPhotography *photography = (GstPhotography *) gst_bin_get_by_interface (GST_BIN_CAST (bcamsrc), GST_TYPE_PHOTOGRAPHY); gboolean ret = FALSE; GstCaps *caps; GstPad *pad, *peer; GST_DEBUG_OBJECT (self, "Starting image capture"); gst_element_set_state (self->src_vid_src, GST_STATE_READY); /* FIXME - V4L2 source will not close the device until all buffers have came * back. Flushing the pipeline, will ensure it's properly closed, and that * setting it back to PLAYING will work. This is more a workaround then a * solution to buffer reclaiming. */ pad = gst_element_get_static_pad (self->src_vid_src, "src"); peer = gst_pad_get_peer (pad); gst_object_unref (pad); gst_pad_send_event (peer, gst_event_new_flush_start ()); gst_pad_send_event (peer, gst_event_new_flush_stop (TRUE)); gst_object_unref (peer); if (self->image_renegotiate) { /* clean capsfilter caps so they don't interfere here */ g_object_set (self->src_filter, "caps", NULL, NULL); if (self->src_zoom_filter) g_object_set (self->src_zoom_filter, "caps", NULL, NULL); caps = gst_pad_get_allowed_caps (self->imgsrc); gst_caps_replace (&self->image_capture_caps, caps); gst_caps_unref (caps); /* FIXME - do we need to update basecamerasrc width/height somehow here? * if not, i think we need to do something about _when_ they get updated * to be sure that set_element_zoom doesn't use the wrong values */ /* We caught this event in the src pad event handler and now we want to * actually push it upstream */ gst_pad_send_event (self->outsel_imgpad, gst_event_new_reconfigure ()); self->image_renegotiate = FALSE; } if (photography) { gst_element_set_state (self->src_vid_src, GST_STATE_PLAYING); GST_DEBUG_OBJECT (self, "prepare image capture caps %" GST_PTR_FORMAT, self->image_capture_caps); ret = gst_photography_prepare_for_capture (photography, (GstPhotographyCapturePrepared) img_capture_prepared, self->image_capture_caps, self); } else { g_mutex_unlock (&bcamsrc->capturing_mutex); gst_wrapper_camera_bin_reset_video_src_caps (self, self->image_capture_caps); g_mutex_lock (&bcamsrc->capturing_mutex); ret = TRUE; gst_element_set_state (self->src_vid_src, GST_STATE_PLAYING); } return ret; }