camerabin2: port to 0.11

This commit is contained in:
Thiago Santos 2011-12-23 16:33:45 -03:00
parent 050099ce2d
commit 44eb631841
5 changed files with 113 additions and 109 deletions

View file

@ -306,7 +306,7 @@ GST_PLUGINS_NONPORTED=" adpcmdec adpcmenc aiff asfmux \
sdi segmentclip siren speed subenc stereo tta videofilters \ sdi segmentclip siren speed subenc stereo tta videofilters \
videomaxrate videomeasure videosignal vmnc \ videomaxrate videomeasure videosignal vmnc \
decklink fbdev linsys shm vcd \ decklink fbdev linsys shm vcd \
voaacenc apexsink bz2 camerabin2 cdaudio celt cog curl dc1394 dirac directfb dts resindvd \ voaacenc apexsink bz2 cdaudio celt cog curl dc1394 dirac directfb dts resindvd \
gsettings gsm jp2k ladspa modplug mpeg2enc mplex mimic \ gsettings gsm jp2k ladspa modplug mpeg2enc mplex mimic \
musepack musicbrainz nas neon ofa openal rsvg schro sdl smooth sndfile soundtouch spandsp timidity \ musepack musicbrainz nas neon ofa openal rsvg schro sdl smooth sndfile soundtouch spandsp timidity \
wildmidi xvid apple_media " wildmidi xvid apple_media "

View file

