Add new position API 27/275827/3 accepted/tizen/unified/20220621.140351 submit/tizen/20220609.032959 submit/tizen/20220620.044329
authorHaesu Gwon <haesu.gwon@samsung.com>
Thu, 2 Jun 2022 09:23:00 +0000 (18:23 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Thu, 9 Jun 2022 02:28:18 +0000 (11:28 +0900)
Change gtest tc

[Version] 0.0.11
[Issue Type] New API

Change-Id: If1b2f96318df571a64b40ab3f4cad83e97d03fe2

gtest/testbase.hpp
gtest/ut_clip.cpp
gtest/ut_composition.cpp
include/media_editor.h
include/media_editor_private.h
packaging/capi-media-editor.spec
src/media_editor.c
src/media_editor_clip.c

index 9c1cea1097e699c33ed2c0f021c80f4d08516401..74241b94a8a0d2cdb8ca7e9eca9ea812159a3a6f 100644 (file)
@@ -54,7 +54,8 @@ public:
     }
 
     mediaeditor_h GetHandle() { return _editor; }
-    const std::string& GetBgmPath() { return _bgmPath; }
+    const std::string& GetJpgPath() { return _jpgPath; }
+    const std::string& GetMp3Path() { return _mp3Path; }
     const std::string& GetMp4Path(int idx) { return _mp4Ppath[idx]; }
     const std::string& GetProjectPath(int idx) { return _projectPath[idx]; }
     const std::string& GetOutputPath() { return _outputPath; }
@@ -63,7 +64,8 @@ private:
     mediaeditor_h _editor;
 
     const std::string _basePath = "/tmp/";
-    const std::string _bgmPath = _basePath + "bg.mp3";
+    const std::string _jpgPath = _basePath + "test.jpg";
+    const std::string _mp3Path = _basePath + "test.mp3";
     const std::vector<std::string> _mp4Ppath = {
         _basePath + "test1.mp4",
         _basePath + "test2.mp4",
@@ -75,5 +77,5 @@ private:
         _basePath + "test1.xges",
         _basePath + "test2.xges"
     };
-    std::string _outputPath = _basePath + "output.ogv";
+    std::string _outputPath = _basePath + "output.mp4";
 };
index b6e333c68f79075077a2dace99d6d764645fb6b1..32abe9f348d8c7a1c1c27eb4347e85eab52a3ea1 100644 (file)
@@ -207,34 +207,36 @@ TEST_F(MediaeditorClipTest, DISABLED_clip_set_duration)
     LOGD("get_duration : %d", get_duration);
 }
 
-TEST_F(MediaeditorClipTest, DISABLED_clip_set_get_resolution)
+TEST_F(MediaeditorClipTest, DISABLED_clip_position)
 {
     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 = 100;
+    unsigned int duration = 1000;
     unsigned int in_point = 0;
-    unsigned int width = 0;
-    unsigned int height = 0;
+    unsigned int pos_x = 0;
+    unsigned int pos_y = 0;
 
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
     ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
-    ret = mediaeditor_add_clip(GetHandle(), GetMp4Path(0).c_str(), layer_id, start, duration, in_point, &clip_id);
+    ret = mediaeditor_add_clip(GetHandle(), GetJpgPath().c_str(), layer_id, start, duration, in_point, &clip_id);
     ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
-    ret = mediaeditor_get_clip_resolution(GetHandle(), clip_id, &width, &height);
-    LOGD("original resolution : %dx%d", width, height);
+    ret = mediaeditor_get_clip_position(GetHandle(), clip_id, &pos_x, &pos_y);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(pos_x, 0);
+    ASSERT_EQ(pos_y, 0);
 
-    width = 640;
-    height = 360;
-    ret = mediaeditor_set_clip_resolution(GetHandle(), clip_id, width, height);
-    LOGD("set resolution : %dx%d", width, height);
+    ret = mediaeditor_set_clip_position(GetHandle(), clip_id, 10, 10);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
-    ret = mediaeditor_get_clip_resolution(GetHandle(), clip_id, &width, &height);
-    LOGD("get resolution : %dx%d", width, height);
+    ret = mediaeditor_get_clip_position(GetHandle(), clip_id, &pos_x, &pos_y);
+    ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
+    ASSERT_EQ(pos_x, 10);
+    ASSERT_EQ(pos_y, 10);
 }
 
 TEST_F(MediaeditorClipTest, DISABLED_audio_clip_set_get_resolution)
