• 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_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 HandleGetHistoricalSessionDescriptors(MessageParcel& data, MessageParcel& reply);
32     int32_t HandleGetHistoricalAVQueueInfos(MessageParcel& data, MessageParcel& reply);
33     int32_t HandleStartAVPlayback(MessageParcel& data, MessageParcel& reply);
34     int32_t HandleCreateControllerInner(MessageParcel& data, MessageParcel& reply);
35     int32_t HandleGetAVCastControllerInner(MessageParcel& data, MessageParcel& reply);
36     int32_t HandleRegisterSessionListener(MessageParcel& data, MessageParcel& reply);
37     int32_t HandleSendSystemAVKeyEvent(MessageParcel& data, MessageParcel& reply);
38     int32_t HandleSendSystemControlCommand(MessageParcel& data, MessageParcel& reply);
39     int32_t HandleRegisterClientDeathObserver(MessageParcel& data, MessageParcel& reply);
40     int32_t HandleCastAudio(MessageParcel& data, MessageParcel& reply);
41     int32_t HandleCastAudioForAll(MessageParcel& data, MessageParcel& reply);
42     int32_t HandleRemoteCastAudio(MessageParcel& data, MessageParcel& reply);
43     int32_t HandleStartCastDiscovery(MessageParcel& data, MessageParcel& reply);
44     int32_t HandleStopCastDiscovery(MessageParcel& data, MessageParcel& reply);
45     int32_t HandleSetDiscoverable(MessageParcel& data, MessageParcel& reply);
46     int32_t HandleStartCast(MessageParcel& data, MessageParcel& reply);
47     int32_t HandleStopCast(MessageParcel& data, MessageParcel& reply);
48     int32_t HandleClose(MessageParcel& data, MessageParcel& reply);
49     static bool CheckInterfaceToken(MessageParcel& data);
50     int32_t GetAVQueueInfosImgLength(std::vector<AVQueueInfo>& avQueueInfos);
51     void MarshallingAVQueueInfos(MessageParcel &reply, const std::vector<AVQueueInfo>& avQueueInfos);
52     void AVQueueInfoImgToBuffer(std::vector<AVQueueInfo>& avQueueInfos, unsigned char *buffer);
53 
54     using HandlerFunc = int32_t(AVSessionServiceStub::*)(MessageParcel&, MessageParcel&);
55     static inline HandlerFunc handlers[] = {
56         &AVSessionServiceStub::HandleCreateSessionInner,
57         &AVSessionServiceStub::HandleGetAllSessionDescriptors,
58         &AVSessionServiceStub::HandleGetSessionDescriptorsById,
59         &AVSessionServiceStub::HandleGetHistoricalSessionDescriptors,
60         &AVSessionServiceStub::HandleGetHistoricalAVQueueInfos,
61         &AVSessionServiceStub::HandleStartAVPlayback,
62         &AVSessionServiceStub::HandleCreateControllerInner,
63         &AVSessionServiceStub::HandleGetAVCastControllerInner,
64         &AVSessionServiceStub::HandleRegisterSessionListener,
65         &AVSessionServiceStub::HandleSendSystemAVKeyEvent,
66         &AVSessionServiceStub::HandleSendSystemControlCommand,
67         &AVSessionServiceStub::HandleRegisterClientDeathObserver,
68         &AVSessionServiceStub::HandleCastAudio,
69         &AVSessionServiceStub::HandleCastAudioForAll,
70         &AVSessionServiceStub::HandleRemoteCastAudio,
71         &AVSessionServiceStub::HandleStartCastDiscovery,
72         &AVSessionServiceStub::HandleStopCastDiscovery,
73         &AVSessionServiceStub::HandleSetDiscoverable,
74         &AVSessionServiceStub::HandleStartCast,
75         &AVSessionServiceStub::HandleStopCast,
76         &AVSessionServiceStub::HandleClose,
77     };
78 
79     static constexpr int32_t RECEIVE_DEVICE_NUM_MAX = 10;
80 };
81 } // namespace OHOS::AVSession
82 #endif // OHOS_AVSESSION_SERVICE_STUB_H
83