webrtc: Change ownership of the pushed packet 53/256753/3
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 12 Apr 2021 08:46:11 +0000 (17:46 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 12 Apr 2021 09:08:41 +0000 (18:08 +0900)
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 <sc11.lee@samsung.com>
include/webrtc.h
packaging/capi-media-webrtc.spec
src/webrtc_source.c
test/webrtc_test.c

index 915982052c754fd71b88ecd5acfb4194f11c9709..eb3d599f2fdfbd50c1dea2cef7c86af28874f585 100644 (file)
@@ -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
index 1e1efc0c221ed763e751f04bbf6231126715ceac..300ebd3c1b625d61ac996d5858b6f1106c0283a1 100644 (file)
@@ -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
index 6baeefbc764d88331ec15adae39a5f6d1be02080..83a0f3eb81ec3a40357240f763a6c8d0dab522ea 100644 (file)
@@ -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;
 }
index 644f6a5b78d0b755f16ae8f2ae34ef99de48b39d..f9a97bf41c5549bb68e2c4d13655af0f7ca9a8eb 100644 (file)
@@ -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)