} \
} while (0)
-#define SET_EVAS_OBJECT_EVENT_CALLBACK(evas_image_object, usr_data) \
- do { \
- if (evas_image_object) { \
- LOGD("object callback add"); \
- evas_object_event_callback_add(evas_image_object, EVAS_CALLBACK_RESIZE, _evas_resize_cb, usr_data); \
- } \
- } while (0)
-
-#define UNSET_EVAS_OBJECT_EVENT_CALLBACK(evas_image_object) \
- do { \
- if (evas_image_object) { \
- LOGD("object callback del"); \
- evas_object_event_callback_del(evas_image_object, EVAS_CALLBACK_RESIZE, _evas_resize_cb); \
- } \
- } while (0)
-
enum {
DISP_GEO_METHOD_LETTER_BOX = 0,
DISP_GEO_METHOD_ORIGIN_SIZE,
static void _mm_evas_renderer_set_callback(mm_evas_info *evas_info);
static void _mm_evas_renderer_unset_callback(mm_evas_info *evas_info);
static void _mm_evas_renderer_set_evas_object_size(mm_evas_info *evas_info);
+static gboolean _check_rendering_packet(mm_evas_info *evas_info);
/* must be called after the null surface has been set. */
static int _mm_evas_renderer_update_rendering_info(mm_evas_info *evas_info)
static void _evas_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
- MMER_FENTER();
-
/* now evas object size is changed */
-
mm_evas_info *evas_info = data;
+ MMER_FENTER();
+
MMEVAS_RETURN_IF_FAIL(evas_info);
MMEVAS_RETURN_IF_FAIL(evas_info->eo);
+ g_mutex_lock(&evas_info->idx_lock);
+
+ if (!_check_rendering_packet(evas_info)) {
+ g_mutex_unlock(&evas_info->idx_lock);
+ return;
+ }
+
+ g_mutex_unlock(&evas_info->idx_lock);
+
if (_mm_evas_renderer_update_rendering_info(evas_info) == MM_ERROR_NONE) {
Evas_Native_Surface *surf;
surf = evas_object_image_native_surface_get(evas_info->eo);
static gboolean _check_rendering_packet(mm_evas_info *evas_info)
{
- MMER_FENTER();
gint cur_idx = 0;
tbm_format tbm_fmt = 0;
gchar *s_fmt = NULL;
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, FALSE);
cur_idx = evas_info->cur_idx;
/* must be called after the null surface has been set. */
static void _mm_evas_renderer_surface_set(mm_evas_info *evas_info)
{
- MMER_FENTER();
-
gint cur_idx = 0;
gint prev_idx = 0;
+ MMER_FENTER();
+
MMEVAS_RETURN_IF_FAIL(evas_info);
MMEVAS_RETURN_IF_FAIL(evas_info->eo);
if (_flush_all_packets(evas_info) != MM_ERROR_NONE)
LOGE("flushing packets is failed");
break;
- case UPDATE_DESTROY:
- g_mutex_unlock(&evas_info->mp_lock);
- if (_mm_evas_renderer_reset(evas_info, TRUE) != MM_ERROR_NONE)
- LOGE("_mm_evas_renderer_reset is failed");
- break;
default:
LOGW("invalid info type : %d", info);
break;
static void _evas_pipe_cb(void *data, void *buffer, update_info info)
{
- MMER_FENTER();
mm_evas_info *evas_info = data;
+ MMER_FENTER();
+
MMEVAS_RETURN_IF_FAIL(evas_info);
MMEVAS_RETURN_IF_FAIL(evas_info->eo);
LOGD("ecore_pipe is called");
+
+ if (!evas_info->is_set_resize_cb)
+ _mm_evas_renderer_set_callback(evas_info);
+
g_mutex_lock(&evas_info->mp_lock);
_mm_evas_renderer_select_task(evas_info, info);
- if (info != UPDATE_DESTROY)
- g_mutex_unlock(&evas_info->mp_lock);
+ g_mutex_unlock(&evas_info->mp_lock);
MMER_FLEAVE();
return;
static void _free_previous_packets(mm_evas_info *evas_info)
{
- MMER_FENTER();
-
gint index = evas_info->cur_idx;
gint prev_idx = evas_info->pkt_info[index].prev_idx;
+ MMER_FENTER();
+
while (prev_idx != -1) {
LOGD("destroy previous packet [%p] idx %d", evas_info->pkt_info[prev_idx].packet, prev_idx);
if (evas_info->packet_rendered_cb) {
static int _get_video_size(media_packet_h packet, mm_evas_info *evas_info)
{
+ media_format_h fmt;
+
MMER_FENTER();
- media_format_h fmt;
if (media_packet_get_format(packet, &fmt) == MEDIA_PACKET_ERROR_NONE) {
int w, h;
if (media_format_get_video_info(fmt, NULL, &w, &h, NULL, NULL) == MEDIA_PACKET_ERROR_NONE) {
static int _find_empty_index(mm_evas_info *evas_info)
{
- MMER_FENTER();
-
int i;
+ MMER_FENTER();
+
for (i = 0; i < MAX_PACKET_NUM; i++) {
if (!evas_info->pkt_info[i].packet) {
LOGD("selected idx %d", i);
/* must be called after the null surface has been set. */
static int _destroy_all_packets(mm_evas_info *evas_info)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
int ret_mp = MEDIA_PACKET_ERROR_NONE;
int i = 0;
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
g_mutex_lock(&evas_info->idx_lock);
static int _set_flush_buffer(mm_evas_info *evas_info)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
Evas_Native_Surface surf = { 0 };
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
/* set flush buffer surface*/
/* EVAS API must be called by main thread */
static int _flush_all_packets(mm_evas_info *evas_info)
{
+ int ret = MM_ERROR_NONE;
+
MMER_FENTER();
- int ret = MM_ERROR_NONE;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
+ MMEVAS_RETURN_VAL_IF_FAIL(evas_info->eo, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
/* update the screen only if visible is true */
/* if flush buffer is null, we cant keep screen */
ret = _set_flush_buffer(evas_info);
if (ret != MM_ERROR_NONE) return ret;
} else {
- /* unset evas native surface for displaying black screen */
+ /* unset evas native surface for removing rendered video frame */
evas_object_image_native_surface_set(evas_info->eo, NULL);
evas_object_image_pixels_dirty_set(evas_info->eo, EINA_TRUE);
+ _mm_evas_renderer_unset_callback(evas_info);
}
LOGD("sent packet %d", evas_info->sent_buffer_cnt);
static void _mm_evas_renderer_set_callback(mm_evas_info *evas_info)
{
MMER_FENTER();
- if (evas_info->eo)
- SET_EVAS_OBJECT_EVENT_CALLBACK(evas_info->eo, evas_info);
+
+ if (evas_info->eo) {
+ LOGD("resize callback add");
+ evas_object_event_callback_add(evas_info->eo, EVAS_CALLBACK_RESIZE, _evas_resize_cb, evas_info);
+ evas_info->is_set_resize_cb = TRUE;
+ }
MMER_FLEAVE();
}
static void _mm_evas_renderer_unset_callback(mm_evas_info *evas_info)
{
MMER_FENTER();
- if (evas_info->eo)
- UNSET_EVAS_OBJECT_EVENT_CALLBACK(evas_info->eo);
+
+ if (evas_info->eo) {
+ LOGD("resize callback del");
+ evas_object_event_callback_del(evas_info->eo, EVAS_CALLBACK_RESIZE, _evas_resize_cb);
+ evas_info->is_set_resize_cb = FALSE;
+ }
MMER_FLEAVE();
}
static void _mm_evas_renderer_set_evas_object_size(mm_evas_info *evas_info)
{
MMER_FENTER();
+
MMEVAS_RETURN_IF_FAIL(evas_info);
MMEVAS_RETURN_IF_FAIL(evas_info->eo);
evas_object_size_hint_align_set(evas_info->eo, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(evas_info->eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ MMER_FLEAVE();
+
return;
}
static int _mm_evas_pipe_write(mm_evas_info *evas_info, update_info info)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
MMEVAS_RETURN_VAL_IF_FAIL(evas_info->epipe, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
g_mutex_unlock(&evas_info->write_lock);
MMER_FLEAVE();
+
return ret;
}
static int _mm_evas_renderer_create(mm_evas_info **evas_info)
{
+ mm_evas_info *ptr = NULL;
+
MMER_FENTER();
- mm_evas_info *ptr = NULL;
ptr = g_malloc0(sizeof(mm_evas_info));
if (!ptr) {
static int _mm_evas_renderer_destroy(mm_evas_info **evas_info)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
- pid_t pid = getpid();
- pid_t tid = syscall(SYS_gettid);
mm_evas_info *ptr = (mm_evas_info *)*evas_info;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(ptr, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
LOGD("finalize evas_info %p", ptr);
- /* this API can be call by sub thread */
- LOGD("pid [%d], tid [%d]", pid, tid);
- if (pid == tid) { /* API call by main thread */
- ret = _mm_evas_renderer_reset(ptr, FALSE);
- if (ret != MM_ERROR_NONE)
- LOGE("_mm_evas_renderer_reset is failed");
- } else {
- g_mutex_lock(&ptr->evas_lock);
- ret = _mm_evas_pipe_write(ptr, UPDATE_DESTROY);
- if (ret == MM_ERROR_NONE) {
- LOGD("Wait for g_cond_signal...");
- g_cond_wait(&ptr->evas_cond[COND_DESTROY], &ptr->evas_lock);
- LOGD("get g_cond_signal");
- }
- g_mutex_unlock(&ptr->evas_lock);
- }
+ ret = _mm_evas_renderer_reset(ptr, FALSE);
+ if (ret != MM_ERROR_NONE)
+ LOGE("_mm_evas_renderer_reset is failed");
g_mutex_clear(&ptr->mp_lock);
g_mutex_clear(&ptr->idx_lock);
static int _mm_evas_renderer_set_info(mm_evas_info *evas_info, Evas_Object *eo)
{
+ int i;
+
MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
MMEVAS_RETURN_VAL_IF_FAIL(eo, MM_ERROR_EVASRENDER_INVALID_ARGUMENT);
g_mutex_lock(&evas_info->idx_lock);
LOGD("set evas_info");
- int i;
+
for (i = 0; i < MAX_PACKET_NUM; i++) {
evas_info->pkt_info[i].packet = NULL;
evas_info->pkt_info[i].tbm_surf = NULL;
evas_info->cur_idx = -1;
evas_info->dst_roi.x = evas_info->dst_roi.y = evas_info->dst_roi.w = evas_info->dst_roi.h = 0;
evas_info->is_set_roi_area = FALSE;
+ evas_info->is_set_resize_cb = FALSE;
evas_info->display_geometry_method = evas_info->pre_display_geometry_method = DISP_GEO_METHOD_LETTER_BOX;
evas_info->eo = eo;
evas_info->epipe = ecore_pipe_add((Ecore_Pipe_Cb) _evas_pipe_cb, evas_info);
return MM_ERROR_EVASRENDER_INTERNAL;
}
LOGD("created pipe %p", evas_info->epipe);
- _mm_evas_renderer_set_callback(evas_info);
evas_object_geometry_get(evas_info->eo, &evas_info->eo_size.x, &evas_info->eo_size.y, &evas_info->eo_size.w, &evas_info->eo_size.h);
LOGI("evas object %p (%d, %d, %d, %d)", evas_info->eo, evas_info->eo_size.x, evas_info->eo_size.y, evas_info->eo_size.w, evas_info->eo_size.h);
static int _mm_evas_renderer_reset(mm_evas_info *evas_info, gboolean is_sub_thread)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
MMEVAS_RETURN_VAL_IF_FAIL(evas_info->eo, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
g_mutex_lock(&evas_info->mp_lock);
- evas_object_image_native_surface_set(evas_info->eo, NULL);
- evas_object_image_pixels_dirty_set(evas_info->eo, EINA_TRUE);
-
evas_info->eo_size.x = evas_info->eo_size.y = evas_info->eo_size.w = evas_info->eo_size.h = 0;
evas_info->dst_roi.x = evas_info->dst_roi.y = evas_info->dst_roi.w = evas_info->dst_roi.h = 0;
evas_info->w = evas_info->h = 0;
- evas_info->flush_all_packets = FALSE;
if (evas_info->flush_buffer)
_mm_evas_renderer_release_flush_buffer(evas_info);
- if (!evas_info->flush_all_packets) {
- ret = _destroy_all_packets(evas_info);
- if (ret != MM_ERROR_NONE) {
- g_mutex_unlock(&evas_info->mp_lock);
- return MM_ERROR_EVASRENDER_INTERNAL;
- }
- }
-
- if (evas_info->eo) {
- _mm_evas_renderer_unset_callback(evas_info);
+ if (evas_info->eo)
evas_info->eo = NULL;
- }
if (evas_info->epipe) {
LOGD("pipe %p will be deleted", evas_info->epipe);
static void _mm_evas_renderer_update_geometry(mm_evas_info *evas_info)
{
- MMER_FENTER();
-
gint video_width = 0;
gint video_height = 0;
rect_info result = { 0 };
gint disp_mode = -1;
+ MMER_FENTER();
+
MMEVAS_RETURN_IF_FAIL(evas_info);
MMEVAS_RETURN_IF_FAIL(evas_info->eo); //need to check evas object
static int _mm_evas_renderer_retrieve_all_packets(mm_evas_info *evas_info, bool keep_screen)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
pid_t pid = getpid();
pid_t tid = syscall(SYS_gettid);
gint64 end_time = g_get_monotonic_time() + SIGNAL_TIMEOUT * G_TIME_SPAN_SECOND;
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
/* this API can be call by sub thread */
static int _mm_evas_renderer_make_flush_buffer(mm_evas_info *evas_info)
{
MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
if (evas_info->cur_idx == -1) {
static void _mm_evas_renderer_release_flush_buffer(mm_evas_info *evas_info)
{
MMER_FENTER();
+
MMEVAS_RETURN_IF_FAIL(evas_info);
LOGW("release FLUSH BUFFER start");
int mm_evas_renderer_create(MMHandleType *handle, Evas_Object *eo)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = NULL;
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(handle, MM_ERROR_EVASRENDER_INVALID_ARGUMENT);
MMEVAS_RETURN_VAL_IF_FAIL(eo, MM_ERROR_EVASRENDER_INVALID_ARGUMENT);
int mm_evas_renderer_destroy(MMHandleType *handle)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info *)*handle;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
ret = _mm_evas_renderer_destroy(&evas_info);
int mm_evas_renderer_set_visible(MMHandleType handle, bool visible)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
evas_info->visible = visible;
int mm_evas_renderer_get_visible(MMHandleType handle, bool *visible)
{
+ mm_evas_info *evas_info = (mm_evas_info *)handle;
+
MMER_FENTER();
- mm_evas_info *evas_info = (mm_evas_info *)handle;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
*visible = evas_info->visible;
int mm_evas_renderer_set_rotation(MMHandleType handle, int rotate)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info *)handle;
guint value;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
switch (rotate) {
int mm_evas_renderer_get_rotation(MMHandleType handle, int *rotate)
{
+ mm_evas_info *evas_info = (mm_evas_info *)handle;
+
MMER_FENTER();
- mm_evas_info *evas_info = (mm_evas_info *)handle;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
switch (evas_info->rotate_angle) {
int mm_evas_renderer_set_geometry(MMHandleType handle, int mode)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
if (evas_info->display_geometry_method != mode) {
int mm_evas_renderer_get_geometry(MMHandleType handle, int *mode)
{
+ mm_evas_info *evas_info = (mm_evas_info *)handle;
+
MMER_FENTER();
- mm_evas_info *evas_info = (mm_evas_info *)handle;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
*mode = evas_info->display_geometry_method;
int mm_evas_renderer_set_roi_area(MMHandleType handle, int x, int y, int w, int h)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info *)handle;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
if (w <= 0 || h <= 0) {
int mm_evas_renderer_get_roi_area(MMHandleType handle, int *x, int *y, int *w, int *h)
{
+ mm_evas_info *evas_info = (mm_evas_info *)handle;
+
MMER_FENTER();
- mm_evas_info *evas_info = (mm_evas_info *)handle;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
*x = evas_info->dst_roi.x;
int mm_evas_renderer_set_flip(MMHandleType handle, int flip)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info *)handle;
guint value;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
switch (flip) {
int mm_evas_renderer_get_flip(MMHandleType handle, int *flip)
{
+ mm_evas_info *evas_info = (mm_evas_info *)handle;
+
MMER_FENTER();
- mm_evas_info *evas_info = (mm_evas_info *)handle;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
switch (evas_info->flip) {
int mm_evas_renderer_retrieve_all_packets(MMHandleType handle, bool keep_screen)
{
- MMER_FENTER();
-
int ret = MM_ERROR_NONE;
mm_evas_info *evas_info = (mm_evas_info*) handle;
+
+ MMER_FENTER();
+
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
ret = _mm_evas_renderer_retrieve_all_packets(evas_info, keep_screen);
int mm_evas_renderer_set_packet_rendered_callback(MMHandleType handle, mm_evas_renderer_media_packet_rendered_cb callback, void *user_data)
{
+ mm_evas_info *evas_info = (mm_evas_info*) handle;
+
MMER_FENTER();
- mm_evas_info *evas_info = (mm_evas_info*) handle;
MMEVAS_RETURN_VAL_IF_FAIL(evas_info, MM_ERROR_EVASRENDER_NOT_INITIALIZED);
evas_info->packet_rendered_cb = callback;