[cheese/libcheese: 1/5] cheese-camera: Adding pointer to priv in CheeseCamera
- From: Luciana Fujii Pontello <lufujii src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/libcheese: 1/5] cheese-camera: Adding pointer to priv in CheeseCamera
- Date: Fri, 28 Jan 2011 22:49:13 +0000 (UTC)
commit 45f1351fa3478e010611d848acb791fafa1311b0
Author: Luciana Fujii Pontello <luciana fujii eti br>
Date: Thu Jan 27 22:49:30 2011 -0200
cheese-camera: Adding pointer to priv in CheeseCamera
Added a pointer to priv in CheeseCamera and used it instead of using
CHEESE_CAMERA_GET_PRIVATE.
libcheese/cheese-camera.c | 92 +++++++++++++++++++-------------------------
libcheese/cheese-camera.h | 5 ++
2 files changed, 45 insertions(+), 52 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 6aed32e..ec2fdf0 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -45,7 +45,7 @@ G_DEFINE_TYPE (CheeseCamera, cheese_camera, G_TYPE_OBJECT)
#define CHEESE_CAMERA_ERROR cheese_camera_error_quark ()
-typedef struct
+struct _CheeseCameraPrivate
{
GtkWidget *video_window;
@@ -91,7 +91,7 @@ typedef struct
CheeseVideoFormat *current_format;
guint eos_timeout_id;
-} CheeseCameraPrivate;
+};
enum
{
@@ -125,7 +125,7 @@ static void
cheese_camera_change_sink (CheeseCamera *camera, GstElement *src,
GstElement *new_sink, GstElement *old_sink)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
gboolean is_playing = priv->pipeline_is_playing;
cheese_camera_stop (camera);
@@ -145,7 +145,7 @@ static void
cheese_camera_photo_data_cb (GstElement *element, GstBuffer *buffer,
GstPad *pad, CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GstCaps *caps;
const GstStructure *structure;
@@ -196,7 +196,7 @@ cheese_camera_photo_data_cb (GstElement *element, GstBuffer *buffer,
static void
cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
switch (GST_MESSAGE_TYPE (message))
{
@@ -266,7 +266,7 @@ cheese_camera_add_device (CheeseCameraDeviceMonitor *monitor,
gint api_version,
CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GError *error = NULL;
CheeseCameraDevice *device = cheese_camera_device_new (id,
@@ -289,7 +289,7 @@ cheese_camera_add_device (CheeseCameraDeviceMonitor *monitor,
static void
cheese_camera_detect_camera_devices (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
CheeseCameraDeviceMonitor *monitor;
priv->num_camera_devices = 0;
@@ -305,7 +305,7 @@ cheese_camera_detect_camera_devices (CheeseCamera *camera)
static gboolean
cheese_camera_create_camera_source_bin (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GError *err = NULL;
char *camera_input;
@@ -393,7 +393,7 @@ cheese_camera_set_error_element_not_found (GError **error, const char *factoryna
static gboolean
cheese_camera_create_video_display_bin (CheeseCamera *camera, GError **error)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GstElement *save_tee, *video_display_queue, *video_scale, *video_sink, *save_queue;
@@ -509,7 +509,7 @@ cheese_camera_create_video_display_bin (CheeseCamera *camera, GError **error)
static void
cheese_camera_relink_camera_source_bin (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
gst_element_unlink (priv->camera_source_bin, priv->camera_tee);
gst_bin_remove (GST_BIN (priv->video_display_bin), priv->camera_source_bin);
@@ -523,7 +523,7 @@ cheese_camera_relink_camera_source_bin (CheeseCamera *camera)
static gboolean
cheese_camera_create_photo_save_bin (CheeseCamera *camera, GError **error)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GstElement *csp_photo_save_bin;
@@ -571,7 +571,7 @@ cheese_camera_create_photo_save_bin (CheeseCamera *camera, GError **error)
static gboolean
cheese_camera_create_video_save_bin (CheeseCamera *camera, GError **error)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GstElement *audio_queue, *audio_convert, *audio_enc;
GstElement *video_save_csp, *video_save_rate, *video_save_scale, *video_enc;
@@ -670,7 +670,7 @@ cheese_camera_create_video_save_bin (CheeseCamera *camera, GError **error)
int
cheese_camera_get_num_camera_devices (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
return priv->num_camera_devices;
}
@@ -678,7 +678,7 @@ cheese_camera_get_num_camera_devices (CheeseCamera *camera)
CheeseCameraDevice *
cheese_camera_get_selected_device (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
if (cheese_camera_get_num_camera_devices (camera) > 0)
return CHEESE_CAMERA_DEVICE (
@@ -690,7 +690,7 @@ cheese_camera_get_selected_device (CheeseCamera *camera)
gboolean
cheese_camera_switch_camera_device (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
gboolean was_recording = FALSE;
gboolean pipeline_was_playing = FALSE;
@@ -725,7 +725,7 @@ cheese_camera_switch_camera_device (CheeseCamera *camera)
void
cheese_camera_play (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
CheeseCameraDevice *device = g_ptr_array_index (priv->camera_devices, priv->selected_device);
GstCaps *caps;
@@ -755,7 +755,7 @@ cheese_camera_play (CheeseCamera *camera)
void
cheese_camera_stop (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
if (priv->pipeline != NULL)
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
@@ -765,7 +765,7 @@ cheese_camera_stop (CheeseCamera *camera)
static void
cheese_camera_change_effect_filter (CheeseCamera *camera, GstElement *new_filter)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
gboolean ok;
g_object_set (G_OBJECT (priv->main_valve), "drop", TRUE, NULL);
@@ -832,7 +832,7 @@ cheese_camera_set_effect (CheeseCamera *camera, CheeseEffect *effect)
void
cheese_camera_toggle_effects_pipeline (CheeseCamera *camera, gboolean active)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
if (active)
{
@@ -849,7 +849,7 @@ cheese_camera_toggle_effects_pipeline (CheeseCamera *camera, gboolean active)
void
cheese_camera_connect_effect_texture (CheeseCamera *camera, CheeseEffect *effect, ClutterTexture *texture)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GstElement *effect_filter;
GstElement *display_element;
@@ -888,9 +888,9 @@ cheese_camera_connect_effect_texture (CheeseCamera *camera, CheeseEffect *effect
void
cheese_camera_start_video_recording (CheeseCamera *camera, char *filename)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
- g_object_set (CHEESE_CAMERA_GET_PRIVATE (camera)->video_file_sink, "location", filename, NULL);
+ g_object_set (priv->video_file_sink, "location", filename, NULL);
cheese_camera_change_sink (camera, priv->video_display_bin,
priv->video_save_bin, priv->photo_save_bin);
priv->is_recording = TRUE;
@@ -900,7 +900,7 @@ static gboolean
cheese_camera_force_stop_video_recording (gpointer data)
{
CheeseCamera *camera = CHEESE_CAMERA (data);
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
if (priv->is_recording)
{
@@ -918,7 +918,7 @@ cheese_camera_force_stop_video_recording (gpointer data)
void
cheese_camera_stop_video_recording (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
GstState state;
gst_element_get_state (priv->pipeline, &state, NULL, 0);
@@ -940,7 +940,7 @@ cheese_camera_stop_video_recording (CheeseCamera *camera)
gboolean
cheese_camera_take_photo (CheeseCamera *camera, char *filename)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
if (priv->photo_handler_signal_id != 0)
{
@@ -962,7 +962,7 @@ cheese_camera_take_photo (CheeseCamera *camera, char *filename)
gboolean
cheese_camera_take_photo_pixbuf (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
if (priv->photo_handler_signal_id != 0)
{
@@ -984,7 +984,7 @@ cheese_camera_finalize (GObject *object)
CheeseCamera *camera;
camera = CHEESE_CAMERA (object);
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
cheese_camera_stop (camera);
if (priv->pipeline != NULL)
@@ -1009,10 +1009,8 @@ static void
cheese_camera_get_property (GObject *object, guint prop_id, GValue *value,
GParamSpec *pspec)
{
- CheeseCamera *self;
-
- self = CHEESE_CAMERA (object);
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (self);
+ CheeseCamera *self = CHEESE_CAMERA (object);
+ CheeseCameraPrivate *priv = self->priv;
switch (prop_id)
{
@@ -1035,10 +1033,8 @@ static void
cheese_camera_set_property (GObject *object, guint prop_id, const GValue *value,
GParamSpec *pspec)
{
- CheeseCamera *self;
-
- self = CHEESE_CAMERA (object);
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (self);
+ CheeseCamera *self = CHEESE_CAMERA (object);
+ CheeseCameraPrivate *priv = self->priv;
switch (prop_id)
{
@@ -1134,6 +1130,7 @@ cheese_camera_init (CheeseCamera *camera)
{
CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ camera->priv = priv;
priv->is_recording = FALSE;
priv->pipeline_is_playing = FALSE;
priv->photo_filename = NULL;
@@ -1171,7 +1168,7 @@ cheese_camera_new (ClutterTexture *video_texture, char *camera_device_name,
void
cheese_camera_setup (CheeseCamera *camera, char *id, GError **error)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
gboolean ok = TRUE;
GError *tmp_error = NULL;
@@ -1222,11 +1219,10 @@ cheese_camera_setup (CheeseCamera *camera, char *id, GError **error)
GPtrArray *
cheese_camera_get_camera_devices (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv;
+ CheeseCameraPrivate *priv = camera->priv;
g_return_val_if_fail (CHEESE_IS_CAMERA (camera), NULL);
- priv = CHEESE_CAMERA_GET_PRIVATE (camera);
return g_ptr_array_ref (priv->camera_devices);
}
@@ -1241,12 +1237,11 @@ cheese_camera_set_device_by_dev_file (CheeseCamera *camera, char *file)
void
cheese_camera_set_device_by_dev_udi (CheeseCamera *camera, char *udi)
{
- CheeseCameraPrivate *priv;
+ CheeseCameraPrivate *priv = camera->priv;
int i;
g_return_if_fail (CHEESE_IS_CAMERA (camera));
- priv = CHEESE_CAMERA_GET_PRIVATE (camera);
for (i = 0; i < priv->num_camera_devices; i++)
{
@@ -1279,25 +1274,21 @@ cheese_camera_get_video_formats (CheeseCamera *camera)
gboolean
cheese_camera_is_playing (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv;
+ CheeseCameraPrivate *priv = camera->priv;
g_return_val_if_fail (CHEESE_IS_CAMERA (camera), FALSE);
- priv = CHEESE_CAMERA_GET_PRIVATE (camera);
-
return priv->pipeline_is_playing;
}
void
cheese_camera_set_video_format (CheeseCamera *camera, CheeseVideoFormat *format)
{
- CheeseCameraPrivate *priv;
+ CheeseCameraPrivate *priv = camera->priv;
g_return_if_fail (CHEESE_IS_CAMERA (camera));
g_return_if_fail (format != NULL);
- priv = CHEESE_CAMERA_GET_PRIVATE (camera);
-
if (!(priv->current_format->width == format->width &&
priv->current_format->height == format->height))
{
@@ -1313,7 +1304,7 @@ cheese_camera_set_video_format (CheeseCamera *camera, CheeseVideoFormat *format)
const CheeseVideoFormat *
cheese_camera_get_current_video_format (CheeseCamera *camera)
{
- CheeseCameraPrivate *priv = CHEESE_CAMERA_GET_PRIVATE (camera);
+ CheeseCameraPrivate *priv = camera->priv;
g_return_val_if_fail (CHEESE_IS_CAMERA (camera), NULL);
@@ -1325,12 +1316,11 @@ cheese_camera_get_balance_property_range (CheeseCamera *camera,
gchar *property,
gdouble *min, gdouble *max, gdouble *def)
{
- CheeseCameraPrivate *priv;
+ CheeseCameraPrivate *priv = camera->priv;
GParamSpec *pspec;
g_return_val_if_fail (CHEESE_IS_CAMERA (camera), FALSE);
- priv = CHEESE_CAMERA_GET_PRIVATE (camera);
*min = 0.0;
*max = 1.0;
@@ -1353,11 +1343,9 @@ cheese_camera_get_balance_property_range (CheeseCamera *camera,
void
cheese_camera_set_balance_property (CheeseCamera *camera, gchar *property, gdouble value)
{
- CheeseCameraPrivate *priv;
+ CheeseCameraPrivate *priv = camera->priv;
g_return_if_fail (CHEESE_IS_CAMERA (camera));
- priv = CHEESE_CAMERA_GET_PRIVATE (camera);
-
g_object_set (G_OBJECT (priv->video_balance), property, value, NULL);
}
diff --git a/libcheese/cheese-camera.h b/libcheese/cheese-camera.h
index 958bd34..fc27088 100644
--- a/libcheese/cheese-camera.h
+++ b/libcheese/cheese-camera.h
@@ -40,9 +40,14 @@ G_BEGIN_DECLS
#define CHEESE_IS_CAMERA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CHEESE_TYPE_CAMERA))
#define CHEESE_CAMERA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CHEESE_TYPE_CAMERA, CheeseCameraClass))
+typedef struct _CheeseCameraPrivate CheeseCameraPrivate;
+
typedef struct
{
GObject parent;
+
+ /* private */
+ CheeseCameraPrivate *priv;
} CheeseCamera;
typedef struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]