• 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_SERVICE_PROXY_H
17 #define OHOS_AVSESSION_SERVICE_PROXY_H
18 
19 #include "iavsession_service.h"
20 #include "iremote_proxy.h"
21 #include "av_session.h"
22 #include "avsession_controller.h"
23 #include "avsession_errors.h"
24 
25 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
26 #include "avcast_controller.h"
27 #endif
28 
29 namespace OHOS::AVSession {
30 class AVSessionServiceProxy : public IRemoteProxy<IAVSessionService> {
31 public:
32     explicit AVSessionServiceProxy(const sptr<IRemoteObject>& impl);
33 
34     std::shared_ptr<AVSession> CreateSession(const std::string& tag, int32_t type,
35                                              const AppExecFwk::ElementName& elementName);
36 
37     sptr<IRemoteObject> CreateSessionInner(const std::string& tag, int32_t type,
38                                            const AppExecFwk::ElementName& elementName) override;
39 
40     int32_t GetAllSessionDescriptors(std::vector<AVSessionDescriptor>& descriptors) override;
41 
42     int32_t GetSessionDescriptorsBySessionId(const std::string& sessionId, AVSessionDescriptor& descriptor) override;
43 
44     int32_t GetHistoricalSessionDescriptors(int32_t maxSize, std::vector<AVSessionDescriptor>& descriptors) override;
45 
46     int32_t CreateController(const std::string& sessionId, std::shared_ptr<AVSessionController>& controller);
47 
48     int32_t CreateControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) override;
49 
50 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
51     int32_t GetAVCastController(const std::string& sessionId, std::shared_ptr<AVCastController>& castController);
52 
53     int32_t GetAVCastControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) override;
54 #endif
55 
56     int32_t RegisterSessionListener(const sptr<ISessionListener>& listener) override;
57 
58     int32_t SendSystemAVKeyEvent(const MMI::KeyEvent& keyEvent) override;
59 
60     int32_t SendSystemControlCommand(const AVControlCommand& command) override;
61 
62     int32_t RegisterClientDeathObserver(const sptr<IClientDeath>& observer) override;
63 
64     int32_t CastAudio(const SessionToken& token,
65                       const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) override;
66 
67     int32_t CastAudioForAll(const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) override;
68 
ProcessCastAudioCommand(const RemoteServiceCommand command,const std::string & input,std::string & output)69     int32_t ProcessCastAudioCommand(const RemoteServiceCommand command, const std::string& input,
70                                     std::string& output) override
71     {
72         return AVSESSION_SUCCESS;
73     }
74 
75 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
76     int32_t StartCastDiscovery(int32_t castDeviceCapability);
77 
78     int32_t StopCastDiscovery();
79 
80     int32_t SetDiscoverable(const bool enable);
81 
82     int32_t StartCast(const SessionToken& sessionToken, const OutputDeviceInfo& outputDeviceInfo) override;
83 
84     int32_t StopCast(const SessionToken& sessionToken) override;
85 #endif
86 
87 private:
88     static inline BrokerDelegator<AVSessionServiceProxy> delegator_;
89 };
90 } // namespace OHOS
91 #endif // OHOS_AVSESSION_SERVICE_PROXY_H
92