• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_SESSION_LISTENER_STUB_H
17 #define OHOS_SESSION_LISTENER_STUB_H
18 
19 #include <map>
20 #include "iremote_stub.h"
21 #include "isession_listener.h"
22 
23 namespace OHOS::AVSession {
24 class SessionListenerStub : public IRemoteStub<ISessionListener> {
25 public:
26     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
27 
28 private:
29     int32_t HandleOnSessionCreate(MessageParcel& data, MessageParcel& reply);
30 
31     int32_t HandleOnSessionRelease(MessageParcel& data, MessageParcel& reply);
32 
33     int32_t HandleOnTopSessionChange(MessageParcel& data, MessageParcel& reply);
34 
35     int32_t HandleOnAudioSessionChecked(MessageParcel& data, MessageParcel& reply);
36 
37     int32_t HandleOnDeviceAvailable(MessageParcel& data, MessageParcel& reply);
38 
39     int32_t HandleOnDeviceLogEvent(MessageParcel& data, MessageParcel& reply);
40 
41     int32_t HandleOnDeviceOffline(MessageParcel& data, MessageParcel& reply);
42 
43     int32_t HandleOnRemoteDistributedSessionChange(MessageParcel& data, MessageParcel& reply);
44 
45     static bool CheckInterfaceToken(MessageParcel& data);
46 
47     using HandlerFunc = std::function<int32_t(MessageParcel&, MessageParcel&)>;
48     std::map<uint32_t, HandlerFunc> handlers = {
49         {LISTENER_CMD_ON_CREATE,
50             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnSessionCreate(data, reply); }},
51         {LISTENER_CMD_ON_RELEASE,
52             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnSessionRelease(data, reply); }},
53         {LISTENER_CMD_TOP_CHANGED,
54             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnTopSessionChange(data, reply); }},
55         {LISTENER_CMD_AUDIO_CHECKED,
56             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnAudioSessionChecked(data, reply); }},
57         {LISTENER_CMD_DEVICE_AVAILABLE,
58             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnDeviceAvailable(data, reply); }},
59         {LISTENER_CMD_DEVICE_LOG_EVENT,
60             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnDeviceLogEvent(data, reply); }},
61         {LISTENER_CMD_DEVICE_OFFLINE,
62             [this](MessageParcel& data, MessageParcel& reply) { return HandleOnDeviceOffline(data, reply); }},
63         {LISTENER_CMD_REMOTE_SESSION_CONTROLLER_CHANGED,
64             [this](MessageParcel& data, MessageParcel& reply) {
65             return HandleOnRemoteDistributedSessionChange(data, reply); }}
66     };
67 };
68 }
69 #endif // OHOS_SESSION_LISTENER_STUB_H