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 GetAllSessionDescriptors(std::vector<AVSessionDescriptor>& descriptors) = 0;
47 
48     virtual int32_t GetSessionDescriptorsBySessionId(const std::string& sessionId,
49         AVSessionDescriptor& descriptor) = 0;
50 
51     virtual int32_t GetHistoricalSessionDescriptors(int32_t maxSize, std::vector<AVSessionDescriptor>& descriptors) = 0;
52 
53     virtual int32_t GetHistoricalAVQueueInfos(int32_t maxSize, int32_t maxAppSize,
54                                               std::vector<AVQueueInfo>& avQueueInfos) = 0;
55 
56     virtual int32_t StartAVPlayback(const std::string& bundleName, const std::string& assetId) = 0;
57 
58     virtual int32_t CreateControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) = 0;
59 
60 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
61     virtual int32_t GetAVCastControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) = 0;
62 #endif
63 
64     virtual int32_t RegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
65 
66     virtual int32_t RegisterSessionListenerForAllUsers(const sptr<ISessionListener>& listener) = 0;
67 
68     virtual int32_t SendSystemAVKeyEvent(const MMI::KeyEvent& keyEvent) = 0;
69 
70     virtual int32_t SendSystemControlCommand(const AVControlCommand& command) = 0;
71 
72     virtual int32_t RegisterClientDeathObserver(const sptr<IClientDeath>& observer) = 0;
73 
74     virtual int32_t CastAudio(const SessionToken& token,
75                               const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) = 0;
76 
77     virtual int32_t CastAudioForAll(const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) = 0;
78 
79     virtual int32_t ProcessCastAudioCommand(const RemoteServiceCommand command, const std::string& input,
80                                             std::string& output) = 0;
81 
82 #ifdef CASTPLUS_CAST_ENGINE_ENABLE
83     virtual int32_t StartCast(const SessionToken& sessionToken, const OutputDeviceInfo& outputDeviceInfo) = 0;
84 
85     virtual int32_t StopCast(const SessionToken& sessionToken) = 0;
86 
87     virtual int32_t checkEnableCast(bool enable) = 0;
88 #endif
89 
90     virtual int32_t Close() = 0;
91 };
92 } // namespace OHOS::AVSession
93 #endif // OHOS_IAVSESSION_SERVICE_H
94