• 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_SERVICE_STUB_H
17 #define OHOS_AVSESSION_SERVICE_STUB_H
18 
19 #include "iavsession_service.h"
20 #include "iremote_stub.h"
21 
22 namespace OHOS::AVSession {
23 class AVSessionServiceStub : public IRemoteStub<IAVSessionService> {
24 public:
25     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
26 
27 private:
28     int32_t HandleCreateSessionInner(MessageParcel& data, MessageParcel& reply);
29     int32_t HandleGetAllSessionDescriptors(MessageParcel& data, MessageParcel& reply);
30     int32_t HandleGetSessionDescriptorsById(MessageParcel& data, MessageParcel& reply);
31     int32_t HandleCreateControllerInner(MessageParcel& data, MessageParcel& reply);
32     int32_t HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply);
33     int32_t HandleSendSystemAVKeyEvent(MessageParcel& data, MessageParcel& reply);
34     int32_t HandleSendSystemControlCommand(MessageParcel& data, MessageParcel& reply);
35     int32_t HandleRegisterClientDeathObserver(MessageParcel& data, MessageParcel& reply);
36     int32_t HandleCastAudio(MessageParcel& data, MessageParcel& reply);
37     int32_t HandleCastAudioForAll(MessageParcel& data, MessageParcel& reply);
38     int32_t HandleRemoteCastAudio(MessageParcel& data, MessageParcel& reply);
39     static bool CheckInterfaceToken(MessageParcel& data);
40 
41     using HanlerFunc = int32_t(AVSessionServiceStub::*)(MessageParcel&, MessageParcel&);
42     static inline HanlerFunc handlers[] = {
43         [SERVICE_CMD_CREATE_SESSION] = &AVSessionServiceStub::HandleCreateSessionInner,
44         [SERVICE_CMD_GET_ALL_SESSION_DESCRIPTORS] = &AVSessionServiceStub::HandleGetAllSessionDescriptors,
45         [SERVICE_CMD_GET_SESSION_DESCRIPTORS_BY_ID] = &AVSessionServiceStub::HandleGetSessionDescriptorsById,
46         [SERVICE_CMD_CREATE_CONTROLLER] = &AVSessionServiceStub::HandleCreateControllerInner,
47         [SERVICE_CMD_REGISTER_SESSION_LISTENER] = &AVSessionServiceStub::HandleRegisterSessionListener,
48         [SERVICE_CMD_SEND_SYSTEM_AV_KEY_EVENT] = &AVSessionServiceStub::HandleSendSystemAVKeyEvent,
49         [SERVICE_CMD_SEND_SYSTEM_CONTROL_COMMAND] = &AVSessionServiceStub::HandleSendSystemControlCommand,
50         [SERVICE_CMD_REGISTER_CLIENT_DEATH] = &AVSessionServiceStub::HandleRegisterClientDeathObserver,
51         [SERVICE_CMD_CAST_AUDIO] = &AVSessionServiceStub::HandleCastAudio,
52         [SERVICE_CMD_CAST_AUDIO_FOR_ALL] = &AVSessionServiceStub::HandleCastAudioForAll,
53         [SERVICE_CMD_SEND_COMMAND_TO_REMOTE] = &AVSessionServiceStub::HandleRemoteCastAudio,
54     };
55 
56     static constexpr int32_t RECEIVE_DEVICE_NUM_MAX = 10;
57 };
58 } // namespace OHOS::AVSession
59 #endif // OHOS_AVSESSION_SERVICE_STUB_H