17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci/** 177777dab0Sopenharmony_ci * @addtogroup AVPlayer 187777dab0Sopenharmony_ci * @{ 197777dab0Sopenharmony_ci * 207777dab0Sopenharmony_ci * @brief Provides APIs of Playback capability for Media Source. 217777dab0Sopenharmony_ci * 227777dab0Sopenharmony_ci * @Syscap SystemCapability.Multimedia.Media.AVPlayer 237777dab0Sopenharmony_ci * @since 11 247777dab0Sopenharmony_ci * @version 1.0 257777dab0Sopenharmony_ci */ 267777dab0Sopenharmony_ci 277777dab0Sopenharmony_ci/** 287777dab0Sopenharmony_ci * @file avplayer.h 297777dab0Sopenharmony_ci * 307777dab0Sopenharmony_ci * @brief Defines the avplayer APIs. Uses the Native APIs provided by Media AVPlayer 317777dab0Sopenharmony_ci * to play the media source. 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @kit MediaKit 347777dab0Sopenharmony_ci * @library libavplayer.so 357777dab0Sopenharmony_ci * @since 11 367777dab0Sopenharmony_ci * @version 1.0 377777dab0Sopenharmony_ci */ 387777dab0Sopenharmony_ci 397777dab0Sopenharmony_ci#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H 407777dab0Sopenharmony_ci#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#include <stdbool.h> 437777dab0Sopenharmony_ci#include <stdint.h> 447777dab0Sopenharmony_ci#include <stdio.h> 457777dab0Sopenharmony_ci#include "native_averrors.h" 467777dab0Sopenharmony_ci#include "avplayer_base.h" 477777dab0Sopenharmony_ci#include "native_window/external_window.h" 487777dab0Sopenharmony_ci#include "ohaudio/native_audiostream_base.h" 497777dab0Sopenharmony_ci 507777dab0Sopenharmony_ci#ifdef __cplusplus 517777dab0Sopenharmony_ciextern "C" { 527777dab0Sopenharmony_ci#endif 537777dab0Sopenharmony_ci 547777dab0Sopenharmony_ci/** 557777dab0Sopenharmony_ci * @brief MediaKeySession field. 567777dab0Sopenharmony_ci * @since 12 577777dab0Sopenharmony_ci * @version 1.0 587777dab0Sopenharmony_ci */ 597777dab0Sopenharmony_citypedef struct MediaKeySession MediaKeySession; 607777dab0Sopenharmony_ci/** 617777dab0Sopenharmony_ci * @brief DRM_MediaKeySystemInfo field. 627777dab0Sopenharmony_ci * @since 12 637777dab0Sopenharmony_ci * @version 1.0 647777dab0Sopenharmony_ci */ 657777dab0Sopenharmony_citypedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; 667777dab0Sopenharmony_ci 677777dab0Sopenharmony_ci/** 687777dab0Sopenharmony_ci * @brief Call back will be invoked when updating DRM information. 697777dab0Sopenharmony_ci * @param player Player instance. 707777dab0Sopenharmony_ci * @param mediaKeySystemInfo DRM information. 717777dab0Sopenharmony_ci * @return void 727777dab0Sopenharmony_ci * @since 12 737777dab0Sopenharmony_ci * @version 1.0 747777dab0Sopenharmony_ci */ 757777dab0Sopenharmony_citypedef void (*Player_MediaKeySystemInfoCallback)(OH_AVPlayer *player, DRM_MediaKeySystemInfo* mediaKeySystemInfo); 767777dab0Sopenharmony_ci 777777dab0Sopenharmony_ci/** 787777dab0Sopenharmony_ci * @brief Create a player 797777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 807777dab0Sopenharmony_ci * @return Returns a pointer to an OH_AVPlayer instance for success, nullptr for failure 817777dab0Sopenharmony_ci * Possible failure causes: 1. failed to PlayerFactory::CreatePlayer. 2. failed to new PlayerObject. 827777dab0Sopenharmony_ci * @since 11 837777dab0Sopenharmony_ci * @version 1.0 847777dab0Sopenharmony_ci*/ 857777dab0Sopenharmony_ciOH_AVPlayer *OH_AVPlayer_Create(void); 867777dab0Sopenharmony_ci 877777dab0Sopenharmony_ci/** 887777dab0Sopenharmony_ci * @brief Sets the playback source for the player. The corresponding source can be http url 897777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 907777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 917777dab0Sopenharmony_ci * @param url Indicates the playback source. 927777dab0Sopenharmony_ci * @return Function result code. 937777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 947777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr, url is null or player setUrlSource failed. 957777dab0Sopenharmony_ci * @since 11 967777dab0Sopenharmony_ci * @version 1.0 977777dab0Sopenharmony_ci */ 987777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetURLSource(OH_AVPlayer *player, const char *url); 997777dab0Sopenharmony_ci 1007777dab0Sopenharmony_ci/** 1017777dab0Sopenharmony_ci * @brief Sets the playback media file descriptor source for the player. 1027777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1037777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1047777dab0Sopenharmony_ci * @param fd Indicates the file descriptor of media source. 1057777dab0Sopenharmony_ci * @param offset Indicates the offset of media source in file descriptor. 1067777dab0Sopenharmony_ci * @param size Indicates the size of media source. 1077777dab0Sopenharmony_ci * @return Function result code. 1087777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1097777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player setFdSource failed. 1107777dab0Sopenharmony_ci * @since 11 1117777dab0Sopenharmony_ci * @version 1.0 1127777dab0Sopenharmony_ci */ 1137777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetFDSource(OH_AVPlayer *player, int32_t fd, int64_t offset, int64_t size); 1147777dab0Sopenharmony_ci 1157777dab0Sopenharmony_ci/** 1167777dab0Sopenharmony_ci * @brief Prepares the playback environment and buffers media data asynchronous. 1177777dab0Sopenharmony_ci * 1187777dab0Sopenharmony_ci * This function must be called after {@link SetSource}. 1197777dab0Sopenharmony_ci * 1207777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1217777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1227777dab0Sopenharmony_ci * @return Function result code. 1237777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1247777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Prepare failed. 1257777dab0Sopenharmony_ci * @since 11 1267777dab0Sopenharmony_ci * @version 1.0 1277777dab0Sopenharmony_ci */ 1287777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Prepare(OH_AVPlayer *player); 1297777dab0Sopenharmony_ci 1307777dab0Sopenharmony_ci/** 1317777dab0Sopenharmony_ci * @brief Start playback. 1327777dab0Sopenharmony_ci * 1337777dab0Sopenharmony_ci * This function must be called after {@link Prepare}. If the player state is <b>Prepared</b>, 1347777dab0Sopenharmony_ci * this function is called to start playback. 1357777dab0Sopenharmony_ci * 1367777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1377777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1387777dab0Sopenharmony_ci * @return Function result code. 1397777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1407777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Play failed. 1417777dab0Sopenharmony_ci * @since 11 1427777dab0Sopenharmony_ci * @version 1.0 1437777dab0Sopenharmony_ci */ 1447777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Play(OH_AVPlayer *player); 1457777dab0Sopenharmony_ci 1467777dab0Sopenharmony_ci/** 1477777dab0Sopenharmony_ci * @brief Pauses playback. 1487777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1497777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1507777dab0Sopenharmony_ci * @return Function result code. 1517777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1527777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Pause failed. 1537777dab0Sopenharmony_ci * @since 11 1547777dab0Sopenharmony_ci * @version 1.0 1557777dab0Sopenharmony_ci */ 1567777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Pause(OH_AVPlayer *player); 1577777dab0Sopenharmony_ci 1587777dab0Sopenharmony_ci/** 1597777dab0Sopenharmony_ci * @brief Stop playback. 1607777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1617777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1627777dab0Sopenharmony_ci * @return Function result code. 1637777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1647777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Stop failed. 1657777dab0Sopenharmony_ci * @since 11 1667777dab0Sopenharmony_ci * @version 1.0 1677777dab0Sopenharmony_ci */ 1687777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Stop(OH_AVPlayer *player); 1697777dab0Sopenharmony_ci 1707777dab0Sopenharmony_ci/** 1717777dab0Sopenharmony_ci * @brief Restores the player to the initial state. 1727777dab0Sopenharmony_ci * 1737777dab0Sopenharmony_ci * After the function is called, add a playback source by calling {@link SetSource}, 1747777dab0Sopenharmony_ci * call {@link Play} to start playback again after {@link Prepare} is called. 1757777dab0Sopenharmony_ci * 1767777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1777777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1787777dab0Sopenharmony_ci * @return Function result code. 1797777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1807777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Reset failed. 1817777dab0Sopenharmony_ci * @since 11 1827777dab0Sopenharmony_ci * @version 1.0 1837777dab0Sopenharmony_ci */ 1847777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Reset(OH_AVPlayer *player); 1857777dab0Sopenharmony_ci 1867777dab0Sopenharmony_ci/** 1877777dab0Sopenharmony_ci * @brief Releases player resources async 1887777dab0Sopenharmony_ci * 1897777dab0Sopenharmony_ci * Asynchronous release guarantees the performance 1907777dab0Sopenharmony_ci * but cannot ensure whether the surfacebuffer is released. 1917777dab0Sopenharmony_ci * The caller needs to ensure the life cycle security of the surface 1927777dab0Sopenharmony_ci * 1937777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 1947777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 1957777dab0Sopenharmony_ci * @return Function result code. 1967777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 1977777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Release failed. 1987777dab0Sopenharmony_ci * @since 11 1997777dab0Sopenharmony_ci * @version 1.0 2007777dab0Sopenharmony_ci */ 2017777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Release(OH_AVPlayer *player); 2027777dab0Sopenharmony_ci 2037777dab0Sopenharmony_ci/** 2047777dab0Sopenharmony_ci * @brief Releases player resources sync 2057777dab0Sopenharmony_ci * 2067777dab0Sopenharmony_ci * Synchronous release ensures effective release of surfacebuffer 2077777dab0Sopenharmony_ci * but this interface will take a long time (when the engine is not idle state) 2087777dab0Sopenharmony_ci * requiring the caller to design an asynchronous mechanism by itself 2097777dab0Sopenharmony_ci * 2107777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 2117777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 2127777dab0Sopenharmony_ci * @return Function result code. 2137777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 2147777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player ReleaseSync failed. 2157777dab0Sopenharmony_ci * @since 11 2167777dab0Sopenharmony_ci * @version 1.0 2177777dab0Sopenharmony_ci */ 2187777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_ReleaseSync(OH_AVPlayer *player); 2197777dab0Sopenharmony_ci 2207777dab0Sopenharmony_ci/** 2217777dab0Sopenharmony_ci * @brief Sets the volume of the player. 2227777dab0Sopenharmony_ci * 2237777dab0Sopenharmony_ci * This function can be used during playback or pause. The value <b>0</b> indicates no sound, 2247777dab0Sopenharmony_ci * and <b>1</b> indicates the original volume. If no audio device is started or no audio 2257777dab0Sopenharmony_ci * stream exists, the value <b>-1</b> is returned. 2267777dab0Sopenharmony_ci * 2277777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 2287777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 2297777dab0Sopenharmony_ci * @param leftVolume Indicates the target volume of the left audio channel to set, 2307777dab0Sopenharmony_ci * ranging from 0 to 1. each step is 0.01. 2317777dab0Sopenharmony_ci * @param rightVolume Indicates the target volume of the right audio channel to set, 2327777dab0Sopenharmony_ci * ranging from 0 to 1. each step is 0.01. 2337777dab0Sopenharmony_ci * @return Function result code. 2347777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 2357777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetVolume failed. 2367777dab0Sopenharmony_ci * @since 11 2377777dab0Sopenharmony_ci * @version 1.0 2387777dab0Sopenharmony_ci */ 2397777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetVolume(OH_AVPlayer *player, float leftVolume, float rightVolume); 2407777dab0Sopenharmony_ci 2417777dab0Sopenharmony_ci/** 2427777dab0Sopenharmony_ci * @brief Changes the playback position. 2437777dab0Sopenharmony_ci * 2447777dab0Sopenharmony_ci * This function can be used during play or pause. 2457777dab0Sopenharmony_ci * 2467777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 2477777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 2487777dab0Sopenharmony_ci * @param mSeconds Indicates the target playback position, accurate to milliseconds. 2497777dab0Sopenharmony_ci * @param mode Indicates the player seek mode. For details, see {@link AVPlayerSeekMode}. 2507777dab0Sopenharmony_ci * @return Function result code. 2517777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 2527777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player Seek failed. 2537777dab0Sopenharmony_ci * @since 11 2547777dab0Sopenharmony_ci * @version 1.0 2557777dab0Sopenharmony_ci*/ 2567777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_Seek(OH_AVPlayer *player, int32_t mSeconds, AVPlayerSeekMode mode); 2577777dab0Sopenharmony_ci 2587777dab0Sopenharmony_ci/** 2597777dab0Sopenharmony_ci * @brief Obtains the playback position, accurate to millisecond. 2607777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 2617777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 2627777dab0Sopenharmony_ci * @param currentTime Indicates the playback position. 2637777dab0Sopenharmony_ci * @return Function result code. 2647777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 2657777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetCurrentTime failed. 2667777dab0Sopenharmony_ci * @since 11 2677777dab0Sopenharmony_ci * @version 1.0 2687777dab0Sopenharmony_ci */ 2697777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetCurrentTime(OH_AVPlayer *player, int32_t *currentTime); 2707777dab0Sopenharmony_ci 2717777dab0Sopenharmony_ci/** 2727777dab0Sopenharmony_ci * @brief get the video width. 2737777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 2747777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 2757777dab0Sopenharmony_ci * @param videoWidth The video width 2767777dab0Sopenharmony_ci * @return Function result code. 2777777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 2787777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr. 2797777dab0Sopenharmony_ci * @since 11 2807777dab0Sopenharmony_ci * @version 1.0 2817777dab0Sopenharmony_ci */ 2827777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetVideoWidth(OH_AVPlayer *player, int32_t *videoWidth); 2837777dab0Sopenharmony_ci 2847777dab0Sopenharmony_ci/** 2857777dab0Sopenharmony_ci * @brief get the video height. 2867777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 2877777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 2887777dab0Sopenharmony_ci * @param videoHeight The video height 2897777dab0Sopenharmony_ci * @return Function result code. 2907777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 2917777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr. 2927777dab0Sopenharmony_ci * @since 11 2937777dab0Sopenharmony_ci * @version 1.0 2947777dab0Sopenharmony_ci */ 2957777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetVideoHeight(OH_AVPlayer *player, int32_t *videoHeight); 2967777dab0Sopenharmony_ci 2977777dab0Sopenharmony_ci/** 2987777dab0Sopenharmony_ci * @brief set the player playback rate 2997777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 3007777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3017777dab0Sopenharmony_ci * @param speed the rate mode {@link AVPlaybackSpeed} which can set. 3027777dab0Sopenharmony_ci * @return Function result code. 3037777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3047777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetPlaybackSpeed failed. 3057777dab0Sopenharmony_ci * @since 11 3067777dab0Sopenharmony_ci * @version 1.0 3077777dab0Sopenharmony_ci */ 3087777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed speed); 3097777dab0Sopenharmony_ci 3107777dab0Sopenharmony_ci/** 3117777dab0Sopenharmony_ci * @brief get the current player playback rate 3127777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 3137777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3147777dab0Sopenharmony_ci * @param speed the rate mode {@link AVPlaybackSpeed} which can get. 3157777dab0Sopenharmony_ci * @return Function result code. 3167777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3177777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetPlaybackSpeed failed. 3187777dab0Sopenharmony_ci * @since 11 3197777dab0Sopenharmony_ci * @version 1.0 3207777dab0Sopenharmony_ci */ 3217777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetPlaybackSpeed(OH_AVPlayer *player, AVPlaybackSpeed *speed); 3227777dab0Sopenharmony_ci 3237777dab0Sopenharmony_ci/** 3247777dab0Sopenharmony_ci * @brief Set the renderer information of the player's audio renderer 3257777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3267777dab0Sopenharmony_ci * @param streamUsage The value {@link OH_AudioStream_Usage} used for the stream usage of the player audio render. 3277777dab0Sopenharmony_ci * @return Function result code. 3287777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3297777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or streamUsage value is invalid. 3307777dab0Sopenharmony_ci * @since 12 3317777dab0Sopenharmony_ci * @version 1.0 3327777dab0Sopenharmony_ci */ 3337777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetAudioRendererInfo(OH_AVPlayer *player, OH_AudioStream_Usage streamUsage); 3347777dab0Sopenharmony_ci 3357777dab0Sopenharmony_ci/** 3367777dab0Sopenharmony_ci * @brief Set the interruption mode of the player's audio stream 3377777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3387777dab0Sopenharmony_ci * @param interruptMode The value {@link OH_AudioInterrupt_Mode} used for the interruption mode of 3397777dab0Sopenharmony_ci * the player audio stream. 3407777dab0Sopenharmony_ci * @return Function result code. 3417777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3427777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or interruptMode value is invalid. 3437777dab0Sopenharmony_ci * @since 12 3447777dab0Sopenharmony_ci * @version 1.0 3457777dab0Sopenharmony_ci */ 3467777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetAudioInterruptMode(OH_AVPlayer *player, OH_AudioInterrupt_Mode interruptMode); 3477777dab0Sopenharmony_ci 3487777dab0Sopenharmony_ci/** 3497777dab0Sopenharmony_ci * @brief Set the effect mode of the player's audio stream 3507777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3517777dab0Sopenharmony_ci * @param effectMode The value {@link OH_AudioStream_AudioEffectMode} used for the effect mode of 3527777dab0Sopenharmony_ci * the player audio stream. 3537777dab0Sopenharmony_ci * @return Function result code. 3547777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3557777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or effectMode value is invalid. 3567777dab0Sopenharmony_ci * @since 12 3577777dab0Sopenharmony_ci * @version 1.0 3587777dab0Sopenharmony_ci */ 3597777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetAudioEffectMode(OH_AVPlayer *player, OH_AudioStream_AudioEffectMode effectMode); 3607777dab0Sopenharmony_ci 3617777dab0Sopenharmony_ci/** 3627777dab0Sopenharmony_ci * @brief set the bit rate use for hls player 3637777dab0Sopenharmony_ci * 3647777dab0Sopenharmony_ci * the playback bitrate expressed in bits per second, expressed in bits per second, 3657777dab0Sopenharmony_ci * which is only valid for HLS protocol network flow. By default, 3667777dab0Sopenharmony_ci * the player will select the appropriate bit rate and speed according to the network connection. 3677777dab0Sopenharmony_ci * report the effective bit rate linked list by "INFO_TYPE_BITRATE_COLLECT" 3687777dab0Sopenharmony_ci * set and select the specified bit rate, and select the bit rate that is less than and closest 3697777dab0Sopenharmony_ci * to the specified bit rate for playback. When ready, read it to query the currently selected bit rate. 3707777dab0Sopenharmony_ci * 3717777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 3727777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3737777dab0Sopenharmony_ci * @param bitRate the bit rate, The unit is bps. 3747777dab0Sopenharmony_ci * @return Function result code. 3757777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3767777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SelectBitRate failed. 3777777dab0Sopenharmony_ci * @since 11 3787777dab0Sopenharmony_ci * @version 1.0 3797777dab0Sopenharmony_ci */ 3807777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SelectBitRate(OH_AVPlayer *player, uint32_t bitRate); 3817777dab0Sopenharmony_ci 3827777dab0Sopenharmony_ci/** 3837777dab0Sopenharmony_ci * @brief Method to set the surface. 3847777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 3857777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 3867777dab0Sopenharmony_ci * @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow} 3877777dab0Sopenharmony_ci * @return Function result code. 3887777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 3897777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr, input window is nullptr, 3907777dab0Sopenharmony_ci * or player SetVideoSurface failed. 3917777dab0Sopenharmony_ci * @since 11 3927777dab0Sopenharmony_ci * @version 1.0 3937777dab0Sopenharmony_ci */ 3947777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetVideoSurface(OH_AVPlayer *player, OHNativeWindow *window); 3957777dab0Sopenharmony_ci 3967777dab0Sopenharmony_ci/** 3977777dab0Sopenharmony_ci * @brief Obtains the total duration of media files, accurate to milliseconds. 3987777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 3997777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4007777dab0Sopenharmony_ci * @param duration Indicates the total duration of media files. 4017777dab0Sopenharmony_ci * @return Function result code. 4027777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 4037777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetDuration failed. 4047777dab0Sopenharmony_ci * @since 11 4057777dab0Sopenharmony_ci * @version 1.0 4067777dab0Sopenharmony_ci */ 4077777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetDuration(OH_AVPlayer *player, int32_t *duration); 4087777dab0Sopenharmony_ci 4097777dab0Sopenharmony_ci/** 4107777dab0Sopenharmony_ci * @brief get current playback state. 4117777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4127777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4137777dab0Sopenharmony_ci * @param state the current playback state 4147777dab0Sopenharmony_ci * @return Function result code. 4157777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 4167777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr. 4177777dab0Sopenharmony_ci * @since 11 4187777dab0Sopenharmony_ci * @version 1.0 4197777dab0Sopenharmony_ci */ 4207777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetState(OH_AVPlayer *player, AVPlayerState *state); 4217777dab0Sopenharmony_ci 4227777dab0Sopenharmony_ci/** 4237777dab0Sopenharmony_ci * @brief Checks whether the player is playing. 4247777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4257777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4267777dab0Sopenharmony_ci * @return Returns true if the playback is playing; Return false if not or input player is nullptr. 4277777dab0Sopenharmony_ci * @since 11 4287777dab0Sopenharmony_ci * @version 1.0 4297777dab0Sopenharmony_ci */ 4307777dab0Sopenharmony_cibool OH_AVPlayer_IsPlaying(OH_AVPlayer *player); 4317777dab0Sopenharmony_ci 4327777dab0Sopenharmony_ci/** 4337777dab0Sopenharmony_ci * @brief Returns the value whether single looping is enabled or not . 4347777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4357777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4367777dab0Sopenharmony_ci * @return Returns true if the playback is single looping; Return false if not or input player is nullptr. 4377777dab0Sopenharmony_ci * @since 11 4387777dab0Sopenharmony_ci * @version 1.0 4397777dab0Sopenharmony_ci */ 4407777dab0Sopenharmony_cibool OH_AVPlayer_IsLooping(OH_AVPlayer *player); 4417777dab0Sopenharmony_ci 4427777dab0Sopenharmony_ci/** 4437777dab0Sopenharmony_ci * @brief Enables single looping of the media playback. 4447777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4457777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4467777dab0Sopenharmony_ci * @param loop The switch to set loop 4477777dab0Sopenharmony_ci * @return Function result code. 4487777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 4497777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetLooping failed. 4507777dab0Sopenharmony_ci * @since 11 4517777dab0Sopenharmony_ci * @version 1.0 4527777dab0Sopenharmony_ci */ 4537777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); 4547777dab0Sopenharmony_ci 4557777dab0Sopenharmony_ci/** 4567777dab0Sopenharmony_ci * @brief Method to set player callback. 4577777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4587777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4597777dab0Sopenharmony_ci * @param callback object pointer. 4607777dab0Sopenharmony_ci * @return Function result code. 4617777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 4627777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, 4637777dab0Sopenharmony_ci * or player SetPlayerCallback failed. 4647777dab0Sopenharmony_ci * @since 11 4657777dab0Sopenharmony_ci * @deprecated since 12 4667777dab0Sopenharmony_ci * @useinstead {@link OH_AVPlayer_SetPlayerOnInfoCallback} {@link OH_AVPlayer_SetPlayerOnErrorCallback} 4677777dab0Sopenharmony_ci * @version 1.0 4687777dab0Sopenharmony_ci */ 4697777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback callback); 4707777dab0Sopenharmony_ci 4717777dab0Sopenharmony_ci/** 4727777dab0Sopenharmony_ci * @brief Select audio or subtitle track. 4737777dab0Sopenharmony_ci * 4747777dab0Sopenharmony_ci * By default, the first audio stream with data is played, and the subtitle track is not played. 4757777dab0Sopenharmony_ci * After the settings take effect, the original track will become invalid. Please set subtitles 4767777dab0Sopenharmony_ci * in prepared/playing/paused/completed state and set audio tracks in prepared state. 4777777dab0Sopenharmony_ci * 4787777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4797777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4807777dab0Sopenharmony_ci * @param index Track index 4817777dab0Sopenharmony_ci * @return Function result code. 4827777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 4837777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SelectTrack failed. 4847777dab0Sopenharmony_ci * @since 11 4857777dab0Sopenharmony_ci * @version 1.0 4867777dab0Sopenharmony_ci*/ 4877777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SelectTrack(OH_AVPlayer *player, int32_t index); 4887777dab0Sopenharmony_ci 4897777dab0Sopenharmony_ci/** 4907777dab0Sopenharmony_ci * @brief Deselect the current audio or subtitle track. 4917777dab0Sopenharmony_ci * 4927777dab0Sopenharmony_ci * After audio is deselected, the default track will be played, and after subtitles are deselected, 4937777dab0Sopenharmony_ci * they will not be played. Please set subtitles in prepared/playing/paused/completed state and set 4947777dab0Sopenharmony_ci * audio tracks in prepared state. 4957777dab0Sopenharmony_ci * 4967777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 4977777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 4987777dab0Sopenharmony_ci * @param index Track index 4997777dab0Sopenharmony_ci * @return Function result code. 5007777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5017777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player DeselectTrack failed. 5027777dab0Sopenharmony_ci * @since 11 5037777dab0Sopenharmony_ci * @version 1.0 5047777dab0Sopenharmony_ci*/ 5057777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_DeselectTrack(OH_AVPlayer *player, int32_t index); 5067777dab0Sopenharmony_ci 5077777dab0Sopenharmony_ci/** 5087777dab0Sopenharmony_ci * @brief Obtain the currently effective track index. 5097777dab0Sopenharmony_ci * 5107777dab0Sopenharmony_ci * Please get it in the prepared/playing/paused/completed state. 5117777dab0Sopenharmony_ci * 5127777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 5137777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 5147777dab0Sopenharmony_ci * @param trackType Media type. 5157777dab0Sopenharmony_ci * @param index Track index 5167777dab0Sopenharmony_ci * @return Function result code. 5177777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5187777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player GetCurrentTrack failed. 5197777dab0Sopenharmony_ci * @since 11 5207777dab0Sopenharmony_ci * @version 1.0 5217777dab0Sopenharmony_ci */ 5227777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, int32_t *index); 5237777dab0Sopenharmony_ci 5247777dab0Sopenharmony_ci/** 5257777dab0Sopenharmony_ci * @brief Method to set player media key system info callback. 5267777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 5277777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 5287777dab0Sopenharmony_ci * @param callback object pointer. 5297777dab0Sopenharmony_ci * @return Function result code. 5307777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5317777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr, MediaKeySystemInfoCallback is null 5327777dab0Sopenharmony_ci * player SetDrmSystemInfoCallback failed, SetDrmSystemInfoCallback failed or SetDrmSystemInfoCallback failed. 5337777dab0Sopenharmony_ci * @since 12 5347777dab0Sopenharmony_ci * @version 1.0 5357777dab0Sopenharmony_ci */ 5367777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetMediaKeySystemInfoCallback(OH_AVPlayer *player, 5377777dab0Sopenharmony_ci Player_MediaKeySystemInfoCallback callback); 5387777dab0Sopenharmony_ci 5397777dab0Sopenharmony_ci/** 5407777dab0Sopenharmony_ci * @brief Obtains media key system info to create media key session. 5417777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 5427777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 5437777dab0Sopenharmony_ci * @param mediaKeySystemInfo Media key system info. 5447777dab0Sopenharmony_ci * @return Function result code. 5457777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5467777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or no memory. 5477777dab0Sopenharmony_ci * @since 12 5487777dab0Sopenharmony_ci * @version 1.0 5497777dab0Sopenharmony_ci */ 5507777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKeySystemInfo *mediaKeySystemInfo); 5517777dab0Sopenharmony_ci 5527777dab0Sopenharmony_ci/** 5537777dab0Sopenharmony_ci * @brief Set decryption info. 5547777dab0Sopenharmony_ci * 5557777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 5567777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance 5577777dab0Sopenharmony_ci * @param mediaKeySession A media key session instance with decryption function. 5587777dab0Sopenharmony_ci * @param secureVideoPath Require secure decoder or not. 5597777dab0Sopenharmony_ci * @return Function result code. 5607777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5617777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player SetDecryptConfig failed. 5627777dab0Sopenharmony_ci * @since 12 5637777dab0Sopenharmony_ci * @version 1.0 5647777dab0Sopenharmony_ci*/ 5657777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySession *mediaKeySession, 5667777dab0Sopenharmony_ci bool secureVideoPath); 5677777dab0Sopenharmony_ci 5687777dab0Sopenharmony_ci/** 5697777dab0Sopenharmony_ci * @brief Method to set player information notify callback. 5707777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 5717777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance. 5727777dab0Sopenharmony_ci * @param callback Pointer to callback function, nullptr indicates unregister callback. 5737777dab0Sopenharmony_ci * @param userData Pointer to user specific data. 5747777dab0Sopenharmony_ci * @return Function result code. 5757777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5767777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnInfoCallback failed. 5777777dab0Sopenharmony_ci * @since 12 5787777dab0Sopenharmony_ci */ 5797777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInfoCallback callback, void *userData); 5807777dab0Sopenharmony_ci 5817777dab0Sopenharmony_ci/** 5827777dab0Sopenharmony_ci * @brief Method to set player error callback. 5837777dab0Sopenharmony_ci * @syscap SystemCapability.Multimedia.Media.AVPlayer 5847777dab0Sopenharmony_ci * @param player Pointer to an OH_AVPlayer instance. 5857777dab0Sopenharmony_ci * @param callback Pointer to callback function, nullptr indicates unregister callback. 5867777dab0Sopenharmony_ci * @param userData Pointer to user specific data. 5877777dab0Sopenharmony_ci * @return Function result code. 5887777dab0Sopenharmony_ci * {@link AV_ERR_OK} if the execution is successful. 5897777dab0Sopenharmony_ci * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnErrorCallback failed. 5907777dab0Sopenharmony_ci * @since 12 5917777dab0Sopenharmony_ci */ 5927777dab0Sopenharmony_ciOH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnErrorCallback callback, void *userData); 5937777dab0Sopenharmony_ci 5947777dab0Sopenharmony_ci#ifdef __cplusplus 5957777dab0Sopenharmony_ci} 5967777dab0Sopenharmony_ci#endif 5977777dab0Sopenharmony_ci 5987777dab0Sopenharmony_ci#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVPLAYER_H 599