180922886Sopenharmony_ci/* 280922886Sopenharmony_ci * Copyright (c) 2022-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#ifndef OHOS_AVSESSION_PROXY_H 1780922886Sopenharmony_ci#define OHOS_AVSESSION_PROXY_H 1880922886Sopenharmony_ci 1980922886Sopenharmony_ci#include <mutex> 2080922886Sopenharmony_ci 2180922886Sopenharmony_ci#include "iav_session.h" 2280922886Sopenharmony_ci#include "iremote_proxy.h" 2380922886Sopenharmony_ci#include "want_agent.h" 2480922886Sopenharmony_ci#include "avcall_meta_data.h" 2580922886Sopenharmony_ci#include "avcall_state.h" 2680922886Sopenharmony_ci#include "avsession_log.h" 2780922886Sopenharmony_ci#include "avsession_errors.h" 2880922886Sopenharmony_ci#include "avmeta_data.h" 2980922886Sopenharmony_ci#include "avplayback_state.h" 3080922886Sopenharmony_ci#include "avmedia_description.h" 3180922886Sopenharmony_ci#include "avqueue_item.h" 3280922886Sopenharmony_ci 3380922886Sopenharmony_cinamespace OHOS::AVSession { 3480922886Sopenharmony_ciclass AVSessionProxy : public IRemoteProxy<IAVSession> { 3580922886Sopenharmony_cipublic: 3680922886Sopenharmony_ci explicit AVSessionProxy(const sptr<IRemoteObject>& impl); 3780922886Sopenharmony_ci 3880922886Sopenharmony_ci ~AVSessionProxy() override; 3980922886Sopenharmony_ci 4080922886Sopenharmony_ci std::string GetSessionId() override; 4180922886Sopenharmony_ci 4280922886Sopenharmony_ci std::string GetSessionType() override; 4380922886Sopenharmony_ci 4480922886Sopenharmony_ci int32_t SetAVCallMetaData(const AVCallMetaData& avCallMetaData) override; 4580922886Sopenharmony_ci 4680922886Sopenharmony_ci int32_t SetAVCallState(const AVCallState& avCallState) override; 4780922886Sopenharmony_ci 4880922886Sopenharmony_ci int32_t GetAVMetaData(AVMetaData& meta) override; 4980922886Sopenharmony_ci 5080922886Sopenharmony_ci int32_t SetAVMetaData(const AVMetaData& meta) override; 5180922886Sopenharmony_ci 5280922886Sopenharmony_ci int32_t GetAVPlaybackState(AVPlaybackState& state) override; 5380922886Sopenharmony_ci 5480922886Sopenharmony_ci int32_t SetAVPlaybackState(const AVPlaybackState& state) override; 5580922886Sopenharmony_ci 5680922886Sopenharmony_ci int32_t GetAVQueueItems(std::vector<AVQueueItem>& items) override; 5780922886Sopenharmony_ci 5880922886Sopenharmony_ci int32_t SetAVQueueItems(const std::vector<AVQueueItem>& items) override; 5980922886Sopenharmony_ci 6080922886Sopenharmony_ci int32_t GetAVQueueTitle(std::string& title) override; 6180922886Sopenharmony_ci 6280922886Sopenharmony_ci int32_t SetAVQueueTitle(const std::string& title) override; 6380922886Sopenharmony_ci 6480922886Sopenharmony_ci int32_t SetLaunchAbility(const AbilityRuntime::WantAgent::WantAgent& ability) override; 6580922886Sopenharmony_ci 6680922886Sopenharmony_ci int32_t GetExtras(AAFwk::WantParams& extras) override; 6780922886Sopenharmony_ci 6880922886Sopenharmony_ci int32_t SetExtras(const AAFwk::WantParams& extras) override; 6980922886Sopenharmony_ci 7080922886Sopenharmony_ci std::shared_ptr<AVSessionController> GetController() override; 7180922886Sopenharmony_ci 7280922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 7380922886Sopenharmony_ci std::shared_ptr<AVCastController> GetAVCastController() override; 7480922886Sopenharmony_ci 7580922886Sopenharmony_ci int32_t StartCastDisplayListener() override; 7680922886Sopenharmony_ci 7780922886Sopenharmony_ci int32_t StopCastDisplayListener() override; 7880922886Sopenharmony_ci 7980922886Sopenharmony_ci int32_t GetAllCastDisplays(std::vector<CastDisplayInfo>& castDisplays) override; 8080922886Sopenharmony_ci#endif 8180922886Sopenharmony_ci 8280922886Sopenharmony_ci int32_t RegisterCallback(const std::shared_ptr<AVSessionCallback>& callback) override; 8380922886Sopenharmony_ci 8480922886Sopenharmony_ci int32_t Activate() override; 8580922886Sopenharmony_ci 8680922886Sopenharmony_ci int32_t Deactivate() override; 8780922886Sopenharmony_ci 8880922886Sopenharmony_ci bool IsActive() override; 8980922886Sopenharmony_ci 9080922886Sopenharmony_ci int32_t Destroy() override; 9180922886Sopenharmony_ci 9280922886Sopenharmony_ci int32_t AddSupportCommand(const int32_t cmd) override; 9380922886Sopenharmony_ci 9480922886Sopenharmony_ci int32_t DeleteSupportCommand(const int32_t cmd) override; 9580922886Sopenharmony_ci 9680922886Sopenharmony_ci int32_t SetSessionEvent(const std::string& event, const AAFwk::WantParams& args) override; 9780922886Sopenharmony_ci 9880922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 9980922886Sopenharmony_ci int32_t ReleaseCast() override; 10080922886Sopenharmony_ci#endif 10180922886Sopenharmony_ci 10280922886Sopenharmony_ciprotected: 10380922886Sopenharmony_ci int32_t RegisterCallbackInner(const sptr<IAVSessionCallback>& callback) override; 10480922886Sopenharmony_ci sptr<IRemoteObject> GetControllerInner() override; 10580922886Sopenharmony_ci 10680922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 10780922886Sopenharmony_ci sptr<IRemoteObject> GetAVCastControllerInner() override; 10880922886Sopenharmony_ci#endif 10980922886Sopenharmony_ci 11080922886Sopenharmony_ciprivate: 11180922886Sopenharmony_ci int32_t GetPixelMapBuffer(AVMetaData& metaData, MessageParcel& data); 11280922886Sopenharmony_ci sptr<IAVSessionCallback> callback_; 11380922886Sopenharmony_ci static inline BrokerDelegator<AVSessionProxy> delegator_; 11480922886Sopenharmony_ci bool isDestroyed_ = {}; 11580922886Sopenharmony_ci std::shared_ptr<AVSessionController> controller_; 11680922886Sopenharmony_ci const size_t defaultIpcCapacity = 1048576; // Increase the IPC default capacity(200K) to 1M 11780922886Sopenharmony_ci std::mutex setMetadataLock_; 11880922886Sopenharmony_ci std::mutex setPlaybackLock_; 11980922886Sopenharmony_ci std::mutex setCommandLock_; 12080922886Sopenharmony_ci std::mutex isDestroyedLock_; 12180922886Sopenharmony_ci 12280922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE 12380922886Sopenharmony_ci std::shared_ptr<AVCastController> castController_; 12480922886Sopenharmony_ci#endif 12580922886Sopenharmony_ci}; 12680922886Sopenharmony_ci} 12780922886Sopenharmony_ci#endif // OHOS_AVSESSION_PROXY_H