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_STUB_H 17 #define OHOS_AVSESSION_STUB_H 18 19 #include "iav_session.h" 20 #include "iremote_stub.h" 21 #include "want_agent.h" 22 #include "avsession_log.h" 23 #include "avsession_errors.h" 24 25 namespace OHOS::AVSession { 26 class AVSessionStub : public IRemoteStub<IAVSession> { 27 public: 28 int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; 29 RegisterCallback(const std::shared_ptr<AVSessionCallback> & callback)30 int32_t RegisterCallback(const std::shared_ptr<AVSessionCallback>& callback) override 31 { 32 return ERR_NONE; 33 } 34 GetController()35 std::shared_ptr<AVSessionController> GetController() override 36 { 37 return nullptr; 38 } 39 private: 40 int32_t HandleGetSessionId(MessageParcel& data, MessageParcel& reply); 41 42 int32_t HandleGetAVMetaData(MessageParcel& data, MessageParcel& reply); 43 44 int32_t HandleSetAVMetaData(MessageParcel& data, MessageParcel& reply); 45 46 int32_t HandleGetAVPlaybackState(MessageParcel& data, MessageParcel& reply); 47 48 int32_t HandleSetAVPlaybackState(MessageParcel& data, MessageParcel& reply); 49 50 int32_t HandleSetLaunchAbility(MessageParcel& data, MessageParcel& reply); 51 52 int32_t HandleGetController(MessageParcel& data, MessageParcel& reply); 53 54 int32_t HandleRegisterCallbackInner(MessageParcel& data, MessageParcel& reply); 55 56 int32_t HandleActivate(MessageParcel& data, MessageParcel& reply); 57 58 int32_t HandleDeactivate(MessageParcel& data, MessageParcel& reply); 59 60 int32_t HandleIsActive(MessageParcel& data, MessageParcel& reply); 61 62 int32_t HandleDestroy(MessageParcel& data, MessageParcel& reply); 63 64 int32_t HandleAddSupportCommand(MessageParcel& data, MessageParcel& reply); 65 66 int32_t HandleDeleteSupportCommand(MessageParcel& data, MessageParcel& reply); 67 68 static bool CheckInterfaceToken(MessageParcel& data); 69 70 using HanlerFunc = int32_t(AVSessionStub::*)(MessageParcel&, MessageParcel&); 71 static inline HanlerFunc handlers[] = { 72 [SESSION_CMD_GET_SESSION_ID] = &AVSessionStub::HandleGetSessionId, 73 [SESSION_CMD_GET_META_DATA] = &AVSessionStub::HandleGetAVMetaData, 74 [SESSION_CMD_SET_META_DATA] = &AVSessionStub::HandleSetAVMetaData, 75 [SESSION_CMD_GET_PLAYBACK_STATE] = &AVSessionStub::HandleGetAVPlaybackState, 76 [SESSION_CMD_SET_PLAYBACK_STATE] = &AVSessionStub::HandleSetAVPlaybackState, 77 [SESSION_CMD_SET_LAUNCH_ABILITY] = &AVSessionStub::HandleSetLaunchAbility, 78 [SESSION_CMD_GET_CONTROLLER] = &AVSessionStub::HandleGetController, 79 [SESSION_CMD_REGISTER_CALLBACK] = &AVSessionStub::HandleRegisterCallbackInner, 80 [SESSION_CMD_ACTIVATE] = &AVSessionStub::HandleActivate, 81 [SESSION_CMD_DEACTIVATE] = &AVSessionStub::HandleDeactivate, 82 [SESSION_CMD_ISACTIVE] = &AVSessionStub::HandleIsActive, 83 [SESSION_CMD_DESTROY] = &AVSessionStub::HandleDestroy, 84 [SESSION_CMD_ADD_SUPPORT_COMMAND] = &AVSessionStub::HandleAddSupportCommand, 85 [SESSION_CMD_DELETE_SUPPORT_COMMAND] = &AVSessionStub::HandleDeleteSupportCommand, 86 }; 87 }; 88 } 89 #endif // OHOS_AVSESSION_STUB_H