• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_CONTROLLER_PROXY_H
17 #define OHOS_AVSESSION_CONTROLLER_PROXY_H
18 
19 #include <mutex>
20 
21 #include "iavsession_controller.h"
22 #include "iremote_proxy.h"
23 #include "avcontroller_callback_client.h"
24 
25 namespace OHOS::AVSession {
26 class AVSessionControllerProxy : public IRemoteProxy<IAVSessionController> {
27 public:
28     explicit AVSessionControllerProxy(const sptr<IRemoteObject>& impl);
29 
30     ~AVSessionControllerProxy() override;
31 
32     int32_t GetAVCallState(AVCallState& avCallState) override;
33 
34     int32_t GetAVCallMetaData(AVCallMetaData& avCallMetaData) override;
35 
36     int32_t GetAVPlaybackState(AVPlaybackState& state) override;
37 
38     int32_t GetAVMetaData(AVMetaData& data) override;
39 
40     int32_t SendAVKeyEvent(const MMI::KeyEvent& keyEvent) override;
41 
42     int32_t GetLaunchAbility(AbilityRuntime::WantAgent::WantAgent& ability) override;
43 
44     int32_t GetLaunchAbilityInner(AbilityRuntime::WantAgent::WantAgent*& ability) override;
45 
46     int32_t GetValidCommands(std::vector<int32_t>& cmds) override;
47 
48     int32_t IsSessionActive(bool& isActive) override;
49 
50     int32_t SendControlCommand(const AVControlCommand& cmd) override;
51 
52     int32_t SendCommonCommand(const std::string& commonCommand, const AAFwk::WantParams& commandArgs) override;
53 
54     int32_t RegisterCallback(const std::shared_ptr<AVControllerCallback>& callback) override;
55 
56     int32_t SetAVCallMetaFilter(const AVCallMetaData::AVCallMetaMaskType& filter) override;
57 
58     int32_t SetAVCallStateFilter(const AVCallState::AVCallStateMaskType& filter) override;
59 
60     int32_t SetMetaFilter(const AVMetaData::MetaMaskType& filter) override;
61 
62     int32_t SetPlaybackFilter(const AVPlaybackState::PlaybackStateMaskType& filter) override;
63 
64     int32_t GetAVQueueItems(std::vector<AVQueueItem>& items) override;
65 
66     int32_t GetAVQueueTitle(std::string& title) override;
67 
68     int32_t SkipToQueueItem(int32_t& itemId) override;
69 
70     int32_t GetExtras(AAFwk::WantParams& extras) override;
71 
72     int32_t GetExtrasWithEvent(const std::string& extraEvent, AAFwk::WantParams& extras) override;
73 
74     int32_t Destroy() override;
75 
76     std::string GetSessionId() override;
77 
78     int64_t GetRealPlaybackPosition() override;
79 
80     bool IsDestroy() override;
81 
82 protected:
83     int32_t RegisterCallbackInner(const sptr<IRemoteObject>& callback) override;
84 
85 private:
86     static inline BrokerDelegator<AVSessionControllerProxy> delegator_;
87     const size_t defaultIpcCapacity = 1048576; // Increase the IPC default capacity(200K) to 1M
88     std::recursive_mutex currentStateLock_;
89     AVPlaybackState currentState_;
90     bool isDestroy_ = false;
91     const int32_t maxItemNumber = 1000;
92     const int32_t maxImageSize = 10 * 1024 * 1024;
93 
94     std::recursive_mutex controllerProxyLock_;
95     sptr<AVControllerCallbackClient> callback_;
96 };
97 }
98 
99 #endif // OHOS_AVSESSION_CONTROLLER_PROXY_H