• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "avcall_meta_data.h"
23 #include "avcall_state.h"
24 #include "avsession_log.h"
25 #include "avsession_errors.h"
26 #include "avmeta_data.h"
27 #include "avplayback_state.h"
28 #include "avmedia_description.h"
29 #include "avqueue_item.h"
30 
31 namespace OHOS::AVSession {
32 class AVSessionProxy : public IRemoteProxy<IAVSession> {
33 public:
34     explicit AVSessionProxy(const sptr<IRemoteObject>& impl);
35 
36     ~AVSessionProxy() override;
37 
38     std::string GetSessionId() override;
39 
40     std::string GetSessionType() override;
41 
42     int32_t SetAVCallMetaData(const AVCallMetaData& avCallMetaData) override;
43 
44     int32_t SetAVCallState(const AVCallState& avCallState) override;
45 
46     int32_t GetAVMetaData(AVMetaData& meta) override;
47 
48     int32_t SetAVMetaData(const AVMetaData& meta) override;
49 
50     int32_t GetAVPlaybackState(AVPlaybackState& state) override;
51 
52     int32_t SetAVPlaybackState(const AVPlaybackState& state) override;
53 
54     int32_t GetAVQueueItems(std::vector<AVQueueItem>& items) override;
55 
56     int32_t SetAVQueueItems(const std::vector<AVQueueItem>& items) override;
57 
58     int32_t GetAVQueueTitle(std::string& title) override;
59 
60     int32_t SetAVQueueTitle(const std::string& title) override;
61 
62     int32_t SetLaunchAbility(const AbilityRuntime::WantAgent::WantAgent& ability) override;
63 
64     int32_t GetExtras(AAFwk::WantParams& extras) override;
65 
66     int32_t SetExtras(const AAFwk::WantParams& extras) override;
67 
68     std::shared_ptr<AVSessionController> GetController() override;
69 
70 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
71     std::shared_ptr<AVCastController> GetAVCastController() override;
72 #endif
73 
74     int32_t RegisterCallback(const std::shared_ptr<AVSessionCallback>& callback) override;
75 
76     int32_t Activate() override;
77 
78     int32_t Deactivate() override;
79 
80     bool IsActive() override;
81 
82     int32_t Destroy() override;
83 
84     int32_t AddSupportCommand(const int32_t cmd) override;
85 
86     int32_t DeleteSupportCommand(const int32_t cmd) override;
87 
88     int32_t SetSessionEvent(const std::string& event, const AAFwk::WantParams& args) override;
89 
90 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
91     int32_t ReleaseCast() override;
92 #endif
93 
94 protected:
95     int32_t RegisterCallbackInner(const sptr<IAVSessionCallback>& callback) override;
96     sptr<IRemoteObject> GetControllerInner() override;
97 
98 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
99     sptr<IRemoteObject> GetAVCastControllerInner() override;
100 #endif
101 
102 private:
103     int32_t GetPixelMapBuffer(AVMetaData& metaData, MessageParcel& data);
104     sptr<IAVSessionCallback> callback_;
105     static inline BrokerDelegator<AVSessionProxy> delegator_;
106     bool isDestroyed_ = {};
107     std::shared_ptr<AVSessionController> controller_;
108     const size_t DEFAULT_IPC_CAPACITY = 1048576; // Increase the IPC default capacity(200K) to 1M
109 
110 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
111     std::shared_ptr<AVCastController> castController_;
112 #endif
113 };
114 }
115 #endif // OHOS_AVSESSION_PROXY_H