Fix resource leak and other bugs 41/274441/6 accepted/tizen/unified/20220502.003744 submit/tizen/20220429.052416
authorHaesu Gwon <haesu.gwon@samsung.com>
Thu, 28 Apr 2022 09:40:28 +0000 (18:40 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Fri, 29 Apr 2022 02:28:54 +0000 (11:28 +0900)
media_editor         : Check null parameter
media_editor_clip    : Check invalid clip id
                       Fix resource leak
media_editor_private : Change bus priority

[Version] 0.0.5
[Issue Type] Bug fix

Change-Id: I69a6083f83127fb11407a8ad3518d9db65df18ba

12 files changed:
gtest/testbase.hpp
gtest/ut_clip.cpp
gtest/ut_composition.cpp
gtest/ut_effect.cpp
gtest/ut_layer.cpp
gtest/ut_project.cpp
include/media_editor.h
include/media_editor_private.h
packaging/capi-media-editor.spec
src/media_editor.c
src/media_editor_clip.c
src/media_editor_private.c

index f0cf8a34a196a228a29e1a2c6004fdb73ba35daf..9c1cea1097e699c33ed2c0f021c80f4d08516401 100644 (file)
@@ -57,6 +57,7 @@ public:
     const std::string& GetBgmPath() { return _bgmPath; }
     const std::string& GetMp4Path(int idx) { return _mp4Ppath[idx]; }
     const std::string& GetProjectPath(int idx) { return _projectPath[idx]; }
+    const std::string& GetOutputPath() { return _outputPath; }
 
 private:
     mediaeditor_h _editor;
@@ -74,4 +75,5 @@ private:
         _basePath + "test1.xges",
         _basePath + "test2.xges"
     };
+    std::string _outputPath = _basePath + "output.ogv";
 };
index aa043b591035a7e0411f23ff1b85ea612201418c..b6e333c68f79075077a2dace99d6d764645fb6b1 100644 (file)
@@ -24,25 +24,38 @@ public:
 
     static void RenderCompletedCb(void *user_data)
     {
-        LOGD("Enter");
+        LOGD("Render completed");
+
         if (mainloop)
             g_main_loop_quit(mainloop);
     }
 
     static void ErrorCb(mediaeditor_error_e error, mediaeditor_state_e state, void *user_data)
     {
-        LOGD("Enter. error[%d] state[%d]", error, state);
+        LOGD("error[%d], state[%d]", error, state);
+
         if (mainloop)
             g_main_loop_quit(mainloop);
     }
 
+    static void StateChangedCb(mediaeditor_state_e previous, mediaeditor_state_e current, void *user_data)
+    {
+        LOGD("previous state[%d], current state[%d]", previous, current);
+
+        if (current == MEDIAEDITOR_STATE_RENDERING && mainloop)
+            g_main_loop_quit(mainloop);
+    }
+
     static void WaitForAsync()
     {
         mainloop = g_main_loop_new(NULL, TRUE);
 
-        LOGD("Wait render completed cb");
+        LOGD("Call g_main_loop_run()");
+
         g_main_loop_run(mainloop);
 
+        LOGD("Quit g_main_loop_run()");
+
         g_main_loop_unref(mainloop);
         mainloop = NULL;
     }
