From 27f2a99aaacec0c099e08c767a86582b505aba5d Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 5 Mar 2021 13:13:33 +0900 Subject: [PATCH] webrtc_sink: Set width/height to media format for encoded frame callback 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 --- packaging/capi-media-webrtc.spec | 2 +- src/webrtc_sink.c | 38 ++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 835f6965..c6363436 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -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 diff --git a/src/webrtc_sink.c b/src/webrtc_sink.c index 2c2949dc..14a6e91b 100644 --- a/src/webrtc_sink.c +++ b/src/webrtc_sink.c @@ -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) -- 2.34.1