Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_enums.h ewl_media.c ewl_media.h Log Message: - API breakage. - ewl_media_new now takes no parameters - the module to use for emotion is now set through an enum in ewl, so you don't have to know what the names of the emotion decoders are. - formatting - type checking =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_enums.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- ewl_enums.h 20 Oct 2005 04:33:47 -0000 1.16 +++ ewl_enums.h 24 Oct 2005 02:52:07 -0000 1.17 @@ -344,6 +344,13 @@ }; typedef enum Ewl_Attach_Data_Type Ewl_Attach_Data_Type; +enum Ewl_Media_Module_Type +{ + EWL_MEDIA_MODULE_XINE, + EWL_MEDIA_MODULE_GSTREAMER +}; +typedef enum Ewl_Media_Module_Type Ewl_Media_Module_Type; + /** * @} */ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_media.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_media.c 3 Oct 2005 06:43:07 -0000 1.6 +++ ewl_media.c 24 Oct 2005 02:52:07 -0000 1.7 @@ -5,16 +5,16 @@ static void ewl_media_size_update(Ewl_Media *m); static void ewl_media_update_timer_cb(void *data, Evas_Object *obj, void - *event_info); + *event_info); /** - * @param media: the media to be played or NULL * @return Returns a pointer to a new media on success, NULL on failure. * @brief Allocate a new media widget */ -Ewl_Widget *ewl_media_new(char *module, char *media) +Ewl_Widget * +ewl_media_new(void) { - Ewl_Media *m; + Ewl_Media *m; DENTER_FUNCTION(DLEVEL_STABLE); @@ -22,7 +22,7 @@ if (!m) DRETURN_PTR(NULL, DLEVEL_STABLE); - if (!ewl_media_init(m, module, media)) { + if (!ewl_media_init(m)) { ewl_widget_destroy(EWL_WIDGET(m)); DRETURN_PTR(NULL, DLEVEL_STABLE); } @@ -32,13 +32,13 @@ /** * @param m: the media area to be initialized - * @param media: the media to be played or NULL * @return Returns TRUE on success, FALSE on failure. * @brief Initialize the fields and callbacks of a media object * * Sets the internal fields and callbacks of a media object to there defaults. */ -int ewl_media_init(Ewl_Media *m, char *module, char *media) +int +ewl_media_init(Ewl_Media *m) { Ewl_Widget *w; @@ -49,20 +49,16 @@ if (!ewl_widget_init(EWL_WIDGET(w))) DRETURN_INT(FALSE, DLEVEL_STABLE); + ewl_widget_appearance_set(w, "media"); ewl_widget_inherit(EWL_WIDGET(w), "media"); ewl_callback_append(w, EWL_CALLBACK_REALIZE, ewl_media_realize_cb, - NULL); - ewl_callback_append(w, EWL_CALLBACK_UNREALIZE, - ewl_media_unrealize_cb, NULL); - ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, - ewl_media_configure_cb, NULL); - - if (module) - ewl_media_module_set(m, module); - if (media) - ewl_media_media_set(m, media); + NULL); + ewl_callback_append(w, EWL_CALLBACK_UNREALIZE, ewl_media_unrealize_cb, + NULL); + ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_media_configure_cb, + NULL); DRETURN_INT(TRUE, DLEVEL_STABLE); } @@ -70,45 +66,58 @@ /** * @param m: the media area widget to set the module * @param module: the module to set in the media widget @a m - * @return Returns 0 if fail to load the module, 1 otherwise. + * @return Returns FALSE if we failed to load the module, TRUE otherwise. * @brief Set the module of a media widget * * Sets the module of the media widget @a m */ -int ewl_media_module_set(Ewl_Media * m, char *module) +int +ewl_media_module_set(Ewl_Media *m, Ewl_Media_Module_Type module) { + int ret = FALSE; + DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("m", m, 0); - DCHECK_PARAM_PTR_RET("module", module, 0); + DCHECK_PARAM_PTR_RET("m", m, FALSE); + DCHECK_TYPE_RET("m", m, "media", FALSE); - IF_FREE(m->module); - m->module = strdup(module); + m->module = module; /* * Initialize emotion */ - if (m->video && m->module && emotion_object_init(m->video, m->module)) - DRETURN_INT(TRUE, DLEVEL_STABLE); + if (m->video) + { + switch (module) + { + case EWL_MEDIA_MODULE_GSTREAMER: + ret = emotion_object_init(m->video, + "emotion_decoder_gstreamer.so"); + break; + + case EWL_MEDIA_MODULE_XINE: + default: + ret = emotion_object_init(m->video, + "emotion_decoder_xine.so"); + break; + } + } - DRETURN_INT(FALSE, DLEVEL_STABLE); + DRETURN_INT(ret, DLEVEL_STABLE); } /** * @param m: the media widget to retrieve module contents - * @return Returns a copy of the module in @a m on success, NULL on failure. + * @return Returns a the module associated with the media object * @brief Retrieve the module of a media widget */ -char *ewl_media_module_get(Ewl_Media * m) +Ewl_Media_Module_Type +ewl_media_module_get(Ewl_Media *m) { - char *txt = NULL; - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("m", m, NULL); - - if (m->module) - txt = strdup(m->module); + DCHECK_PARAM_PTR_RET("m", m, EWL_MEDIA_MODULE_XINE); + DCHECK_TYPE_RET("m", m, "media", EWL_MEDIA_MODULE_XINE); - DRETURN_PTR(txt, DLEVEL_STABLE); + DRETURN_INT(m->module, DLEVEL_STABLE); } /** @@ -119,11 +128,13 @@ * * Sets the media of the media widget @a m */ -void ewl_media_media_set(Ewl_Media * m, char *media) +void +ewl_media_media_set(Ewl_Media *m, const char *media) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("m", m); DCHECK_PARAM_PTR("media", media); + DCHECK_TYPE("m", m, "media"); IF_FREE(m->media); m->media = strdup(media); @@ -144,17 +155,14 @@ * @return Returns a copy of the media in @a m on success, NULL on failure. * @brief Retrieve the media of a media widget */ -char *ewl_media_media_get(Ewl_Media * m) +const char * +ewl_media_media_get(Ewl_Media *m) { - char *txt = NULL; - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("m", m, NULL); + DCHECK_TYPE_RET("m", m, "media", NULL); - if (m->media) - txt = strdup(m->media); - - DRETURN_PTR(txt, DLEVEL_STABLE); + DRETURN_PTR(m->media, DLEVEL_STABLE); } /** @@ -162,12 +170,14 @@ * @return Returns the length of the media contained in the widget. * @brief Retrieve the length of the media displayed by the media widget. */ -int ewl_media_length_get(Ewl_Media *m) +int +ewl_media_length_get(Ewl_Media *m) { int length = 0; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_TYPE_RET("m", m, "media", 0); if (m->video) length = emotion_object_play_length_get(m->video); @@ -182,14 +192,23 @@ * @param s: seconds variable * @brief Puts the length of the video into the @a h, @a m, @a s variables */ -void ewl_media_length_time_get(Ewl_Media *m, int *h, int *min, double *s) +void +ewl_media_length_time_get(Ewl_Media *m, int *h, int *min, double *s) { - double pos = ewl_media_length_get(m); + double pos; - /* stolen from envision by benr */ - *h = (int)pos / (60 * 60); - *min = ((int)pos / 60) - (*h * 60); - *s = pos - (*h * 60 * 60) - (*min * 60); + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); + + pos = ewl_media_length_get(m); + + /* stolen from envision by benr */ + if (h) *h = (int)pos / (60 * 60); + if (min) *min = ((int)pos / 60) - (*h * 60); + if (s) *s = pos - (*h * 60 * 60) - (*min * 60); + + DLEAVE_FUNCTION(DLEVEL_STABLE); } /** @@ -198,10 +217,12 @@ * @return Returns no value * @brief Sets the media widget into the given state */ -void ewl_media_play_set(Ewl_Media *m, int p) +void +ewl_media_play_set(Ewl_Media *m, int p) { DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR("m", m); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); if (m->video) emotion_object_play_set(m->video, p); @@ -214,15 +235,17 @@ * @return Returns if the media area is seekable * @brief Returns if the media area is seekable */ -int ewl_media_seekable_get(Ewl_Media *m) +int +ewl_media_seekable_get(Ewl_Media *m) { int seekable = 0; DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_TYPE_RET("m", m, "media", 0); if (m->video && !m->block_seek) - seekable = emotion_object_seekable_get(m->video); + seekable = emotion_object_seekable_get(m->video); DRETURN_INT(seekable, DLEVEL_STABLE); } @@ -232,15 +255,17 @@ * @return Returns the current media position * @brief Returns the position of the current media */ -double ewl_media_position_get(Ewl_Media *m) +double +ewl_media_position_get(Ewl_Media *m) { double p = 0.0; DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_TYPE_RET("m", m, "media", 0); if (m->video) - p = emotion_object_position_get(m->video); + p = emotion_object_position_get(m->video); DRETURN_FLOAT(p, DLEVEL_STABLE); } @@ -252,14 +277,21 @@ * @param s: seconds variable * @brief Puts the position of the video into the @a h, @a m, @a s variables */ -void ewl_media_position_time_get(Ewl_Media *m, int *h, int *min, double *s) +void +ewl_media_position_time_get(Ewl_Media *m, int *h, int *min, double *s) { - double pos = ewl_media_position_get(m); + double pos = ewl_media_position_get(m); + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); + + /* stolen from envision by benr */ + if (h) *h = (int)pos / (60 * 60); + if (min) *min = ((int)pos / 60) - (*h * 60); + if (s) *s = pos - (*h * 60 * 60) - (*min * 60); - /* stolen from envision by benr */ - *h = (int)pos / (60 * 60); - *min = ((int)pos / 60) - (*h * 60); - *s = pos - (*h * 60 * 60) - (*min * 60); + DLEAVE_FUNCTION(DLEVEL_STABLE); } /** @@ -268,10 +300,12 @@ * @return Returns no value * @brief Sets the media widget to the specified position */ -void ewl_media_position_set(Ewl_Media *m, double p) +void +ewl_media_position_set(Ewl_Media *m, double p) { DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR("m", m); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); if (m->video && ewl_media_seekable_get(m)) { m->block_seek = 1; @@ -287,15 +321,17 @@ * @return Returns if the media widget is muted * @brief Checks if the media widget is muted */ -int ewl_media_audio_mute_get(Ewl_Media *m) +int +ewl_media_audio_mute_get(Ewl_Media *m) { int mute = 0; DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_TYPE("m", m, "media"); if (m->video) - mute = emotion_object_audio_mute_get(m->video); + mute = emotion_object_audio_mute_get(m->video); DRETURN_INT(mute, DLEVEL_STABLE); } @@ -306,13 +342,15 @@ * @return Returns no value * @brief Mutes the media widget */ -void ewl_media_audio_mute_set(Ewl_Media *m, int mute) +void +ewl_media_audio_mute_set(Ewl_Media *m, int mute) { DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR("m", m); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); if (m->video) - emotion_object_audio_mute_set(m->video, mute); + emotion_object_audio_mute_set(m->video, mute); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -322,15 +360,17 @@ * @return Returns the media widget volume * @brief Gets the current volume from the media widget */ -double ewl_media_audio_volume_get(Ewl_Media *m) +double +ewl_media_audio_volume_get(Ewl_Media *m) { double v = 0.0; DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_PARAM_PTR_RET("m", m, 0); + DCHECK_TYPE_RET("m", m, "media", 0.0); if (m->video) - emotion_object_audio_volume_get(m->video); + emotion_object_audio_volume_get(m->video); DRETURN_FLOAT(v, DLEVEL_STABLE); } @@ -341,26 +381,29 @@ * @return Returns no value * @brief Sets the media widget to the given volume */ -void ewl_media_audio_volume_set(Ewl_Media *m, double v ) +void +ewl_media_audio_volume_set(Ewl_Media *m, double v) { DENTER_FUNCTION(DLEVEL_STABLE) - DCHECK_PARAM_PTR("m", m); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); if (m->video) - emotion_object_audio_volume_set(m->video, v); + emotion_object_audio_volume_set(m->video, v); DLEAVE_FUNCTION(DLEVEL_STABLE); } - -void ewl_media_realize_cb(Ewl_Widget * w, void *ev_data __UNUSED__, - void *user_data __UNUSED__) +void +ewl_media_realize_cb(Ewl_Widget *w, void *ev_data __UNUSED__, + void *user_data __UNUSED__) { - Ewl_Media *m; + Ewl_Media *m; Ewl_Embed *emb; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, "widget"); m = EWL_MEDIA(w); @@ -373,7 +416,7 @@ * Create the emotion */ m->video = emotion_object_add(emb->evas); - if (m->module && emotion_object_init(m->video, m->module) && m->media) { + if (ewl_media_module_set(m, m->module)) { emotion_object_file_set(m->video, m->media); ewl_media_size_update(m); } @@ -389,13 +432,15 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } -void ewl_media_unrealize_cb(Ewl_Widget * w, void *ev_data __UNUSED__, - void *user_data __UNUSED__) +void +ewl_media_unrealize_cb(Ewl_Widget *w, void *ev_data __UNUSED__, + void *user_data __UNUSED__) { - Ewl_Media *m; + Ewl_Media *m; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, "widget"); m = EWL_MEDIA(w); @@ -405,13 +450,15 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } -void ewl_media_configure_cb(Ewl_Widget * w, void *ev_data __UNUSED__, - void *user_data __UNUSED__) +void +ewl_media_configure_cb(Ewl_Widget *w, void *ev_data __UNUSED__, + void *user_data __UNUSED__) { - Ewl_Media *m; + Ewl_Media *m; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); + DCHECK_TYPE("w", w, "widget"); m = EWL_MEDIA(w); @@ -423,28 +470,43 @@ evas_object_resize(m->video, CURRENT_W(w), CURRENT_H(w)); evas_object_layer_set(m->video, ewl_widget_layer_sum_get(w)); evas_object_smart_callback_add(m->video, "frame_decode", - ewl_media_update_timer_cb, m); + ewl_media_update_timer_cb, m); } DLEAVE_FUNCTION(DLEVEL_STABLE); } -static void ewl_media_size_update(Ewl_Media *m) +static void +ewl_media_size_update(Ewl_Media *m) { int width, height; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("m", m); + DCHECK_TYPE("m", m, "media"); + emotion_object_size_get(m->video, &width, &height); if (width && height) ewl_object_preferred_inner_size_set(EWL_OBJECT(m), width, height); + + DLEAVE_FUNCTION(DLEVEL_STABLE); } static void ewl_media_update_timer_cb(void *data, - Evas_Object *obj __UNUSED__, - void *event_info __UNUSED__) + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) { - Ewl_Widget *m = (Ewl_Widget *)data; + Ewl_Widget *m; + + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("data", data); + + m = (Ewl_Widget *)data; EWL_MEDIA(m)->block_seek = 1; ewl_callback_call(m, EWL_CALLBACK_VALUE_CHANGED); EWL_MEDIA(m)->block_seek = 0; + + DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_media.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_media.h 3 Oct 2005 06:43:07 -0000 1.5 +++ ewl_media.h 24 Oct 2005 02:52:07 -0000 1.6 @@ -33,40 +33,45 @@ */ struct Ewl_Media { - Ewl_Widget widget; /**< Inherit from Ewl_Widget */ - Evas_Object *video; /**< Emotion does the actual work */ - char *module; /**< Path to the module file */ - char *media; /**< Path to the media file */ - int block_seek; /**< Temporarily prevent seeking */ + Ewl_Widget widget; /**< Inherit from Ewl_Widget */ + Evas_Object *video; /**< Emotion does the actual work */ + Ewl_Media_Module_Type module; /**< Path to the module file */ + char *media; /**< Path to the media file */ + int block_seek; /**< Temporarily prevent seeking */ }; -Ewl_Widget *ewl_media_new(char *module, char *media); -int ewl_media_init(Ewl_Media * m, char *module, char *media); +Ewl_Widget *ewl_media_new(void); +int ewl_media_init(Ewl_Media *m); -int ewl_media_module_set(Ewl_Media * m, char *module); -char *ewl_media_module_get(Ewl_Media * m); -void ewl_media_media_set(Ewl_Media * m, char *media); -char *ewl_media_media_get(Ewl_Media * m); -int ewl_media_length_get(Ewl_Media *m); -void ewl_media_length_time_get(Ewl_Media *m, int *h, int *min, double *s); - -void ewl_media_play_set(Ewl_Media *m, int p); -int ewl_media_seekable_get(Ewl_Media *m); -double ewl_media_position_get(Ewl_Media *m); -void ewl_media_position_time_get(Ewl_Media *m, int *h, int *min, double *s); -void ewl_media_position_set(Ewl_Media *m, double p); - -int ewl_media_audio_mute_get(Ewl_Media *m); -void ewl_media_audio_mute_set(Ewl_Media *m, int mute); -double ewl_media_audio_volume_get(Ewl_Media *m); -void ewl_media_audio_volume_set(Ewl_Media *m, double v); +int ewl_media_module_set(Ewl_Media *m, + Ewl_Media_Module_Type module); +Ewl_Media_Module_Type ewl_media_module_get(Ewl_Media *m); + +void ewl_media_media_set(Ewl_Media *m, const char *media); +const char *ewl_media_media_get(Ewl_Media *m); + +int ewl_media_length_get(Ewl_Media *m); +void ewl_media_length_time_get(Ewl_Media *m, int *h, + int *min, double *s); + +void ewl_media_play_set(Ewl_Media *m, int p); +int ewl_media_seekable_get(Ewl_Media *m); +double ewl_media_position_get(Ewl_Media *m); +void ewl_media_position_time_get(Ewl_Media *m, int *h, + int *min, double *s); +void ewl_media_position_set(Ewl_Media *m, double p); + +int ewl_media_audio_mute_get(Ewl_Media *m); +void ewl_media_audio_mute_set(Ewl_Media *m, int mute); +double ewl_media_audio_volume_get(Ewl_Media *m); +void ewl_media_audio_volume_set(Ewl_Media *m, double v); /* * Internally used callbacks, override at your own risk. */ -void ewl_media_realize_cb(Ewl_Widget * w, void *ev_data, void *user_data); -void ewl_media_unrealize_cb(Ewl_Widget * w, void *ev_data, void *user_data); -void ewl_media_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data); +void ewl_media_realize_cb(Ewl_Widget *w, void *ev_data, void *user_data); +void ewl_media_unrealize_cb(Ewl_Widget *w, void *ev_data, void *user_data); +void ewl_media_configure_cb(Ewl_Widget *w, void *ev_data, void *user_data); /** * @} ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs