1049e185fSopenharmony_ci/* 2049e185fSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 3049e185fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4049e185fSopenharmony_ci * you may not use this file except in compliance with the License. 5049e185fSopenharmony_ci * You may obtain a copy of the License at 6049e185fSopenharmony_ci * 7049e185fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8049e185fSopenharmony_ci * 9049e185fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10049e185fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11049e185fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12049e185fSopenharmony_ci * See the License for the specific language governing permissions and 13049e185fSopenharmony_ci * limitations under the License. 14049e185fSopenharmony_ci */ 15049e185fSopenharmony_ci 16049e185fSopenharmony_ci/** 17049e185fSopenharmony_ci * @addtogroup AVPlayer 18049e185fSopenharmony_ci * @{ 19049e185fSopenharmony_ci * 20049e185fSopenharmony_ci * @brief Provides APIs of Playback capability for Media Source. 21049e185fSopenharmony_ci * 22049e185fSopenharmony_ci * @Syscap SystemCapability.Multimedia.Media.AVPlayer 23049e185fSopenharmony_ci * @since 11 24049e185fSopenharmony_ci * @version 1.0 25049e185fSopenharmony_ci */ 26049e185fSopenharmony_ci 27049e185fSopenharmony_ci/** 28049e185fSopenharmony_ci * @file avplayer.h 29049e185fSopenharmony_ci * 30049e185fSopenharmony_ci * @brief Defines the avplayer APIs. Uses the Native APIs provided by Media AVPlayer 31049e185fSopenharmony_ci * to play the media source. 32049e185fSopenharmony_ci * 33049e185fSopenharmony_ci * @kit MediaKit 34049e185fSopenharmony_ci * @library libavplayer.so 35049e185fSopenharmony_ci * @since 11 36049e185fSopenharmony_ci * @version 1.0 37049e185fSopenharmony_ci */ 38049e185fSopenharmony_ci 39049e185fSopenharmony_ci#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H 40049e185fSopenharmony_ci#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H 41049e185fSopenharmony_ci 42049e185fSopenharmony_ci#include <stdint.h> 43049e185fSopenharmony_ci#include <stdio.h> 44049e185fSopenharmony_ci#include "native_averrors.h" 45049e185fSopenharmony_ci#include "avplayer_base.h" 46049e185fSopenharmony_ci#include "native_audiostream_base.h" 47049e185fSopenharmony_ci 48049e185fSopenharmony_ci 49049e185fSopenharmony_ci#ifdef __cplusplus 50049e185fSopenharmony_ciextern "C" { 51049e185fSopenharmony_ci#endif 52049e185fSopenharmony_ci 53049e185fSopenharmony_citypedef struct MediaKeySession MediaKeySession; 54049e185fSopenharmony_citypedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; 55049e185fSopenharmony_citypedef void (*Player_MediaKeySystemInfoCallback)(OH_AVPlayer *play, DRM_MediaKeySystemInfo* mediaKeySystemInfo); 56049e185fSopenharmony_ci 57049e185fSopenharmony_ci/** 58049e185fSopenharmony_ci * @brief Create a player 59049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 60049e185fSopenharmony_ci * @return Returns a pointer to an OH_AVPlayer instance 61049e185fSopenharmony_ci * @since 11 62049e185fSopenharmony_ci * @version 1.0 63049e185fSopenharmony_ci*/ 64049e185fSopenharmony_ciOH_AVPlayer *OH_AVPlayer_Create(void); 65049e185fSopenharmony_ci 66049e185fSopenharmony_ci/** 67049e185fSopenharmony_ci * @brief Sets the playback source for the player. The corresponding source can be http url 68049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 69049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 70049e185fSopenharmony_ci * @param url Indicates the playback source. 71049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the url is set successfully; returns an error code defined 72049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 73049e185fSopenharmony_ci * @since 11 74049e185fSopenharmony_ci * @version 1.0 75049e185fSopenharmony_ci */ 76049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetURLSource(OH_AVPlayer *player, const char *url); 77049e185fSopenharmony_ci 78049e185fSopenharmony_ci/** 79049e185fSopenharmony_ci * @brief Sets the playback media file descriptor source for the player. 80049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 81049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 82049e185fSopenharmony_ci * @param fd Indicates the file descriptor of media source. 83049e185fSopenharmony_ci * @param offset Indicates the offset of media source in file descriptor. 84049e185fSopenharmony_ci * @param size Indicates the size of media source. 85049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the fd source is set successfully; returns an error code defined 86049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 87049e185fSopenharmony_ci * @since 11 88049e185fSopenharmony_ci * @version 1.0 89049e185fSopenharmony_ci */ 90049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetFDSource(OH_AVPlayer *player, int32_t fd, int64_t offset, int64_t size); 91049e185fSopenharmony_ci 92049e185fSopenharmony_ci/** 93049e185fSopenharmony_ci * @brief Prepares the playback environment and buffers media data asynchronous. 94049e185fSopenharmony_ci * 95049e185fSopenharmony_ci * This function must be called after {@link SetSource}. 96049e185fSopenharmony_ci * 97049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 98049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 99049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if {@link Prepare} is successfully added to the task queue; 100049e185fSopenharmony_ci * returns an error code defined in {@link native_averrors.h} otherwise. 101049e185fSopenharmony_ci * @since 11 102049e185fSopenharmony_ci * @version 1.0 103049e185fSopenharmony_ci */ 104049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Prepare(OH_AVPlayer *player); 105049e185fSopenharmony_ci 106049e185fSopenharmony_ci/** 107049e185fSopenharmony_ci * @brief Start playback. 108049e185fSopenharmony_ci * 109049e185fSopenharmony_ci * This function must be called after {@link Prepare}. If the player state is <b>Prepared</b>, 110049e185fSopenharmony_ci * this function is called to start playback. 111049e185fSopenharmony_ci * 112049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 113049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 114049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the playback is started; otherwise returns an error code defined 115049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 116049e185fSopenharmony_ci * @since 11 117049e185fSopenharmony_ci * @version 1.0 118049e185fSopenharmony_ci */ 119049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Play(OH_AVPlayer *player); 120049e185fSopenharmony_ci 121049e185fSopenharmony_ci/** 122049e185fSopenharmony_ci * @brief Pauses playback. 123049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 124049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 125049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if {@link Pause} is successfully added to the task queue; 126049e185fSopenharmony_ci * returns an error code defined in {@link native_averrors.h} otherwise. 127049e185fSopenharmony_ci * @since 11 128049e185fSopenharmony_ci * @version 1.0 129049e185fSopenharmony_ci */ 130049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Pause(OH_AVPlayer *player); 131049e185fSopenharmony_ci 132049e185fSopenharmony_ci/** 133049e185fSopenharmony_ci * @brief Stop playback. 134049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 135049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 136049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if {@link Stop} is successfully added to the task queue; 137049e185fSopenharmony_ci * returns an error code defined in {@link native_averrors.h} otherwise. 138049e185fSopenharmony_ci * @since 11 139049e185fSopenharmony_ci * @version 1.0 140049e185fSopenharmony_ci */ 141049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Stop(OH_AVPlayer *player); 142049e185fSopenharmony_ci 143049e185fSopenharmony_ci/** 144049e185fSopenharmony_ci * @brief Restores the player to the initial state. 145049e185fSopenharmony_ci * 146049e185fSopenharmony_ci * After the function is called, add a playback source by calling {@link SetSource}, 147049e185fSopenharmony_ci * call {@link Play} to start playback again after {@link Prepare} is called. 148049e185fSopenharmony_ci * 149049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 150049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 151049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if {@link Reset} is successfully added to the task queue; 152049e185fSopenharmony_ci * returns an error code defined in {@link native_averrors.h} otherwise. 153049e185fSopenharmony_ci * @since 11 154049e185fSopenharmony_ci * @version 1.0 155049e185fSopenharmony_ci */ 156049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Reset(OH_AVPlayer *player); 157049e185fSopenharmony_ci 158049e185fSopenharmony_ci/** 159049e185fSopenharmony_ci * @brief Releases player resources async 160049e185fSopenharmony_ci * 161049e185fSopenharmony_ci * Asynchronous release guarantees the performance 162049e185fSopenharmony_ci * but cannot ensure whether the surfacebuffer is released. 163049e185fSopenharmony_ci * The caller needs to ensure the life cycle security of the surface 164049e185fSopenharmony_ci * 165049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 166049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 167049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if {@link Release} is successfully added to the task queue; 168049e185fSopenharmony_ci * returns an error code defined in {@link native_averrors.h} otherwise. 169049e185fSopenharmony_ci * @since 11 170049e185fSopenharmony_ci * @version 1.0 171049e185fSopenharmony_ci */ 172049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Release(OH_AVPlayer *player); 173049e185fSopenharmony_ci 174049e185fSopenharmony_ci/** 175049e185fSopenharmony_ci * @brief Releases player resources sync 176049e185fSopenharmony_ci * 177049e185fSopenharmony_ci * Synchronous release ensures effective release of surfacebuffer 178049e185fSopenharmony_ci * but this interface will take a long time (when the engine is not idle state) 179049e185fSopenharmony_ci * requiring the caller to design an asynchronous mechanism by itself 180049e185fSopenharmony_ci * 181049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 182049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 183049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the playback is released; returns an error code defined 184049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 185049e185fSopenharmony_ci * @since 11 186049e185fSopenharmony_ci * @version 1.0 187049e185fSopenharmony_ci */ 188049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_ReleaseSync(OH_AVPlayer *player); 189049e185fSopenharmony_ci 190049e185fSopenharmony_ci/** 191049e185fSopenharmony_ci * @brief Sets the volume of the player. 192049e185fSopenharmony_ci * 193049e185fSopenharmony_ci * This function can be used during playback or pause. The value <b>0</b> indicates no sound, 194049e185fSopenharmony_ci * and <b>1</b> indicates the original volume. If no audio device is started or no audio 195049e185fSopenharmony_ci * stream exists, the value <b>-1</b> is returned. 196049e185fSopenharmony_ci * 197049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 198049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 199049e185fSopenharmony_ci * @param leftVolume Indicates the target volume of the left audio channel to set, 200049e185fSopenharmony_ci * ranging from 0 to 1. each step is 0.01. 201049e185fSopenharmony_ci * @param rightVolume Indicates the target volume of the right audio channel to set, 202049e185fSopenharmony_ci * ranging from 0 to 1. each step is 0.01. 203049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the volume is set; returns an error code defined 204049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 205049e185fSopenharmony_ci * @since 11 206049e185fSopenharmony_ci * @version 1.0 207049e185fSopenharmony_ci */ 208049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetVolume(OH_AVPlayer *player, float leftVolume, float rightVolume); 209049e185fSopenharmony_ci 210049e185fSopenharmony_ci/** 211049e185fSopenharmony_ci * @brief Changes the playback position. 212049e185fSopenharmony_ci * 213049e185fSopenharmony_ci * This function can be used during play or pause. 214049e185fSopenharmony_ci * 215049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 216049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 217049e185fSopenharmony_ci * @param mSeconds Indicates the target playback position, accurate to milliseconds. 218049e185fSopenharmony_ci * @param mode Indicates the player seek mode. For details, see {@link AVPlayerSeekMode}. 219049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the seek is done; returns an error code defined 220049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 221049e185fSopenharmony_ci * @since 11 222049e185fSopenharmony_ci * @version 1.0 223049e185fSopenharmony_ci*/ 224049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_Seek(OH_AVPlayer *player, int32_t mSeconds, AVPlayerSeekMode mode); 225049e185fSopenharmony_ci 226049e185fSopenharmony_ci/** 227049e185fSopenharmony_ci * @brief Obtains the playback position, accurate to millisecond. 228049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 229049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 230049e185fSopenharmony_ci * @param currentTime Indicates the playback position. 231049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined 232049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 233049e185fSopenharmony_ci * @since 11 234049e185fSopenharmony_ci * @version 1.0 235049e185fSopenharmony_ci */ 236049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetCurrentTime(OH_AVPlayer *player, int32_t *currentTime); 237049e185fSopenharmony_ci 238049e185fSopenharmony_ci/** 239049e185fSopenharmony_ci * @brief get the video width. 240049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 241049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 242049e185fSopenharmony_ci * @param videoWidth The video width 243049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined 244049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 245049e185fSopenharmony_ci * @since 11 246049e185fSopenharmony_ci * @version 1.0 247049e185fSopenharmony_ci */ 248049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetVideoWidth(OH_AVPlayer *player, int32_t *videoWidth); 249049e185fSopenharmony_ci 250049e185fSopenharmony_ci/** 251049e185fSopenharmony_ci * @brief get the video height. 252049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 253049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 254049e185fSopenharmony_ci * @param videoHeight The video height 255049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined 256049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 257049e185fSopenharmony_ci * @since 11 258049e185fSopenharmony_ci * @version 1.0 259049e185fSopenharmony_ci */ 260049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetVideoHeight(OH_AVPlayer *player, int32_t *videoHeight); 261049e185fSopenharmony_ci 262049e185fSopenharmony_ci/** 263049e185fSopenharmony_ci * @brief set the player playback rate 264049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 265049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 266049e185fSopenharmony_ci * @param speed the rate mode {@link AVPlaybackSpeed} which can set. 267049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the playback rate is set successful; returns an error code defined 268049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 269049e185fSopenharmony_ci * @since 11 270049e185fSopenharmony_ci * @version 1.0 271049e185fSopenharmony_ci */ 272049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed speed); 273049e185fSopenharmony_ci 274049e185fSopenharmony_ci/** 275049e185fSopenharmony_ci * @brief get the current player playback rate 276049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 277049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 278049e185fSopenharmony_ci * @param speed the rate mode {@link AVPlaybackSpeed} which can get. 279049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current player playback rate is get; returns an error code defined 280049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 281049e185fSopenharmony_ci * @since 11 282049e185fSopenharmony_ci * @version 1.0 283049e185fSopenharmony_ci */ 284049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed); 285049e185fSopenharmony_ci 286049e185fSopenharmony_ci/** 287049e185fSopenharmony_ci * @brief Set the renderer information of the player's audio renderer 288049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 289049e185fSopenharmony_ci * @param streamUsage The value {@link OH_AudioStream_Usage} used for the stream usage of the player audio render. 290049e185fSopenharmony_ci * @return Function result code. 291049e185fSopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 292049e185fSopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or streamUsage value is invalid. 293049e185fSopenharmony_ci * @since 12 294049e185fSopenharmony_ci * @version 1.0 295049e185fSopenharmony_ci */ 296049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetAudioRendererInfo(OH_AVPlayer *player, OH_AudioStream_Usage streamUsage); 297049e185fSopenharmony_ci 298049e185fSopenharmony_ci/** 299049e185fSopenharmony_ci * @brief Set the interruption mode of the player's audio stream 300049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 301049e185fSopenharmony_ci * @param interruptMode The value {@link OH_AudioInterrupt_Mode} used for the interruption mode of 302049e185fSopenharmony_ci * the player audio stream. 303049e185fSopenharmony_ci * @return Function result code. 304049e185fSopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 305049e185fSopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or interruptMode value is invalid. 306049e185fSopenharmony_ci * @since 12 307049e185fSopenharmony_ci * @version 1.0 308049e185fSopenharmony_ci */ 309049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetAudioInterruptMode(OH_AVPlayer *player, OH_AudioInterrupt_Mode interruptMode); 310049e185fSopenharmony_ci 311049e185fSopenharmony_ci/** 312049e185fSopenharmony_ci * @brief Set the effect mode of the player's audio stream 313049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 314049e185fSopenharmony_ci * @param effectMode The value {@link OH_AudioStream_AudioEffectMode} used for the effect mode of 315049e185fSopenharmony_ci * the player audio stream. 316049e185fSopenharmony_ci * @return Function result code. 317049e185fSopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 318049e185fSopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or effectMode value is invalid. 319049e185fSopenharmony_ci * @since 12 320049e185fSopenharmony_ci * @version 1.0 321049e185fSopenharmony_ci */ 322049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetAudioEffectMode(OH_AVPlayer *player, OH_AudioStream_AudioEffectMode effectMode); 323049e185fSopenharmony_ci 324049e185fSopenharmony_ci/** 325049e185fSopenharmony_ci * @brief set the bit rate use for hls player 326049e185fSopenharmony_ci * 327049e185fSopenharmony_ci * the playback bitrate expressed in bits per second, expressed in bits per second, 328049e185fSopenharmony_ci * which is only valid for HLS protocol network flow. By default, 329049e185fSopenharmony_ci * the player will select the appropriate bit rate and speed according to the network connection. 330049e185fSopenharmony_ci * report the effective bit rate linked list by "INFO_TYPE_BITRATE_COLLECT" 331049e185fSopenharmony_ci * set and select the specified bit rate, and select the bit rate that is less than and closest 332049e185fSopenharmony_ci * to the specified bit rate for playback. When ready, read it to query the currently selected bit rate. 333049e185fSopenharmony_ci * 334049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 335049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 336049e185fSopenharmony_ci * @param bitRate the bit rate, The unit is bps. 337049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the bit rate is set successfully; returns an error code defined 338049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 339049e185fSopenharmony_ci * @since 11 340049e185fSopenharmony_ci * @version 1.0 341049e185fSopenharmony_ci */ 342049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SelectBitRate(OH_AVPlayer *player, uint32_t bitRate); 343049e185fSopenharmony_ci 344049e185fSopenharmony_ci/** 345049e185fSopenharmony_ci * @brief Method to set the surface. 346049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 347049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 348049e185fSopenharmony_ci * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} 349049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the surface is set; returns an error code defined 350049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 351049e185fSopenharmony_ci * @since 11 352049e185fSopenharmony_ci * @version 1.0 353049e185fSopenharmony_ci */ 354049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetVideoSurface(OH_AVPlayer *player, OHNativeWindow *window); 355049e185fSopenharmony_ci 356049e185fSopenharmony_ci/** 357049e185fSopenharmony_ci * @brief Obtains the total duration of media files, accurate to milliseconds. 358049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 359049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 360049e185fSopenharmony_ci * @param duration Indicates the total duration of media files. 361049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined 362049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 363049e185fSopenharmony_ci * @since 11 364049e185fSopenharmony_ci * @version 1.0 365049e185fSopenharmony_ci */ 366049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetDuration(OH_AVPlayer *player, int32_t *duration); 367049e185fSopenharmony_ci 368049e185fSopenharmony_ci/** 369049e185fSopenharmony_ci * @brief get current playback state. 370049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 371049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 372049e185fSopenharmony_ci * @param state the current playback state 373049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current duration is get; returns an error code defined 374049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 375049e185fSopenharmony_ci * @since 11 376049e185fSopenharmony_ci * @version 1.0 377049e185fSopenharmony_ci */ 378049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetState(OH_AVPlayer *player, AVPlayerState *state); 379049e185fSopenharmony_ci 380049e185fSopenharmony_ci/** 381049e185fSopenharmony_ci * @brief Checks whether the player is playing. 382049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 383049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 384049e185fSopenharmony_ci * @return Returns true if the playback is playing; false otherwise. 385049e185fSopenharmony_ci * @since 11 386049e185fSopenharmony_ci * @version 1.0 387049e185fSopenharmony_ci */ 388049e185fSopenharmony_cibool OH_AVPlayer_IsPlaying(OH_AVPlayer *player); 389049e185fSopenharmony_ci 390049e185fSopenharmony_ci/** 391049e185fSopenharmony_ci * @brief Returns the value whether single looping is enabled or not . 392049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 393049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 394049e185fSopenharmony_ci * @return Returns true if the playback is single looping; false otherwise. 395049e185fSopenharmony_ci * @since 11 396049e185fSopenharmony_ci * @version 1.0 397049e185fSopenharmony_ci */ 398049e185fSopenharmony_cibool OH_AVPlayer_IsLooping(OH_AVPlayer *player); 399049e185fSopenharmony_ci 400049e185fSopenharmony_ci/** 401049e185fSopenharmony_ci * @brief Enables single looping of the media playback. 402049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 403049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 404049e185fSopenharmony_ci * @param loop The switch to set loop 405049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the single looping is set; returns an error code defined 406049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 407049e185fSopenharmony_ci * @since 11 408049e185fSopenharmony_ci * @version 1.0 409049e185fSopenharmony_ci */ 410049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); 411049e185fSopenharmony_ci 412049e185fSopenharmony_ci/** 413049e185fSopenharmony_ci * @brief Method to set player callback. 414049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 415049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 416049e185fSopenharmony_ci * @param callback object pointer. 417049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the playercallback is set; returns an error code defined 418049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 419049e185fSopenharmony_ci * @since 11 420049e185fSopenharmony_ci * @deprecated since 12 421049e185fSopenharmony_ci * @useinstead {@link OH_AVPlayer_SetPlayerOnInfoCallback} {@link OH_AVPlayer_SetPlayerOnErrorCallback} 422049e185fSopenharmony_ci * @version 1.0 423049e185fSopenharmony_ci */ 424049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback callback); 425049e185fSopenharmony_ci 426049e185fSopenharmony_ci/** 427049e185fSopenharmony_ci * @brief Select audio or subtitle track. 428049e185fSopenharmony_ci * 429049e185fSopenharmony_ci * By default, the first audio stream with data is played, and the subtitle track is not played. 430049e185fSopenharmony_ci * After the settings take effect, the original track will become invalid. Please set subtitles 431049e185fSopenharmony_ci * in prepared/playing/paused/completed state and set audio tracks in prepared state. 432049e185fSopenharmony_ci * 433049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 434049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 435049e185fSopenharmony_ci * @param index Track index 436049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined 437049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 438049e185fSopenharmony_ci * @since 11 439049e185fSopenharmony_ci * @version 1.0 440049e185fSopenharmony_ci*/ 441049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SelectTrack(OH_AVPlayer *player, int32_t index); 442049e185fSopenharmony_ci 443049e185fSopenharmony_ci/** 444049e185fSopenharmony_ci * @brief Deselect the current audio or subtitle track. 445049e185fSopenharmony_ci * 446049e185fSopenharmony_ci * After audio is deselected, the default track will be played, and after subtitles are deselected, 447049e185fSopenharmony_ci * they will not be played. Please set subtitles in prepared/playing/paused/completed state and set 448049e185fSopenharmony_ci * audio tracks in prepared state. 449049e185fSopenharmony_ci * 450049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 451049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 452049e185fSopenharmony_ci * @param index Track index 453049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if selected successfully; returns an error code defined 454049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 455049e185fSopenharmony_ci * @since 11 456049e185fSopenharmony_ci * @version 1.0 457049e185fSopenharmony_ci*/ 458049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_DeselectTrack(OH_AVPlayer *player, int32_t index); 459049e185fSopenharmony_ci 460049e185fSopenharmony_ci/** 461049e185fSopenharmony_ci * @brief Obtain the currently effective track index. 462049e185fSopenharmony_ci * 463049e185fSopenharmony_ci * Please get it in the prepared/playing/paused/completed state. 464049e185fSopenharmony_ci * 465049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 466049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 467049e185fSopenharmony_ci * @param trackType Media type. 468049e185fSopenharmony_ci * @param index Track index 469049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the track index is get; returns an error code defined 470049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 471049e185fSopenharmony_ci * @since 11 472049e185fSopenharmony_ci * @version 1.0 473049e185fSopenharmony_ci */ 474049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, int32_t *index); 475049e185fSopenharmony_ci 476049e185fSopenharmony_ci/** 477049e185fSopenharmony_ci * @brief Method to set player media key system info callback. 478049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 479049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 480049e185fSopenharmony_ci * @param callback object pointer. 481049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined 482049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 483049e185fSopenharmony_ci * @since 12 484049e185fSopenharmony_ci * @version 1.0 485049e185fSopenharmony_ci */ 486049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetMediaKeySystemInfoCallback(OH_AVPlayer *player, 487049e185fSopenharmony_ci Player_MediaKeySystemInfoCallback callback); 488049e185fSopenharmony_ci 489049e185fSopenharmony_ci/** 490049e185fSopenharmony_ci * @brief Obtains media key system info to create media key session. 491049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 492049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 493049e185fSopenharmony_ci * @param mediaKeySystemInfo Media key system info. 494049e185fSopenharmony_ci * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined 495049e185fSopenharmony_ci * in {@link native_averrors.h} otherwise. 496049e185fSopenharmony_ci * @since 12 497049e185fSopenharmony_ci * @version 1.0 498049e185fSopenharmony_ci */ 499049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKeySystemInfo *mediaKeySystemInfo); 500049e185fSopenharmony_ci 501049e185fSopenharmony_ci/** 502049e185fSopenharmony_ci * @brief Set decryption info. 503049e185fSopenharmony_ci * 504049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 505049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 506049e185fSopenharmony_ci * @param mediaKeySession A media key session instance with decryption function. 507049e185fSopenharmony_ci * @param secureVideoPath Require secure decoder or not. 508049e185fSopenharmony_ci * @return Returns AV_ERR_OK if the execution is successful, 509049e185fSopenharmony_ci * otherwise returns a specific error code, refer to {@link OH_AVErrCode} 510049e185fSopenharmony_ci * @since 12 511049e185fSopenharmony_ci * @version 1.0 512049e185fSopenharmony_ci*/ 513049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySession *mediaKeySession, 514049e185fSopenharmony_ci bool secureVideoPath); 515049e185fSopenharmony_ci 516049e185fSopenharmony_ci/** 517049e185fSopenharmony_ci * @brief Method to set player information notify callback. 518049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 519049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance. 520049e185fSopenharmony_ci * @param callback Pointer to callback function, nullptr indicates unregister callback. 521049e185fSopenharmony_ci * @param userData Pointer to user specific data. 522049e185fSopenharmony_ci * @return Function result code. 523049e185fSopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 524049e185fSopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnInfoCallback failed. 525049e185fSopenharmony_ci * @since 12 526049e185fSopenharmony_ci */ 527049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInfoCallback callback, void *userData); 528049e185fSopenharmony_ci 529049e185fSopenharmony_ci/** 530049e185fSopenharmony_ci * @brief Method to set player error callback. 531049e185fSopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 532049e185fSopenharmony_ci * @param player Pointer to an OH_AVPlayer instance. 533049e185fSopenharmony_ci * @param callback Pointer to callback function, nullptr indicates unregister callback. 534049e185fSopenharmony_ci * @param userData Pointer to user specific data. 535049e185fSopenharmony_ci * @return Function result code. 536049e185fSopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 537049e185fSopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnErrorCallback failed. 538049e185fSopenharmony_ci * @since 12 539049e185fSopenharmony_ci */ 540049e185fSopenharmony_ciOH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnErrorCallback callback, void *userData); 541049e185fSopenharmony_ci 542049e185fSopenharmony_ci#ifdef __cplusplus 543049e185fSopenharmony_ci} 544049e185fSopenharmony_ci#endif 545049e185fSopenharmony_ci 546049e185fSopenharmony_ci#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H 547