180922886Sopenharmony_ci/*
280922886Sopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
380922886Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
480922886Sopenharmony_ci * you may not use this file except in compliance with the License.
580922886Sopenharmony_ci * You may obtain a copy of the License at
680922886Sopenharmony_ci *
780922886Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
880922886Sopenharmony_ci *
980922886Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1080922886Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1180922886Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1280922886Sopenharmony_ci * See the License for the specific language governing permissions and
1380922886Sopenharmony_ci * limitations under the License.
1480922886Sopenharmony_ci */
1580922886Sopenharmony_ci
1680922886Sopenharmony_ci#ifndef OHOS_IAVSESSION_SERVICE_H
1780922886Sopenharmony_ci#define OHOS_IAVSESSION_SERVICE_H
1880922886Sopenharmony_ci
1980922886Sopenharmony_ci#include "audio_system_manager.h"
2080922886Sopenharmony_ci#include "iremote_broker.h"
2180922886Sopenharmony_ci#include "iav_session.h"
2280922886Sopenharmony_ci#include "iavsession_service_ipc_interface_code.h"
2380922886Sopenharmony_ci#include "iclient_death.h"
2480922886Sopenharmony_ci#include "isession_listener.h"
2580922886Sopenharmony_ci#include "key_event.h"
2680922886Sopenharmony_ci#include "avqueue_info.h"
2780922886Sopenharmony_ci
2880922886Sopenharmony_cinamespace OHOS::AVSession {
2980922886Sopenharmony_ciclass IAVSessionService : public IRemoteBroker {
3080922886Sopenharmony_cipublic:
3180922886Sopenharmony_ci    DECLARE_INTERFACE_DESCRIPTOR(u"ohos.avsession.IAVSessionService");
3280922886Sopenharmony_ci
3380922886Sopenharmony_ci    enum RemoteServiceCommand {
3480922886Sopenharmony_ci        COMMAND_INVALID = -1,
3580922886Sopenharmony_ci        COMMAND_CAST_AUDIO = 0,
3680922886Sopenharmony_ci        COMMAND_CANCEL_CAST_AUDIO = 1,
3780922886Sopenharmony_ci        COMMAND_MAX = 2
3880922886Sopenharmony_ci    };
3980922886Sopenharmony_ci
4080922886Sopenharmony_ci    virtual sptr<IRemoteObject> CreateSessionInner(const std::string& tag, int32_t type,
4180922886Sopenharmony_ci                                                   const AppExecFwk::ElementName& elementName) = 0;
4280922886Sopenharmony_ci
4380922886Sopenharmony_ci    virtual int32_t CreateSessionInner(const std::string& tag, int32_t type, const AppExecFwk::ElementName& elementName,
4480922886Sopenharmony_ci                                       sptr<IRemoteObject>& session) = 0;
4580922886Sopenharmony_ci
4680922886Sopenharmony_ci    virtual int32_t GetAllSessionDescriptors(std::vector<AVSessionDescriptor>& descriptors) = 0;
4780922886Sopenharmony_ci
4880922886Sopenharmony_ci    virtual int32_t GetSessionDescriptorsBySessionId(const std::string& sessionId,
4980922886Sopenharmony_ci        AVSessionDescriptor& descriptor) = 0;
5080922886Sopenharmony_ci
5180922886Sopenharmony_ci    virtual int32_t GetHistoricalSessionDescriptors(int32_t maxSize, std::vector<AVSessionDescriptor>& descriptors) = 0;
5280922886Sopenharmony_ci
5380922886Sopenharmony_ci    virtual int32_t GetHistoricalAVQueueInfos(int32_t maxSize, int32_t maxAppSize,
5480922886Sopenharmony_ci                                              std::vector<AVQueueInfo>& avQueueInfos) = 0;
5580922886Sopenharmony_ci
5680922886Sopenharmony_ci    virtual int32_t StartAVPlayback(const std::string& bundleName, const std::string& assetId) = 0;
5780922886Sopenharmony_ci
5880922886Sopenharmony_ci    virtual int32_t CreateControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) = 0;
5980922886Sopenharmony_ci
6080922886Sopenharmony_ci    virtual bool IsAudioPlaybackAllowed(const int32_t uid, const int32_t pid) = 0;
6180922886Sopenharmony_ci
6280922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE
6380922886Sopenharmony_ci    virtual int32_t GetAVCastControllerInner(const std::string& sessionId, sptr<IRemoteObject>& object) = 0;
6480922886Sopenharmony_ci#endif
6580922886Sopenharmony_ci
6680922886Sopenharmony_ci    virtual int32_t RegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
6780922886Sopenharmony_ci
6880922886Sopenharmony_ci    virtual int32_t RegisterSessionListenerForAllUsers(const sptr<ISessionListener>& listener) = 0;
6980922886Sopenharmony_ci
7080922886Sopenharmony_ci    virtual int32_t SendSystemAVKeyEvent(const MMI::KeyEvent& keyEvent) = 0;
7180922886Sopenharmony_ci
7280922886Sopenharmony_ci    virtual int32_t SendSystemControlCommand(const AVControlCommand& command) = 0;
7380922886Sopenharmony_ci
7480922886Sopenharmony_ci    virtual int32_t RegisterClientDeathObserver(const sptr<IClientDeath>& observer) = 0;
7580922886Sopenharmony_ci
7680922886Sopenharmony_ci    virtual int32_t CastAudio(const SessionToken& token,
7780922886Sopenharmony_ci                              const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) = 0;
7880922886Sopenharmony_ci
7980922886Sopenharmony_ci    virtual int32_t CastAudioForAll(const std::vector<AudioStandard::AudioDeviceDescriptor>& descriptors) = 0;
8080922886Sopenharmony_ci
8180922886Sopenharmony_ci    virtual int32_t ProcessCastAudioCommand(const RemoteServiceCommand command, const std::string& input,
8280922886Sopenharmony_ci                                            std::string& output) = 0;
8380922886Sopenharmony_ci
8480922886Sopenharmony_ci#ifdef CASTPLUS_CAST_ENGINE_ENABLE
8580922886Sopenharmony_ci    virtual int32_t StartCast(const SessionToken& sessionToken, const OutputDeviceInfo& outputDeviceInfo) = 0;
8680922886Sopenharmony_ci
8780922886Sopenharmony_ci    virtual int32_t StopCast(const SessionToken& sessionToken) = 0;
8880922886Sopenharmony_ci
8980922886Sopenharmony_ci    virtual int32_t checkEnableCast(bool enable) = 0;
9080922886Sopenharmony_ci#endif
9180922886Sopenharmony_ci
9280922886Sopenharmony_ci    virtual int32_t Close() = 0;
9380922886Sopenharmony_ci};
9480922886Sopenharmony_ci} // namespace OHOS::AVSession
9580922886Sopenharmony_ci#endif // OHOS_IAVSESSION_SERVICE_H
96