diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h new file mode 100644 index 0000000000000000000000000000000000000000..32a883a55794b65cea274104caaffc31b79e9c53 --- /dev/null +++ b/multimedia/player_framework/avplayer.h @@ -0,0 +1,434 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup AVPlayer + * @{ + * + * @brief Provides APIs of Playback capability for Media Source. + * + * @Syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 11 + * @version 1.0 + */ + +/** + * @file avplayer.h + * + * @brief Defines the avplayer APIs. Uses the Native APIs provided by Media AVPlayer + * to play the media source. + * + * @library libavplayer.so + * @since 11 + * @version 1.0 + */ + +#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H +#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H + +#include +#include +#include "native_averrors.h" +#include "avplayer_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a player + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @return Returns a pointer to an OH_AVPlayer instance + * @since 11 + * @version 1.0 +*/ +OH_AVPlayer *OH_AVPlayer_Create(void); + +/** + * @brief Sets the playback source for the player. The corresponding source can be http url + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param url Indicates the playback source. + * @return Returns {@link AV_ERR_OK} if the url is set successfully; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetURLSource(OH_AVPlayer *player, const char *url); + +/** + * @brief Sets the playback media file descriptor source for the player. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param fd Indicates the file descriptor of media source. + * @param offset Indicates the offset of media source in file descriptor. + * @param size Indicates the size of media source. + * @return Returns {@link AV_ERR_OK} if the fd source is set successfully; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetFDSource(OH_AVPlayer *player, int32_t fd, int64_t offset, int64_t size); + +/** + * @brief Prepares the playback environment and buffers media data asynchronous. + * + * This function must be called after {@link SetSource}. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if {@link Prepare} is successfully added to the task queue; + * returns an error code defined in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_Prepare(OH_AVPlayer *player); + +/** + * @brief Start playback. + * + * This function must be called after {@link Prepare}. If the player state is Prepared, + * this function is called to start playback. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if the playback is started; otherwise returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_Play(OH_AVPlayer *player); + +/** + * @brief Pauses playback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if {@link Pause} is successfully added to the task queue; + * returns an error code defined in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_Pause(OH_AVPlayer *player); + +/** + * @brief Stop playback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if {@link Stop} is successfully added to the task queue; + * returns an error code defined in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_Stop(OH_AVPlayer *player); + +/** + * @brief Restores the player to the initial state. + * + * After the function is called, add a playback source by calling {@link SetSource}, + * call {@link Play} to start playback again after {@link Prepare} is called. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if {@link Reset} is successfully added to the task queue; + * returns an error code defined in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_Reset(OH_AVPlayer *player); + +/** + * @brief Releases player resources async + * + * Asynchronous release guarantees the performance + * but cannot ensure whether the surfacebuffer is released. + * The caller needs to ensure the life cycle security of the surface + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if {@link Release} is successfully added to the task queue; + * returns an error code defined in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_Release(OH_AVPlayer *player); + +/** + * @brief Releases player resources sync + * + * Synchronous release ensures effective release of surfacebuffer + * but this interface will take a long time (when the engine is not idle state) + * requiring the caller to design an asynchronous mechanism by itself + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns {@link AV_ERR_OK} if the playback is released; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_ReleaseSync(OH_AVPlayer *player); + +/** + * @brief Sets the volume of the player. + * + * This function can be used during playback or pause. The value 0 indicates no sound, + * and 1 indicates the original volume. If no audio device is started or no audio + * stream exists, the value -1 is returned. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param leftVolume Indicates the target volume of the left audio channel to set, + * ranging from 0 to 1. each step is 0.01. + * @param rightVolume Indicates the target volume of the right audio channel to set, + * ranging from 0 to 1. each step is 0.01. + * @return Returns {@link AV_ERR_OK} if the volume is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetVolume(OH_AVPlayer *player, float leftVolume, float rightVolume); + +/** + * @brief Changes the playback position. + * + * This function can be used during play or pause. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param mSeconds Indicates the target playback position, accurate to milliseconds. + * @param mode Indicates the player seek mode. For details, see {@link AVPlayerSeekMode}. + * @return Returns {@link AV_ERR_OK} if the seek is done; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 +*/ +OH_AVErrCode OH_AVPlayer_Seek(OH_AVPlayer *player, int32_t mSeconds, AVPlayerSeekMode mode); + +/** + * @brief Obtains the playback position, accurate to millisecond. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param currentTime Indicates the playback position. + * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetCurrentTime(OH_AVPlayer *player, int32_t *currentTime); + +/** + * @brief get the video width. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param videoWidth The video width + * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetVideoWidth(OH_AVPlayer *player, int32_t *videoWidth); + +/** + * @brief get the video height. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param videoHeight The video height + * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetVideoHeight(OH_AVPlayer *player, int32_t *videoHeight); + +/** + * @brief set the player playback rate + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param speed the rate mode {@link AVPlaybackSpeed} which can set. + * @return Returns {@link AV_ERR_OK} if the playback rate is set successful; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed speed); + +/** + * @brief get the current player playback rate + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param speed the rate mode {@link AVPlaybackSpeed} which can get. + * @return Returns {@link AV_ERR_OK} if the current player playback rate is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed); + +/** + * @brief set the bit rate use for hls player + * + * the playback bitrate expressed in bits per second, expressed in bits per second, + * which is only valid for HLS protocol network flow. By default, + * the player will select the appropriate bit rate and speed according to the network connection. + * report the effective bit rate linked list by "INFO_TYPE_BITRATE_COLLECT" + * set and select the specified bit rate, and select the bit rate that is less than and closest + * to the specified bit rate for playback. When ready, read it to query the currently selected bit rate. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param bitRate the bit rate, The unit is bps. + * @return Returns {@link AV_ERR_OK} if the bit rate is set successfully; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SelectBitRate(OH_AVPlayer *player, uint32_t bitRate); + +/** + * @brief Method to set the surface. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} + * @return Returns {@link AV_ERR_OK} if the surface is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetVideoSurface(OH_AVPlayer *player, OHNativeWindow *window); + +/** + * @brief Obtains the total duration of media files, accurate to milliseconds. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param duration Indicates the total duration of media files. + * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetDuration(OH_AVPlayer *player, int32_t *duration); + +/** + * @brief get current playback state. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param state the current playback state + * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetState(OH_AVPlayer *player, AVPlayerState *state); + +/** + * @brief Checks whether the player is playing. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns true if the playback is playing; false otherwise. + * @since 11 + * @version 1.0 + */ +bool OH_AVPlayer_IsPlaying(OH_AVPlayer *player); + +/** + * @brief Returns the value whether single looping is enabled or not . + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @return Returns true if the playback is single looping; false otherwise. + * @since 11 + * @version 1.0 + */ +bool OH_AVPlayer_IsLooping(OH_AVPlayer *player); + +/** + * @brief Enables single looping of the media playback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param loop The switch to set loop + * @return Returns {@link AV_ERR_OK} if the single looping is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); + +/** + * @brief Method to set player callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param callback object pointer. + * @return Returns {@link AV_ERR_OK} if the playercallback is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback callback); + +/** + * @brief Select audio or subtitle track. + * + * By default, the first audio stream with data is played, and the subtitle track is not played. + * After the settings take effect, the original track will become invalid. Please set subtitles + * in prepared/playing/paused/completed state and set audio tracks in prepared state. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param index Track index + * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 +*/ +OH_AVErrCode OH_AVPlayer_SelectTrack(OH_AVPlayer *player, int32_t index); + +/** + * @brief Deselect the current audio or subtitle track. + * + * After audio is deselected, the default track will be played, and after subtitles are deselected, + * they will not be played. Please set subtitles in prepared/playing/paused/completed state and set + * audio tracks in prepared state. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param index Track index + * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 +*/ +OH_AVErrCode OH_AVPlayer_DeselectTrack(OH_AVPlayer *player, int32_t index); + +/** + * @brief Obtain the currently effective track index. + * + * Please get it in the prepared/playing/paused/completed state. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param trackType Media type. + * @param index Track index + * @return Returns {@link AV_ERR_OK} if the track index is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 11 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, int32_t *index); + + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H diff --git a/multimedia/player_framework/avplayer/BUILD.gn b/multimedia/player_framework/avplayer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..16d8f7f6f84d6f1d2f4581a74a3b0eee5a7f5f3b --- /dev/null +++ b/multimedia/player_framework/avplayer/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (C) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +import("//foundation/multimedia/player_framework/config.gni") + +ohos_ndk_headers("avplayer_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ + "../avplayer.h", + "../avplayer_base.h", + ] +} + +ohos_ndk_library("libavplayer") { + ndk_description_file = "./libavplayer.ndk.json" + output_name = "avplayer" + output_extension = "so" + system_capability = "SystemCapability.Multimedia.Media.AVPlayer" + system_capability_headers = [ + "multimedia/player_framework/avplayer.h", + "multimedia/player_framework/avplayer_base.h", + ] +} diff --git a/multimedia/player_framework/avplayer/libavplayer.ndk.json b/multimedia/player_framework/avplayer/libavplayer.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..d622cc601c308aa2d630fac0e76e9e7d42098ea8 --- /dev/null +++ b/multimedia/player_framework/avplayer/libavplayer.ndk.json @@ -0,0 +1,30 @@ +[ + { "name": "OH_AVPlayer_Create" }, + { "name": "OH_AVPlayer_SetURLSource" }, + { "name": "OH_AVPlayer_SetFDSource" }, + { "name": "OH_AVPlayer_Prepare" }, + { "name": "OH_AVPlayer_Play" }, + { "name": "OH_AVPlayer_Pause" }, + { "name": "OH_AVPlayer_Stop" }, + { "name": "OH_AVPlayer_Reset" }, + { "name": "OH_AVPlayer_Release" }, + { "name": "OH_AVPlayer_ReleaseSync" }, + { "name": "OH_AVPlayer_SetVolume" }, + { "name": "OH_AVPlayer_Seek" }, + { "name": "OH_AVPlayer_GetCurrentTime" }, + { "name": "OH_AVPlayer_GetVideoWidth" }, + { "name": "OH_AVPlayer_GetVideoHeight" }, + { "name": "OH_AVPlayer_SetPlaybackSpeed" }, + { "name": "OH_AVPlayer_GetPlaybackSpeed" }, + { "name": "OH_AVPlayer_SetVideoSurface" }, + { "name": "OH_AVPlayer_SelectBitRate" }, + { "name": "OH_AVPlayer_GetDuration" }, + { "name": "OH_AVPlayer_GetState" }, + { "name": "OH_AVPlayer_IsPlaying" }, + { "name": "OH_AVPlayer_IsLooping" }, + { "name": "OH_AVPlayer_SetLooping" }, + { "name": "OH_AVPlayer_SetPlayerCallback" }, + { "name": "OH_AVPlayer_SelectTrack" }, + { "name": "OH_AVPlayer_DeselectTrack" }, + { "name": "OH_AVPlayer_GetCurrentTrack" } +] \ No newline at end of file diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h new file mode 100644 index 0000000000000000000000000000000000000000..3128b6852522d1f81bd96a506f9951347220be0b --- /dev/null +++ b/multimedia/player_framework/avplayer_base.h @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup AVPlayer + * @{ + * + * @brief Provides APIs of Playback capability for Media Source. + * + * @Syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 11 + * @version 1.0 + */ + +/** + * @file avplayer_base.h + * + * @brief Defines the structure and enumeration for Media AVPlayer. + * + * @library libavplayer.so + * @since 11 + * @version 1.0 + */ + +#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_BASH_H +#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_BASH_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVPlayer OH_AVPlayer; +typedef struct NativeWindow OHNativeWindow; + +/** + * @brief Player States + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 11 + * @version 1.0 + */ +typedef enum AVPlayerState { + /* idle states */ + AV_IDLE = 0, + /* initialized states */ + AV_INITIALIZED = 1, + /* prepared states */ + AV_PREPARED = 2, + /* playing states */ + AV_PLAYING = 3, + /* paused states */ + AV_PAUSED = 4, + /* stopped states */ + AV_STOPPED = 5, + /* Play to the end states */ + AV_COMPLETED = 6, + /* released states */ + AV_RELEASED = 7, + /* error states */ + AV_ERROR = 8, +} AVPlayerState; + +/** + * @brief Player Seek Mode + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 11 + * @version 1.0 + */ +typedef enum AVPlayerSeekMode { + /* sync to keyframes after the time point. */ + AV_SEEK_NEXT_SYNC = 0, + /* sync to keyframes before the time point. */ + AV_SEEK_PREVIOUS_SYNC, +} AVPlayerSeekMode; + +/** + * @brief Playback Speed + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 11 + * @version 1.0 + */ +typedef enum AVPlaybackSpeed { + /* Video playback at 0.75x normal speed */ + AV_SPEED_FORWARD_0_75_X, + /* Video playback at normal speed */ + AV_SPEED_FORWARD_1_00_X, + /* Video playback at 1.25x normal speed */ + AV_SPEED_FORWARD_1_25_X, + /* Video playback at 1.75x normal speed */ + AV_SPEED_FORWARD_1_75_X, + /* Video playback at 2.0x normal speed */ + AV_SPEED_FORWARD_2_00_X, +} AVPlaybackSpeed; + +/** + * @brief Player OnInfo Type + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 11 + * @version 1.0 + */ +typedef enum AVPlayerOnInfoType { + /* return the message when seeking done. */ + AV_INFO_TYPE_SEEKDONE = 0, + /* return the message when speeding done. */ + AV_INFO_TYPE_SPEEDDONE = 1, + /* return the message when select bitrate done */ + AV_INFO_TYPE_BITRATEDONE = 2, + /* return the message when playback is end of steam. */ + AV_INFO_TYPE_EOS = 3, + /* return the message when PlayerStates changed. */ + AV_INFO_TYPE_STATE_CHANGE = 4, + /* return the current posion of playback automatically. */ + AV_INFO_TYPE_POSITION_UPDATE = 5, + /* return the playback message. */ + AV_INFO_TYPE_MESSAGE = 6, + /* return the message when volume changed. */ + AV_INFO_TYPE_VOLUME_CHANGE = 7, + /* return the message when video size is first known or updated. */ + AV_INFO_TYPE_RESOLUTION_CHANGE = 8, + /* return multiqueue buffering time. */ + AV_INFO_TYPE_BUFFERING_UPDATE = 9, + /* return hls bitrate. + Bitrate is to convert data into uint8_t array storage, + which needs to be forcibly converted to uint32_t through offset access. */ + AV_INFO_TYPE_BITRATE_COLLECT = 10, + /* return the message when audio focus changed. */ + AV_INFO_TYPE_INTERRUPT_EVENT = 11, + /* return the duration of playback. */ + AV_INFO_TYPE_DURATION_UPDATE = 12, + /* return the playback is live stream. */ + AV_INFO_TYPE_IS_LIVE_STREAM = 13, + /* return the message when track changes. */ + AV_INFO_TYPE_TRACKCHANGE = 14, + /* return the message when subtitle track info updated. */ + AV_INFO_TYPE_TRACK_INFO_UPDATE = 15, + /* return the subtitle of playback. */ + AV_INFO_TYPE_SUBTITLE_UPDATE = 16, +} AVPlayerOnInfoType; + +/** + * @brief Called when a player message or alarm is received. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player The pointer to an OH_AVPlayer instance. + * @param type Indicates the information type. For details, see {@link AVPlayerOnInfoType}. + * @param extra Indicates other information, for example, the start time position of a playing file. + * @since 11 + * @version 1.0 + */ +typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, int32_t extra); + +/** + * @brief Called when an error occurred for versions above api9 + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player The pointer to an OH_AVPlayer instance. + * @param errorCode Error code. + * @param errorMsg Error message. + * @since 11 + * @version 1.0 + */ +typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg); + +/** + * @brief A collection of all callback function pointers in OH_AVPlayer. Register an instance of this + * structure to the OH_AVPlayer instance, and process the information reported through the callback to ensure the + * normal operation of OH_AVPlayer. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param onInfo Monitor OH_AVPlayer operation information, refer to {@link OH_AVPlayerOnInfo} + * @param onError Monitor OH_AVPlayer operation errors, refer to {@link OH_AVPlayerOnError} + * @since 11 + * @version 1.0 + */ +typedef struct AVPlayerCallback { + OH_AVPlayerOnInfo onInfo; + OH_AVPlayerOnError onError; +} AVPlayerCallback; + + +#ifdef __cplusplus +} +#endif +#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_BASH_H