• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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_AVCAST_CONTROLLER_CALLBACK_STUB_H
17 #define OHOS_AVCAST_CONTROLLER_CALLBACK_STUB_H
18 
19 #include <map>
20 #include "iavcast_controller_callback.h"
21 #include "iremote_stub.h"
22 #include "av_shared_memory_helper.h"
23 
24 namespace OHOS::AVSession {
25 class AVCastControllerCallbackStub : public IRemoteStub<IAVCastControllerCallback> {
26 public:
27     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
28 
29 private:
30 
31     int32_t HandleOnStateChange(MessageParcel& data, MessageParcel& reply);
32 
33     int32_t HandleOnMediaItemChange(MessageParcel& data, MessageParcel& reply);
34 
35     int32_t HandleOnPlayNext(MessageParcel& data, MessageParcel& reply);
36 
37     int32_t HandleOnPlayPrevious(MessageParcel& data, MessageParcel& reply);
38 
39     int32_t HandleOnSeekDone(MessageParcel& data, MessageParcel& reply);
40 
41     int32_t HandleOnVideoSizeChange(MessageParcel& data, MessageParcel& reply);
42 
43     int32_t HandleOnPlayerError(MessageParcel& data, MessageParcel& reply);
44 
45     int32_t HandleOnEndOfStream(MessageParcel& data, MessageParcel& reply);
46 
47     int32_t HandleOnPlayRequest(MessageParcel& data, MessageParcel& reply);
48 
49     int32_t HandleOnKeyRequest(MessageParcel& data, MessageParcel& reply);
50 
51     int32_t HandleOnCastValidCommandChanged(MessageParcel& data, MessageParcel& reply);
52 
53     int32_t HandleOnDataSrcRead(MessageParcel& data, MessageParcel& reply);
54 
55     static bool CheckInterfaceToken(MessageParcel& data);
56 
57     using HandlerFunc = std::function<int32_t(MessageParcel&, MessageParcel&)>;
58     std::map<uint32_t, HandlerFunc> handlers = {
59         {CAST_CONTROLLER_CMD_ON_CAST_PLAYBACK_STATE_CHANGE,
60             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnStateChange(data, reply); }},
61         {CAST_CONTROLLER_CMD_ON_MEDIA_ITEM_CHANGE,
62             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnMediaItemChange(data, reply); }},
63         {CAST_CONTROLLER_CMD_ON_PLAY_NEXT,
64             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnPlayNext(data, reply); }},
65         {CAST_CONTROLLER_CMD_ON_PLAY_PREVIOUS,
66             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnPlayPrevious(data, reply); }},
67         {CAST_CONTROLLER_CMD_ON_SEEK_DONE,
68             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnSeekDone(data, reply); }},
69         {CAST_CONTROLLER_CMD_ON_VIDEO_SIZE_CHANGE,
70             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnVideoSizeChange(data, reply); }},
71         {CAST_CONTROLLER_CMD_ON_ERROR,
72             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnPlayerError(data, reply); }},
73         {CAST_CONTROLLER_CMD_ON_END_OF_STREAM,
74             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnEndOfStream(data, reply); }},
75         {CAST_CONTROLLER_CMD_ON_PLAY_REQUEST,
76             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnPlayRequest(data, reply); }},
77         {CAST_CONTROLLER_CMD_ON_KEY_REQUEST,
78             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnKeyRequest(data, reply); }},
79         {CAST_CONTROLLER_CMD_ON_VALID_COMMAND_CHANGED,
80             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnCastValidCommandChanged(data, reply); }},
81         {CAST_CONTROLLER_CMD_ON_DATA_SRC_READ,
82             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnDataSrcRead(data, reply); }}
83     };
84 };
85 }
86 #endif // OHOS_AVCAST_CONTROLLER_CALLBACK_STUB_H
87