From: Haesu Gwon Date: Thu, 28 Apr 2022 09:40:28 +0000 (+0900) Subject: Fix resource leak and other bugs X-Git-Tag: submit/tizen/20220429.052416^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f85334a73296e007fcc031cd8467cb0378d477e;p=platform%2Fcore%2Fapi%2Fmediaeditor.git Fix resource leak and other bugs 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 --- diff --git a/gtest/testbase.hpp b/gtest/testbase.hpp index f0cf8a3..9c1cea1 100644 --- a/gtest/testbase.hpp +++ b/gtest/testbase.hpp @@ -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"; }; diff --git a/gtest/ut_clip.cpp b/gtest/ut_clip.cpp index aa043b5..b6e333c 100644 --- a/gtest/ut_clip.cpp +++ b/gtest/ut_clip.cpp @@ -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 diff --git a/gtest/ut_composition.cpp b/gtest/ut_composition.cpp index 75924ec..b6eceee 100644 --- a/gtest/ut_composition.cpp +++ b/gtest/ut_composition.cpp @@ -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(); } diff --git a/gtest/ut_effect.cpp b/gtest/ut_effect.cpp index 28b6cc8..f58da52 100644 --- a/gtest/ut_effect.cpp +++ b/gtest/ut_effect.cpp @@ -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); } diff --git a/gtest/ut_layer.cpp b/gtest/ut_layer.cpp index 65c3609..de70b4c 100644 --- a/gtest/ut_layer.cpp +++ b/gtest/ut_layer.cpp @@ -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); } diff --git a/gtest/ut_project.cpp b/gtest/ut_project.cpp index 69d8e79..5a95026 100644 --- a/gtest/ut_project.cpp +++ b/gtest/ut_project.cpp @@ -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); } diff --git a/include/media_editor.h b/include/media_editor.h index 721579a..fc76bc5 100644 --- a/include/media_editor.h +++ b/include/media_editor.h @@ -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 diff --git a/include/media_editor_private.h b/include/media_editor_private.h index 51dfa89..a6e9c85 100644 --- a/include/media_editor_private.h +++ b/include/media_editor_private.h @@ -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; \ diff --git a/packaging/capi-media-editor.spec b/packaging/capi-media-editor.spec index fd73bdc..0be2599 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.4 +Version: 0.0.5 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_editor.c b/src/media_editor.c index a42b724..75f19be 100644 --- a/src/media_editor.c +++ b/src/media_editor.c @@ -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); diff --git a/src/media_editor_clip.c b/src/media_editor_clip.c index 46611ae..ee819cf 100644 --- a/src/media_editor_clip.c +++ b/src/media_editor_clip.c @@ -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"); diff --git a/src/media_editor_private.c b/src/media_editor_private.c index 8b286a1..e99f9ad 100644 --- a/src/media_editor_private.c +++ b/src/media_editor_private.c @@ -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; }