@@ -59,10 +72,10 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_create)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_clip_delete)
@@ -76,13 +89,13 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_delete)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_remove_clip(GetHandle(), clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_clip_split)
@@ -97,16 +110,16 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_split)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_split_clip(GetHandle(), clip_id, (start + duration) / 2, &new_clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
-TEST_F(MediaeditorClipTest, ENABLED_clip_group_ungroup)
+TEST_F(MediaeditorClipTest, DISABLED_clip_group_ungroup)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     unsigned int layer_id = 0;
@@ -119,11 +132,11 @@ TEST_F(MediaeditorClipTest, ENABLED_clip_group_ungroup)
     unsigned int duration = 100;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     for (int i = 0; i < 5; i++) {
         ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, i * 100, &src_ids[i]);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
         LOGD("clip id : %d", src_ids[i]);
 
         start += duration;
@@ -133,11 +146,11 @@ TEST_F(MediaeditorClipTest, ENABLED_clip_group_ungroup)
         src_ids[i] += 1;
 
     ret = mediaeditor_group_clip(GetHandle(), src_ids, 4, &group_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     LOGD("grouped id : %d", group_id);
 
     ret = mediaeditor_ungroup_clip(GetHandle(), group_id, &dst_ids, &ungroup_size);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     for (int i = 0 ; i < (int)ungroup_size ; i++) {
         LOGD("src_ids[%d], ungrouped_ids[%d]", src_ids[i], dst_ids[i]);
@@ -156,14 +169,14 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_move)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     LOGD("clip id : %d", clip_id);
 
     ret = mediaeditor_move_clip_layer(GetHandle(), clip_id, 0);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_clip_set_duration)
@@ -179,14 +192,14 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_set_duration)
     unsigned int get_duration = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     LOGD("original duration : %d", duration);
 
     ret = mediaeditor_set_clip_duration(GetHandle(), clip_id, set_duration);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     LOGD("set_duration : %d", set_duration);
 
     ret = mediaeditor_get_clip_duration(GetHandle(), clip_id, &get_duration);
@@ -207,10 +220,10 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_set_get_resolution)
     unsigned int height = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_get_clip_resolution(GetHandle(), clip_id, &width, &height);
     LOGD("original resolution : %dx%d", width, height);
@@ -237,14 +250,14 @@ TEST_F(MediaeditorClipTest, DISABLED_audio_clip_set_get_resolution)
     unsigned int height = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetBgmPath().c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_get_clip_resolution(GetHandle(), clip_id, &width, &height);
     LOGD("Audio clip doesn't have resolution information. Should return error.");
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_INVALID_OPERATION);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_INVALID_OPERATION);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_volume)
@@ -259,21 +272,21 @@ TEST_F(MediaeditorClipTest, DISABLED_volume)
     double volume = 0.0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_get_clip_volume(GetHandle(), clip_id, &volume);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
-    ASSERT_TRUE(volume == 1.0);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(volume, 1.0);
 
     ret = mediaeditor_set_clip_volume(GetHandle(), clip_id, 2.0);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_get_clip_volume(GetHandle(), clip_id, &volume);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
-    ASSERT_TRUE(volume == 2.0);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(volume, 2.0);
     LOGD("get volume [%f]", volume);
 }
 
@@ -288,16 +301,16 @@ TEST_F(MediaeditorClipTest, DISABLED_transition)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(1).c_str(), layer_id, start + (duration / 2), duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_transition(GetHandle(), MEDIAEDITOR_TRANSITION_TYPE_CROSSFADE, layer_id, start + (duration / 2), duration / 2);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_transition_n)
@@ -311,25 +324,54 @@ TEST_F(MediaeditorClipTest, DISABLED_transition_n)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_set_error_cb(GetHandle(), ErrorCb, GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     /* Test for no overlapped area */
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(1).c_str(), layer_id, start + (duration * 2), duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_transition(GetHandle(), MEDIAEDITOR_TRANSITION_TYPE_CROSSFADE, layer_id, start + duration, duration / 2);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+
+    ret = mediaeditor_start_render(GetHandle(), GetOutputPath().c_str(), RenderCompletedCb, GetHandle());
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+
+    WaitForAsync();
+}
+
+TEST_F(MediaeditorClipTest, DISABLED_cancel_render)
+{
+    int ret = MEDIAEDITOR_ERROR_NONE;
+    unsigned int layer_id = 0;
+    unsigned int layer_priority = 0;
+    unsigned int clip_id = 0;
+    unsigned int start = 0;
+    unsigned int duration = 10000;
+    unsigned int in_point = 0;
 
-    ret = mediaeditor_start_render(GetHandle(), "/tmp/out_trans.ogv", RenderCompletedCb, GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+
+    ret = mediaeditor_set_state_changed_cb(GetHandle(), StateChangedCb, GetHandle());
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+
+    /* Test for no overlapped area */
+    ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+
+    ret = mediaeditor_start_render(GetHandle(), GetOutputPath().c_str(), RenderCompletedCb, GetHandle());
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     WaitForAsync();
+
+    ret = mediaeditor_cancel_render(GetHandle());
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 #ifdef TIZEN_MEDIAEDITOR_TEXTOVERLAY_SUPPORT
@@ -345,13 +387,13 @@ TEST_F(MediaeditorClipTest, DISABLED_text_overlay)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id1);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_text_overlay(GetHandle(), "Text Overlay", "sans-serif 13", start, duration, 0xFFFFFFFF, 0.5, 0.8, &clip_id2);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_title)
@@ -368,15 +410,15 @@ TEST_F(MediaeditorClipTest, DISABLED_title)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id1, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id2, &layer_priority2);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id2, start, duration, in_point, &clip_id1);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_title(GetHandle(), "Title", "sans-serif 20", start, duration, 0x80FFFF00, 0.5, 0.8, &clip_id2);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 #endif
index 75924ece8b527fde555f9c921fb7a8d1edc4860f..b6eceee41875cacd4cb6cce634f23461daa8d005 100644 (file)
@@ -42,7 +42,8 @@ public:
 
     static void RenderCompletedCb(void *user_data)
     {
-        LOGD("Enter");
+        LOGD("Render completed");
+
         if (mainloop)
             g_main_loop_quit(mainloop);
     }
@@ -51,9 +52,12 @@ public:
     {
         mainloop = g_main_loop_new(NULL, TRUE);
 
-        LOGD("Wait render completed cb");
+        LOGD("Call g_main_loop_run()");
+
         g_main_loop_run(mainloop);
 
+        LOGD("Quit g_main_loop_run()");
+
         g_main_loop_unref(mainloop);
         mainloop = NULL;
     }
@@ -95,23 +99,23 @@ TEST_F(MediaeditorCompositionTest, DISABLED_mp4_bgm_transition_text)
     // Create layer
     for (int i = 0 ; i < num_of_layer ; i++) {
         ret = mediaeditor_add_layer(GetHandle(), &layer_id[i], &layer_priority);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     }
 
     // Add clips
     for (int i = 0 ; i < num_of_clip ; i++) {
         ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(i).c_str(), layer_id[VIDEO_LAYER], start, duration[i], 0, &clip_id);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
         start += duration[i];
 
         if (editing_element[TRANSITION_ELEMENT] && is_transition[i])
         {
-            ASSERT_TRUE(start > transition_duration);
+            ASSERT_GT(start, transition_duration);
             start -= transition_duration;
 
             ret = mediaeditor_add_transition(GetHandle(), MEDIAEDITOR_TRANSITION_TYPE_CROSSFADE, layer_id[VIDEO_LAYER], start, transition_duration);
-            ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+            ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
         }
 
         total = start;
@@ -129,10 +133,10 @@ TEST_F(MediaeditorCompositionTest, DISABLED_mp4_bgm_transition_text)
             }
 
             ret = mediaeditor_add_clip(GetHandle(), GetBgmPath().c_str(), layer_id[BGM_LAYER], start, duration_bgm, G_TIME_SPAN_MILLISECOND * 0, &clip_id);
-            ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+            ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
             ret = mediaeditor_set_clip_volume(GetHandle(), clip_id, 0.3);
-            ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+            ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
             start += duration_bgm;
         }
@@ -142,23 +146,23 @@ TEST_F(MediaeditorCompositionTest, DISABLED_mp4_bgm_transition_text)
     // Add textoverlay
     if (editing_element[TEXTOVERLAY_ELEMENT]) {
         ret = mediaeditor_add_text_overlay(GetHandle(), "Editing test", "sans-serif 30", 0, total, 0xFFFFFF00, 0.5, 0.9, &clip_id);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
         ret = mediaeditor_set_text_overlay_outline(GetHandle(), clip_id, false);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
         ret = mediaeditor_set_text_overlay_shadow(GetHandle(), clip_id, true);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     }
 #endif
 
     // Add effect
     ret = mediaeditor_add_effect(GetHandle(), MEDIAEDITOR_EFFECT_VIDEO_TYPE_AGINGTV, layer_id[VIDEO_LAYER],
         G_TIME_SPAN_MILLISECOND * 0, duration[0], &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
-    ret = mediaeditor_start_render(GetHandle(), "/tmp/out_bgm_trans.ogv", RenderCompletedCb, GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ret = mediaeditor_start_render(GetHandle(), GetOutputPath().c_str(), RenderCompletedCb, GetHandle());
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     WaitForAsync();
 }
@@ -171,16 +175,16 @@ TEST_F(MediaeditorCompositionTest, DISABLED_mp4_concat_many)
     unsigned int clip_id = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     for (int i = 0 ; i < (int)(G_TIME_SPAN_MILLISECOND * 10) ; i += 100) {
         LOGD("offset : %d", i);
         ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, i, 100, G_TIME_SPAN_MILLISECOND * 20 - i, &clip_id);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     }
 
-    ret = mediaeditor_start_render(GetHandle(), "/tmp/out_concat_many.ogv", RenderCompletedCb, GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ret = mediaeditor_start_render(GetHandle(), GetOutputPath().c_str(), RenderCompletedCb, GetHandle());
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     WaitForAsync();
 }
index 28b6cc8e06b8e962d9699c610dc2dd8124030175..f58da52a4b444fdedb7fe8ffe543edc283f6ba23 100644 (file)
@@ -33,16 +33,16 @@ TEST_F(MediaeditorEffectTest, DISABLED_effect_add_remove)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &path_clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_effect(GetHandle(), MEDIAEDITOR_EFFECT_VIDEO_TYPE_AGINGTV, layer_id, start, duration, &effect_clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_remove_effect(GetHandle(), effect_clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorEffectTest, DISABLED_audio_fade_in_out)
@@ -56,14 +56,14 @@ TEST_F(MediaeditorEffectTest, DISABLED_audio_fade_in_out)
     unsigned int in_point = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_effect(GetHandle(), MEDIAEDITOR_EFFECT_AUDIO_TYPE_FADE_IN, 0, start, duration / 2, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_effect(GetHandle(), MEDIAEDITOR_EFFECT_AUDIO_TYPE_FADE_OUT, 0, start + (duration / 2), duration / 2, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
index 65c3609d0702090cdf3cbb8558432b68d5c917f9..de70b4c7f60f0307063a21674eca4af5d5c7fdd7 100644 (file)
@@ -35,7 +35,7 @@ TEST_F(MediaeditorLayerTest, DISABLED_layer_add)
 
     for (int i = 0 ; i < 2 ; i++) {
         ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority[i]);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
         ASSERT_EQ(layer_priority[i], i);
     }
 }
@@ -47,18 +47,18 @@ TEST_F(MediaeditorLayerTest, DISABLED_layer_remove)
     unsigned int layer_priority;
 
     ret = mediaeditor_set_layer_priority_changed_cb(GetHandle(), LayerPriorityChangedCb, NULL);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     for (int i = 0 ; i < 4 ; i++) {
         ret = mediaeditor_add_layer(GetHandle(), &layer_id[i], &layer_priority);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     }
 
     ret = mediaeditor_remove_layer(GetHandle(), layer_id[0]);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_remove_layer(GetHandle(), layer_id[1]);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorLayerTest, DISABLED_layer_remove_n)
@@ -66,10 +66,10 @@ TEST_F(MediaeditorLayerTest, DISABLED_layer_remove_n)
     int ret = MEDIAEDITOR_ERROR_NONE;
 
     ret = mediaeditor_remove_layer(GetHandle(), 0);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_INVALID_PARAMETER);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_INVALID_PARAMETER);
 
     ret = mediaeditor_remove_layer(GetHandle(), 10);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_INVALID_PARAMETER);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_INVALID_PARAMETER);
 }
 
 TEST_F(MediaeditorLayerTest, DISABLED_layer_move)
@@ -79,18 +79,18 @@ TEST_F(MediaeditorLayerTest, DISABLED_layer_move)
     unsigned int layer_priority = 0;
 
     ret = mediaeditor_set_layer_priority_changed_cb(GetHandle(), LayerPriorityChangedCb, NULL);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     for (int i = 0 ; i < 4 ; i++) {
         ret = mediaeditor_add_layer(GetHandle(), &layer_id[i], &layer_priority);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     }
 
     ret = mediaeditor_move_layer(GetHandle(), layer_id[0], 3);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_move_layer(GetHandle(), layer_id[0], 2);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorLayerTest, DISABLED_layer_move_to_bottom)
