1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_AVSESSION_PROXY_H 17 #define OHOS_AVSESSION_PROXY_H 18 19 #include "iav_session.h" 20 #include "iremote_proxy.h" 21 #include "want_agent.h" 22 #include "avsession_log.h" 23 #include "avsession_errors.h" 24 #include "avmeta_data.h" 25 #include "avplayback_state.h" 26 #include "avmedia_description.h" 27 #include "avqueue_item.h" 28 29 namespace OHOS::AVSession { 30 class AVSessionProxy : public IRemoteProxy<IAVSession> { 31 public: 32 explicit AVSessionProxy(const sptr<IRemoteObject>& impl); 33 34 ~AVSessionProxy() override; 35 36 std::string GetSessionId() override; 37 38 std::string GetSessionType() override; 39 40 int32_t GetAVMetaData(AVMetaData& meta) override; 41 42 int32_t SetAVMetaData(const AVMetaData& meta) override; 43 44 int32_t GetAVPlaybackState(AVPlaybackState& state) override; 45 46 int32_t SetAVPlaybackState(const AVPlaybackState& state) override; 47 48 int32_t GetAVQueueItems(std::vector<AVQueueItem>& items) override; 49 50 int32_t SetAVQueueItems(const std::vector<AVQueueItem>& items) override; 51 52 int32_t GetAVQueueTitle(std::string& title) override; 53 54 int32_t SetAVQueueTitle(const std::string& title) override; 55 56 int32_t SetLaunchAbility(const AbilityRuntime::WantAgent::WantAgent& ability) override; 57 58 int32_t GetExtras(AAFwk::WantParams& extras) override; 59 60 int32_t SetExtras(const AAFwk::WantParams& extras) override; 61 62 std::shared_ptr<AVSessionController> GetController() override; 63 64 #ifdef CASTPLUS_CAST_ENGINE_ENABLE 65 std::shared_ptr<AVCastController> GetAVCastController() override; 66 #endif 67 68 int32_t RegisterCallback(const std::shared_ptr<AVSessionCallback>& callback) override; 69 70 int32_t Activate() override; 71 72 int32_t Deactivate() override; 73 74 bool IsActive() override; 75 76 int32_t Destroy() override; 77 78 int32_t AddSupportCommand(const int32_t cmd) override; 79 80 int32_t DeleteSupportCommand(const int32_t cmd) override; 81 82 int32_t SetSessionEvent(const std::string& event, const AAFwk::WantParams& args) override; 83 84 #ifdef CASTPLUS_CAST_ENGINE_ENABLE 85 int32_t ReleaseCast() override; 86 #endif 87 88 protected: 89 int32_t RegisterCallbackInner(const sptr<IAVSessionCallback>& callback) override; 90 sptr<IRemoteObject> GetControllerInner() override; 91 92 #ifdef CASTPLUS_CAST_ENGINE_ENABLE 93 sptr<IRemoteObject> GetAVCastControllerInner() override; 94 #endif 95 96 private: 97 sptr<IAVSessionCallback> callback_; 98 static inline BrokerDelegator<AVSessionProxy> delegator_; 99 bool isDestroyed_ = {}; 100 std::shared_ptr<AVSessionController> controller_; 101 102 #ifdef CASTPLUS_CAST_ENGINE_ENABLE 103 std::shared_ptr<AVCastController> castController_; 104 #endif 105 }; 106 } 107 #endif // OHOS_AVSESSION_PROXY_H