@ -229,19 +229,19 @@ void
gst_camerabin_remove_elements_from_bin (GstBin * bin) gst_camerabin_remove_elements_from_bin (GstBin * bin)
{ {
GstIterator *iter = NULL; GstIterator *iter = NULL;
gpointer data = NULL; GValue value = { 0 };
GstElement *elem = NULL; GstElement *elem = NULL;
gboolean done = FALSE; gboolean done = FALSE;
iter = gst_bin_iterate_elements (bin); iter = gst_bin_iterate_elements (bin);
while (!done) { while (!done) {
switch (gst_iterator_next (iter, &data)) { switch (gst_iterator_next (iter, &value)) {
case GST_ITERATOR_OK: case GST_ITERATOR_OK:
elem = GST_ELEMENT (data); elem = (GstElement *) g_value_get_object (&value);
gst_bin_remove (bin, elem); gst_bin_remove (bin, elem);
gst_element_set_state (GST_ELEMENT (elem), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (elem), GST_STATE_NULL);
/* Iterator increased the element refcount, so unref */ /* Iterator increased the element refcount, so unref */
gst_object_unref (elem); g_value_unset (&value);
break; break;
case GST_ITERATOR_RESYNC: case GST_ITERATOR_RESYNC:
gst_iterator_resync (iter); gst_iterator_resync (iter);

View file

@ -350,7 +350,7 @@ static GstEvent *
gst_camera_bin_new_event_renegotiate (void) gst_camera_bin_new_event_renegotiate (void)
{ {
return gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, return gst_event_new_custom (GST_EVENT_CUSTOM_BOTH,
gst_structure_new ("renegotiate", NULL)); gst_structure_new_empty ("renegotiate"));
} }
static GstEvent * static GstEvent *
@ -754,7 +754,7 @@ gst_camera_bin_class_init (GstCameraBin2Class * klass)
GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_VIDEO_ENCODING_PROFILE, g_object_class_install_property (object_class, PROP_VIDEO_ENCODING_PROFILE,
gst_param_spec_mini_object ("video-profile", "Video Profile", g_param_spec_boxed ("video-profile", "Video Profile",
"The GstEncodingProfile to use for video recording. Audio is enabled " "The GstEncodingProfile to use for video recording. Audio is enabled "
"when this profile supports audio.", GST_TYPE_ENCODING_PROFILE, "when this profile supports audio.", GST_TYPE_ENCODING_PROFILE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@ -827,7 +827,7 @@ gst_camera_bin_class_init (GstCameraBin2Class * klass)
* getting the 2nd buffer. * getting the 2nd buffer.
*/ */
g_object_class_install_property (object_class, PROP_IMAGE_ENCODING_PROFILE, g_object_class_install_property (object_class, PROP_IMAGE_ENCODING_PROFILE,
gst_param_spec_mini_object ("image-profile", "Image Profile", g_param_spec_boxed ("image-profile", "Image Profile",
"The GstEncodingProfile to use for image captures.", "The GstEncodingProfile to use for image captures.",
GST_TYPE_ENCODING_PROFILE, GST_TYPE_ENCODING_PROFILE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@ -947,7 +947,7 @@ gst_video_capture_bin_post_video_done (GstCameraBin2 * camera)
GstMessage *msg; GstMessage *msg;
msg = gst_message_new_element (GST_OBJECT_CAST (camera), msg = gst_message_new_element (GST_OBJECT_CAST (camera),
gst_structure_new ("video-done", NULL)); gst_structure_new_empty ("video-done"));
if (!gst_element_post_message (GST_ELEMENT_CAST (camera), msg)) if (!gst_element_post_message (GST_ELEMENT_CAST (camera), msg))
GST_WARNING_OBJECT (camera, "Failed to post video-done message"); GST_WARNING_OBJECT (camera, "Failed to post video-done message");
@ -1187,17 +1187,19 @@ encodebin_element_added (GstElement * encodebin, GstElement * new_element,
GstElementFactory *factory = gst_element_get_factory (new_element); GstElementFactory *factory = gst_element_get_factory (new_element);
if (factory != NULL) { if (factory != NULL) {
if (strcmp (GST_PLUGIN_FEATURE_NAME (factory), "audiorate") == 0 || if (strcmp (GST_OBJECT_NAME (factory), "audiorate") == 0 ||
strcmp (GST_PLUGIN_FEATURE_NAME (factory), "videorate") == 0) { strcmp (GST_OBJECT_NAME (factory), "videorate") == 0) {
g_object_set (new_element, "skip-to-first", TRUE, NULL); g_object_set (new_element, "skip-to-first", TRUE, NULL);
} }
} }
/* TODO porting
if (gst_element_implements_interface (new_element, GST_TYPE_TAG_SETTER)) { if (gst_element_implements_interface (new_element, GST_TYPE_TAG_SETTER)) {
GstTagSetter *tagsetter = GST_TAG_SETTER (new_element); GstTagSetter *tagsetter = GST_TAG_SETTER (new_element);
gst_tag_setter_set_tag_merge_mode (tagsetter, GST_TAG_MERGE_REPLACE); gst_tag_setter_set_tag_merge_mode (tagsetter, GST_TAG_MERGE_REPLACE);
} }
*/
} }
#define VIDEO_PAD 1 #define VIDEO_PAD 1
@ -1206,6 +1208,7 @@ static GstPad *
encodebin_find_pad (GstCameraBin2 * camera, GstElement * encodebin, encodebin_find_pad (GstCameraBin2 * camera, GstElement * encodebin,
gint pad_type) gint pad_type)
{ {
GValue value = { 0 };
GstPad *pad = NULL; GstPad *pad = NULL;
GstIterator *iter; GstIterator *iter;
gboolean done; gboolean done;
@ -1216,8 +1219,10 @@ encodebin_find_pad (GstCameraBin2 * camera, GstElement * encodebin,
iter = gst_element_iterate_sink_pads (encodebin); iter = gst_element_iterate_sink_pads (encodebin);
done = FALSE; done = FALSE;
while (!done) { while (!done) {
switch (gst_iterator_next (iter, (gpointer *) & pad)) { switch (gst_iterator_next (iter, &value)) {
case GST_ITERATOR_OK: case GST_ITERATOR_OK:
pad = g_value_dup_object (&value);
g_value_unset (&value);
if (pad_type == VIDEO_PAD) { if (pad_type == VIDEO_PAD) {
if (strstr (GST_PAD_NAME (pad), "video") != NULL) { if (strstr (GST_PAD_NAME (pad), "video") != NULL) {
GST_DEBUG_OBJECT (camera, "Found video pad %s", GST_PAD_NAME (pad)); GST_DEBUG_OBJECT (camera, "Found video pad %s", GST_PAD_NAME (pad));
@ -1338,11 +1343,11 @@ gst_camera_bin_src_notify_zoom_cb (GObject * self, GParamSpec * pspec,
g_object_notify (G_OBJECT (camera), "zoom"); g_object_notify (G_OBJECT (camera), "zoom");
} }
static gboolean static GstPadProbeReturn
gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf, gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer data) gpointer data)
{ {
gboolean ret = TRUE; GstPadProbeReturn ret = GST_PAD_PROBE_OK;
GstCameraBin2 *camerabin = data; GstCameraBin2 *camerabin = data;
GstEvent *evt; GstEvent *evt;
gchar *location = NULL; gchar *location = NULL;
@ -1392,7 +1397,7 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
} else { } else {
/* This means we don't have to encode the capture, it is used for /* This means we don't have to encode the capture, it is used for
* signaling the application just wants the preview */ * signaling the application just wants the preview */
ret = FALSE; ret = GST_PAD_PROBE_DROP;
GST_CAMERA_BIN2_PROCESSING_DEC (camerabin); GST_CAMERA_BIN2_PROCESSING_DEC (camerabin);
} }
@ -1400,11 +1405,12 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstBuffer * buf,
} }
static gboolean static GstPadProbeReturn
gst_camera_bin_image_sink_event_probe (GstPad * pad, GstEvent * event, gst_camera_bin_image_sink_event_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer data) gpointer data)
{ {
GstCameraBin2 *camerabin = data; GstCameraBin2 *camerabin = data;
GstEvent *event = GST_EVENT (info->data);
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_DOWNSTREAM:{ case GST_EVENT_CUSTOM_DOWNSTREAM:{
@ -1430,20 +1436,21 @@ gst_camera_bin_image_sink_event_probe (GstPad * pad, GstEvent * event,
break; break;
} }
return TRUE; return GST_PAD_PROBE_OK;
} }
static gboolean static GstPadProbeReturn
gst_camera_bin_audio_src_event_probe (GstPad * pad, GstEvent * event, gst_camera_bin_audio_src_event_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer data) gpointer data)
{ {
GstCameraBin2 *camera = data; GstCameraBin2 *camera = data;
gboolean ret = TRUE; gboolean ret = GST_PAD_PROBE_OK;
GstEvent *event = GST_EVENT (info->data);
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
/* we only let an EOS pass when the user is stopping a capture */ /* we only let an EOS pass when the user is stopping a capture */
if (camera->audio_drop_eos) { if (camera->audio_drop_eos) {
ret = FALSE; ret = GST_PAD_PROBE_DROP;
} else { } else {
camera->audio_drop_eos = TRUE; camera->audio_drop_eos = TRUE;
} }
@ -1510,12 +1517,12 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
GstEncodingContainerProfile *prof; GstEncodingContainerProfile *prof;
GstCaps *caps; GstCaps *caps;
caps = gst_caps_new_simple ("application/ogg", NULL); caps = gst_caps_new_simple ("application/ogg", NULL, NULL);
prof = gst_encoding_container_profile_new ("ogg", "theora+vorbis+ogg", prof = gst_encoding_container_profile_new ("ogg", "theora+vorbis+ogg",
caps, NULL); caps, NULL);
gst_caps_unref (caps); gst_caps_unref (caps);
caps = gst_caps_new_simple ("video/x-theora", NULL); caps = gst_caps_new_simple ("video/x-theora", NULL, NULL);
if (!gst_encoding_container_profile_add_profile (prof, if (!gst_encoding_container_profile_add_profile (prof,
(GstEncodingProfile *) gst_encoding_video_profile_new (caps, (GstEncodingProfile *) gst_encoding_video_profile_new (caps,
NULL, NULL, 1))) { NULL, NULL, 1))) {
@ -1523,7 +1530,7 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
} }
gst_caps_unref (caps); gst_caps_unref (caps);
caps = gst_caps_new_simple ("audio/x-vorbis", NULL); caps = gst_caps_new_simple ("audio/x-vorbis", NULL, NULL);
if (!gst_encoding_container_profile_add_profile (prof, if (!gst_encoding_container_profile_add_profile (prof,
(GstEncodingProfile *) gst_encoding_audio_profile_new (caps, (GstEncodingProfile *) gst_encoding_audio_profile_new (caps,
NULL, NULL, 1))) { NULL, NULL, 1))) {
@ -1562,7 +1569,7 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
GstEncodingVideoProfile *vprof; GstEncodingVideoProfile *vprof;
GstCaps *caps; GstCaps *caps;
caps = gst_caps_new_simple ("image/jpeg", NULL); caps = gst_caps_new_simple ("image/jpeg", NULL, NULL);
vprof = gst_encoding_video_profile_new (caps, NULL, NULL, 1); vprof = gst_encoding_video_profile_new (caps, NULL, NULL, 1);
gst_encoding_video_profile_set_variableframerate (vprof, TRUE); gst_encoding_video_profile_set_variableframerate (vprof, TRUE);
@ -1609,8 +1616,9 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
srcpad = gst_element_get_static_pad (camera->image_encodebin, "src"); srcpad = gst_element_get_static_pad (camera->image_encodebin, "src");
gst_pad_add_event_probe (srcpad, gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
(GCallback) gst_camera_bin_image_sink_event_probe, camera); gst_camera_bin_image_sink_event_probe, gst_object_ref (camera),
gst_object_unref);
gst_object_unref (srcpad); gst_object_unref (srcpad);
} }
@ -1738,8 +1746,9 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
goto fail; goto fail;
} }
gst_pad_add_buffer_probe (imgsrc, gst_pad_add_probe (imgsrc, GST_PAD_PROBE_TYPE_BUFFER,
(GCallback) gst_camera_bin_image_src_buffer_probe, camera); gst_camera_bin_image_src_buffer_probe, gst_object_ref (camera),
gst_object_unref);
gst_object_unref (imgsrc); gst_object_unref (imgsrc);
} }
@ -1801,8 +1810,9 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera)
/* drop EOS for audiosrc elements that push them on state_changes /* drop EOS for audiosrc elements that push them on state_changes
* (basesrc does this) */ * (basesrc does this) */
gst_pad_add_event_probe (srcpad, gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
(GCallback) gst_camera_bin_audio_src_event_probe, camera); gst_camera_bin_audio_src_event_probe, gst_object_ref (camera),
gst_object_unref);
gst_object_unref (srcpad); gst_object_unref (srcpad);
} }
@ -2133,8 +2143,7 @@ gst_camera_bin_set_property (GObject * object, guint prop_id,
case PROP_VIDEO_ENCODING_PROFILE: case PROP_VIDEO_ENCODING_PROFILE:
if (camera->video_profile) if (camera->video_profile)
gst_encoding_profile_unref (camera->video_profile); gst_encoding_profile_unref (camera->video_profile);
camera->video_profile = camera->video_profile = (GstEncodingProfile *) g_value_dup_boxed (value);
(GstEncodingProfile *) gst_value_dup_mini_object (value);
camera->video_profile_switch = TRUE; camera->video_profile_switch = TRUE;
break; break;
case PROP_IMAGE_FILTER: case PROP_IMAGE_FILTER:
@ -2190,8 +2199,7 @@ gst_camera_bin_set_property (GObject * object, guint prop_id,
case PROP_IMAGE_ENCODING_PROFILE: case PROP_IMAGE_ENCODING_PROFILE:
if (camera->image_profile) if (camera->image_profile)
gst_encoding_profile_unref (camera->image_profile); gst_encoding_profile_unref (camera->image_profile);
camera->image_profile = camera->image_profile = (GstEncodingProfile *) g_value_dup_boxed (value);
(GstEncodingProfile *) gst_value_dup_mini_object (value);
camera->image_profile_switch = TRUE; camera->image_profile_switch = TRUE;
break; break;
case PROP_FLAGS: case PROP_FLAGS:
@ -2262,7 +2270,7 @@ gst_camera_bin_get_property (GObject * object, guint prop_id,
* won't negotiate. Need to take care on the special case of the * won't negotiate. Need to take care on the special case of the
* pad being unlinked. * pad being unlinked.
*/ */
caps = gst_pad_get_caps_reffed (pad); caps = gst_pad_query_caps (pad, NULL);
if (caps) { if (caps) {
gst_value_set_caps (value, caps); gst_value_set_caps (value, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -2328,8 +2336,7 @@ gst_camera_bin_get_property (GObject * object, guint prop_id,
break; break;
case PROP_VIDEO_ENCODING_PROFILE: case PROP_VIDEO_ENCODING_PROFILE:
if (camera->video_profile) { if (camera->video_profile) {
gst_value_set_mini_object (value, g_value_set_boxed (value, camera->video_profile);
(GstMiniObject *) camera->video_profile);
} }
break; break;
case PROP_VIDEO_FILTER: case PROP_VIDEO_FILTER:
@ -2367,8 +2374,7 @@ gst_camera_bin_get_property (GObject * object, guint prop_id,
break; break;
case PROP_IMAGE_ENCODING_PROFILE: case PROP_IMAGE_ENCODING_PROFILE:
if (camera->image_profile) { if (camera->image_profile) {
gst_value_set_mini_object (value, g_value_set_boxed (value, camera->image_profile);
(GstMiniObject *) camera->image_profile);
} }
break; break;
case PROP_IDLE: case PROP_IDLE:

View file

@ -61,8 +61,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
); );
/* class initialization */ /* class initialization */
#define gst_viewfinder_bin_parent_class parent_class
GST_BOILERPLATE (GstViewfinderBin, gst_viewfinder_bin, GstBin, GST_TYPE_BIN); G_DEFINE_TYPE (GstViewfinderBin, gst_viewfinder_bin, GST_TYPE_BIN);
static void gst_viewfinder_bin_set_property (GObject * object, guint prop_id, static void gst_viewfinder_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * spec); const GValue * value, GParamSpec * spec);
@ -95,19 +95,6 @@ gst_viewfinder_bin_dispose (GObject * object)
G_OBJECT_CLASS (parent_class)->dispose ((GObject *) viewfinderbin); G_OBJECT_CLASS (parent_class)->dispose ((GObject *) viewfinderbin);
} }
static void
gst_viewfinder_bin_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "Viewfinder Bin",
"Sink/Video", "Viewfinder Bin used in camerabin2",
"Thiago Santos <thiago.sousa.santos@collabora.co.uk>");
}
static void static void
gst_viewfinder_bin_class_init (GstViewfinderBinClass * klass) gst_viewfinder_bin_class_init (GstViewfinderBinClass * klass)
{ {
@ -134,11 +121,17 @@ gst_viewfinder_bin_class_init (GstViewfinderBinClass * klass)
"If video converters should be disabled (must be set on NULL)", "If video converters should be disabled (must be set on NULL)",
DEFAULT_DISABLE_CONVERTERS, DEFAULT_DISABLE_CONVERTERS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "Viewfinder Bin",
"Sink/Video", "Viewfinder Bin used in camerabin2",
"Thiago Santos <thiago.sousa.santos@collabora.com>");
} }
static void static void
gst_viewfinder_bin_init (GstViewfinderBin * viewfinderbin, gst_viewfinder_bin_init (GstViewfinderBin * viewfinderbin)
GstViewfinderBinClass * viewfinderbin_class)
{ {
GstPadTemplate *templ = gst_static_pad_template_get (&sink_template); GstPadTemplate *templ = gst_static_pad_template_get (&sink_template);
viewfinderbin->ghostpad = gst_ghost_pad_new_no_target_from_template ("sink", viewfinderbin->ghostpad = gst_ghost_pad_new_no_target_from_template ("sink",

View file

@ -1,7 +1,7 @@
/* /*
* GStreamer * GStreamer
* Copyright (C) 2010 Texas Instruments, Inc * Copyright (C) 2010 Texas Instruments, Inc
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk> * Copyright (C) 2011 Thiago Santos <thiago.sousa.santos@collabora.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -44,8 +44,9 @@ enum
GST_DEBUG_CATEGORY (wrapper_camera_bin_src_debug); GST_DEBUG_CATEGORY (wrapper_camera_bin_src_debug);
#define GST_CAT_DEFAULT wrapper_camera_bin_src_debug #define GST_CAT_DEFAULT wrapper_camera_bin_src_debug
GST_BOILERPLATE (GstWrapperCameraBinSrc, gst_wrapper_camera_bin_src, #define gst_wrapper_camera_bin_src_parent_class parent_class
GstBaseCameraSrc, GST_TYPE_BASE_CAMERA_SRC); G_DEFINE_TYPE (GstWrapperCameraBinSrc, gst_wrapper_camera_bin_src,
GST_TYPE_BIN);
static void set_capsfilter_caps (GstWrapperCameraBinSrc * self, static void set_capsfilter_caps (GstWrapperCameraBinSrc * self,
GstCaps * new_caps); GstCaps * new_caps);
@ -165,13 +166,14 @@ gst_wrapper_camera_bin_reset_video_src_caps (GstWrapperCameraBinSrc * self,
if (GST_IS_BIN (self->src_vid_src)) { if (GST_IS_BIN (self->src_vid_src)) {
GstIterator *it = GstIterator *it =
gst_bin_iterate_elements (GST_BIN (self->src_vid_src)); gst_bin_iterate_elements (GST_BIN (self->src_vid_src));
gpointer item = NULL; GValue item = { 0 };
gboolean done = FALSE; gboolean done = FALSE;
while (!done) { while (!done) {
switch (gst_iterator_next (it, &item)) { switch (gst_iterator_next (it, &item)) {
case GST_ITERATOR_OK: case GST_ITERATOR_OK:
gst_element_set_base_time (GST_ELEMENT (item), base_time); gst_element_set_base_time (GST_ELEMENT (g_value_get_object
gst_object_unref (item); (&item)), base_time);
g_value_unset (&item);
break; break;
case GST_ITERATOR_RESYNC: case GST_ITERATOR_RESYNC:
gst_iterator_resync (it); gst_iterator_resync (it);
@ -197,20 +199,21 @@ gst_wrapper_camera_bin_reset_video_src_caps (GstWrapperCameraBinSrc * self,
* *
* Buffer probe called before sending each buffer to image queue. * Buffer probe called before sending each buffer to image queue.
*/ */
static gboolean static GstPadProbeReturn
gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstBuffer * buffer, gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer data) gpointer data)
{ {
GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (data); GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (data);
GstBaseCameraSrc *camerasrc = GST_BASE_CAMERA_SRC (data); GstBaseCameraSrc *camerasrc = GST_BASE_CAMERA_SRC (data);
gboolean ret = FALSE; GstBuffer *buffer = GST_BUFFER (info->data);
GstPadProbeReturn ret = GST_PAD_PROBE_DROP;
GST_LOG_OBJECT (self, "Image probe, mode %d, capture count %d", GST_LOG_OBJECT (self, "Image probe, mode %d, capture count %d",
camerasrc->mode, self->image_capture_count); camerasrc->mode, self->image_capture_count);
g_mutex_lock (camerasrc->capturing_mutex); g_mutex_lock (camerasrc->capturing_mutex);
if (self->image_capture_count > 0) { if (self->image_capture_count > 0) {
ret = TRUE; ret = GST_PAD_PROBE_OK;
self->image_capture_count--; self->image_capture_count--;
/* post preview */ /* post preview */
@ -232,13 +235,14 @@ gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstBuffer * buffer,
* *
* Buffer probe called before sending each buffer to image queue. * Buffer probe called before sending each buffer to image queue.
*/ */
static gboolean static GstPadProbeReturn
gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstBuffer * buffer, gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer data) gpointer data)
{ {
GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (data); GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (data);
GstBaseCameraSrc *camerasrc = GST_BASE_CAMERA_SRC_CAST (self); GstBaseCameraSrc *camerasrc = GST_BASE_CAMERA_SRC_CAST (self);
gboolean ret = FALSE; GstPadProbeReturn ret = GST_PAD_PROBE_DROP;
GstBuffer *buffer = GST_BUFFER (info->data);
GST_LOG_OBJECT (self, "Video probe, mode %d, capture status %d", GST_LOG_OBJECT (self, "Video probe, mode %d, capture status %d",
camerasrc->mode, self->video_rec_status); camerasrc->mode, self->video_rec_status);
@ -260,7 +264,7 @@ gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstBuffer * buffer,
GST_DEBUG_OBJECT (self, "Posting preview for video"); GST_DEBUG_OBJECT (self, "Posting preview for video");
gst_base_camera_src_post_preview (camerasrc, buffer); gst_base_camera_src_post_preview (camerasrc, buffer);
ret = TRUE; ret = GST_PAD_PROBE_OK;
} else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_FINISHING) { } else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_FINISHING) {
/* send eos */ /* send eos */
GST_DEBUG_OBJECT (self, "Finishing video recording, pushing eos"); GST_DEBUG_OBJECT (self, "Finishing video recording, pushing eos");
@ -268,14 +272,15 @@ gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstBuffer * buffer,
self->video_rec_status = GST_VIDEO_RECORDING_STATUS_DONE; self->video_rec_status = GST_VIDEO_RECORDING_STATUS_DONE;
gst_base_camera_src_finish_capture (camerasrc); gst_base_camera_src_finish_capture (camerasrc);
} else { } else {
ret = TRUE; ret = GST_PAD_PROBE_OK;
} }
g_mutex_unlock (camerasrc->capturing_mutex); g_mutex_unlock (camerasrc->capturing_mutex);
return ret; return ret;
} }
static gboolean static gboolean
gst_wrapper_camera_bin_src_event (GstPad * pad, GstEvent * event) gst_wrapper_camera_bin_src_event (GstPad * pad, GstObject * parent,
GstEvent * event)
{ {
GstWrapperCameraBinSrc *src = GstWrapperCameraBinSrc *src =
GST_WRAPPER_CAMERA_BIN_SRC (GST_PAD_PARENT (pad)); GST_WRAPPER_CAMERA_BIN_SRC (GST_PAD_PARENT (pad));
@ -292,25 +297,27 @@ gst_wrapper_camera_bin_src_event (GstPad * pad, GstEvent * event)
src->video_renegotiate = TRUE; src->video_renegotiate = TRUE;
} }
} }
//TODO porting
return src->srcpad_event_func (pad, event); //return src->srcpad_event_func (pad, event);
return TRUE;
} }
static gboolean static GstPadProbeReturn
gst_wrapper_camera_src_src_event_probe (GstPad * pad, GstEvent * evt, gst_wrapper_camera_src_src_event_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer udata) gpointer udata)
{ {
gboolean ret = TRUE; GstPadProbeReturn ret = GST_PAD_PROBE_OK;
GstWrapperCameraBinSrc *self = udata; GstWrapperCameraBinSrc *self = udata;
GstEvent *evt = GST_EVENT (info->data);
switch (GST_EVENT_TYPE (evt)) { switch (GST_EVENT_TYPE (evt)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
/* drop */ /* drop */
ret = FALSE; ret = GST_PAD_PROBE_DROP;
break; break;
case GST_EVENT_NEWSEGMENT: case GST_EVENT_SEGMENT:
if (self->drop_newseg) { if (self->drop_newseg) {
ret = FALSE; ret = GST_PAD_PROBE_DROP;
self->drop_newseg = FALSE; self->drop_newseg = FALSE;
} }
break; break;
@ -333,7 +340,7 @@ gst_wrapper_camera_bin_src_caps_cb (GObject * gobject, GParamSpec * pspec,
/* get the new caps that were set on the capsfilter that configures the /* get the new caps that were set on the capsfilter that configures the
* source */ * source */
src_caps_src_pad = gst_element_get_static_pad (self->src_filter, "src"); src_caps_src_pad = gst_element_get_static_pad (self->src_filter, "src");
caps = gst_pad_get_caps_reffed (src_caps_src_pad); caps = gst_pad_query_caps (src_caps_src_pad, NULL);
gst_object_unref (src_caps_src_pad); gst_object_unref (src_caps_src_pad);
GST_DEBUG_OBJECT (self, "src-filter caps changed to %s", GST_DEBUG_OBJECT (self, "src-filter caps changed to %s",
gst_caps_to_string (caps)); gst_caps_to_string (caps));
@ -429,8 +436,10 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
GstPad *pad; GstPad *pad;
pad = gst_element_get_static_pad (self->src_vid_src, "src"); pad = gst_element_get_static_pad (self->src_vid_src, "src");
self->src_event_probe_id = gst_pad_add_event_probe (pad, self->src_event_probe_id =
(GCallback) gst_wrapper_camera_src_src_event_probe, self); gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
gst_wrapper_camera_src_src_event_probe, gst_object_ref (self),
gst_object_unref);
gst_object_unref (pad); gst_object_unref (pad);
} }
@ -500,10 +509,12 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
g_assert (self->outsel_vidpad != NULL); g_assert (self->outsel_vidpad != NULL);
g_assert (self->outsel_imgpad != NULL); g_assert (self->outsel_imgpad != NULL);
gst_pad_add_buffer_probe (self->outsel_imgpad, gst_pad_add_probe (self->outsel_imgpad, GST_PAD_PROBE_TYPE_BUFFER,
G_CALLBACK (gst_wrapper_camera_bin_src_imgsrc_probe), self); gst_wrapper_camera_bin_src_imgsrc_probe, gst_object_ref (self),
gst_pad_add_buffer_probe (self->outsel_vidpad, gst_object_unref);
G_CALLBACK (gst_wrapper_camera_bin_src_vidsrc_probe), self); gst_pad_add_probe (self->outsel_vidpad, GST_PAD_PROBE_TYPE_BUFFER,
gst_wrapper_camera_bin_src_vidsrc_probe, gst_object_ref (self),
gst_object_unref);
gst_ghost_pad_set_target (GST_GHOST_PAD (self->imgsrc), gst_ghost_pad_set_target (GST_GHOST_PAD (self->imgsrc),
self->outsel_imgpad); self->outsel_imgpad);
gst_ghost_pad_set_target (GST_GHOST_PAD (self->vidsrc), gst_ghost_pad_set_target (GST_GHOST_PAD (self->vidsrc),
@ -1047,19 +1058,6 @@ end:
return ret; return ret;
} }
static void
gst_wrapper_camera_bin_src_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
GST_DEBUG_CATEGORY_INIT (wrapper_camera_bin_src_debug, "wrappercamerabinsrc",
0, "V4l2 camera src");
gst_element_class_set_details_simple (gstelement_class,
"V4l2 camera src element for camerabin", "Source/Video",
"V4l2 camera src element for camerabin", "Rob Clark <rob@ti.com>");
}
static void static void
gst_wrapper_camera_bin_src_class_init (GstWrapperCameraBinSrcClass * klass) gst_wrapper_camera_bin_src_class_init (GstWrapperCameraBinSrcClass * klass)
{ {
@ -1097,11 +1095,18 @@ gst_wrapper_camera_bin_src_class_init (GstWrapperCameraBinSrcClass * klass)
gst_wrapper_camera_bin_src_start_capture; gst_wrapper_camera_bin_src_start_capture;
gstbasecamerasrc_class->stop_capture = gstbasecamerasrc_class->stop_capture =
gst_wrapper_camera_bin_src_stop_capture; gst_wrapper_camera_bin_src_stop_capture;
GST_DEBUG_CATEGORY_INIT (wrapper_camera_bin_src_debug, "wrappercamerabinsrc",
0, "wrapper camera src");
gst_element_class_set_details_simple (gstelement_class,
"Wrapper camera src element for camerabin2", "Source/Video",
"Wrapper camera src element for camerabin2",
"Thiago Santos <thiago.sousa.santos@collabora.com>");
} }
static void static void
gst_wrapper_camera_bin_src_init (GstWrapperCameraBinSrc * self, gst_wrapper_camera_bin_src_init (GstWrapperCameraBinSrc * self)
GstWrapperCameraBinSrcClass * klass)
{ {
self->vfsrc = self->vfsrc =
gst_ghost_pad_new_no_target (GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME, gst_ghost_pad_new_no_target (GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME,