From: Sangchul Lee Date: Mon, 12 Apr 2021 08:46:11 +0000 (+0900) Subject: webrtc: Change ownership of the pushed packet X-Git-Tag: submit/tizen/20210729.023123~96 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c0e88007aa282715283c0c3a54d67b370c5cd72;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc: Change ownership of the pushed packet Regarding webrtc_media_packet_source_push_packet(), it is now changed to take the ownership of the packet. Therefore, a caller should not release the packet after pushing it using the API from now on. Description about it is added to the function. webrtc_test is modified according to this change. [Version] 0.1.145 [Issue Type] API Change-Id: I88dfc003365c6167c421feb594c037d79a90e5f6 Signed-off-by: Sangchul Lee --- diff --git a/include/webrtc.h b/include/webrtc.h index 91598205..eb3d599f 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -568,6 +568,7 @@ int webrtc_media_packet_source_set_format(webrtc_h webrtc, unsigned int source_i /** * @brief Pushes media packet to the media packet source. * @since_tizen 6.5 + * @remarks This function takes ownership of the @a packet. * @param[in] webrtc WebRTC handle * @param[in] source_id The media packet source id * @param[in] packet The media packet diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 1e1efc0c..300ebd3c 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.144 +Version: 0.1.145 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 6baeefbc..83a0f3eb 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -1489,6 +1489,7 @@ int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h LOG_ERROR("failed to 'push-buffer', gst_ret[0x%x]", gst_ret); return WEBRTC_ERROR_INVALID_OPERATION; } + media_packet_destroy(packet); return WEBRTC_ERROR_NONE; } @@ -1539,6 +1540,8 @@ int _push_media_packet(webrtc_s *webrtc, unsigned int source_id, media_packet_h exit: gst_buffer_unref(new_buffer); + if (ret == WEBRTC_ERROR_NONE) + media_packet_destroy(packet); return ret; } diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 644f6a5b..f9a97bf4 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -1945,11 +1945,13 @@ static void __stream_handoff_cb(GstElement *object, GstBuffer *buffer, GstPad *p g_printerr("failed to 'push-buffer', gst_ret[0x%x]\n", gst_ret); if (is_new_buffer) gst_buffer_unref(buffer_from_packet); + media_packet_destroy(packet); #else - if (webrtc_media_packet_source_push_packet(packet_source->webrtc, packet_source->source_id, packet) != WEBRTC_ERROR_NONE) + if (webrtc_media_packet_source_push_packet(packet_source->webrtc, packet_source->source_id, packet) != WEBRTC_ERROR_NONE) { g_printerr("failed to webrtc_media_packet_source_push_packet()\n"); + media_packet_destroy(packet); + } #endif - media_packet_destroy(packet); } static GstCaps *__make_raw_caps(media_format_h format)