forked from enlightenment/efl
emotion: add two events to trigger when a webcam is plugged or unplugged
This commit is contained in:
parent
80bcfac650
commit
4ce3e1e72f
2
AUTHORS
2
AUTHORS
|
@ -306,6 +306,8 @@ Pierre Le Magourou <pierre.lemagourou@openwide.fr>
|
|||
Hugo Camboulive <hugo.camboulive@zodiacaerospace.com>
|
||||
Sohyun Kim <anna1014.kim@samsung.com>
|
||||
Leandro Dorileo <dorileo@profusion.mobi>
|
||||
Michael Bouchaud (yoz) <yoz@efl.so>
|
||||
Aymeric Dumaz <aymeric.dumaz@gmail.com>
|
||||
|
||||
Ethumb
|
||||
------
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2013-10-10 Michael Bouchaud (yoz)
|
||||
|
||||
* Emotion: add two events to trigger webcam plug and unplug
|
||||
|
||||
2013-10-04 ChunEon Park (Hermet)
|
||||
|
||||
* Eina: fix eina_file_map_lines() to not drop of one character in the last line.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -424,6 +424,7 @@ Fixes:
|
|||
* Emotion:
|
||||
- Fix memory leak in gstreamer_ecore_x_check.
|
||||
- Fix backend priority order.
|
||||
- Add two events to trigger webcam plug and unplug
|
||||
* Ethumb:
|
||||
- Fix memory leak in error case.
|
||||
* Eeze:
|
||||
|
|
|
@ -1287,7 +1287,9 @@ EAPI Evas_Object *emotion_object_image_get(const Evas_Object *obj);
|
|||
|
||||
typedef struct _Emotion_Webcam Emotion_Webcam; /**< Webcam description */
|
||||
|
||||
EAPI extern int EMOTION_WEBCAM_UPDATE; /**< Ecore_Event triggered when a new webcam is plugged in */
|
||||
EAPI extern int EMOTION_WEBCAM_UPDATE; /**< Ecore_Event triggered when a new webcam is plugged or unplugged */
|
||||
EAPI extern int EMOTION_WEBCAM_ADD; /**< Ecore_Event triggered when a new webcam is plugged in @since 1.8*/
|
||||
EAPI extern int EMOTION_WEBCAM_DEL; /**< Ecore_Event triggered when a webcam is unplugged @since 1.8 */
|
||||
|
||||
/**
|
||||
* @brief Get a list of active and available webcam
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "emotion_private.h"
|
||||
|
||||
EAPI int EMOTION_WEBCAM_UPDATE = 0;
|
||||
EAPI int EMOTION_WEBCAM_ADD = 0;
|
||||
EAPI int EMOTION_WEBCAM_DEL = 0;
|
||||
|
||||
typedef struct _Emotion_Webcams Emotion_Webcams;
|
||||
|
||||
|
@ -89,7 +91,7 @@ emotion_webcam_destroy(Emotion_Webcam *ew)
|
|||
#ifdef HAVE_EEZE
|
||||
static Eeze_Udev_Watch *eeze_watcher = NULL;
|
||||
|
||||
static void
|
||||
static Eina_Bool
|
||||
_emotion_check_device(Emotion_Webcam *ew)
|
||||
{
|
||||
#ifdef HAVE_V4L2
|
||||
|
@ -99,7 +101,7 @@ _emotion_check_device(Emotion_Webcam *ew)
|
|||
int fd = -1;
|
||||
#endif
|
||||
|
||||
if (!ew) return;
|
||||
if (!ew) return EINA_FALSE;
|
||||
#ifdef HAVE_V4L2
|
||||
if (!ew->device) goto on_error;
|
||||
|
||||
|
@ -125,7 +127,7 @@ _emotion_check_device(Emotion_Webcam *ew)
|
|||
|
||||
if (fd >= 0) close(fd);
|
||||
|
||||
return;
|
||||
return EINA_TRUE;
|
||||
|
||||
on_error:
|
||||
#endif
|
||||
|
@ -137,6 +139,7 @@ _emotion_check_device(Emotion_Webcam *ew)
|
|||
#ifdef HAVE_V4L2
|
||||
if (fd > 0) close(fd);
|
||||
#endif
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Emotion_Webcam *
|
||||
|
@ -182,6 +185,21 @@ _emotion_enumerate_all_webcams(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_emotion_webcam_remove_cb(void *user_data, void *func_data EINA_UNUSED)
|
||||
{
|
||||
Emotion_Webcam *webcam;
|
||||
|
||||
/* called at the end of EMOTION_WEBCAM_ADD event, to prevent the free */
|
||||
if (!user_data)
|
||||
return;
|
||||
|
||||
webcam = user_data;
|
||||
|
||||
EINA_REFCOUNT_UNREF(webcam)
|
||||
emotion_webcam_destroy(webcam);
|
||||
}
|
||||
|
||||
static void
|
||||
_emotion_eeze_events(const char *syspath,
|
||||
Eeze_Udev_Event ev,
|
||||
|
@ -196,9 +214,10 @@ _emotion_eeze_events(const char *syspath,
|
|||
EINA_LIST_FOREACH(_emotion_webcams->webcams, l, check)
|
||||
if (check->syspath == syspath)
|
||||
{
|
||||
_emotion_webcams->webcams = eina_list_remove_list(_emotion_webcams->webcams, l);
|
||||
EINA_REFCOUNT_UNREF(check)
|
||||
emotion_webcam_destroy(check);
|
||||
_emotion_webcams->webcams =
|
||||
eina_list_remove_list(_emotion_webcams->webcams, l);
|
||||
ecore_event_add(EMOTION_WEBCAM_DEL, check,
|
||||
_emotion_webcam_remove_cb, check);
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +226,8 @@ _emotion_eeze_events(const char *syspath,
|
|||
Emotion_Webcam *test;
|
||||
|
||||
test = _emotion_webcam_new(syspath);
|
||||
if (test) _emotion_check_device(test);
|
||||
if ((test) && (_emotion_check_device(test)))
|
||||
ecore_event_add(EMOTION_WEBCAM_ADD, test, NULL, NULL);
|
||||
}
|
||||
ecore_event_add(EMOTION_WEBCAM_UPDATE, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -217,6 +237,8 @@ _emotion_eeze_events(const char *syspath,
|
|||
Eina_Bool emotion_webcam_init(void)
|
||||
{
|
||||
EMOTION_WEBCAM_UPDATE = ecore_event_type_new();
|
||||
EMOTION_WEBCAM_ADD = ecore_event_type_new();
|
||||
EMOTION_WEBCAM_DEL = ecore_event_type_new();
|
||||
|
||||
eet_init();
|
||||
_emotion_webcams_edds_new();
|
||||
|
|
Loading…
Reference in New Issue