emotion: add webcam detection, cleanup code and add timing detection.

SVN revision: 61452
This commit is contained in:
Cedric BAIL 2011-07-17 21:38:54 +00:00
parent 1fdf2c67b5
commit dad10a507f
9 changed files with 56 additions and 144 deletions

View File

@ -134,6 +134,11 @@ PKG_CHECK_EXISTS([evas-fb >= 1.0.0], [AC_DEFINE(HAVE_EVAS_FB, 1, [Evas Framebuff
EFL_EDJE_EXTERNAL([have_edje_external="yes"], [have_edje_external="no"])
PKG_CHECK_MODULES(EEZE, [eeze >= 1.0.99], [have_eeze="yes"], [have_eeze="no"])
if test "x${have_eeze}" = "xyes"; then
AC_DEFINE(EMOTION_HAVE_EEZE, 1, [Define to 1 if Eeze is available])
fi
### Checks for header files
AC_HEADER_STDC

View File

@ -223,6 +223,9 @@ extern "C" {
* @defgroup Emotion_Info Miscellaneous information retrieval functions
*/
EAPI Eina_Bool emotion_init(void);
EAPI Eina_Bool emotion_shutdown(void);
/**
* @brief Add an emotion object to the canvas.
*
@ -760,12 +763,15 @@ EAPI void emotion_object_last_position_save (Evas_Object *obj);
EAPI void emotion_object_suspend_set (Evas_Object *obj, Emotion_Suspend state);
EAPI Emotion_Suspend emotion_object_suspend_get (Evas_Object *obj);
EAPI Eina_Bool emotion_object_extension_can_play_get(const Evas_Object *obj, const char *file);
EAPI Eina_Bool emotion_object_extension_can_play_fast_get(const Evas_Object *obj, const char *file);
EAPI Eina_Bool emotion_object_extension_may_play_fast_get(const char *file);
EAPI Eina_Bool emotion_object_extension_may_play_get(const char *file);
typedef struct _Emotion_Webcam Emotion_Webcam;
EAPI const Eina_List *emotion_webcams_get(void);
EAPI const char *emotion_webcam_name_get(Emotion_Webcam *ew);
EAPI const char *emotion_webcam_device_get(Emotion_Webcam *ew);
/**
* @}
*/

View File

@ -10,7 +10,8 @@ AM_CPPFLAGS = \
@EMOTION_CPPFLAGS@ \
@EMOTION_CFLAGS@ \
@EIO_CFLAGS@ \
@EFL_EMOTION_BUILD@
@EFL_EMOTION_BUILD@ \
@EEZE_CFLAGS@
if EMOTION_STATIC_BUILD_XINE
AM_CPPFLAGS += @XINE_CFLAGS@
@ -28,7 +29,7 @@ lib_LTLIBRARIES = libemotion.la
includes_HEADERS = Emotion.h
includesdir = $(includedir)/emotion-@VMAJ@
libemotion_la_SOURCES = emotion_smart.c
libemotion_la_SOURCES = emotion_smart.c emotion_main.c
if EMOTION_STATIC_BUILD_XINE
libemotion_la_SOURCES += \
@ -47,7 +48,7 @@ libemotion_la_SOURCES += \
$(top_srcdir)/src/modules/vlc/emotion_vlc.c
endif
libemotion_la_LIBADD = @EMOTION_LIBS@ @EIO_LIBS@
libemotion_la_LIBADD = @EMOTION_LIBS@ @EIO_LIBS@ @EEZE_LIBS@
if EMOTION_STATIC_BUILD_XINE
libemotion_la_LIBADD += @XINE_LIBS@

View File

@ -109,7 +109,6 @@ struct _Emotion_Video_Module
double (*speed_get) (void *ef);
int (*eject) (void *ef);
const char * (*meta_get) (void *ef, int meta);
Eina_Bool (*can_play_get) (const void *ef, const char *file);
Eina_Emotion_Plugins *plugin;
};
@ -132,8 +131,6 @@ EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num);
EAPI void _emotion_spu_button_set(Evas_Object *obj, int button);
EAPI void _emotion_seek_done(Evas_Object *obj);
EAPI Eina_Bool _emotion_object_extension_can_play_generic_get(const void *data __UNUSED__, const char *file);
EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close);
EAPI Eina_Bool _emotion_module_unregister(const char *name);

View File

@ -1156,52 +1156,6 @@ emotion_object_last_position_save(Evas_Object *obj)
#endif
}
EAPI Eina_Bool
emotion_object_extension_can_play_fast_get(const Evas_Object *obj, const char *file)
{
const Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
if (!sd->module) return EINA_FALSE;
if (!sd->video) return EINA_FALSE;
if (!sd->module->can_play_get) return EINA_FALSE;
return sd->module->can_play_get(sd->video, file);
}
EAPI Eina_Bool
emotion_object_extension_can_play_get(const Evas_Object *obj, const char *file)
{
const char *tmp;
Eina_Bool result;
tmp = eina_stringshare_add(file);
result = emotion_object_extension_can_play_fast_get(obj, tmp);
eina_stringshare_del(tmp);
return result;
}
EAPI Eina_Bool
emotion_object_extension_may_play_fast_get(const char *file)
{
if (!file) return EINA_FALSE;
return _emotion_object_extension_can_play_generic_get(NULL, file);
}
EAPI Eina_Bool
emotion_object_extension_may_play_get(const char *file)
{
const char *tmp;
Eina_Bool result;
if (!file) return EINA_FALSE;
tmp = eina_stringshare_add(file);
result = emotion_object_extension_may_play_fast_get(tmp);
eina_stringshare_del(tmp);
return result;
}
EAPI void
emotion_object_suspend_set(Evas_Object *obj, Emotion_Suspend state)
{
@ -1238,87 +1192,6 @@ motion_object_suspend_get(Evas_Object *obj)
/* Utility calls for modules */
/*****************************/
struct ext_match_s
{
unsigned int length;
const char *extension;
};
#define MATCHING(Ext) \
{ sizeof (Ext), Ext }
static const struct ext_match_s matchs[] =
{ /* map extensions to know if it's a emotion playable content for good first-guess tries */
MATCHING(".264"),
MATCHING(".3g2"),
MATCHING(".3gp"),
MATCHING(".3gp2"),
MATCHING(".3gpp"),
MATCHING(".3gpp2"),
MATCHING(".3p2"),
MATCHING(".asf"),
MATCHING(".avi"),
MATCHING(".bdm"),
MATCHING(".bdmv"),
MATCHING(".clpi"),
MATCHING(".clp"),
MATCHING(".fla"),
MATCHING(".flv"),
MATCHING(".m1v"),
MATCHING(".m2v"),
MATCHING(".m2t"),
MATCHING(".m4v"),
MATCHING(".mkv"),
MATCHING(".mov"),
MATCHING(".mp2"),
MATCHING(".mp2ts"),
MATCHING(".mp4"),
MATCHING(".mpe"),
MATCHING(".mpeg"),
MATCHING(".mpg"),
MATCHING(".mpl"),
MATCHING(".mpls"),
MATCHING(".mts"),
MATCHING(".mxf"),
MATCHING(".nut"),
MATCHING(".nuv"),
MATCHING(".ogg"),
MATCHING(".ogm"),
MATCHING(".ogv"),
MATCHING(".rm"),
MATCHING(".rmj"),
MATCHING(".rmm"),
MATCHING(".rms"),
MATCHING(".rmx"),
MATCHING(".rmvb"),
MATCHING(".swf"),
MATCHING(".ts"),
MATCHING(".weba"),
MATCHING(".webm"),
MATCHING(".wmv")
};
EAPI Eina_Bool
_emotion_object_extension_can_play_generic_get(const void *data __UNUSED__, const char *file)
{
unsigned int length;
unsigned int i;
length = eina_stringshare_strlen(file) + 1;
if (length < 5) return EINA_FALSE;
for (i = 0; i < sizeof (matchs) / sizeof (struct ext_match_s); ++i)
{
if (matchs[i].length > length) continue;
if (!strcasecmp(matchs[i].extension,
file + length - matchs[i].length))
return EINA_TRUE;
}
return EINA_FALSE;
}
EAPI void *
_emotion_video_get(const Evas_Object *obj)
{
@ -1880,3 +1753,4 @@ _emotion_image_get(const Evas_Object *obj)
if (!sd) return NULL;
return sd->obj;
}

View File

@ -227,7 +227,6 @@ static Emotion_Video_Module em_module =
em_speed_get, /* speed_get */
em_eject, /* eject */
em_meta_get, /* meta_get */
_emotion_object_extension_can_play_generic_get, /* play_get */
NULL /* handle */
};
@ -379,6 +378,7 @@ em_file_open(const char *file,
Emotion_Gstreamer_Video *ev;
Eina_Strbuf *sbuf = NULL;
const char *uri;
double start, end;
int i;
ev = (Emotion_Gstreamer_Video *)video;
@ -407,20 +407,26 @@ em_file_open(const char *file,
eina_strbuf_append(sbuf, file);
}
start = ecore_time_get();
uri = sbuf ? eina_strbuf_string_get(sbuf) : file;
DBG("setting file to '%s'", uri);
ev->pipeline = gstreamer_video_sink_new(ev, obj, uri);
if (sbuf) eina_strbuf_free(sbuf);
end = ecore_time_get();
DBG("Pipeline creation: %f", end - start);
if (!ev->pipeline)
return EINA_FALSE;
start = ecore_time_get();
ev->eos_bus = gst_pipeline_get_bus(GST_PIPELINE(ev->pipeline));
if (!ev->eos_bus)
{
ERR("could not get the bus");
return EINA_FALSE;
}
end = ecore_time_get();
DBG("Get the bus: %f", end - start);
/* Evas Object */
ev->obj = obj;
@ -442,6 +448,7 @@ em_file_open(const char *file,
/* video stream */
start = ecore_time_get();
for (i = 0; i < ev->video_stream_nbr; i++)
{
Emotion_Video_Stream *vstream;
@ -515,9 +522,12 @@ em_file_open(const char *file,
unref_pad_v:
gst_object_unref(pad);
}
end = ecore_time_get();
DBG("Get video streams: %f", end - start);
/* Audio streams */
start = ecore_time_get();
for (i = 0; i < ev->audio_stream_nbr; i++)
{
Emotion_Audio_Stream *astream;
@ -575,9 +585,12 @@ em_file_open(const char *file,
unref_pad_a:
gst_object_unref(pad);
}
end = ecore_time_get();
DBG("Get audio streams: %f", end - start);
/* Visualization sink */
start = ecore_time_get();
if (ev->video_stream_nbr == 0)
{
GstElement *vis = NULL;
@ -613,6 +626,8 @@ em_file_open(const char *file,
flags |= 0x00000008;
g_object_set(G_OBJECT(ev->pipeline), "flags", flags, NULL);
}
end = ecore_time_get();
DBG("Get visualization streams: %f", end - start);
finalize:
@ -656,10 +671,13 @@ em_file_open(const char *file,
_free_metadata(ev->metadata);
ev->metadata = calloc(1, sizeof(Emotion_Gstreamer_Metadata));
start = ecore_time_get();
em_audio_channel_volume_set(ev, ev->volume);
_eos_timer_fct(ev);
_emotion_open_done(ev->obj);
end = ecore_time_get();
DBG("Last stuff: %f", end - start);
return 1;
}

View File

@ -471,10 +471,10 @@ static void evas_video_sink_render_handler(void *data,
if (priv->format == GST_VIDEO_FORMAT_I420) {
int i;
unsigned char **rows;
const unsigned char **rows;
evas_object_image_pixels_dirty_set(priv->o, 1);
rows = (unsigned char **)evas_data;
rows = (const unsigned char **)evas_data;
for (i = 0; i < priv->height; i++)
rows[i] = &gst_data[i * priv->width];
@ -490,11 +490,11 @@ static void evas_video_sink_render_handler(void *data,
if (priv->format == GST_VIDEO_FORMAT_YV12) {
int i;
unsigned char **rows;
const unsigned char **rows;
evas_object_image_pixels_dirty_set(priv->o, 1);
rows = (unsigned char **)evas_data;
rows = (const unsigned char **)evas_data;
for (i = 0; i < priv->height; i++)
rows[i] = &gst_data[i * priv->width];
@ -646,6 +646,7 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
GstElement *sink;
Evas_Object *obj;
GstStateChangeReturn res;
double start, end;
obj = _emotion_image_get(o);
if (!obj)
@ -654,13 +655,17 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
return NULL;
}
start = ecore_time_get();
playbin = gst_element_factory_make("playbin2", "playbin");
if (!playbin)
{
ERR("Unable to create 'playbin' GstElement.");
return NULL;
}
end = ecore_time_get();
DBG("Playbin2: %f", end - start);
start = ecore_time_get();
sink = gst_element_factory_make("emotion-sink", "sink");
if (!sink)
{
@ -671,20 +676,29 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
g_object_set(G_OBJECT(playbin), "video-sink", sink, NULL);
g_object_set(G_OBJECT(playbin), "uri", uri, NULL);
g_object_set(G_OBJECT(sink), "evas-object", obj, NULL);
end = ecore_time_get();
DBG("emotion-sink: %f", end - start);
start = ecore_time_get();
res = gst_element_set_state(playbin, GST_STATE_PAUSED);
if (res == GST_STATE_CHANGE_FAILURE)
{
ERR("Unable to set GST_STATE_PAUSED.");
goto unref_pipeline;
}
end = ecore_time_get();
DBG("Pause pipeline: %f", end - start);
start = ecore_time_get();
res = gst_element_get_state(playbin, NULL, NULL, GST_CLOCK_TIME_NONE);
if (res != GST_STATE_CHANGE_SUCCESS)
{
ERR("Unable to get GST_CLOCK_TIME_NONE.");
goto unref_pipeline;
}
end = ecore_time_get();
DBG("No time: %f", end - start);
evas_object_data_set(obj, "_emotion_gstreamer_video", ev);

View File

@ -1193,8 +1193,6 @@ static Emotion_Video_Module em_module =
em_speed_get, /* speed_get */
em_eject, /* eject */
em_meta_get, /* meta_get */
_emotion_object_extension_can_play_generic_get, /* can_play_get */
NULL /* handle */
};

View File

@ -1556,7 +1556,6 @@ static Emotion_Video_Module em_module =
em_speed_get, /* speed_get */
em_eject, /* eject */
em_meta_get, /* meta_get */
_emotion_object_extension_can_play_generic_get, /* can_play_get */
NULL /* handle */
};