Change precondition of webrtc_media_packet_source_push_packet() 94/260494/5
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 25 Jun 2021 10:48:05 +0000 (19:48 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 1 Jul 2021 03:31:01 +0000 (12:31 +0900)
New preconditions are added before calling this function.
 1. webrtc_media_packet_source_set_format() must be called.
 2. webrtc_media_packet_source_buffer_state_changed_cb() must be set.

The previous state limitation is removed.

[Version] 0.2.27
[Issue Type] API

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

index 43909be021143d700b82589fb028c1b26fc968b0..7bb769e3305327c3aef09d265398ce1c9eead72b 100644 (file)
@@ -913,9 +913,9 @@ int webrtc_media_packet_source_set_format(webrtc_h webrtc, unsigned int source_i
  * @retval #WEBRTC_ERROR_NONE    Successful
  * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
- * @retval #WEBRTC_ERROR_INVALID_STATE Invalid state
  * @pre Add media packet source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
- * @pre @a webrtc state must be set to #WEBRTC_STATE_NEGOTIATING or #WEBRTC_STATE_PLAYING.
+ * @pre webrtc_media_packet_source_set_format() must be called before calling this function.
+ * @pre webrtc_media_packet_source_buffer_state_changed_cb() must be set by calling webrtc_media_packet_source_set_buffer_state_changed_cb().
  * @see webrtc_media_packet_source_set_format()
  * @see webrtc_media_packet_source_set_buffer_state_changed_cb()
  */
index 55d82ca3387d0c8617328f79d34d18f1a51f32be..553858e691abd85f69a1412fbaaad44cb9cc39b1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.26
+Version:    0.2.27
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 4d62247cd7b4ceaa1316a7b6289ee3fb59bc8bf6..62d7110bbfa668c0772f06971ecbce5cac0f3003 100644 (file)
@@ -554,13 +554,21 @@ int webrtc_media_packet_source_push_packet(webrtc_h webrtc, unsigned int source_
 {
        int ret = WEBRTC_ERROR_NONE;
        webrtc_s *_webrtc = (webrtc_s*)webrtc;
+       webrtc_gst_slot_s *source;
 
        RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
        RET_VAL_IF(packet == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "packet is NULL");
 
        g_mutex_lock(&_webrtc->mutex);
 
-       RET_VAL_WITH_UNLOCK_IF(_webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, &_webrtc->mutex, "the state should NOT be IDLE");
+       RET_VAL_WITH_UNLOCK_IF((source = _get_slot_by_id(_webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER,
+               &_webrtc->mutex, "source is NULL");
+       RET_VAL_WITH_UNLOCK_IF(source->type != WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, WEBRTC_ERROR_INVALID_PARAMETER, &_webrtc->mutex,
+               "source is not media packet type");
+       RET_VAL_WITH_UNLOCK_IF(source->media_format == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex,
+               "the media format should be set");
+       RET_VAL_WITH_UNLOCK_IF(source->buffer_state_changed_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex,
+               "the buffer state changed callback should be set");
 
        ret = _push_media_packet(webrtc, source_id, packet);