void test_without_implements_interface() { GstElement *element; std_log(LOG_FILENAME_LINE, "Test Started test_without_implements_interface"); /* we shouldn't crash if someone tries to use * gst_element_implements_interface() on an element which doesn't implement * the GstImplementsInterface (neither if the element does implement the * requested interface, nor if it doesn't) */ element = gst_element_factory_make ("filesrc", "filesrc"); fail_unless (element != NULL, "Could not create filesrc element"); /* does not implement GstImplementsInterface, but does implement the * GstUriHandler interface, so should just return TRUE */ fail_if (!gst_element_implements_interface (element, GST_TYPE_URI_HANDLER)); fail_if (gst_element_implements_interface (element, GST_TYPE_IMPLEMENTS_INTERFACE)); gst_object_unref (element); element = gst_element_factory_make ("identity", "identity"); fail_unless (element != NULL, "Could not create identity element"); fail_if (gst_element_implements_interface (element, GST_TYPE_URI_HANDLER)); fail_if (gst_element_implements_interface (element, GST_TYPE_IMPLEMENTS_INTERFACE)); gst_object_unref (element); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static void set_playbin_volume (RBPlayerGst *player, float volume) { /* ignore the deep-notify we get directly from the sink, as it causes deadlock. * we still get another one anyway. */ g_signal_handlers_block_by_func (player->priv->playbin, volume_notify_cb, player); if (gst_element_implements_interface (player->priv->playbin, GST_TYPE_STREAM_VOLUME)) gst_stream_volume_set_volume (GST_STREAM_VOLUME (player->priv->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC, volume); else g_object_set (player->priv->playbin, "volume", volume, NULL); g_signal_handlers_unblock_by_func (player->priv->playbin, volume_notify_cb, player); }
static gboolean emit_volume_changed_idle (RBPlayerGst *player) { double vol; if (gst_element_implements_interface (player->priv->playbin, GST_TYPE_STREAM_VOLUME)) { vol = gst_stream_volume_get_volume (GST_STREAM_VOLUME (player->priv->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC); } else { vol = player->priv->cur_volume; } _rb_player_emit_volume_changed (RB_PLAYER (player), vol); return FALSE; }
static gboolean emit_volume_changed_idle(XmrPlayer *player) { gdouble vol; if (gst_element_implements_interface(player->priv->playbin, GST_TYPE_STREAM_VOLUME)) { vol = gst_stream_volume_get_volume(GST_STREAM_VOLUME (player->priv->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC); } else { vol = player->priv->cur_volume; } g_signal_emit(player, signals[VOLUME_CHANGED], 0, vol); return FALSE; }
gpointer gst_implements_interface_cast (gpointer from, GType iface_type) { GstImplementsInterface *iface; /* check cast, give warning+fail if it's invalid */ if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type, GstImplementsInterface))) { return NULL; } /* if we're an element, take care that this interface * is actually implemented */ if (GST_IS_ELEMENT (from)) { g_return_val_if_fail (gst_element_implements_interface (GST_ELEMENT (from), iface_type), NULL); } return iface; }
static GstPhotoCaps gst_camerabin_get_capabilities (GstPhotography * photo) { GstCameraBin *camera; /* camerabin can zoom by itself */ GstPhotoCaps pcaps = GST_PHOTOGRAPHY_CAPS_ZOOM; g_return_val_if_fail (photo != NULL, FALSE); camera = GST_CAMERABIN (photo); if (GST_IS_ELEMENT (camera->src_vid_src) && gst_element_implements_interface (camera->src_vid_src, GST_TYPE_PHOTOGRAPHY)) { GstPhotography *p2 = GST_PHOTOGRAPHY (camera->src_vid_src); pcaps |= gst_photography_get_capabilities (p2); } return pcaps; }
gboolean gst_implements_interface_check (gpointer from, GType type) { GstImplementsInterface *iface; /* check cast, return FALSE if it fails, don't give a warning... */ if (!G_TYPE_CHECK_INSTANCE_TYPE (from, type)) { return FALSE; } iface = G_TYPE_CHECK_INSTANCE_CAST (from, type, GstImplementsInterface); /* now, if we're an element (or derivative), is this thing * actually implemented for real? */ if (GST_IS_ELEMENT (from)) { if (!gst_element_implements_interface (GST_ELEMENT (from), type)) { return FALSE; } } return TRUE; }
void xmr_player_set_volume(XmrPlayer *player, float volume) { g_return_if_fail( player != NULL); g_return_if_fail (volume >= 0.0 && volume <= 1.0); if (player->priv->playbin == NULL) return ; g_signal_handlers_block_by_func(player->priv->playbin, volume_notify_cb, player); if (gst_element_implements_interface(player->priv->playbin, GST_TYPE_STREAM_VOLUME)) gst_stream_volume_set_volume(GST_STREAM_VOLUME(player->priv->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC, volume); else g_object_set(player->priv->playbin, "volume", volume, NULL); g_signal_handlers_unblock_by_func(player->priv->playbin, volume_notify_cb, player); player->priv->cur_volume = volume; }
static gboolean run_pipeline (gpointer user_data) { GstCaps *preview_caps = NULL; gchar *filename_str = NULL; GstElement *video_source = NULL; const gchar *filename_suffix; g_object_set (camerabin, "mode", mode, NULL); if (preview_caps_name != NULL) { preview_caps = gst_caps_from_string (preview_caps_name); if (preview_caps) { g_object_set (camerabin, "preview-caps", preview_caps, NULL); GST_DEBUG ("Preview caps set"); } else GST_DEBUG ("Preview caps set but could not create caps from string"); } set_metadata (camerabin); /* Construct filename */ if (mode == MODE_VIDEO) filename_suffix = ".mp4"; else filename_suffix = ".jpg"; filename_str = g_strdup_printf ("%s/test_%04u%s", filename->str, capture_count, filename_suffix); GST_DEBUG ("Setting filename: %s", filename_str); g_object_set (camerabin, "location", filename_str, NULL); g_free (filename_str); g_object_get (camerabin, "camera-src", &video_source, NULL); if (video_source) { if (GST_IS_ELEMENT (video_source) && gst_element_implements_interface (video_source, GST_TYPE_PHOTOGRAPHY)) { /* Set GstPhotography interface options. If option not given as command-line parameter use default of the source element. */ if (scene_mode != SCENE_MODE_NONE) g_object_set (video_source, "scene-mode", scene_mode, NULL); if (ev_compensation != EV_COMPENSATION_NONE) g_object_set (video_source, "ev-compensation", ev_compensation, NULL); if (aperture != APERTURE_NONE) g_object_set (video_source, "aperture", aperture, NULL); if (flash_mode != FLASH_MODE_NONE) g_object_set (video_source, "flash-mode", flash_mode, NULL); if (exposure != EXPOSURE_NONE) g_object_set (video_source, "exposure", exposure, NULL); if (iso_speed != ISO_SPEED_NONE) g_object_set (video_source, "iso-speed", iso_speed, NULL); if (wb_mode != WHITE_BALANCE_MODE_NONE) g_object_set (video_source, "white-balance-mode", wb_mode, NULL); if (color_mode != COLOR_TONE_MODE_NONE) g_object_set (video_source, "colour-tone-mode", color_mode, NULL); } g_object_unref (video_source); } g_object_set (camerabin, "zoom", zoom / 100.0f, NULL); capture_count++; g_timer_start (timer); g_signal_emit_by_name (camerabin, "start-capture", 0); if (mode == MODE_VIDEO) { g_timeout_add ((capture_time * 1000), (GSourceFunc) stop_capture, NULL); } return FALSE; }