media_editor_clip : Add missing feature 66/287966/4
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 8 Feb 2023 08:41:43 +0000 (17:41 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Thu, 9 Feb 2023 03:44:41 +0000 (03:44 +0000)
- 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
packaging/capi-media-editor.spec
src/media_editor_clip.c
src/media_editor_layer.c

index cb6f66e..4eae115 100644 (file)
@@ -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);
index b796585..f9acfd1 100644 (file)
@@ -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
index 65e7d11..810aa4c 100644 (file)
@@ -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);
index c61eb3b..7c26f0d 100644 (file)
@@ -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);