Exemplo n.º 1
0
void
ubiquity_webcam_stop (UbiquityWebcam *webcam) {
	UbiquityWebcamPrivate *priv = UBIQUITY_WEBCAM_PRIVATE (webcam);
	if (gst_element_set_state (priv->camerabin, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) {
		g_print ("setting camerabin to STOPPED failed\n");
		return;
	}
}
Exemplo n.º 2
0
void
ubiquity_webcam_play (UbiquityWebcam *webcam) {
	UbiquityWebcamPrivate *priv = UBIQUITY_WEBCAM_PRIVATE (webcam);
	if (!priv || !priv->camerabin)
		return;
	if (gst_element_set_state (priv->camerabin, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
		g_print ("setting camerabin to PLAYING failed\n");
		return;
	}
}
Exemplo n.º 3
0
static void
ubiquity_webcam_init (UbiquityWebcam *self) {
	UbiquityWebcamPrivate *priv;
	gint width = 172, height = 129;

	assert (width * 3 == height * 4); /* 4x3 ratio */

	priv = self->priv = UBIQUITY_WEBCAM_PRIVATE (self);

	gtk_orientable_set_orientation (GTK_ORIENTABLE (self),
					GTK_ORIENTATION_VERTICAL);
	gtk_box_set_spacing (GTK_BOX (self), 1);
	priv->drawing_area = gtk_drawing_area_new ();
	gtk_widget_set_size_request (priv->drawing_area, width, height);
	g_signal_connect (priv->drawing_area, "realize",
			G_CALLBACK(drawing_area_realized_cb), NULL);
	gtk_widget_set_double_buffered (priv->drawing_area, FALSE);

	priv->button = gtk_button_new ();
	gtk_button_set_label (GTK_BUTTON (priv->button), "Take Photo");

	gtk_box_pack_start (GTK_BOX (self), priv->drawing_area, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (self), priv->button, FALSE, FALSE, 0);

	priv->camerabin = gst_element_factory_make ("camerabin2" , "cam");
	priv->viewfinder_caps = gst_caps_new_simple ("video/x-raw-rgb",
		"width", G_TYPE_INT, 640,
		"height", G_TYPE_INT, 480, NULL);
	g_object_set (G_OBJECT (priv->camerabin),
		"viewfinder-caps", priv->viewfinder_caps, NULL);
    g_signal_new ("image-captured",
					UBIQUITY_TYPE_WEBCAM,
					G_SIGNAL_RUN_FIRST,
					0,
					NULL,
					NULL,
					g_cclosure_marshal_VOID__OBJECT,
					G_TYPE_NONE, 1,
					G_TYPE_STRING);
	if (!priv->camerabin) {
		g_print ("Failed to create camerabin.\n");
		return;
	}
	g_signal_connect (priv->button, "clicked",
			G_CALLBACK(button_clicked_cb), priv->camerabin);

	priv->bus = gst_element_get_bus (priv->camerabin);
	gst_bus_add_signal_watch (priv->bus);
	g_signal_connect (priv->bus, "message", G_CALLBACK (message_cb), self);
	gst_bus_set_sync_handler (priv->bus, (GstBusSyncHandler) window_id_cb, NULL);
	gst_object_ref (priv->bus);
	gst_object_ref (priv->camerabin);
}
Exemplo n.º 4
0
static void
ubiquity_webcam_get_property (GObject *object, guint prop_id, GValue *value,
			      GParamSpec *pspec) {
	UbiquityWebcamPrivate *priv = UBIQUITY_WEBCAM_PRIVATE (object);

	switch (prop_id) {
		case PROP_BUTTON:
			g_value_set_object (value, (GObject *) priv->button);
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id,
							   pspec);
	}
}
Exemplo n.º 5
0
void
ubiquity_webcam_test (UbiquityWebcam *webcam) {
	UbiquityWebcamPrivate *priv = UBIQUITY_WEBCAM_PRIVATE (webcam);
	if (!priv || !priv->camerabin)
		return;
	if (priv->src)
		return;
	priv->src = gst_element_factory_make ("wrappercamerabinsrc", NULL);
	priv->testsrc = gst_element_factory_make ("videotestsrc", NULL);
	g_object_set (G_OBJECT (priv->testsrc), "is-live", TRUE,
		"peer-alloc", FALSE, NULL);
	g_object_set (G_OBJECT (priv->src), "video-src", priv->testsrc, NULL);
	g_object_set (G_OBJECT (priv->camerabin), "camera-src", priv->src, NULL);
	ubiquity_webcam_stop (webcam);
	ubiquity_webcam_play (webcam);
	gst_object_ref (priv->src);
	gst_object_ref (priv->testsrc);
}