• 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 #ifndef OHOS_AVSESSION_CALLBACK_STUB_H
16 #define OHOS_AVSESSION_CALLBACK_STUB_H
17 
18 #include "iremote_stub.h"
19 #include "iavsession_callback.h"
20 
21 namespace OHOS::AVSession {
22 class AVSessionCallbackStub : public IRemoteStub<IAVSessionCallback> {
23 public:
24     int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
25 
26 private:
27     static bool CheckInterfaceToken(MessageParcel& data);
28 
29     int32_t HandleOnPlay(MessageParcel& data, MessageParcel& reply);
30     int32_t HandleOnPause(MessageParcel& data, MessageParcel& reply);
31     int32_t HandleOnStop(MessageParcel& data, MessageParcel& reply);
32     int32_t HandleOnPlayNext(MessageParcel& data, MessageParcel& reply);
33     int32_t HandleOnPlayPrevious(MessageParcel& data, MessageParcel& reply);
34     int32_t HandleOnFastForward(MessageParcel& data, MessageParcel& reply);
35     int32_t HandleOnRewind(MessageParcel& data, MessageParcel& reply);
36     int32_t HandleOnSeek(MessageParcel& data, MessageParcel& reply);
37     int32_t HandleOnSetSpeed(MessageParcel& data, MessageParcel& reply);
38     int32_t HandleOnSetLoopMode(MessageParcel& data, MessageParcel& reply);
39     int32_t HandleOnToggleFavorite(MessageParcel& data, MessageParcel& reply);
40     int32_t HandleOnMediaKeyEvent(MessageParcel& data, MessageParcel& reply);
41     int32_t HandOnOutputDeviceChange(MessageParcel& data, MessageParcel& reply);
42     using HanlerFunc = int32_t(AVSessionCallbackStub::*)(MessageParcel&, MessageParcel&);
43     static inline HanlerFunc handlers[] = {
44         [SESSION_CALLBACK_ON_PLAY] = &AVSessionCallbackStub::HandleOnPlay,
45         [SESSION_CALLBACK_ON_PAUSE] = &AVSessionCallbackStub::HandleOnPause,
46         [SESSION_CALLBACK_ON_STOP] = &AVSessionCallbackStub::HandleOnStop,
47         [SESSION_CALLBACK_ON_PLAY_NEXT] = &AVSessionCallbackStub::HandleOnPlayNext,
48         [SESSION_CALLBACK_ON_PLAY_PREVIOUS] = &AVSessionCallbackStub::HandleOnPlayPrevious,
49         [SESSION_CALLBACK_ON_FAST_FORWARD] = &AVSessionCallbackStub::HandleOnFastForward,
50         [SESSION_CALLBACK_ON_REWIND] = &AVSessionCallbackStub::HandleOnRewind,
51         [SESSION_CALLBACK_ON_SEEK] = &AVSessionCallbackStub::HandleOnSeek,
52         [SESSION_CALLBACK_ON_SET_SPEED] = &AVSessionCallbackStub::HandleOnSetSpeed,
53         [SESSION_CALLBACK_ON_SET_LOOPMODE] = &AVSessionCallbackStub::HandleOnSetLoopMode,
54         [SESSION_CALLBACK_ON_TOGGLE_FAVORITE] = &AVSessionCallbackStub::HandleOnToggleFavorite,
55         [SESSION_CALLBACK_ON_MEDIA_KEY_EVENT] = &AVSessionCallbackStub::HandleOnMediaKeyEvent,
56         [SESSION_CALLBACK_ON_OUTPUT_DEVICE_CHANGE] = &AVSessionCallbackStub::HandOnOutputDeviceChange
57     };
58 };
59 } // namespace OHOS::AVSession
60 #endif // OHOS_AVSESSION_CALLBACK_STUB_H