webrtc_sink: Set width/height to media format for encoded frame callback 96/254596/1
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 5 Mar 2021 04:13:33 +0000 (13:13 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 5 Mar 2021 04:13:40 +0000 (13:13 +0900)
In case of video format, these will be set if caps has width and height
information in its structure.

[Version] 0.1.122
[Issue Type] Improvement

Change-Id: I77da9d41ec3ac3c3a63d31f34974161511bc4d1e
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
src/webrtc_sink.c

index 835f69653df2e9c987243411f7d59a34f1456ae7..c63634367e08ad87fac2372dd585a42bd8d97d0f 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.1.121
+Version:    0.1.122
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 2c2949dcbae439dc7fd361b618ef63115cf6194e..14a6e91bf4ec8250e9d90a8a3db7676afeb88007 100644 (file)
@@ -544,37 +544,51 @@ static media_format_h __make_media_format(GstPad *pad)
        caps = gst_pad_get_current_caps(pad);
        structure = gst_caps_get_structure(caps, 0);
        mime = gst_structure_get_name(structure);
-
        caps_str = gst_caps_to_string(caps);
        LOG_WARNING("%s", caps_str);
        g_free(caps_str);
 
-       if (__get_media_format_mimetype(mime, &mimetype) != WEBRTC_ERROR_NONE) {
-               gst_caps_unref(caps);
-               media_format_unref(format);
-               return NULL;
-       }
-       gst_caps_unref(caps);
+       if (__get_media_format_mimetype(mime, &mimetype) != WEBRTC_ERROR_NONE)
+               goto error;
 
-       LOG_INFO("mimetype[0x%x]", mimetype);
+       LOG_WARNING("media format mimetype[0x%x]", mimetype);
 
        if (mimetype & MEDIA_FORMAT_VIDEO) {
+               gint width = 0;
+               gint height = 0;
+
                ret = media_format_set_video_mime(format, mimetype);
                if (ret != MEDIA_FORMAT_ERROR_NONE) {
                        LOG_ERROR("failed to media_format_set_video_mime()");
-                       media_format_unref(format);
-                       return NULL;
+                       goto error;
+               }
+
+               /* FIXME: We also need to get width/height in case of H26x with not this way. */
+               gst_structure_get_int(structure, "width", &width);
+               gst_structure_get_int(structure, "height", &height);
+               if (width > 0 && height > 0) {
+                       ret |= media_format_set_video_width(format, width);
+                       ret |= media_format_set_video_height(format, height);
+                       if (ret != MEDIA_FORMAT_ERROR_NONE) {
+                               LOG_ERROR("failed to media_format_set_video_width/height()");
+                               goto error;
+                       }
                }
        } else if (mimetype & MEDIA_FORMAT_AUDIO) {
                ret = media_format_set_audio_mime(format, mimetype);
                if (ret != MEDIA_FORMAT_ERROR_NONE) {
                        LOG_ERROR("failed to media_format_set_audio_mime()");
-                       media_format_unref(format);
-                       return NULL;
+                       goto error;
                }
        }
 
+       gst_caps_unref(caps);
        return format;
+
+error:
+       gst_caps_unref(caps);
+       media_format_unref(format);
+       return NULL;
 }
 
 static int __media_packet_finalize_cb(media_packet_h packet, int error_code, void *user_data)