• 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_CONTROLLER_STUB_H
17 #define OHOS_AVSESSION_CONTROLLER_STUB_H
18 
19 #include "iavsession_controller.h"
20 #include "iremote_stub.h"
21 
22 namespace OHOS::AVSession {
23 class AVSessionControllerStub : public IRemoteStub<IAVSessionController> {
24 public:
25     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
26 
RegisterCallback(const std::shared_ptr<AVControllerCallback> & callback)27     int32_t RegisterCallback(const std::shared_ptr<AVControllerCallback>& callback) override
28     {
29         return 0;
30     }
31 
GetRealPlaybackPosition()32     int64_t GetRealPlaybackPosition() override
33     {
34         return 0;
35     }
36 
IsDestroy()37     bool IsDestroy() override
38     {
39         return true;
40     }
41 
42 private:
43     int32_t HandleRegisterCallbackInner(MessageParcel& data, MessageParcel& reply);
44 
45     int32_t HandleDestroy(MessageParcel& data, MessageParcel& reply);
46 
47     int32_t HandleGetAVPlaybackState(MessageParcel& data, MessageParcel& reply);
48 
49     int32_t HandleSendControlCommand(MessageParcel& data, MessageParcel& reply);
50 
51     int32_t HandleGetAVMetaData(MessageParcel& data, MessageParcel& reply);
52 
53     int32_t HandleSendAVKeyEvent(MessageParcel& data, MessageParcel& reply);
54 
55     int32_t HandleGetLaunchAbility(MessageParcel& data, MessageParcel& reply);
56 
57     int32_t HandleGetValidCommands(MessageParcel& data, MessageParcel& reply);
58 
59     int32_t HandleSetMetaFilter(MessageParcel& data, MessageParcel& reply);
60 
61     int32_t HandleSetPlaybackFilter(MessageParcel& data, MessageParcel& reply);
62 
63     int32_t HandleIsSessionActive(MessageParcel& data, MessageParcel& reply);
64 
65     int32_t HandleGetSessionId(MessageParcel& data, MessageParcel& reply);
66 
67     static bool CheckInterfaceToken(MessageParcel& data);
68 
69     using HanlerFunc = int32_t (AVSessionControllerStub::*)(MessageParcel& data, MessageParcel& reply);
70     static inline HanlerFunc handlers[] = {
71         [CONTROLLER_CMD_REGISTER_CALLBACK] = &AVSessionControllerStub::HandleRegisterCallbackInner,
72         [CONTROLLER_CMD_DESTROY] = &AVSessionControllerStub::HandleDestroy,
73         [CONTROLLER_CMD_GET_AV_PLAYBACK_STATE] = &AVSessionControllerStub::HandleGetAVPlaybackState,
74         [CONTROLLER_CMD_SEND_CONTROL_COMMAND] = &AVSessionControllerStub::HandleSendControlCommand,
75         [CONTROLLER_CMD_GET_AV_META_DATA] = &AVSessionControllerStub::HandleGetAVMetaData,
76         [CONTROLLER_CMD_SEND_AV_KEYEVENT] = &AVSessionControllerStub::HandleSendAVKeyEvent,
77         [CONTROLLER_CMD_GET_LAUNCH_ABILITY] = &AVSessionControllerStub::HandleGetLaunchAbility,
78         [CONTROLLER_CMD_GET_VALID_COMMANDS] = &AVSessionControllerStub::HandleGetValidCommands,
79         [CONTROLLER_CMD_SET_META_FILTER] = &AVSessionControllerStub::HandleSetMetaFilter,
80         [CONTROLLER_CMD_SET_PLAYBACK_FILTER] = &AVSessionControllerStub::HandleSetPlaybackFilter,
81         [CONTROLLER_CMD_IS_SESSION_ACTIVE] = &AVSessionControllerStub::HandleIsSessionActive,
82         [CONTROLLER_CMD_GET_SESSION_ID] = &AVSessionControllerStub::HandleGetSessionId,
83     };
84 };
85 } // namespace OHOS::AVSession
86 #endif // OHOS_AVSESSION_CONTROLLER_STUB_H