webrtc_source: Make sure to get ssrc before returning webrtc_start_media_source() 46/311746/3
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 12 Apr 2024 23:48:58 +0000 (08:48 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 14 Jun 2024 01:24:01 +0000 (10:24 +0900)
It is modified to return the function after invoking
__webrtcbin_on_negotiation_needed_cb() to get ssrc properly when
the following funcion is called - webrtc_create_offer().

[Version] 1.1.3
[Issue Type] Bug fix

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

index 60df3f5265d64cf633596623a9874d30ea004153..e82470b52812ffdd3a0e8c5a33001987d047bb8a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    1.1.2
+Version:    1.1.3
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 8cb80386d9e02c8ef449c870bbd1bcfd3ccaf5c3..46f33b0def146bdc1cc9bb8c954cf7803bc45b81 100644 (file)
@@ -1122,12 +1122,14 @@ static void __webrtcbin_on_negotiation_needed_cb(GstElement *webrtcbin, gpointer
        RET_IF(webrtc == NULL, "webrtc is NULL");
 
        if (webrtc->is_start_sync) {
-               webrtc->state = WEBRTC_STATE_NEGOTIATING;
+               if (webrtc->state == WEBRTC_STATE_IDLE)
+                       webrtc->state = WEBRTC_STATE_NEGOTIATING;
                g_mutex_lock(&webrtc->state_mutex);
                g_cond_signal(&webrtc->state_cond);
                g_mutex_unlock(&webrtc->state_mutex);
        } else {
-               _post_state_cb_in_idle(webrtc, WEBRTC_STATE_NEGOTIATING);
+               if (webrtc->state == WEBRTC_STATE_IDLE)
+                       _post_state_cb_in_idle(webrtc, WEBRTC_STATE_NEGOTIATING);
        }
 
        if (webrtc->negotiation_needed_cb.callback == NULL) {
index 53404ca5f3774d535244f60a8753a983f73981a9..4898a8897b3f137d2ea4b6543f8440a6b2309b6c 100644 (file)
@@ -393,18 +393,43 @@ int _start_media_source(webrtc_s *webrtc, unsigned int source_id)
                        LOG_ERROR("codec must be set to the null source");
                        return WEBRTC_ERROR_INVALID_OPERATION;
                }
-               break;
+               /* NOTE: null source does not need ssrc, hence it does not need to wait for the signal */
+               goto complete_source;
        }
        }
 
        /* TODO: add resource check */
 
+       if (webrtc->state >= WEBRTC_STATE_NEGOTIATING) {
+               g_mutex_lock(&webrtc->state_mutex);
+               webrtc->is_start_sync = true;
+               LOG_DEBUG("start sync... state[%d]", webrtc->state);
+       }
+
+complete_source:
        ret = __complete_source(webrtc, source);
-       RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to complete sources");
+       if (ret != WEBRTC_ERROR_NONE)
+               goto out;
+
+       if (webrtc->is_start_sync) {
+               gint64 end_time = g_get_monotonic_time() + 10 * G_TIME_SPAN_SECOND;
+               LOG_DEBUG("wait...");
+               if (!g_cond_wait_until(&webrtc->state_cond, &webrtc->state_mutex, end_time)) {
+                       LOG_ERROR("timeout of g_cond_wait_until()");
+                       ret = WEBRTC_ERROR_INVALID_OPERATION;
+                       goto out;
+               }
+       }
 
        LOG_INFO("webrtc[%p] source[type:%d, id:%u]", webrtc, source->type, source_id);
 
-       return WEBRTC_ERROR_NONE;
+out:
+       if (webrtc->is_start_sync) {
+               webrtc->is_start_sync = false;
+               g_mutex_unlock(&webrtc->state_mutex);
+       }
+
+       return ret;
 }
 
 int _build_audiosrc(webrtc_s *webrtc, webrtc_gst_slot_s *source, bool use_mic, int ssrc)