• 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_IAVSESSION_SERVICE_H
17 #define OHOS_IAVSESSION_SERVICE_H
18 
19 #include "audio_system_manager.h"
20 #include "iremote_broker.h"
21 #include "iav_session.h"
22 #include "iavsession_service_ipc_interface_code.h"
23 #include "iclient_death.h"
24 #include "isession_listener.h"
25 #include "key_event.h"
26 #include "avqueue_info.h"
27 
28 namespace OHOS::AVSession {
29 class IAVSessionService : public IRemoteBroker {
30 public:
31     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.avsession.IAVSessionService");
32 
33     enum RemoteServiceCommand {
34         COMMAND_INVALID = -1,
35         COMMAND_CAST_AUDIO = 0,
36         COMMAND_CANCEL_CAST_AUDIO = 1,
37         COMMAND_MAX = 2
38     };
39 
40     virtual sptr<IRemoteObject> CreateSessionInner(const std::string& tag, int32_t type,
41                                                    const AppExecFwk::ElementName& elementName) = 0;
42 
43     virtual int32_t CreateSessionInner(const std::string& tag, int32_t type, const AppExecFwk::ElementName& elementName,
44                                        sptr<IRemoteObject>& session) = 0;
45 
46     virtual int32_t CreateSessionInnerWithExtra(const std::string& tag, int32_t type, const std::string& extraInfo,
47                                            const AppExecFwk::ElementName& elementName,
48                                            sptr<IRemoteObject>& session) = 0;
49 
50     virtual int32_t GetAllSessionDescriptors(std::vector<AVSessionDescriptor>& descriptors) = 0;
51 
52     virtual int32_t GetSessionDescriptorsBySessionId(const std::string& sessionId,
53         AVSessionDescriptor& descriptor) = 0;
54 
55     virtual int32_t GetHistoricalSessionDescriptors(int32_t maxSize, std::vector<AVSessionDescriptor>& descriptors) = 0;
56 
57     virtual int32_t GetHistoricalAVQueueInfos(int32_t maxSize, int32_t maxAppSize,
58                                               std::vector<AVQueueInfo>& avQueueInfos) = 0;
59 
60     virtual int32_t StartAVPlayback(const std::string& bundleName, const std::string& assetId) = 0;
61 
62     virtual int32_t CreateControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) = 0;
63 
64 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
65     virtual int32_t GetAVCastControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) = 0;
66 #endif
67 
68     virtual int32_t RegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
69 
70     virtual int32_t RegisterSessionListenerForAllUsers(const sptr<ISessionListener>& listener) = 0;
71 
72     virtual int32_t SendSystemAVKeyEvent(const MMI::KeyEvent& keyEvent) = 0;
73 
74     virtual int32_t SendSystemAVKeyEvent(const MMI::KeyEvent& keyEvent, const AAFwk::Want &wantParam) = 0;
75 
76     virtual int32_t SendSystemControlCommand(const AVControlCommand& command) = 0;
77 
78     virtual int32_t RegisterClientDeathObserver(const sptr<IClientDeath>& observer) = 0;
79 
80     virtual int32_t CastAudio(const SessionToken& token,
81                               const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) = 0;
82 
83     virtual int32_t CastAudioForAll(const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) = 0;
84 
85     virtual int32_t ProcessCastAudioCommand(const RemoteServiceCommand command, const std::string& input,
86                                             std::string& output) = 0;
87 
88 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
89     virtual int32_t StartCast(const SessionToken& sessionToken, const OutputDeviceInfo& outputDeviceInfo) = 0;
90 
91     virtual int32_t StopCast(const SessionToken& sessionToken) = 0;
92 
93     virtual int32_t checkEnableCast(bool enable) = 0;
94 #endif
95 
96     virtual int32_t Close() = 0;
97 
98     virtual int32_t GetDistributedSessionControllersInner(const DistributedSessionType& sessionType,
99         std::vector<sptr<IRemoteObject>>& sessionControllers) = 0;
100 };
101 } // namespace OHOS::AVSession
102 #endif // OHOS_IAVSESSION_SERVICE_H
103