@@ -252,7 +254,7 @@ TEST_F(MediaeditorClipTest, DISABLED_audio_clip_set_get_resolution)
     ret = mediaeditor_add_layer(GetHandle(), &layer_id, &layer_priority);
     ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
-    ret = mediaeditor_add_clip(GetHandle(), GetBgmPath().c_str(), layer_id, start, duration, in_point, &clip_id);
+    ret = mediaeditor_add_clip(GetHandle(), GetMp3Path().c_str(), layer_id, start, duration, in_point, &clip_id);
     ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
     ret = mediaeditor_get_clip_resolution(GetHandle(), clip_id, &width, &height);
index b6eceee41875cacd4cb6cce634f23461daa8d005..8ae55baa1e2658c8ae59124d1e2ef8c6fd5bf3fb 100644 (file)
@@ -132,7 +132,7 @@ TEST_F(MediaeditorCompositionTest, DISABLED_mp4_bgm_transition_text)
                 duration_bgm = total - start;
             }
 
-            ret = mediaeditor_add_clip(GetHandle(), GetBgmPath().c_str(), layer_id[BGM_LAYER], start, duration_bgm, G_TIME_SPAN_MILLISECOND * 0, &clip_id);
+            ret = mediaeditor_add_clip(GetHandle(), GetMp3Path().c_str(), layer_id[BGM_LAYER], start, duration_bgm, G_TIME_SPAN_MILLISECOND * 0, &clip_id);
             ASSERT_EQ(ret, MEDIAEDITOR_ERROR_NONE);
 
             ret = mediaeditor_set_clip_volume(GetHandle(), clip_id, 0.3);
index fc76bc5e7d4916c8b16683aa434883638b1ee143..3eaeddecc8037d03c22bb5e0c68a7ab2eaf5935b 100644 (file)
@@ -1034,6 +1034,43 @@ int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int clip_id,
  */
 int mediaeditor_set_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int width, unsigned int height);
 
