From b9f9cf99ea1c31ff14c9f99ef97af686ef05ec74 Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Wed, 8 Feb 2023 17:41:43 +0900 Subject: [PATCH] media_editor_clip : Add missing feature - if start is less than 0, clip will be added to the end of layer. [Version] 0.0.17 [Issue Type] Bug fix Change-Id: Ic86736c1d2627677199b43ec276644c6e21bf983 --- include/media_editor_private.h | 1 + packaging/capi-media-editor.spec | 2 +- src/media_editor_clip.c | 11 ++++++++++- src/media_editor_layer.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/media_editor_private.h b/include/media_editor_private.h index cb6f66e..4eae115 100644 --- a/include/media_editor_private.h +++ b/include/media_editor_private.h @@ -342,6 +342,7 @@ int _destroy_resource_manager(mediaeditor_s *editor); #endif /* media_editor_layer */ +int _mediaeditor_get_layer_end_time(mediaeditor_s *editor, unsigned int layer_id, int *end_time); int _mediaeditor_get_layer(mediaeditor_s *editor, unsigned int layer_id, GESLayer **layer); int _mediaeditor_add_layer(mediaeditor_s *editor, unsigned int *layer_id, unsigned int *layer_priority); int _mediaeditor_remove_layer(mediaeditor_s *editor, unsigned int layer_id); diff --git a/packaging/capi-media-editor.spec b/packaging/capi-media-editor.spec index b796585..f9acfd1 100644 --- a/packaging/capi-media-editor.spec +++ b/packaging/capi-media-editor.spec @@ -1,6 +1,6 @@ Name: capi-media-editor Summary: A Tizen Media Editor API -Version: 0.0.16 +Version: 0.0.17 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_editor_clip.c b/src/media_editor_clip.c index 65e7d11..810aa4c 100644 --- a/src/media_editor_clip.c +++ b/src/media_editor_clip.c @@ -238,11 +238,20 @@ int _mediaeditor_add_clip(mediaeditor_s *editor, const char *path, unsigned int uri = gst_filename_to_uri(path, NULL); RET_VAL_IF(uri == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "failed to get uri"); - LOGI("uri : [%s]", uri); + LOG_INFO("uri : [%s]", uri); clip = GES_CLIP(ges_uri_clip_new(uri)); RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create clip"); + if (start < 0) { + int end_time = 0; + ret = _mediaeditor_get_layer_end_time(editor, layer_id, &end_time); + RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to get layer end time"); + + LOG_INFO("start point[%d] is changed to [%d]ms of layer_id[%d]", start, end_time, layer_id); + start = end_time; + } + start_nsec = MILLI_TO_NANO(start); duration_nsec = MILLI_TO_NANO(duration); in_point_nsec = MILLI_TO_NANO(in_point); diff --git a/src/media_editor_layer.c b/src/media_editor_layer.c index c61eb3b..7c26f0d 100644 --- a/src/media_editor_layer.c +++ b/src/media_editor_layer.c @@ -220,6 +220,42 @@ static int __mediaeditor_create_layer_common(mediaeditor_s *editor, GESLayer *la return MEDIAEDITOR_ERROR_NONE; } +int _mediaeditor_get_layer_end_time(mediaeditor_s *editor, unsigned int layer_id, int *end_time) +{ + GList *l = NULL; + GList *clip_list = NULL; + GESClip *clip = NULL; + GESLayer *layer = NULL; + unsigned int start_tmp = 0; + unsigned int duration_tmp = 0; + unsigned int end_time_tmp = 0; + + NULL_PARAM_CHECK(editor); + NULL_PARAM_CHECK(end_time); + + layer = __mediaeditor_find_layer(editor->layers, layer_id); + RET_VAL_IF(layer == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid layer id"); + + clip_list = ges_layer_get_clips(layer); + RET_VAL_IF(clip_list == NULL, MEDIAEDITOR_ERROR_NONE, "no clips on layer_id[%d]", layer_id); + + for (l = g_list_first(clip_list); l; l = g_list_next(l)) { + clip = (GESClip *)l->data; + + start_tmp = NANO_TO_MILLI(ges_timeline_element_get_start(GES_TIMELINE_ELEMENT(clip))); + duration_tmp = NANO_TO_MILLI(ges_timeline_element_get_duration(GES_TIMELINE_ELEMENT(clip))); + + if (end_time_tmp < start_tmp + duration_tmp) + end_time_tmp = start_tmp + duration_tmp; + } + + *end_time = end_time_tmp; + + LOG_DEBUG("layer_id[%d], end_time[%d]", layer_id, *end_time); + + return MEDIAEDITOR_ERROR_NONE; +} + int _mediaeditor_get_layer(mediaeditor_s *editor, unsigned int layer_id, GESLayer **layer) { NULL_PARAM_CHECK(editor); -- 2.7.4