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_INFO_H 17 #define OHOS_AVSESSION_INFO_H 18 19 #include <string> 20 21 #include "avmeta_data.h" 22 #include "avplayback_state.h" 23 #include "avsession_descriptor.h" 24 #include "key_event.h" 25 26 namespace OHOS::AVSession { 27 using DeathCallback = std::function<void()>; 28 29 class SessionListener { 30 public: 31 virtual void OnSessionCreate(const AVSessionDescriptor& descriptor) = 0; 32 33 virtual void OnSessionRelease(const AVSessionDescriptor& descriptor) = 0; 34 35 virtual void OnTopSessionChange(const AVSessionDescriptor& descriptor) = 0; 36 37 virtual ~SessionListener() = default; 38 }; 39 40 class AVSessionCallback { 41 public: 42 virtual void OnPlay() = 0; 43 virtual void OnPause() = 0; 44 virtual void OnStop() = 0; 45 virtual void OnPlayNext() = 0; 46 virtual void OnPlayPrevious() = 0; 47 virtual void OnFastForward() = 0; 48 virtual void OnRewind() = 0; 49 virtual void OnSeek(int64_t time) = 0; 50 virtual void OnSetSpeed(double speed) = 0; 51 virtual void OnSetLoopMode(int32_t loopMode) = 0; 52 virtual void OnToggleFavorite(const std::string& mediald) = 0; 53 virtual void OnMediaKeyEvent(const MMI::KeyEvent& keyEvent) = 0; 54 virtual void OnOutputDeviceChange(const OutputDeviceInfo& outputDeviceInfo) = 0; 55 virtual ~AVSessionCallback() = default; 56 }; 57 58 class AVControllerCallback { 59 public: 60 virtual void OnSessionDestroy() = 0; 61 62 virtual void OnPlaybackStateChange(const AVPlaybackState& state) = 0; 63 64 virtual void OnMetaDataChange(const AVMetaData& data) = 0; 65 66 virtual void OnActiveStateChange(bool isActive) = 0; 67 68 virtual void OnValidCommandChange(const std::vector<int32_t>& cmds) = 0; 69 70 virtual void OnOutputDeviceChange(const OutputDeviceInfo& outputDeviceInfo) = 0; 71 72 virtual ~AVControllerCallback() = default; 73 }; 74 75 struct SessionToken { 76 std::string sessionId; 77 pid_t pid; 78 pid_t uid; 79 }; 80 81 enum SessionDataCategory { 82 SESSION_DATA_CATEGORY_INVALID = -1, 83 SESSION_DATA_META = 0, 84 SESSION_DATA_PLAYBACK_STATE = 1, 85 SESSION_DATA_CONTROL_COMMAND = 2, 86 SESSION_DATA_CATEGORY_MAX = 3, 87 }; 88 } // namespace OHOS::AVSession 89 #endif // OHOS_AVSESSION_INFO_H