diff options
author | Serhii Niukalov (GitHub) <36993782+SNiukalov@users.noreply.github.com> | 2020-03-19 18:16:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-19 12:16:54 -0400 |
commit | 15b80391c957d7cc16bce40ff69b14fb1958a3f6 (patch) | |
tree | b0c1690cb572880a4ea362470fed147b78dedb3d /src/components/application_manager | |
parent | 9bc0cfd17259601f8e9eb71724b29cecf3d15be0 (diff) | |
download | sdl_core-15b80391c957d7cc16bce40ff69b14fb1958a3f6.tar.gz |
Fix/consider timeouts during streaming switching (#3293)
* Consider video and audio status before send end of service
Co-authored-by: sniukalov <sniukaov@luxoft.com>
Diffstat (limited to 'src/components/application_manager')
-rw-r--r-- | src/components/application_manager/include/application_manager/application_manager_impl.h | 8 | ||||
-rw-r--r-- | src/components/application_manager/src/application_manager_impl.cc | 59 |
2 files changed, 63 insertions, 4 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 0bab0243d0..1e171ed81b 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -834,12 +834,12 @@ class ApplicationManagerImpl */ void EndNaviServices(uint32_t app_id) OVERRIDE; - /** - * @brief ForbidStreaming forbid the stream over the certain application. - * @param app_id the application's id which should stop streaming. - */ + DEPRECATED void ForbidStreaming(uint32_t app_id) OVERRIDE; + void ForbidStreaming(uint32_t app_id, + protocol_handler::ServiceType service_type) OVERRIDE; + /** * @brief Called when application completes streaming configuration * @param app_id Streaming application id diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 303dca3b65..344240add9 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -3510,6 +3510,65 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { EndNaviServices(app_id); } +void ApplicationManagerImpl::ForbidStreaming( + uint32_t app_id, protocol_handler::ServiceType service_type) { + using namespace mobile_apis::AppInterfaceUnregisteredReason; + using namespace mobile_apis::Result; + using namespace protocol_handler; + + LOG4CXX_AUTO_TRACE(logger_); + + ApplicationSharedPtr app = application(app_id); + if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) { + LOG4CXX_DEBUG( + logger_, + "There is no navi or projection application with id: " << app_id); + return; + } + + if (navi_app_to_stop_.end() != std::find(navi_app_to_stop_.begin(), + navi_app_to_stop_.end(), + app_id) || + navi_app_to_end_stream_.end() != + std::find(navi_app_to_end_stream_.begin(), + navi_app_to_end_stream_.end(), + app_id)) { + return; + } + + bool unregister = false; + { + sync_primitives::AutoLock lock(navi_service_status_lock_); + + NaviServiceStatusMap::iterator it = navi_service_status_.find(app_id); + if (navi_service_status_.end() == it || + (!it->second.first && !it->second.second)) { + unregister = true; + } + } + if (unregister) { + rpc_service_->ManageMobileCommand( + MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile( + app_id, PROTOCOL_VIOLATION), + commands::Command::SOURCE_SDL); + UnregisterApplication(app_id, ABORTED); + return; + } + + if (ServiceType::kMobileNav == service_type && + app->video_streaming_allowed()) { + LOG4CXX_DEBUG(logger_, "Video streaming is still allowed"); + return; + } + + if (ServiceType::kAudio == service_type && app->audio_streaming_allowed()) { + LOG4CXX_DEBUG(logger_, "Audio streaming is still allowed"); + return; + } + + EndNaviServices(app_id); +} + void ApplicationManagerImpl::OnAppStreaming( uint32_t app_id, protocol_handler::ServiceType service_type, bool state) { LOG4CXX_AUTO_TRACE(logger_); |