static void
gst_camerasrc_init (GstCameraSrc * camerasrc, GstCameraSrcClass * klass)
{
- GstPad *second_pad;
- GstPadTemplate *pad_template;
/* number of buffers requested */
camerasrc->always_copy = DEFAULT_PROP_ALWAYS_COPY;
camerasrc->maker_note = FALSE;
/* second pad init */
- pad_template =
- gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "second");
- second_pad = gst_pad_new_from_template (pad_template, "second");
- gst_pad_set_activatepush_function (second_pad, gst_camerasrc_second_pad_activate_push);
- gst_pad_set_activatepull_function (second_pad, gst_camerasrc_second_pad_activate_pull);
- //gst_pad_set_event_function (second_pad, gst_camerasrc_second_pad_event_handler);
- //gst_pad_set_query_function (second_pad, gst_camerasrc_second_pad_query);
- gst_pad_set_checkgetrange_function (second_pad, gst_camerasrc_second_pad_check_get_range);
- //gst_pad_set_getrange_function (second_pad, gst_camerasrc_second_pad_get_range);
- gst_pad_set_getcaps_function (second_pad, gst_camerasrc_second_pad_getcaps);
- gst_pad_set_setcaps_function (second_pad, gst_camerasrc_second_pad_setcaps);
- gst_pad_set_fixatecaps_function (second_pad, gst_camerasrc_second_pad_fixate);
- //gst_pad_set_link_function (second_pad, gst_camerasrc_second_pad_link);
-
- GST_CAMERA_SRC_SECOND_PAD(camerasrc) = second_pad;
- gst_element_add_pad(GST_ELEMENT(camerasrc), second_pad);
-
camerasrc->second_w = 0;
camerasrc->second_h = 0;
camerasrc->second_fps_n = 0;
camerasrc->second_eos_sent = FALSE;
}
+GstPad *
+gst_request_second_pad (GstElement *element,
+ GstPadTemplate *templ,
+ const gchar *name,
+ const GstCaps *caps)
+{
+
+ GstPad *second_pad;
+ GstCameraSrc *camerasrc = GST_CAMERA_SRC_CAST (element);
+
+ GST_DEBUG("second pad request \n");
+ second_pad = gst_pad_new_from_template (templ, name);
+
+ gst_pad_set_activatepush_function (second_pad, gst_camerasrc_second_pad_activate_push);
+ gst_pad_set_activatepull_function (second_pad, gst_camerasrc_second_pad_activate_pull);
+ //gst_pad_set_event_function (second_pad, gst_camerasrc_second_pad_event_handler);
+ //gst_pad_set_query_function (second_pad, gst_camerasrc_second_pad_query);
+ gst_pad_set_checkgetrange_function (second_pad, gst_camerasrc_second_pad_check_get_range);
+ //gst_pad_set_getrange_function (second_pad, gst_camerasrc_second_pad_get_range);
+ gst_pad_set_getcaps_function (second_pad, gst_camerasrc_second_pad_getcaps);
+ gst_pad_set_setcaps_function (second_pad, gst_camerasrc_second_pad_setcaps);
+ gst_pad_set_fixatecaps_function (second_pad, gst_camerasrc_second_pad_fixate);
+ //gst_pad_set_link_function (second_pad, gst_camerasrc_second_pad_link);
+
+
+ gst_element_add_pad (element, second_pad);
+ GST_DEBUG("second pad init \n");
+ GST_CAMERA_SRC_SECOND_PAD(camerasrc) = second_pad;
+
+
+ return second_pad;
+}
+
+void
+gst_release_second_pad (GstElement *element,
+ GstPad *pad)
+{
+
+ gst_element_remove_pad (element, pad);
+ //GST_CAMERA_SRC_SECOND_PAD(camerasrc) = NULL;
+
+}
+
+
/*
*/
static void
GST_DEBUG_CATEGORY (gst_v4l2camsrc_debug);
#define GST_CAT_DEFAULT gst_v4l2camsrc_debug
+
+
+GstPad gst_request_second_pad (GstElement *element,
+ GstPadTemplate *templ,
+ const gchar *name,
+ const GstCaps *caps);
+
+void gst_release_second_pad (GstElement *element, GstPad *pad);
+
+
static gboolean gst_v4l2camsrc_is_open (GstCameraSrc * camsrc);
static void gst_v4l2camsrc_finalize (GObject * object);
static void gst_v4l2camsrc_dispose (GObject * object);
static gboolean gst_v4l2camsrc_makernote_uninit(GstCameraSrc * camsrc,
int handle);
+
+
+
typedef enum
{
PROP_0,
PROP_SECOND_QUEUE_SIZE,
} GstV4L2CamSrcProperties;
-#define GST_V4L2_CAMSRC_PAD_TEMPLATE(padname) \
+#define GST_V4L2_CAMSRC_PAD_TEMPLATE(padname,present) \
GST_STATIC_PAD_TEMPLATE (padname, \
GST_PAD_SRC, \
- GST_PAD_ALWAYS, \
+ present, \
GST_STATIC_CAPS ("video/x-raw-yuv, " \
"format = (fourcc) NV12, " \
"framerate = (fraction) [ 0, 200 ], " \
"framerate = (fraction) [ 0, MAX ]"))
static GstStaticPadTemplate gst_v4l2camsrc_src_template =
- GST_V4L2_CAMSRC_PAD_TEMPLATE("src");
+ GST_V4L2_CAMSRC_PAD_TEMPLATE("src",GST_PAD_ALWAYS);
static GstStaticPadTemplate gst_v4l2camsrc_second_template =
- GST_V4L2_CAMSRC_PAD_TEMPLATE("second");
+ GST_V4L2_CAMSRC_PAD_TEMPLATE("second", GST_PAD_REQUEST);
#define DEFAULT_PROP_DEVICE_NAME NULL
#define DEFAULT_PROP_DEVICE "/dev/video0"
gst_static_pad_template_get (&gst_v4l2camsrc_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_v4l2camsrc_second_template));
+
+ element_class->request_new_pad = gst_request_second_pad;
+ element_class->release_pad = gst_release_second_pad;
}
gboolean gst_v4l2camsrc_set_autofocus (GstCameraSrc * camsrc, gboolean on);