180922886Sopenharmony_ci/* 280922886Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 380922886Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 480922886Sopenharmony_ci * you may not use this file except in compliance with the License. 580922886Sopenharmony_ci * You may obtain a copy of the License at 680922886Sopenharmony_ci * 780922886Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 880922886Sopenharmony_ci * 980922886Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1080922886Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1180922886Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1280922886Sopenharmony_ci * See the License for the specific language governing permissions and 1380922886Sopenharmony_ci * limitations under the License. 1480922886Sopenharmony_ci */ 1580922886Sopenharmony_ci 1680922886Sopenharmony_ci#include "avcast_provider_manager.h" 1780922886Sopenharmony_ci#include "av_router.h" 1880922886Sopenharmony_ci#include "avsession_log.h" 1980922886Sopenharmony_cinamespace OHOS::AVSession { 2080922886Sopenharmony_ciAVCastProviderManager::AVCastProviderManager() 2180922886Sopenharmony_ci{ 2280922886Sopenharmony_ci SLOGD("AVCastProviderManager construct"); 2380922886Sopenharmony_ci} 2480922886Sopenharmony_ci 2580922886Sopenharmony_ci// LCOV_EXCL_START 2680922886Sopenharmony_civoid AVCastProviderManager::Init(int32_t providerId, std::shared_ptr<AVCastProvider> provider) 2780922886Sopenharmony_ci{ 2880922886Sopenharmony_ci providerId_ = providerId; 2980922886Sopenharmony_ci provider_ = provider; 3080922886Sopenharmony_ci} 3180922886Sopenharmony_ci 3280922886Sopenharmony_civoid AVCastProviderManager::OnDeviceAvailable(std::vector<DeviceInfo> deviceInfos) 3380922886Sopenharmony_ci{ 3480922886Sopenharmony_ci SLOGI("On device available"); 3580922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 3680922886Sopenharmony_ci for (size_t i = 0; i < deviceInfos.size(); i++) { 3780922886Sopenharmony_ci deviceInfos[i].providerId_ = providerId_; 3880922886Sopenharmony_ci } 3980922886Sopenharmony_ci OutputDeviceInfo outputDeviceInfo; 4080922886Sopenharmony_ci outputDeviceInfo.deviceInfos_ = deviceInfos; 4180922886Sopenharmony_ci AVRouter::GetInstance().OnDeviceAvailable(outputDeviceInfo); 4280922886Sopenharmony_ci#endif 4380922886Sopenharmony_ci} 4480922886Sopenharmony_ci// LCOV_EXCL_STOP 4580922886Sopenharmony_ci 4680922886Sopenharmony_civoid AVCastProviderManager::OnDeviceLogEvent(const DeviceLogEventCode eventId, const int64_t param) 4780922886Sopenharmony_ci{ 4880922886Sopenharmony_ci SLOGI("On device log event"); 4980922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 5080922886Sopenharmony_ci AVRouter::GetInstance().OnDeviceLogEvent(eventId, param); 5180922886Sopenharmony_ci#endif 5280922886Sopenharmony_ci} 5380922886Sopenharmony_ci 5480922886Sopenharmony_civoid AVCastProviderManager::OnSessionNeedDestroy() 5580922886Sopenharmony_ci{ 5680922886Sopenharmony_ci SLOGI("On cast session need destroy"); 5780922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 5880922886Sopenharmony_ci AVRouter::GetInstance().ReleaseCurrentCastSession(); 5980922886Sopenharmony_ci#endif 6080922886Sopenharmony_ci} 6180922886Sopenharmony_ci 6280922886Sopenharmony_civoid AVCastProviderManager::OnSessionCreated(const int32_t castId) 6380922886Sopenharmony_ci{ 6480922886Sopenharmony_ci SLOGI("On cast session created"); 6580922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 6680922886Sopenharmony_ci AVRouter::GetInstance().OnCastSessionCreated(castId); 6780922886Sopenharmony_ci#endif 6880922886Sopenharmony_ci} 6980922886Sopenharmony_ci 7080922886Sopenharmony_ci// LCOV_EXCL_START 7180922886Sopenharmony_civoid AVCastProviderManager::OnDeviceOffline(const std::string& deviceId) 7280922886Sopenharmony_ci{ 7380922886Sopenharmony_ci SLOGI("On device offline"); 7480922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 7580922886Sopenharmony_ci AVRouter::GetInstance().OnDeviceOffline(deviceId); 7680922886Sopenharmony_ci#endif 7780922886Sopenharmony_ci} 7880922886Sopenharmony_ci 7980922886Sopenharmony_civoid AVCastProviderManager::OnCastServerDied() 8080922886Sopenharmony_ci{ 8180922886Sopenharmony_ci SLOGI("On cast server died"); 8280922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 8380922886Sopenharmony_ci AVRouter::GetInstance().OnCastServerDied(providerId_); 8480922886Sopenharmony_ci#endif 8580922886Sopenharmony_ci} 8680922886Sopenharmony_ci// LCOV_EXCL_STOP 8780922886Sopenharmony_ci} // namespace OHOS::AVSession 88