/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef HW_CAST_PROVIDER_H #define HW_CAST_PROVIDER_H #include #include "cast_session_manager.h" #include "i_avcast_controller_proxy.h" #include "i_cast_session.h" #include "i_stream_player.h" #include "i_cast_session_manager_listener.h" #include "hw_cast_provider_session.h" #include "avsession_info.h" #include "av_cast_provider.h" namespace OHOS::AVSession { class HwCastProvider : public AVCastProvider, public CastEngine::ICastSessionManagerListener, public std::enable_shared_from_this { public: HwCastProvider(); ~HwCastProvider() override; int32_t Init() override; int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) override; int32_t StopDeviceLogging() override; bool StartDiscovery(int castCapability, std::vector drmSchemes) override; void StopDiscovery() override; int32_t SetDiscoverable(const bool enable) override; void Release() override; int StartCastSession() override; void StopCastSession(int castId) override; bool AddCastDevice(int castId, DeviceInfo deviceInfo) override; bool RemoveCastDevice(int castId, DeviceInfo deviceInfo) override; std::shared_ptr GetRemoteController(int castId) override; bool RegisterCastStateListener(std::shared_ptr listener) override; bool UnRegisterCastStateListener(std::shared_ptr listener) override; bool RegisterCastSessionStateListener(int castId, std::shared_ptr listener) override; bool UnRegisterCastSessionStateListener(int castId, std::shared_ptr listener) override; void OnDeviceFound(const std::vector &deviceList) override; void OnLogEvent(const int32_t eventId, const int64_t param) override; void OnDeviceOffline(const std::string &deviceId) override; void OnSessionCreated(const std::shared_ptr &castSession) override; void OnServiceDied() override; bool SetStreamState(int64_t castHandle, DeviceInfo deviceInfo) override; int64_t GetMirrorCastHandle() override; bool GetRemoteNetWorkId(int32_t castId, std::string deviceId, std::string &networkId) override; int32_t GetProtocolType(uint32_t castProtocolType) override; private: static const int maxCastSessionSize = 256; std::vector castFlag_ = std::vector(maxCastSessionSize, false); std::map> hwCastProviderSessionMap_; std::map> avCastControllerMap_; std::vector> castStateListenerList_; std::recursive_mutex mutexLock_; bool isRelease_ = false; int64_t mirrorCastHandle = -1; }; } // namespace OHOS::AVSession #endif