media_editor_clip : Change default clip resolution to its original size 16/277716/2 submit/tizen/20220713.055803
authorHaesu Gwon <haesu.gwon@samsung.com>
Tue, 12 Jul 2022 09:20:25 +0000 (18:20 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Tue, 12 Jul 2022 23:40:57 +0000 (08:40 +0900)
[Version] 0.0.15
[Issue Type] Bug fix

Change-Id: I989ee672879fcee47515a5c2c51fe93278c93e13

include/media_editor.h
packaging/capi-media-editor.spec
src/media_editor_clip.c

index 3eaeddecc8037d03c22bb5e0c68a7ab2eaf5935b..25e396e39db360ba22c633a3d3251e83ddc6b7f3 100644 (file)
@@ -1001,7 +1001,7 @@ 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.\n
- *          @a width and @a height will return 0 before set clip resolution by mediaeditor_set_clip_resolution().
+ *          @a width and @a height will return its original size if it's not changed 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 9a799ada05f5d931ea4c00d41608e346d03a153f..5638bf525eb6c6755474c2ea452dc6f26dee00e5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-editor
 Summary:    A Tizen Media Editor API
-Version:    0.0.14
+Version:    0.0.15
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 4e566d2df1bc347f807198d4fb022ec3557cec6d..13d4a5474bb06404edaa771d5ffae90fb9fdaab2 100644 (file)
@@ -204,23 +204,6 @@ static bool __has_video_track(GESClip *clip)
     return false;
 }
 
-static void __mediaeditor_add_child_properties_resolution(GESClip *clip)
-{
-    GValue val = G_VALUE_INIT;
-
-    g_value_init(&val, G_TYPE_INT);
-
-    if (!ges_timeline_element_get_child_property(GES_TIMELINE_ELEMENT(clip), "width", &val)) {
-        GObjectClass *eklass = G_OBJECT_GET_CLASS(clip);
-
-        if (ges_timeline_element_add_child_property(GES_TIMELINE_ELEMENT(clip), g_object_class_find_property(eklass, "width"), G_OBJECT(clip)))
-            LOG_DEBUG("width property is added in URI clip");
-
-        if (ges_timeline_element_add_child_property(GES_TIMELINE_ELEMENT(clip), g_object_class_find_property(eklass, "height"), G_OBJECT(clip)))
-            LOG_DEBUG("height property is added in URI clip");
-    }
-}
-
 int _mediaeditor_create_clip_common(mediaeditor_s *editor, GESClip *clip, mediaeditor_effect_type_e effect_type, unsigned int *clip_id)
 {
     mediaeditor_clip_s *clip_data = NULL;
@@ -281,8 +264,19 @@ 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");
 
-    if (__has_video_track(clip))
+    if (__has_video_track(clip)) {
+        gint width = 0;
+        gint height = 0;
+
+        GESTrackElement *track_element = ges_clip_find_track_element(clip, NULL, GES_TYPE_VIDEO_SOURCE);
+        RET_VAL_IF(track_element == NULL, MEDIAEDITOR_ERROR_INVALID_OPERATION, "failed to get track element from clip[%p]", clip);
+
+        gboolean result = ges_video_source_get_natural_size(GES_VIDEO_SOURCE(track_element), &width, &height);
+        RET_VAL_IF(!result, MEDIAEDITOR_ERROR_NONE, "failed to get natural size");
+
+        ges_timeline_element_set_child_properties(GES_TIMELINE_ELEMENT(clip), "width", width, "height", height, NULL);
         ges_timeline_element_set_child_properties(GES_TIMELINE_ELEMENT(clip), "posx", 0, "posy", 0, NULL);
+    }
 
     return MEDIAEDITOR_ERROR_NONE;
 }
@@ -540,8 +534,6 @@ int _mediaeditor_get_clip_resolution(mediaeditor_s *editor, unsigned int 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");
 
-    __mediaeditor_add_child_properties_resolution(clip);
-
     ges_timeline_element_get_child_properties(GES_TIMELINE_ELEMENT(clip), "width", width, "height", height, NULL);
 
     return MEDIAEDITOR_ERROR_NONE;
@@ -550,17 +542,19 @@ int _mediaeditor_get_clip_resolution(mediaeditor_s *editor, unsigned int clip_id
 int _mediaeditor_set_clip_resolution(mediaeditor_s *editor, unsigned int clip_id,
   unsigned int width, unsigned int height)
 {
+    mediaeditor_clip_s *clip_data = NULL;
     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);
+    clip_data = _mediaeditor_find_clip_data(editor->clips, clip_id);
+    RET_VAL_IF(clip_data == NULL, MEDIAEDITOR_ERROR_INVALID_PARAMETER, "invalid clip id");
+
+    clip = clip_data->clip;
     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");
 
-    __mediaeditor_add_child_properties_resolution(clip);
-
     ges_timeline_element_set_child_properties(GES_TIMELINE_ELEMENT(clip), "width", width, "height", height, NULL);
 
     return MEDIAEDITOR_ERROR_NONE;