+/**
+ * @brief Gets the position of clip.
+ * @since_tizen 7.0
+ * @remarks If the clip doesn't have video, #MEDIAEDITOR_ERROR_INVALID_OPERATION will be returned.\n
+ *          The default position is the top-left corner(0, 0).
+ * @param[in] editor  The media editor handle
+ * @param[in] clip_id The clip ID
+ * @param[out] pos_x  The horizontal position
+ * @param[out] pos_y  The vertical position
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIAEDITOR_ERROR_NONE Successful
+ * @retval #MEDIAEDITOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIAEDITOR_ERROR_INVALID_OPERATION Invalid operation
+ * @see mediaeditor_add_clip()
+ * @see mediaeditor_set_clip_position()
+ */
+int mediaeditor_get_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int *pos_x, unsigned int *pos_y);
+
+/**
+ * @brief Sets the position of clip.
+ * @since_tizen 7.0
+ * @remarks If the clip doesn't have video, #MEDIAEDITOR_ERROR_INVALID_OPERATION will be returned.
+ * @param[in] editor  The media editor handle
+ * @param[in] clip_id The clip ID
+ * @param[in] pos_x   The horizontal position
+ * @param[in] pos_y   The vertical position
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIAEDITOR_ERROR_NONE Successful
+ * @retval #MEDIAEDITOR_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIAEDITOR_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #MEDIAEDITOR_ERROR_INVALID_STATE     Invalid state
+ * @pre @a editor state must be set to #MEDIAEDITOR_STATE_IDLE.
+ * @see mediaeditor_add_clip()
+ * @see mediaeditor_get_clip_position()
+ */
+int mediaeditor_set_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int pos_x, unsigned int pos_y);
+
 /**
  * @brief Gets the volume of clip.
  * @since_tizen 7.0
index 88f04bde623ef1441ec4cfa02b0093f76bb35a86..764014711cbb247feb9f601fa0588a7a5f773e14 100644 (file)
@@ -166,12 +166,17 @@ do { \
 #define VIDEO_ENCODER_TYPE_THEORA "theora"
 #define VIDEO_ENCODER_TYPE_MPEG   "mpeg"
 
-#define CONTAINER_MIME_TYPE_OGG  "application/ogg"
-#define CONTAINER_MIME_TYPE_MPEG "video/quicktime,variant=iso"
+#define CONTAINER_MIME_TYPE_OGG        "application/ogg"
 #define AUDIO_ENCODER_MIME_TYPE_VORBIS "audio/x-vorbis"
-#define AUDIO_ENCODER_MIME_TYPE_MPEG   "audio/mpeg,channels=2,rate=44100,mpegversion=4,stream-format=raw,base-profile=lc"
 #define VIDEO_ENCODER_MIME_TYPE_THEORA "video/x-theora"
-#define VIDEO_ENCODER_MIME_TYPE_MPEG   "video/mpeg,mpegversion=4,chroma-site=raw"
+
+#define CONTAINER_MIME_TYPE_MPEG     "video/quicktime,variant=iso"
+#define AUDIO_ENCODER_MIME_TYPE_MPEG "audio/mpeg,channels=2,rate=44100,mpegversion=4,stream-format=raw,base-profile=lc"
+#ifdef TIZEN_TV
+#define VIDEO_ENCODER_MIME_TYPE_MPEG "video/mpeg,mpegversion=4,chroma-site=mpeg2"
+#else
+#define VIDEO_ENCODER_MIME_TYPE_MPEG "video/mpeg,mpegversion=4,chroma-site=raw"
+#endif
 
 #define MEDIAEDITOR_CLIP(x) (((mediaeditor_clip_s *)((x)->data))->clip)
 #define MEDIAEDITOR_GROUP(x) (((mediaeditor_group_s *)((x)->data))->group)
@@ -355,6 +360,8 @@ int _mediaeditor_get_clip_in_point(mediaeditor_s *editor, unsigned int clip_id,
 int _mediaeditor_set_clip_in_point(mediaeditor_s *editor, unsigned int clip_id, unsigned int in_point);
 int _mediaeditor_get_clip_resolution(mediaeditor_s *editor, unsigned int clip_id, unsigned int *width, unsigned int *height);
 int _mediaeditor_set_clip_resolution(mediaeditor_s *editor, unsigned int clip_id, unsigned int width, unsigned int height);
+int _mediaeditor_get_clip_position(mediaeditor_s *editor, unsigned int clip_id, unsigned int *pos_x, unsigned int *pos_y);
+int _mediaeditor_set_clip_position(mediaeditor_s *editor, unsigned int clip_id, unsigned int pos_x, unsigned int pos_y);
 int _mediaeditor_get_clip_volume(mediaeditor_s *editor, unsigned int clip_id, double *volume);
 int _mediaeditor_set_clip_volume(mediaeditor_s *editor, unsigned int clip_id, double volume);
 
index 7ee0584799772d2bb7fd8c968f76639ab930a8c8..b23b13019b2763791709104535237b3596c72173 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-editor
 Summary:    A Tizen Media Editor API
-Version:    0.0.10
+Version:    0.0.11
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 75f19bea2188e91d611fd6e8b7799e2d97860931..1ccab0c662cdfc6974c24622512c5b5c3347f90b 100644 (file)
@@ -153,6 +153,7 @@ int mediaeditor_set_display(mediaeditor_h editor, mediaeditor_display_type_e typ
 
 int mediaeditor_get_state(mediaeditor_h editor, mediaeditor_state_e *state)
 {
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
@@ -160,12 +161,10 @@ int mediaeditor_get_state(mediaeditor_h editor, mediaeditor_state_e *state)
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
-    g_mutex_lock(&_editor->mutex);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
     *state = _editor->state;
 
-    g_mutex_unlock(&_editor->mutex);
-
     LOG_DEBUG("Leave editor[%p], state[%d]", editor, *state);
 
     return MEDIAEDITOR_ERROR_NONE;
@@ -383,20 +382,19 @@ int mediaeditor_deactivate_layer(mediaeditor_h editor, unsigned int layer_id)
 int mediaeditor_get_layer_priority(mediaeditor_h editor, unsigned int layer_id, unsigned int *layer_priority)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
     RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
 
-    g_mutex_lock(&_editor->mutex);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
     ret = _mediaeditor_get_layer_priority(_editor, layer_id, layer_priority);
 
-    g_mutex_unlock(&_editor->mutex);
-
-    LOG_DEBUG("Leave editor[%p], id[%d], priority[%d]", editor, layer_id, *layer_priority);
+    LOG_DEBUG("Leave editor[%p], layer_id[%d], priority[%d]", editor, layer_id, *layer_priority);
 
     return ret;
 }
@@ -404,19 +402,18 @@ int mediaeditor_get_layer_priority(mediaeditor_h editor, unsigned int layer_id,
 int mediaeditor_get_layer_lowest_priority(mediaeditor_h editor, unsigned int *layer_priority)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
     RET_VAL_IF(layer_priority == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_priority is NULL");
 
-    g_mutex_lock(&_editor->mutex);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
     ret = _mediaeditor_get_layer_lowest_priority(_editor, layer_priority);
 
-    g_mutex_unlock(&_editor->mutex);
-
     LOG_DEBUG("Leave editor[%p], priority[%d]", editor, *layer_priority);
 
     return ret;
@@ -425,20 +422,19 @@ int mediaeditor_get_layer_lowest_priority(mediaeditor_h editor, unsigned int *la
 int mediaeditor_get_layer_id(mediaeditor_h editor, unsigned int layer_priority, unsigned int *layer_id)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
     RET_VAL_IF(layer_id == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "layer_id is NULL");
 
-    g_mutex_lock(&_editor->mutex);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
     ret = _mediaeditor_get_layer_id(_editor, layer_priority, layer_id);
 
-    g_mutex_unlock(&_editor->mutex);
-
-    LOG_DEBUG("Leave editor[%p], priority[%d], id[%d]", editor, layer_priority, *layer_id);
+    LOG_DEBUG("Leave editor[%p], priority[%d], layer_id[%d]", editor, layer_priority, *layer_id);
 
     return ret;
 }
@@ -583,6 +579,7 @@ int mediaeditor_move_clip_layer(mediaeditor_h editor, unsigned int clip_id, unsi
 int mediaeditor_get_clip_start(mediaeditor_h editor, unsigned int clip_id, unsigned int *start)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
@@ -590,18 +587,18 @@ int mediaeditor_get_clip_start(mediaeditor_h editor, unsigned int clip_id, unsig
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
-    g_mutex_lock(&_editor->mutex);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
     ret = _mediaeditor_get_clip_start(_editor, clip_id, start);
 
     g_mutex_unlock(&_editor->mutex);
 
-    LOG_DEBUG("Leave editor[%p], id[%d], start[%d]", editor, clip_id, *start);
+    LOG_DEBUG("Leave editor[%p], clip_id[%d], start[%d]", editor, clip_id, *start);
 
     return ret;
 }
 
-int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int id, unsigned int start)
+int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int clip_id, unsigned int start)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autoptr(GMutexLocker) locker = NULL;
@@ -611,21 +608,22 @@ int mediaeditor_set_clip_start(mediaeditor_h editor, unsigned int id, unsigned i
 
     locker = g_mutex_locker_new(&_editor->mutex);
 
-    LOG_DEBUG("Enter editor[%p], id[%d], start[%d]", editor, id, start);
+    LOG_DEBUG("Enter editor[%p], clip_id[%d], start[%d]", editor, clip_id, start);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
 
-    ret = _mediaeditor_set_clip_start(_editor, id, start);
+    ret = _mediaeditor_set_clip_start(_editor, clip_id, start);
 
     LOG_DEBUG("Leave editor[%p]", editor);
 
     return ret;
 }
 
-int mediaeditor_get_clip_duration(mediaeditor_h editor, unsigned int id, unsigned int *duration)
+int mediaeditor_get_clip_duration(mediaeditor_h editor, unsigned int clip_id, unsigned int *duration)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
@@ -633,18 +631,16 @@ int mediaeditor_get_clip_duration(mediaeditor_h editor, unsigned int id, unsigne
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
-    g_mutex_lock(&_editor->mutex);
-
-    ret = _mediaeditor_get_clip_duration(_editor, id, duration);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
-    g_mutex_unlock(&_editor->mutex);
+    ret = _mediaeditor_get_clip_duration(_editor, clip_id, duration);
 
-    LOG_DEBUG("Leave editor[%p], id[%d], duration[%d]", editor, id, *duration);
+    LOG_DEBUG("Leave editor[%p], clip_id[%d], duration[%d]", editor, clip_id, *duration);
 
     return ret;
 }
 
-int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int id, unsigned int duration)
+int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int clip_id, unsigned int duration)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autoptr(GMutexLocker) locker = NULL;
@@ -654,21 +650,22 @@ int mediaeditor_set_clip_duration(mediaeditor_h editor, unsigned int id, unsigne
 
     locker = g_mutex_locker_new(&_editor->mutex);
 
-    LOG_DEBUG("Enter editor[%p], id[%d], duration[%d]", editor, id, duration);
+    LOG_DEBUG("Enter editor[%p], clip_id[%d], duration[%d]", editor, clip_id, duration);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
 
-    ret = _mediaeditor_set_clip_duration(_editor, id, duration);
+    ret = _mediaeditor_set_clip_duration(_editor, clip_id, duration);
 
     LOG_DEBUG("Leave editor[%p]", editor);
 
     return ret;
 }
 
-int mediaeditor_get_clip_in_point(mediaeditor_h editor, unsigned int id, unsigned int *in_point)
+int mediaeditor_get_clip_in_point(mediaeditor_h editor, unsigned int clip_id, unsigned int *in_point)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
@@ -676,18 +673,16 @@ int mediaeditor_get_clip_in_point(mediaeditor_h editor, unsigned int id, unsigne
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
-    g_mutex_lock(&_editor->mutex);
-
-    ret = _mediaeditor_get_clip_in_point(_editor, id, in_point);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
-    g_mutex_unlock(&_editor->mutex);
+    ret = _mediaeditor_get_clip_in_point(_editor, clip_id, in_point);
 
-    LOG_DEBUG("Leave editor[%p], id[%d], in_point[%d]", editor, id, *in_point);
+    LOG_DEBUG("Leave editor[%p], clip_id[%d], in_point[%d]", editor, clip_id, *in_point);
 
     return ret;
 }
 
-int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int id, unsigned int in_point)
+int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int clip_id, unsigned int in_point)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autoptr(GMutexLocker) locker = NULL;
@@ -697,21 +692,22 @@ int mediaeditor_set_clip_in_point(mediaeditor_h editor, unsigned int id, unsigne
 
     locker = g_mutex_locker_new(&_editor->mutex);
 
-    LOG_DEBUG("Enter editor[%p], id[%d], in_point[%d]", editor, id, in_point);
+    LOG_DEBUG("Enter editor[%p], clip_id[%d], in_point[%d]", editor, clip_id, in_point);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
 
-    ret = _mediaeditor_set_clip_in_point(_editor, id, in_point);
+    ret = _mediaeditor_set_clip_in_point(_editor, clip_id, in_point);
 
     LOG_DEBUG("Leave editor[%p]", editor);
 
     return ret;
 }
 
-int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int id, unsigned int *width, unsigned int *height)
+int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int *width, unsigned int *height)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
@@ -720,42 +716,84 @@ int mediaeditor_get_clip_resolution(mediaeditor_h editor, unsigned int id, unsig
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
-    g_mutex_lock(&_editor->mutex);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
-    ret = _mediaeditor_get_clip_resolution(_editor, id, width, height);
+    ret = _mediaeditor_get_clip_resolution(_editor, clip_id, width, height);
 
-    g_mutex_unlock(&_editor->mutex);
+    LOG_DEBUG("Leave editor[%p], clip_id[%d], width[%d], height[%d]", editor, clip_id, *width, *height);
 
-    LOG_DEBUG("Leave editor[%p], id[%d], width[%d], height[%d]", editor, id, *width, *height);
+    return ret;
+}
+
+int mediaeditor_set_clip_resolution(mediaeditor_h editor, unsigned int clip_id, unsigned int width, unsigned int height)
+{
+    int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
+    mediaeditor_s *_editor = (mediaeditor_s *)editor;
+
+    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+
+    locker = g_mutex_locker_new(&_editor->mutex);
+
+    LOG_DEBUG("Enter editor[%p], clip_id[%d], width[%d], height[%d]", editor, clip_id, width, height);
+
+    RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
+        "the state should be IDLE");
+
+    ret = _mediaeditor_set_clip_resolution(_editor, clip_id, width, height);
+
+    LOG_DEBUG("Leave editor[%p]", editor);
 
     return ret;
 }
 
-int mediaeditor_set_clip_resolution(mediaeditor_h editor, unsigned int id, unsigned int width, unsigned int height)
+int mediaeditor_get_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int *pos_x, unsigned int *pos_y)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    RET_VAL_IF(pos_x == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pos_x is NULL");
+    RET_VAL_IF(pos_y == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "pos_y is NULL");
+
+    LOG_DEBUG("Enter editor[%p]", editor);
 
     locker = g_mutex_locker_new(&_editor->mutex);
 
-    LOG_DEBUG("Enter editor[%p], id[%d], width[%d], height[%d]", editor, id, width, height);
+    ret = _mediaeditor_get_clip_position(_editor, clip_id, pos_x, pos_y);
+
+    LOG_DEBUG("Leave editor[%p], clip_id[%d], pos_x[%d], pos_x[%d]", editor, clip_id, *pos_x, *pos_y);
+
+    return ret;
+}
+
+int mediaeditor_set_clip_position(mediaeditor_h editor, unsigned int clip_id, unsigned int pos_x, unsigned int pos_y)
+{
+    int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
+    mediaeditor_s *_editor = (mediaeditor_s *)editor;
+
+    RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+
+    locker = g_mutex_locker_new(&_editor->mutex);
+
+    LOG_DEBUG("Enter editor[%p], clip_id[%d], pos_x[%d], pos_y[%d]", editor, clip_id, pos_x, pos_y);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
 
-    ret = _mediaeditor_set_clip_resolution(_editor, id, width, height);
+    ret = _mediaeditor_set_clip_position(_editor, clip_id, pos_x, pos_y);
 
     LOG_DEBUG("Leave editor[%p]", editor);
 
     return ret;
 }
 
-int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int id, double *volume)
+int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int clip_id, double *volume)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
+    g_autoptr(GMutexLocker) locker = NULL;
     mediaeditor_s *_editor = (mediaeditor_s *)editor;
 
     RET_VAL_IF(_editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
@@ -763,18 +801,16 @@ int mediaeditor_get_clip_volume(mediaeditor_h editor, unsigned int id, double *v
 
     LOG_DEBUG("Enter editor[%p]", editor);
 
-    g_mutex_lock(&_editor->mutex);
-
-    ret = _mediaeditor_get_clip_volume(_editor, id, volume);
+    locker = g_mutex_locker_new(&_editor->mutex);
 
-    g_mutex_unlock(&_editor->mutex);
+    ret = _mediaeditor_get_clip_volume(_editor, clip_id, volume);
 
-    LOG_DEBUG("Leave editor[%p], id[%d], volumd[%f]", editor, id, *volume);
+    LOG_DEBUG("Leave editor[%p], clip_id[%d], volumd[%f]", editor, clip_id, *volume);
 
     return ret;
 }
 
-int mediaeditor_set_clip_volume(mediaeditor_h editor, unsigned int id, double volume)
+int mediaeditor_set_clip_volume(mediaeditor_h editor, unsigned int clip_id, double volume)
 {
     int ret = MEDIAEDITOR_ERROR_NONE;
     g_autoptr(GMutexLocker) locker = NULL;
@@ -785,12 +821,12 @@ int mediaeditor_set_clip_volume(mediaeditor_h editor, unsigned int id, double vo
 
     locker = g_mutex_locker_new(&_editor->mutex);
 
-    LOG_DEBUG("Enter editor[%p], id[%d], volume[%f]", editor, id, volume);
+    LOG_DEBUG("Enter editor[%p], clip_id[%d], volume[%f]", editor, clip_id, volume);
 
     RET_VAL_IF(_editor->state != MEDIAEDITOR_STATE_IDLE, MEDIAEDITOR_ERROR_INVALID_STATE,
         "the state should be IDLE");
 
-    ret = _mediaeditor_set_clip_volume(_editor, id, volume);
+    ret = _mediaeditor_set_clip_volume(_editor, clip_id, volume);
 
     LOG_DEBUG("Leave editor[%p]", editor);
 
index ee819cfcf762ddecc481546bf2d680d4a373c601..721d36ff3c1586d5da8a3978e3e28f39f6df9456 100644 (file)
@@ -258,6 +258,7 @@ int _mediaeditor_add_clip(mediaeditor_s *editor, const char *path, unsigned int
     LOGI("uri : [%s]", uri);
 
     clip = GES_CLIP(ges_uri_clip_new(uri));
+    RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to create clip");
 
     start_nsec = MILLI_TO_NANO(start);
     duration_nsec = MILLI_TO_NANO(duration);
@@ -280,6 +281,9 @@ int _mediaeditor_add_clip(mediaeditor_s *editor, const char *path, unsigned int
     ret = _mediaeditor_create_clip_common(editor, clip, MEDIAEDITOR_EFFECT_TYPE_NONE, clip_id);
     RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to create clip common");
 
+    ret = _mediaeditor_set_clip_position(editor, *clip_id, 0, 0);
+    RET_VAL_IF(ret != MEDIAEDITOR_ERROR_NONE, ret, "failed to set initial position");
+
     return MEDIAEDITOR_ERROR_NONE;
 }
 
@@ -562,6 +566,40 @@ int _mediaeditor_set_clip_resolution(mediaeditor_s *editor, unsigned int clip_id
     return MEDIAEDITOR_ERROR_NONE;
 }
 
+int _mediaeditor_get_clip_position(mediaeditor_s *editor, unsigned int clip_id,
+  unsigned int *pos_x, unsigned int *pos_y)
+{
+    GESClip *clip = NULL;
+
+    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
+
+    clip = __mediaeditor_find_clip(editor->clips, clip_id);
+    RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
+    RET_VAL_IF(!__has_video_track(clip), MEDIAEDITOR_ERROR_INVALID_OPERATION, "Not video clip");
+
+    ges_timeline_element_get_child_properties(GES_TIMELINE_ELEMENT(clip), "posx", pos_x, "posy", pos_y, NULL);
+
+    return MEDIAEDITOR_ERROR_NONE;
+}
+
+int _mediaeditor_set_clip_position(mediaeditor_s *editor, unsigned int clip_id,
+  unsigned int pos_x, unsigned int pos_y)
+{
+    GESClip *clip = NULL;
+
+    RET_VAL_IF(editor == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "editor is NULL");
+    RET_VAL_IF(clip_id >= editor->clip_id, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid id");
+
+    clip = __mediaeditor_find_clip(editor->clips, clip_id);
+    RET_VAL_IF(clip == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
+    RET_VAL_IF(!__has_video_track(clip), MEDIAEDITOR_ERROR_INVALID_OPERATION, "Not video clip");
+
+    ges_timeline_element_set_child_properties(GES_TIMELINE_ELEMENT(clip), "posx", pos_x, "posy", pos_y, NULL);
+
+    return MEDIAEDITOR_ERROR_NONE;
+}
+
 int _mediaeditor_get_clip_volume(mediaeditor_s *editor, unsigned int clip_id, double *volume)
 {
     GESClip *clip = NULL;