@@ -101,14 +101,14 @@ TEST_F(MediaeditorLayerTest, DISABLED_layer_move_to_bottom)
 
     for (int i = 0 ; i < 3 ; i++) {
         ret = mediaeditor_add_layer(GetHandle(), &layer_id[i], &layer_priority);
-        ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+        ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
     }
 
     ret = mediaeditor_get_layer_lowest_priority(GetHandle(), &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_move_layer(GetHandle(), layer_id[0], layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorLayerTest, DISABLED_layer_activate_deactivate)
@@ -118,20 +118,20 @@ TEST_F(MediaeditorLayerTest, DISABLED_layer_activate_deactivate)
     unsigned int layer_priority = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_activate_layer(GetHandle(), layer_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_deactivate_layer(GetHandle(), layer_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_remove_layer(GetHandle(), layer_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_activate_layer(GetHandle(), layer_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_INVALID_PARAMETER);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_INVALID_PARAMETER);
 
     ret = mediaeditor_deactivate_layer(GetHandle(), layer_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_INVALID_PARAMETER);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_INVALID_PARAMETER);
 }
index 69d8e7993e2d17e6dd9e6e5753dd018739f27ff1..5a95026918b46b578e0cd5dce359efa01d4f68f8 100644 (file)
@@ -24,7 +24,8 @@ public:
 
     static void TimelineLoadedCb(void *user_data)
     {
-        LOGD("Enter");
+        LOGD("Render completed");
+
         if (mainloop)
             g_main_loop_quit(mainloop);
     }
@@ -33,9 +34,12 @@ public:
     {
         mainloop = g_main_loop_new(NULL, TRUE);
 
-        LOGD("Wait timeline loaded cb");
+        LOGD("Call g_main_loop_run()");
+
         g_main_loop_run(mainloop);
 
+        LOGD("Quit g_main_loop_run()");
+
         g_main_loop_unref(mainloop);
         mainloop = NULL;
     }
@@ -52,19 +56,19 @@ TEST_F(MediaeditorProjectTest, DISABLED_project_create_save)
     unsigned int in_point = 0;
 
     ret = mediaeditor_create_project(GetHandle(), GetProjectPath(0).c_str());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_add_effect(GetHandle(), MEDIAEDITOR_EFFECT_VIDEO_TYPE_AGINGTV, layer_id, start, duration, &clip_id);
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_save_project(GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
 
 TEST_F(MediaeditorProjectTest, DISABLED_project_load_save)
@@ -72,10 +76,10 @@ TEST_F(MediaeditorProjectTest, DISABLED_project_load_save)
     int ret = MEDIAEDITOR_ERROR_NONE;
 
     ret = mediaeditor_load_project(GetHandle(), GetProjectPath(1).c_str(), TimelineLoadedCb, GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     WaitForAsync();
 
     ret = mediaeditor_save_project(GetHandle());
-    ASSERT_TRUE(ret == MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 }
index 721579ab700551e163f49b47076014acb2b49bf1..fc76bc5e7d4916c8b16683aa434883638b1ee143 100644 (file)
@@ -879,6 +879,7 @@ int mediaeditor_move_clip_layer(mediaeditor_h editor, unsigned int clip_id, unsi
 /**
  * @brief Gets the start position of clip.
  * @since_tizen 7.0
+ * @remarks @a start will return value set by mediaeditor_add_clip() or mediaeditor_set_clip_start().
  * @param[in] editor  The media editor handle
  * @param[in] clip_id The clip ID
  * @param[out] start  The current start position of clip (in milliseconds)
@@ -918,6 +919,7 @@ int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int clip_id, unsig
 /**
  * @brief Gets the duration of clip.
  * @since_tizen 7.0
+ * @remarks @a duration will return value set by mediaeditor_add_clip() or mediaeditor_set_clip_duration().
  * @param[in] editor    The media editor handle
  * @param[in] clip_id   The clip ID
  * @param[out] duration The current time duration of clip (in milliseconds)
@@ -957,6 +959,7 @@ int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int clip_id, un
 /**
  * @brief Gets the offset of clip.
  * @since_tizen 7.0
+ * @remarks @a in_point will return value set by mediaeditor_add_clip() or mediaeditor_set_clip_in_point().
  * @param[in] editor    The media editor handle
  * @param[in] clip_id   The clip ID that will be changed
  * @param[out] in_point The offset of clip to use internally when outputting content (in milliseconds)
@@ -997,7 +1000,8 @@ int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int clip_id, un
 /**
  * @brief Gets the resolution of clip.
  * @since_tizen 7.0
- * @remarks If the clip doesn't have video, #MEDIAEDITOR_ERROR_INVALID_OPERATION will be returned.
+ * @remarks If the clip doesn't have video, #MEDIAEDITOR_ERROR_INVALID_OPERATION will be returned.\n
+ *          @a width and @a height will return 0 before set clip resolution by mediaeditor_set_clip_resolution().
  * @param[in] editor  The media editor handle
  * @param[in] clip_id The clip ID
  * @param[out] width  The width
index 51dfa89449859f473295945f070d1cd97edfc49d..a6e9c85857d5f1a66bb5ab2ffb31a133287b9498 100644 (file)
@@ -129,6 +129,13 @@ do { \
 #define SAFE_FREE(x)  { if (x) { free(x); x = NULL; } }
 #define SAFE_G_FREE(x) { if (x) { g_free(x); x = NULL; } }
 
+#define SAFE_G_LIST_FREE(src) \
+do { \
+    if (!src) break; \
+    g_list_free(src); \
+    src = NULL; \
+} while (0)
+
 #define GENERATE_DOT(x_mediaeditor, x_fmt, x_arg...) \
 do { \
     gchar *dot_name; \
index fd73bdcf02ba56e3b11f5cc3c172782c9b456034..0be25993157a6809e8b5f76ecdde4ca56f81bbbb 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-editor
 Summary:    A Tizen Media Editor API
-Version:    0.0.4
+Version:    0.0.5
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a42b7245b32f77c8ac0e200cd25acf8ea69ef38f..75f19bea2188e91d611fd6e8b7799e2d97860931 100644 (file)
@@ -156,6 +156,7 @@ int mediaeditor_get_state(mediaeditor_h editor, mediaeditor_state_e *state)
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    RET_VAL_IF(state == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "state is NULL");
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
index 46611aeccf1d6ebdc3597ed5b33a1cb2c1ccd645..ee819cfcf762ddecc481546bf2d680d4a373c601 100644 (file)
@@ -104,8 +104,14 @@ static GList *__mediaeditor_peek_clips(GList *lists, unsigned int *ids, unsigned
     GESClip *clip = NULL;
 
     for (unsigned int i = 0 ; i < size ; i++) {
-        if ((clip = __mediaeditor_find_clip(lists, ids[i])))
+        if ((clip = __mediaeditor_find_clip(lists, ids[i])) != NULL) {
             list_new = g_list_append(list_new, clip);
+        } else {
+            LOG_ERROR("failed to find clip id[%d]", ids[i]);
+            SAFE_G_LIST_FREE(list_new);
+            return NULL;
+        }
+
     }
 
     return list_new;
@@ -342,7 +348,7 @@ int _mediaeditor_group_clip(mediaeditor_s *editor, unsigned int *clip_ids, unsig
 
     RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
     for (unsigned int i = 0 ; i < size ; i++)
-        RET_VAL_IF(clip_ids[i] >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
+        RET_VAL_IF(clip_ids[i] <= 0 || clip_ids[i] >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
 
     list = __mediaeditor_peek_clips(editor->clips, clip_ids, size);
     RET_VAL_IF(list == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to get clip from list");
index 8b286a1fbf1be54f08c0f29afd58a6bcc17afd4b..e99f9ad53627a1314a660efebc988c4a3e8baca2 100644 (file)
@@ -514,7 +514,7 @@ static int __mediaeditor_set_bus_cb(mediaeditor_s *editor)
     editor->gst.bus = gst_pipeline_get_bus(GST_PIPELINE(editor->gst.pipeline));
     RET_VAL_IF(editor->gst.bus == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to get bus from pipeline");
 
-    gst_bus_add_watch_full(editor->gst.bus, G_PRIORITY_DEFAULT, (GstBusFunc) __bus_cb, editor, NULL);
+    gst_bus_add_watch_full(editor->gst.bus, G_PRIORITY_HIGH, (GstBusFunc)__bus_cb, editor, NULL);
 
     return MEDIAEDITOR_ERROR_NONE;
 }