1 /* 2 * Copyright (C) 2023 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 /** 17 * @addtogroup AVPlayer 18 * @{ 19 * 20 * @brief Provides APIs of Playback capability for Media Source. 21 * 22 * @Syscap SystemCapability.Multimedia.Media.AVPlayer 23 * @since 11 24 * @version 1.0 25 */ 26 27 /** 28 * @file avplayer_base.h 29 * 30 * @brief Defines the structure and enumeration for Media AVPlayer. 31 * 32 * @library libavplayer.so 33 * @since 11 34 * @version 1.0 35 */ 36 37 #ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_BASH_H 38 #define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_BASH_H 39 40 #include <stdint.h> 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 typedef struct OH_AVPlayer OH_AVPlayer; 47 typedef struct NativeWindow OHNativeWindow; 48 49 /** 50 * @brief Player States 51 * @syscap SystemCapability.Multimedia.Media.AVPlayer 52 * @since 11 53 * @version 1.0 54 */ 55 typedef enum AVPlayerState { 56 /* idle states */ 57 AV_IDLE = 0, 58 /* initialized states */ 59 AV_INITIALIZED = 1, 60 /* prepared states */ 61 AV_PREPARED = 2, 62 /* playing states */ 63 AV_PLAYING = 3, 64 /* paused states */ 65 AV_PAUSED = 4, 66 /* stopped states */ 67 AV_STOPPED = 5, 68 /* Play to the end states */ 69 AV_COMPLETED = 6, 70 /* released states */ 71 AV_RELEASED = 7, 72 /* error states */ 73 AV_ERROR = 8, 74 } AVPlayerState; 75 76 /** 77 * @brief Player Seek Mode 78 * @syscap SystemCapability.Multimedia.Media.AVPlayer 79 * @since 11 80 * @version 1.0 81 */ 82 typedef enum AVPlayerSeekMode { 83 /* sync to keyframes after the time point. */ 84 AV_SEEK_NEXT_SYNC = 0, 85 /* sync to keyframes before the time point. */ 86 AV_SEEK_PREVIOUS_SYNC, 87 } AVPlayerSeekMode; 88 89 /** 90 * @brief Playback Speed 91 * @syscap SystemCapability.Multimedia.Media.AVPlayer 92 * @since 11 93 * @version 1.0 94 */ 95 typedef enum AVPlaybackSpeed { 96 /* Video playback at 0.75x normal speed */ 97 AV_SPEED_FORWARD_0_75_X, 98 /* Video playback at normal speed */ 99 AV_SPEED_FORWARD_1_00_X, 100 /* Video playback at 1.25x normal speed */ 101 AV_SPEED_FORWARD_1_25_X, 102 /* Video playback at 1.75x normal speed */ 103 AV_SPEED_FORWARD_1_75_X, 104 /* Video playback at 2.0x normal speed */ 105 AV_SPEED_FORWARD_2_00_X, 106 } AVPlaybackSpeed; 107 108 /** 109 * @brief Player OnInfo Type 110 * @syscap SystemCapability.Multimedia.Media.AVPlayer 111 * @since 11 112 * @version 1.0 113 */ 114 typedef enum AVPlayerOnInfoType { 115 /* return the message when seeking done. */ 116 AV_INFO_TYPE_SEEKDONE = 0, 117 /* return the message when speeding done. */ 118 AV_INFO_TYPE_SPEEDDONE = 1, 119 /* return the message when select bitrate done */ 120 AV_INFO_TYPE_BITRATEDONE = 2, 121 /* return the message when playback is end of steam. */ 122 AV_INFO_TYPE_EOS = 3, 123 /* return the message when PlayerStates changed. */ 124 AV_INFO_TYPE_STATE_CHANGE = 4, 125 /* return the current posion of playback automatically. */ 126 AV_INFO_TYPE_POSITION_UPDATE = 5, 127 /* return the playback message. */ 128 AV_INFO_TYPE_MESSAGE = 6, 129 /* return the message when volume changed. */ 130 AV_INFO_TYPE_VOLUME_CHANGE = 7, 131 /* return the message when video size is first known or updated. */ 132 AV_INFO_TYPE_RESOLUTION_CHANGE = 8, 133 /* return multiqueue buffering time. */ 134 AV_INFO_TYPE_BUFFERING_UPDATE = 9, 135 /* return hls bitrate. 136 Bitrate is to convert data into uint8_t array storage, 137 which needs to be forcibly converted to uint32_t through offset access. */ 138 AV_INFO_TYPE_BITRATE_COLLECT = 10, 139 /* return the message when audio focus changed. */ 140 AV_INFO_TYPE_INTERRUPT_EVENT = 11, 141 /* return the duration of playback. */ 142 AV_INFO_TYPE_DURATION_UPDATE = 12, 143 /* return the playback is live stream. */ 144 AV_INFO_TYPE_IS_LIVE_STREAM = 13, 145 /* return the message when track changes. */ 146 AV_INFO_TYPE_TRACKCHANGE = 14, 147 /* return the message when subtitle track info updated. */ 148 AV_INFO_TYPE_TRACK_INFO_UPDATE = 15, 149 /* return the subtitle of playback. */ 150 AV_INFO_TYPE_SUBTITLE_UPDATE = 16, 151 /** Return the reason when the audio output device changes. When this info is reported, the extra param of 152 * {@link OH_AVPlayerOnInfo} is the same as {@OH_AudioStream_DeviceChangeReason} in audio framework. 153 */ 154 AV_INFO_TYPE_AUDIO_OUTPUT_DEVICE_CHANGE = 17, 155 } AVPlayerOnInfoType; 156 157 /** 158 * @brief Called when a player message or alarm is received. 159 * @syscap SystemCapability.Multimedia.Media.AVPlayer 160 * @param player The pointer to an OH_AVPlayer instance. 161 * @param type Indicates the information type. For details, see {@link AVPlayerOnInfoType}. 162 * @param extra Indicates other information, for example, the start time position of a playing file. 163 * @since 11 164 * @version 1.0 165 */ 166 typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, int32_t extra); 167 168 /** 169 * @brief Called when an error occurred for versions above api9 170 * @syscap SystemCapability.Multimedia.Media.AVPlayer 171 * @param player The pointer to an OH_AVPlayer instance. 172 * @param errorCode Error code. 173 * @param errorMsg Error message. 174 * @since 11 175 * @version 1.0 176 */ 177 typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg); 178 179 /** 180 * @brief A collection of all callback function pointers in OH_AVPlayer. Register an instance of this 181 * structure to the OH_AVPlayer instance, and process the information reported through the callback to ensure the 182 * normal operation of OH_AVPlayer. 183 * @syscap SystemCapability.Multimedia.Media.AVPlayer 184 * @param onInfo Monitor OH_AVPlayer operation information, refer to {@link OH_AVPlayerOnInfo} 185 * @param onError Monitor OH_AVPlayer operation errors, refer to {@link OH_AVPlayerOnError} 186 * @since 11 187 * @version 1.0 188 */ 189 typedef struct AVPlayerCallback { 190 OH_AVPlayerOnInfo onInfo; 191 OH_AVPlayerOnError onError; 192 } AVPlayerCallback; 193 194 195 #ifdef __cplusplus 196 } 197 #endif 198 #endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_BASH_H 199