180922886Sopenharmony_ci/* 280922886Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 380922886Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 480922886Sopenharmony_ci * you may not use this file except in compliance with the License. 580922886Sopenharmony_ci * You may obtain a copy of the License at 680922886Sopenharmony_ci * 780922886Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 880922886Sopenharmony_ci * 980922886Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1080922886Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1180922886Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1280922886Sopenharmony_ci * See the License for the specific language governing permissions and 1380922886Sopenharmony_ci * limitations under the License. 1480922886Sopenharmony_ci */ 1580922886Sopenharmony_ci 1680922886Sopenharmony_ci#ifndef OHOS_OHAVSESSION_CALLBACKIMPL_H 1780922886Sopenharmony_ci#define OHOS_OHAVSESSION_CALLBACKIMPL_H 1880922886Sopenharmony_ci 1980922886Sopenharmony_ci#include "native_avmetadata.h" 2080922886Sopenharmony_ci#include "native_avsession.h" 2180922886Sopenharmony_ci#include "avsession_info.h" 2280922886Sopenharmony_ci 2380922886Sopenharmony_cinamespace OHOS::AVSession { 2480922886Sopenharmony_ci 2580922886Sopenharmony_ciclass OHAVSessionCallbackImpl : public AVSessionCallback { 2680922886Sopenharmony_cipublic: 2780922886Sopenharmony_ci ~OHAVSessionCallbackImpl() override; 2880922886Sopenharmony_ci void OnPlay() override; 2980922886Sopenharmony_ci void OnPause() override; 3080922886Sopenharmony_ci void OnStop() override; 3180922886Sopenharmony_ci void OnPlayNext() override; 3280922886Sopenharmony_ci void OnPlayPrevious() override; 3380922886Sopenharmony_ci void OnFastForward(int64_t time) override; 3480922886Sopenharmony_ci void OnRewind(int64_t time) override; 3580922886Sopenharmony_ci void OnSeek(int64_t time) override; 3680922886Sopenharmony_ci void OnSetSpeed(double speed) override {}; 3780922886Sopenharmony_ci void OnSetLoopMode(int32_t loopMode) override; 3880922886Sopenharmony_ci void OnToggleFavorite(const std::string& mediald) override; 3980922886Sopenharmony_ci void OnMediaKeyEvent(const OHOS::MMI::KeyEvent& keyEvent) override {}; 4080922886Sopenharmony_ci void OnOutputDeviceChange(const int32_t connectionState, 4180922886Sopenharmony_ci const OHOS::AVSession::OutputDeviceInfo& outputDeviceInfo) override {}; 4280922886Sopenharmony_ci void OnCommonCommand(const std::string& commonCommand, const OHOS::AAFwk::WantParams& commandArgs) override {}; 4380922886Sopenharmony_ci void OnSkipToQueueItem(int32_t itemId) override {}; 4480922886Sopenharmony_ci void OnAVCallAnswer() override {}; 4580922886Sopenharmony_ci void OnAVCallHangUp() override {}; 4680922886Sopenharmony_ci void OnAVCallToggleCallMute() override {}; 4780922886Sopenharmony_ci void OnPlayFromAssetId(int64_t assetId) override {}; 4880922886Sopenharmony_ci void OnCastDisplayChange(const CastDisplayInfo& castDisplayInfo) override {}; 4980922886Sopenharmony_ci 5080922886Sopenharmony_ci AVSession_ErrCode SetPlayCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 5180922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback, void* userData); 5280922886Sopenharmony_ci AVSession_ErrCode SetPauseCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 5380922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback, void* userData); 5480922886Sopenharmony_ci AVSession_ErrCode SetStopCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 5580922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback, void* userData); 5680922886Sopenharmony_ci AVSession_ErrCode SetPlayNextCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 5780922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback, void* userData); 5880922886Sopenharmony_ci AVSession_ErrCode SetPlayPreviousCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 5980922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback, void* userData); 6080922886Sopenharmony_ci AVSession_ErrCode UnSetPlayCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 6180922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback); 6280922886Sopenharmony_ci AVSession_ErrCode UnSetPauseCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 6380922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback); 6480922886Sopenharmony_ci AVSession_ErrCode UnSetStopCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 6580922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback); 6680922886Sopenharmony_ci AVSession_ErrCode UnSetPlayNextCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 6780922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback); 6880922886Sopenharmony_ci AVSession_ErrCode UnSetPlayPreviousCallback(OH_AVSession* avsession, AVSession_ControlCommand command, 6980922886Sopenharmony_ci OH_AVSessionCallback_OnCommand callback); 7080922886Sopenharmony_ci 7180922886Sopenharmony_ci AVSession_ErrCode RegisterForwardCallback(OH_AVSession* avsession, 7280922886Sopenharmony_ci OH_AVSessionCallback_OnFastForward callback, void* userData); 7380922886Sopenharmony_ci AVSession_ErrCode UnregisterForwardCallback(OH_AVSession* avsession, 7480922886Sopenharmony_ci OH_AVSessionCallback_OnFastForward callback); 7580922886Sopenharmony_ci AVSession_ErrCode RegisterRewindCallback(OH_AVSession* avsession, 7680922886Sopenharmony_ci OH_AVSessionCallback_OnRewind callback, void* userData); 7780922886Sopenharmony_ci AVSession_ErrCode UnregisterRewindCallback(OH_AVSession* avsession, 7880922886Sopenharmony_ci OH_AVSessionCallback_OnRewind callback); 7980922886Sopenharmony_ci AVSession_ErrCode RegisterSeekCallback(OH_AVSession* avsession, 8080922886Sopenharmony_ci OH_AVSessionCallback_OnSeek callback, void* userData); 8180922886Sopenharmony_ci AVSession_ErrCode UnregisterSeekCallback(OH_AVSession* avsession, 8280922886Sopenharmony_ci OH_AVSessionCallback_OnSeek callback); 8380922886Sopenharmony_ci AVSession_ErrCode RegisterSetLoopModeCallback(OH_AVSession* avsession, 8480922886Sopenharmony_ci OH_AVSessionCallback_OnSetLoopMode callback, void* userData); 8580922886Sopenharmony_ci AVSession_ErrCode UnregisterSetLoopModeCallback(OH_AVSession* avsession, 8680922886Sopenharmony_ci OH_AVSessionCallback_OnSetLoopMode callback); 8780922886Sopenharmony_ci AVSession_ErrCode RegisterToggleFavoriteCallback(OH_AVSession* session, 8880922886Sopenharmony_ci OH_AVSessionCallback_OnToggleFavorite callback, void* userData); 8980922886Sopenharmony_ci AVSession_ErrCode UnregisterToggleFavoriteCallback(OH_AVSession* session, 9080922886Sopenharmony_ci OH_AVSessionCallback_OnToggleFavorite callback); 9180922886Sopenharmony_ci 9280922886Sopenharmony_ciprivate: 9380922886Sopenharmony_ci OH_AVSession* avsession_ = {nullptr}; 9480922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnCommand, void*>> playCallbacks_; 9580922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnCommand, void*>> pauseCallbacks_; 9680922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnCommand, void*>> stopCallbacks_; 9780922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnCommand, void*>> playNextCallbacks_; 9880922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnCommand, void*>> playPreviousCallbacks_; 9980922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnFastForward, void*>> forwardCallbacks_; 10080922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnRewind, void*>> rewindCallbacks_; 10180922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnSeek, void*>> seekCallbacks_; 10280922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnSetLoopMode, void*>> setLoopModeCallbacks_; 10380922886Sopenharmony_ci std::vector<std::pair<OH_AVSessionCallback_OnToggleFavorite, void*>> toggleFavoriteCallbacks_; 10480922886Sopenharmony_ci}; 10580922886Sopenharmony_ci} 10680922886Sopenharmony_ci#endif // OHOS_OHAVSESSION_CALLBACKIMPL_H