diff --git a/include/linphone/api/c-call.h b/include/linphone/api/c-call.h index c90b0a0b3..e1010580b 100644 --- a/include/linphone/api/c-call.h +++ b/include/linphone/api/c-call.h @@ -258,7 +258,13 @@ LINPHONE_PUBLIC void linphone_call_set_authentication_token_verified (LinphoneCa **/ LINPHONE_PUBLIC void linphone_call_send_vfu_request (LinphoneCall *call); -LINPHONE_PUBLIC void linphone_call_set_next_video_frame_decoded_callback (LinphoneCall *call, LinphoneCallCbFunc cb, void *ud); +/** + * Request the callback passed to linphone_call_cbs_set_next_video_frame_decoded() to be called the next time the video decoder properly decodes a video frame. + * @param call the #LinphoneCall +**/ +LINPHONE_PUBLIC void linphone_call_request_notify_next_video_frame_decoded(LinphoneCall *call); + +LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_call_set_next_video_frame_decoded_callback (LinphoneCall *call, LinphoneCallCbFunc cb, void *ud); /** * Returns the current transfer state, if a transfer has been initiated from this call. diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index ffb4b8e30..724c38066 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -364,6 +364,10 @@ void linphone_call_set_next_video_frame_decoded_callback (LinphoneCall *call, Li L_GET_CPP_PTR_FROM_C_OBJECT(call)->setNextVideoFrameDecodedCallback(cb, ud); } +void linphone_call_request_notify_next_video_frame_decoded(LinphoneCall *call){ + L_GET_CPP_PTR_FROM_C_OBJECT(call)->requestNotifyNextVideoFrameDecoded(); +} + LinphoneCallState linphone_call_get_transfer_state (LinphoneCall *call) { return static_cast(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getTransferState()); } diff --git a/src/call/call-p.h b/src/call/call-p.h index 488df87aa..d75942501 100644 --- a/src/call/call-p.h +++ b/src/call/call-p.h @@ -67,7 +67,7 @@ public: void stopMediaStreams (); private: - void resetFirstVideoFrameDecoded (); + void requestNotifyNextVideoFrameDecoded (); void startRemoteRing (); void terminateBecauseOfLostMedia (); diff --git a/src/call/call.cpp b/src/call/call.cpp index a16d08482..945d83471 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -148,12 +148,6 @@ void CallPrivate::stopMediaStreams () { // ----------------------------------------------------------------------------- -void CallPrivate::resetFirstVideoFrameDecoded () { -#ifdef VIDEO_ENABLED - if (nextVideoFrameDecoded._func) - static_pointer_cast(getActiveSession())->resetFirstVideoFrameDecoded(); -#endif // ifdef VIDEO_ENABLED -} void CallPrivate::startRemoteRing () { L_Q(); @@ -419,7 +413,16 @@ void CallPrivate::onFirstVideoFrameDecoded (const shared_ptr &sessi } void CallPrivate::onResetFirstVideoFrameDecoded (const shared_ptr &session) { - resetFirstVideoFrameDecoded(); + /*we are called here by the MediaSession when the stream start to know whether there is the deprecated nextVideoFrameDecoded callback set, + * so that we can request the notification of the next frame decoded.*/ +#ifdef VIDEO_ENABLED + if (nextVideoFrameDecoded._func) + requestNotifyNextVideoFrameDecoded(); +#endif // ifdef VIDEO_ENABLED +} + +void CallPrivate::requestNotifyNextVideoFrameDecoded(){ + static_pointer_cast(getActiveSession())->requestNotifyNextVideoFrameDecoded(); } void CallPrivate::onPlayErrorTone (const shared_ptr &session, LinphoneReason reason) { @@ -924,7 +927,12 @@ void Call::setNextVideoFrameDecodedCallback (LinphoneCallCbFunc cb, void *user_d L_D(); d->nextVideoFrameDecoded._func = cb; d->nextVideoFrameDecoded._user_data = user_data; - d->resetFirstVideoFrameDecoded(); + d->requestNotifyNextVideoFrameDecoded(); +} + +void Call::requestNotifyNextVideoFrameDecoded (){ + L_D(); + d->requestNotifyNextVideoFrameDecoded(); } void Call::setParams (const MediaSessionParams *msp) { diff --git a/src/call/call.h b/src/call/call.h index 7566d9420..49315d9f9 100644 --- a/src/call/call.h +++ b/src/call/call.h @@ -123,6 +123,7 @@ public: void setMicrophoneVolumeGain (float value); void setNativeVideoWindowId (void *id); void setNextVideoFrameDecodedCallback (LinphoneCallCbFunc cb, void *user_data); + void requestNotifyNextVideoFrameDecoded(); void setParams (const MediaSessionParams *msp); void setSpeakerVolumeGain (float value); diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 8e0b1025e..7798513a1 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -4234,10 +4234,6 @@ void MediaSession::sendVfuRequest () { L_D(); MediaSessionParams *curParams = getCurrentParams(); - if (d->videoStream && d->videoStream->ms.decoder) { - ms_filter_call_method_noarg(d->videoStream->ms.decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION); - } - if ((curParams->avpfEnabled() || curParams->getPrivate()->implicitRtcpFbEnabled()) && d->videoStream && media_stream_get_state(&d->videoStream->ms) == MSStreamStarted) { // || sal_media_description_has_implicit_avpf((const SalMediaDescription *)call->resultdesc) lInfo() << "Request Full Intra Request on CallSession [" << this << "]"; @@ -4369,7 +4365,7 @@ LinphoneStatus MediaSession::update (const MediaSessionParams *msp, const string // ----------------------------------------------------------------------------- -void MediaSession::resetFirstVideoFrameDecoded () { +void MediaSession::requestNotifyNextVideoFrameDecoded () { L_D(); if (d->videoStream && d->videoStream->ms.decoder) ms_filter_call_method_noarg(d->videoStream->ms.decoder, MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION); diff --git a/src/conference/session/media-session.h b/src/conference/session/media-session.h index 18fc76d2a..8236c4f8a 100644 --- a/src/conference/session/media-session.h +++ b/src/conference/session/media-session.h @@ -63,7 +63,7 @@ public: void terminateBecauseOfLostMedia (); LinphoneStatus update (const MediaSessionParams *msp, const std::string &subject = ""); - void resetFirstVideoFrameDecoded (); + void requestNotifyNextVideoFrameDecoded (); LinphoneStatus takePreviewSnapshot (const std::string& file); LinphoneStatus takeVideoSnapshot (const std::string& file); void zoomVideo (float zoomFactor, float *cx, float *cy); diff --git a/tester/call_multicast_tester.c b/tester/call_multicast_tester.c index 249c2adfb..f6182aa18 100644 --- a/tester/call_multicast_tester.c +++ b/tester/call_multicast_tester.c @@ -55,7 +55,7 @@ static void call_multicast_base(bool_t video) { BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%d"); if (video) { /*check video path*/ - linphone_call_set_first_video_frame_decoded_cb(linphone_core_get_current_call(marie->lc)); + liblinphone_tester_set_next_video_frame_decoded_cb(linphone_core_get_current_call(marie->lc)); linphone_call_send_vfu_request(linphone_core_get_current_call(marie->lc)); BC_ASSERT_TRUE( wait_for(marie->lc,pauline->lc,&marie->stat.number_of_IframeDecoded,1)); } @@ -149,7 +149,7 @@ static void early_media_with_multicast_base(bool_t video) { /* send a 183 to initiate the early media */ if (video) { /*check video path*/ - linphone_call_set_first_video_frame_decoded_cb(linphone_core_get_current_call(pauline->lc)); + liblinphone_tester_set_next_video_frame_decoded_cb(linphone_core_get_current_call(pauline->lc)); } linphone_call_accept_early_media(linphone_core_get_current_call(pauline->lc)); @@ -160,7 +160,7 @@ static void early_media_with_multicast_base(bool_t video) { /* send a 183 to initiate the early media */ if (video) { /*check video path*/ - linphone_call_set_first_video_frame_decoded_cb(linphone_core_get_current_call(pauline2->lc)); + liblinphone_tester_set_next_video_frame_decoded_cb(linphone_core_get_current_call(pauline2->lc)); } linphone_call_accept_early_media(linphone_core_get_current_call(pauline2->lc)); diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 1afc4ddce..73e4667f0 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -186,11 +186,15 @@ static void linphone_call_next_video_frame_decoded_cb(LinphoneCall *call) { counters->number_of_IframeDecoded++; } -void linphone_call_set_first_video_frame_decoded_cb(LinphoneCall *call) { - LinphoneCallCbs *call_cbs = linphone_factory_create_call_cbs(linphone_factory_get()); - linphone_call_cbs_set_next_video_frame_decoded(call_cbs, linphone_call_next_video_frame_decoded_cb); - linphone_call_add_callbacks(call, call_cbs); - linphone_call_cbs_unref(call_cbs); +void liblinphone_tester_set_next_video_frame_decoded_cb(LinphoneCall *call) { + if (belle_sip_object_data_get(BELLE_SIP_OBJECT(call), "next_video_frame_decoded_set") == NULL){ + LinphoneCallCbs *call_cbs = linphone_factory_create_call_cbs(linphone_factory_get()); + linphone_call_cbs_set_next_video_frame_decoded(call_cbs, linphone_call_next_video_frame_decoded_cb); + linphone_call_add_callbacks(call, call_cbs); + linphone_call_cbs_unref(call_cbs); + belle_sip_object_data_set(BELLE_SIP_OBJECT(call), "next_video_frame_decoded_set", (void*)1, NULL); + } + linphone_call_request_notify_next_video_frame_decoded(call); } #define reset_call_stats(var, value) \ diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index d96b7b1a3..7489a0d8d 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -276,7 +276,7 @@ bool_t request_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bo } if (video_added) { - linphone_call_set_first_video_frame_decoded_cb(call_obj); + liblinphone_tester_set_next_video_frame_decoded_cb(call_obj); /*send vfu*/ linphone_call_send_vfu_request(call_obj); BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_IframeDecoded,initial_callee_stat.number_of_IframeDecoded+1)); @@ -600,7 +600,7 @@ void video_call_base_2(LinphoneCoreManager* caller,LinphoneCoreManager* callee, BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); /*check video path*/ - linphone_call_set_first_video_frame_decoded_cb(callee_call); + liblinphone_tester_set_next_video_frame_decoded_cb(callee_call); linphone_call_send_vfu_request(callee_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); } else { @@ -623,8 +623,8 @@ static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ /*check video path is established in both directions. Indeed, FIR are ignored until the first RTP packet is received, because SSRC is not known.*/ - linphone_call_set_first_video_frame_decoded_cb(callee_call); - linphone_call_set_first_video_frame_decoded_cb(caller_call); + liblinphone_tester_set_next_video_frame_decoded_cb(callee_call); + liblinphone_tester_set_next_video_frame_decoded_cb(caller_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); @@ -640,7 +640,7 @@ static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ ms_message("check_fir: [%p] received %d FIR ",&caller_call ,caller_vstream->ms_video_stat.counter_rcvd_fir); ms_message("check_fir: [%p] stat number of iframe decoded %d ",&callee_call, callee->stat.number_of_IframeDecoded); - linphone_call_set_first_video_frame_decoded_cb(caller_call); + liblinphone_tester_set_next_video_frame_decoded_cb(caller_call); linphone_call_send_vfu_request(caller_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); @@ -669,6 +669,12 @@ void video_call_base_3(LinphoneCoreManager* caller,LinphoneCoreManager* callee, linphone_core_set_video_policy(callee->lc,&callee_policy); linphone_core_set_video_policy(caller->lc,&caller_policy); } + + linphone_core_set_preferred_video_size_by_name(caller->lc, "QVGA"); + linphone_core_set_preferred_video_size_by_name(callee->lc, "QVGA"); + + linphone_core_set_video_device(caller->lc, "Mire: Mire (synthetic moving picture)"); + linphone_core_set_video_device(callee->lc, "Mire: Mire (synthetic moving picture)"); linphone_core_enable_video_display(callee->lc, callee_video_enabled); linphone_core_enable_video_capture(callee->lc, callee_video_enabled); @@ -879,8 +885,8 @@ static void video_call_established_by_reinvite_with_implicit_avpf(void) { BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(callee_call))); BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(caller_call))); - linphone_call_set_first_video_frame_decoded_cb(caller_call); - linphone_call_set_first_video_frame_decoded_cb(callee_call); + liblinphone_tester_set_next_video_frame_decoded_cb(caller_call); + liblinphone_tester_set_next_video_frame_decoded_cb(callee_call); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); @@ -1329,7 +1335,7 @@ static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, Linphone /*The send-only client shall set rtp symmetric in absence of media relay for this test.*/ lp_config_set_int(linphone_core_get_config(marie->lc),"rtp","symmetric",1); - linphone_call_set_first_video_frame_decoded_cb(linphone_core_invite_address(pauline->lc,marie->identity)); + liblinphone_tester_set_next_video_frame_decoded_cb(linphone_core_invite_address(pauline->lc,marie->identity)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,DEFAULT_WAIT_FOR)); @@ -1420,8 +1426,6 @@ static void video_early_media_call(void) { LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); LinphoneCall *pauline_to_marie; - linphone_core_set_video_device(pauline->lc, "Mire: Mire (synthetic moving picture)"); - video_call_base_3(pauline, marie, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); BC_ASSERT_PTR_NOT_NULL(pauline_to_marie = linphone_core_get_current_call(pauline->lc)); diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 9a4000c59..a56b27147 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -410,7 +410,7 @@ void account_manager_destroy(void); LinphoneAddress *account_manager_get_identity_with_modified_identity(const LinphoneAddress *modified_identity); LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, const char *file, void *user_data); -void linphone_call_set_first_video_frame_decoded_cb(LinphoneCall *call); +void liblinphone_tester_set_next_video_frame_decoded_cb(LinphoneCall *call); void call_paused_resumed_base(bool_t multicast,bool_t with_losses); void simple_call_base(bool_t enable_multicast_recv_side); void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel, const char *marie_rc, const char *pauline_rc);