gboolean gst_droidcamsrc_dev_start (GstDroidCamSrcDev * dev, gboolean apply_settings) { gboolean ret = FALSE; GstDroidCamSrc *src = GST_DROIDCAMSRC (GST_PAD_PARENT (dev->imgsrc->pad)); g_rec_mutex_lock (dev->lock); if (dev->running) { GST_WARNING_OBJECT (src, "preview is already running"); ret = TRUE; goto out; } GST_DEBUG_OBJECT (src, "dev start"); if (!gst_buffer_pool_set_active (dev->pool, TRUE)) { GST_ERROR_OBJECT (src, "Failed to activate buffer pool"); goto out; } if (apply_settings) { gst_droidcamsrc_apply_mode_settings (src, SET_ONLY); } /* now set params */ if (!gst_droidcamsrc_dev_set_params (dev)) { goto out; } if (dev->use_raw_data) { GST_INFO_OBJECT (src, "Using raw data mode"); droid_media_camera_set_preview_callback_flags (dev->cam, dev->c.CAMERA_FRAME_CALLBACK_FLAG_CAMERA); } else { GST_INFO_OBJECT (src, "Using native buffers mode"); droid_media_camera_set_preview_callback_flags (dev->cam, dev->c.CAMERA_FRAME_CALLBACK_FLAG_NOOP); } if (!droid_media_camera_start_preview (dev->cam)) { GST_ERROR_OBJECT (src, "error starting preview"); goto out; } dev->running = TRUE; ret = TRUE; out: if (ret != TRUE) { gst_buffer_pool_set_active (dev->pool, FALSE); } g_rec_mutex_unlock (dev->lock); return ret; }
gboolean gst_droidcamsrc_mode_negotiate (GstDroidCamSrcMode * mode, GstPad * pad) { gboolean ret; gboolean running; g_rec_mutex_lock (&mode->src->dev_lock); running = gst_droidcamsrc_dev_is_running (mode->src->dev); if (running && pad == mode->vfsrc) { /* stop preview */ gst_droidcamsrc_dev_stop (mode->src->dev); } gst_droidcamsrc_mode_negotiate_pad (mode, pad, FALSE); if (pad == mode->vfsrc) { /* start which will also apply the settings */ if (running) { ret = gst_droidcamsrc_dev_start (mode->src->dev, FALSE); } else { ret = gst_droidcamsrc_apply_params (mode->src); } /* now update max-zoom that we have a preview size */ gst_droidcamsrc_dev_update_params (mode->src->dev); gst_droidcamsrc_update_max_zoom (mode->src); } else { /* apply settings */ ret = gst_droidcamsrc_dev_set_params (mode->src->dev); } g_rec_mutex_unlock (&mode->src->dev_lock); return ret; }