From 307e51c1597bef13c12c7fcb2f3c5663173bb319 Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Thu, 25 Jul 2024 18:33:23 +0800 Subject: [PATCH 1/9] Add avplayer ndk new api. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer.h | 58 ++++++++ multimedia/player_framework/avplayer_base.h | 157 +++++++++++++++++++- 2 files changed, 214 insertions(+), 1 deletion(-) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index d2d7aa7e8..417a8d555 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -461,6 +461,8 @@ OH_AVErrCode OH_AVPlayer_SetLooping(OH_AVPlayer *player, bool loop); * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, * or player SetPlayerCallback failed. * @since 11 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayer_SetPlayerOnInfoCallback} {@link OH_AVPlayer_SetPlayerOnErrorCallback} * @version 1.0 */ OH_AVErrCode OH_AVPlayer_SetPlayerCallback(OH_AVPlayer *player, AVPlayerCallback callback); @@ -562,6 +564,62 @@ OH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKey OH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySession *mediaKeySession, bool secureVideoPath); +/** + * @brief Method to set player information notify callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param callback object pointer. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, + * or player SetPlayerCallback failed. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInfoCallback callback); + +/** + * @brief Method to set player error callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param callback object pointer. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, + * or player SetPlayerCallback failed. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnError callback); + +/** + * @brief Add the subtitle 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 Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr, url is null or player setUrlSource failed. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_AddSubtitleFromUrl(H_AVPlayer *player, const char *url); + +/** + * @brief Add the subtitle 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 subtitle source. + * @param offset Indicates the offset of subtitle source in file descriptor. + * @param size Indicates the size of subtitle source. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player setFdSource failed. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_AddSubtitleFromFd(H_AVPlayer *player, int32_t fd, int64_t offset, int64_t size); + #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 903a52f72..57eeb8ebd 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -172,6 +172,147 @@ typedef enum AVPlayerOnInfoType { AV_INFO_TYPE_AUDIO_OUTPUT_DEVICE_CHANGE = 17, } AVPlayerOnInfoType; +/** + * @brief Player Buffering Type + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +typedef enum AVPlayerBufferingType{ + AVPLAYER_BUFFERING_START = 1, + AVPLAYER_BUFFERING_END, + AVPLAYER_BUFFERING_PERCENT, + AVPLAYER_BUFFERING_CACHED_DURATION, +} AVPlayerBufferingType; + +/** + * @brief Key to get state, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_STATE; + +/** + * @brief Key to get state changed reason, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_STATE_CHANGED_REASON; + +/** + * @brief Key to get volume, value type is float. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_VOLUME; + +/** + * @brief Key to get subtitle text, value type is char array. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_SUBTITLE_TEXT; + +/** + * @brief Key to get subtitle pts, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_SUBTITLE_PTS; + +/** + * @brief Key to get subtitle duration, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_SUBTITLE_DURATION; + +/** + * @brief Key to get bitrate count, value type is uint32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BITRATE_COUNT; + +/** + * @brief Key to get bitrate count, value type is uint32_t array. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BITRATE_ARRAY; + +/** + * @brief Key to get track count, value type is uint32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_TRACK_COUNT; + +/** + * @brief Key to get track info array, value type is OH_AVFormat pointer array. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_TRACK_INFO_ARRAY; + +/** + * @brief Key to get audio interrupt type, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_INTERRUPT_TYPE; + +/** + * @brief Key to get audio interrupt force, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_INTERRUPT_FORCE; + +/** + * @brief Key to get audio interrupt hint, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_INTERRUPT_HINT; + +/** + * @brief Key to get audio device info, value type is uint8_t array. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_AUDIO_DEVICE_INFO; + +/** + * @brief Key to get buffering type, value type is AVPlayerBufferingType. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BUFFERING_TYPE; + +/** + * @brief Key to get buffering value, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + * @version 1.0 + */ +extern const char* OH_PLAYER_BUFFERING_VALUE; + /** * @brief Called when a player message or alarm is received. * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -179,10 +320,23 @@ typedef enum AVPlayerOnInfoType { * @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 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayerOnInfoCallback} * @version 1.0 */ typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, int32_t extra); +/** + * @brief Called when a player info event 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 infoBody Indicates the information parameters. + * @since 12 + * @version 1.0 + */ +typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoType type, OH_AVFormat* infoBody); + /** * @brief Called when an error occurred for versions above api9 * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -202,6 +356,8 @@ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const * @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 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayerOnInfoCallback} {@link OH_AVPlayerOnError} * @version 1.0 */ typedef struct AVPlayerCallback { @@ -209,7 +365,6 @@ typedef struct AVPlayerCallback { OH_AVPlayerOnError onError; } AVPlayerCallback; - #ifdef __cplusplus } #endif -- Gitee From 5763e43e549f67484323b966c62308606d72f6c1 Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Fri, 26 Jul 2024 10:18:30 +0800 Subject: [PATCH 2/9] Add audio device change reason key, remove audio device info key. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer_base.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 57eeb8ebd..9f251cd0f 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -290,12 +290,12 @@ extern const char* OH_PLAYER_AUDIO_INTERRUPT_FORCE; extern const char* OH_PLAYER_AUDIO_INTERRUPT_HINT; /** - * @brief Key to get audio device info, value type is uint8_t array. + * @brief Key to get audio device change reason, value type is int32_t. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @since 12 * @version 1.0 */ -extern const char* OH_PLAYER_AUDIO_DEVICE_INFO; +extern const char* OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON; /** * @brief Key to get buffering type, value type is AVPlayerBufferingType. -- Gitee From e751956283ce2c166cd03db19c3f58739d59d0f6 Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Sat, 27 Jul 2024 09:28:23 +0800 Subject: [PATCH 3/9] Modify interface according to comments. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer.h | 28 --------------------- multimedia/player_framework/avplayer_base.h | 11 ++++++-- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index 417a8d555..b5ca67921 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -592,34 +592,6 @@ OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInf */ OH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnError callback); -/** - * @brief Add the subtitle 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 Function result code. - * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input player is nullptr, url is null or player setUrlSource failed. - * @since 12 - * @version 1.0 - */ -OH_AVErrCode OH_AVPlayer_AddSubtitleFromUrl(H_AVPlayer *player, const char *url); - -/** - * @brief Add the subtitle 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 subtitle source. - * @param offset Indicates the offset of subtitle source in file descriptor. - * @param size Indicates the size of subtitle source. - * @return Function result code. - * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input player is nullptr or player setFdSource failed. - * @since 12 - * @version 1.0 - */ -OH_AVErrCode OH_AVPlayer_AddSubtitleFromFd(H_AVPlayer *player, int32_t fd, int64_t offset, int64_t size); - #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 9f251cd0f..18ecba073 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -179,9 +179,16 @@ typedef enum AVPlayerOnInfoType { * @version 1.0 */ typedef enum AVPlayerBufferingType{ + /** Indicates the buffer to start buffering. */ AVPLAYER_BUFFERING_START = 1, + + /** Indicates the buffer to end buffering and start playback. */ AVPLAYER_BUFFERING_END, + + /** Indicates the current buffering percentage of the buffer. */ AVPLAYER_BUFFERING_PERCENT, + + /** Indicates how long the buffer cache data can be played. */ AVPLAYER_BUFFERING_CACHED_DURATION, } AVPlayerBufferingType; @@ -194,12 +201,12 @@ typedef enum AVPlayerBufferingType{ extern const char* OH_PLAYER_STATE; /** - * @brief Key to get state changed reason, value type is int32_t. + * @brief Key to get state change reason, value type is int32_t. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @since 12 * @version 1.0 */ -extern const char* OH_PLAYER_STATE_CHANGED_REASON; +extern const char* OH_PLAYER_STATE_CHANGE_REASON; /** * @brief Key to get volume, value type is float. -- Gitee From 9c91d4173e42fa99bb1c1bd9fe1714bc97346bd3 Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Thu, 1 Aug 2024 09:35:34 +0800 Subject: [PATCH 4/9] Remove subtitle and track info related interfaces. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer_base.h | 40 --------------------- 1 file changed, 40 deletions(-) diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 18ecba073..b8db447ac 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -216,30 +216,6 @@ extern const char* OH_PLAYER_STATE_CHANGE_REASON; */ extern const char* OH_PLAYER_VOLUME; -/** - * @brief Key to get subtitle text, value type is char array. - * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @since 12 - * @version 1.0 - */ -extern const char* OH_PLAYER_SUBTITLE_TEXT; - -/** - * @brief Key to get subtitle pts, value type is int32_t. - * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @since 12 - * @version 1.0 - */ -extern const char* OH_PLAYER_SUBTITLE_PTS; - -/** - * @brief Key to get subtitle duration, value type is int32_t. - * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @since 12 - * @version 1.0 - */ -extern const char* OH_PLAYER_SUBTITLE_DURATION; - /** * @brief Key to get bitrate count, value type is uint32_t. * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -256,22 +232,6 @@ extern const char* OH_PLAYER_BITRATE_COUNT; */ extern const char* OH_PLAYER_BITRATE_ARRAY; -/** - * @brief Key to get track count, value type is uint32_t. - * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @since 12 - * @version 1.0 - */ -extern const char* OH_PLAYER_TRACK_COUNT; - -/** - * @brief Key to get track info array, value type is OH_AVFormat pointer array. - * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @since 12 - * @version 1.0 - */ -extern const char* OH_PLAYER_TRACK_INFO_ARRAY; - /** * @brief Key to get audio interrupt type, value type is int32_t. * @syscap SystemCapability.Multimedia.Media.AVPlayer -- Gitee From 2c9e3879dcf3f77a858be529d0e7f517aa7a6c2c Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Wed, 7 Aug 2024 17:11:00 +0800 Subject: [PATCH 5/9] Fix comment wrong issue. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index b5ca67921..0bbc026a2 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -571,8 +571,8 @@ OH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySessio * @param callback object pointer. * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, - * or player SetPlayerCallback failed. + * {@link AV_ERR_INVALID_VAL} if input player is null or callback is null, + * or player SetOnInfoCallback failed. * @since 12 * @version 1.0 */ @@ -585,8 +585,8 @@ OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInf * @param callback object pointer. * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input player is nullptr, callback.onInfo or callback.onError is null, - * or player SetPlayerCallback failed. + * {@link AV_ERR_INVALID_VAL} if input player is null or callback is null, + * or player SetOnErrorCallback failed. * @since 12 * @version 1.0 */ -- Gitee From 3cf7acc963d4ab5a368a4b8d49a91553c4157bc4 Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Thu, 8 Aug 2024 17:31:07 +0800 Subject: [PATCH 6/9] Add userData parameter in callback. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer.h | 22 ++++++++++----------- multimedia/player_framework/avplayer_base.h | 20 ++++++++++++++++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index 0bbc026a2..f8c24b931 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -567,30 +567,28 @@ OH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySessio /** * @brief Method to set player information notify callback. * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @param player Pointer to an OH_AVPlayer instance - * @param callback object pointer. + * @param player Pointer to an OH_AVPlayer instance. + * @param callback Pointer to callback. + * @param userData Pointer to user specific data. * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input player is null or callback is null, - * or player SetOnInfoCallback failed. + * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnInfoCallback failed. * @since 12 - * @version 1.0 */ -OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInfoCallback callback); +OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInfoCallback callback, void *userData); /** * @brief Method to set player error callback. * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @param player Pointer to an OH_AVPlayer instance - * @param callback object pointer. + * @param player Pointer to an OH_AVPlayer instance. + * @param callback Pointer to callback. + * @param userData Pointer to user specific data. * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. - * {@link AV_ERR_INVALID_VAL} if input player is null or callback is null, - * or player SetOnErrorCallback failed. + * {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnErrorCallback failed. * @since 12 - * @version 1.0 */ -OH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnError callback); +OH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnErrorCallback callback, void *userData); #ifdef __cplusplus } diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index b8db447ac..39794e05f 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -299,10 +299,11 @@ typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, * @param player The pointer to an OH_AVPlayer instance. * @param type Indicates the information type. For details, see {@link AVPlayerOnInfoType}. * @param infoBody Indicates the information parameters. + * @param userData Pointer to user specific data. * @since 12 - * @version 1.0 */ -typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoType type, OH_AVFormat* infoBody); +typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoType type, OH_AVFormat* infoBody, + void *userData); /** * @brief Called when an error occurred for versions above api9 @@ -311,10 +312,23 @@ typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoTyp * @param errorCode Error code. * @param errorMsg Error message. * @since 11 + * @deprecated since 12 + * @useinstead {@link OH_AVPlayerOnErrorCallback} * @version 1.0 */ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg); +/** + * @brief Called when an error occurred. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player The pointer to an OH_AVPlayer instance. + * @param errorCode Error code. + * @param errorMsg Error message. + * @param userData Pointer to user specific data. + * @since 12 + */ +typedef void (*OH_AVPlayerOnErrorCallback)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg, void *userData); + /** * @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 @@ -324,7 +338,7 @@ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const * @param onError Monitor OH_AVPlayer operation errors, refer to {@link OH_AVPlayerOnError} * @since 11 * @deprecated since 12 - * @useinstead {@link OH_AVPlayerOnInfoCallback} {@link OH_AVPlayerOnError} + * @useinstead {@link OH_AVPlayerOnInfoCallback} {@link OH_AVPlayerOnErrorCallback} * @version 1.0 */ typedef struct AVPlayerCallback { -- Gitee From fb3272feeb5f7630c7b9ef21759439abd416053e Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Thu, 8 Aug 2024 17:41:39 +0800 Subject: [PATCH 7/9] Add comments. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer.h | 4 ++-- multimedia/player_framework/avplayer_base.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index f8c24b931..2b3b7e76f 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -568,7 +568,7 @@ OH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySessio * @brief Method to set player information notify callback. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance. - * @param callback Pointer to callback. + * @param callback Pointer to callback function, nullptr indicates unregister callback. * @param userData Pointer to user specific data. * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. @@ -581,7 +581,7 @@ OH_AVErrCode OH_AVPlayer_SetOnInfoCallback(OH_AVPlayer *player, OH_AVPlayerOnInf * @brief Method to set player error callback. * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player Pointer to an OH_AVPlayer instance. - * @param callback Pointer to callback. + * @param callback Pointer to callback function, nullptr indicates unregister callback. * @param userData Pointer to user specific data. * @return Function result code. * {@link AV_ERR_OK} if the execution is successful. diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 39794e05f..2de5b3dc7 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -298,7 +298,7 @@ typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, * @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 infoBody Indicates the information parameters. + * @param infoBody Indicates the information parameters, only valid in callback function. * @param userData Pointer to user specific data. * @since 12 */ @@ -323,7 +323,7 @@ typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const * @syscap SystemCapability.Multimedia.Media.AVPlayer * @param player The pointer to an OH_AVPlayer instance. * @param errorCode Error code. - * @param errorMsg Error message. + * @param errorMsg Error message, only valid in callback function. * @param userData Pointer to user specific data. * @since 12 */ -- Gitee From c0946389910076053ed34ef90c5df09b72930d8d Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Fri, 9 Aug 2024 15:52:28 +0800 Subject: [PATCH 8/9] Add more constants. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer_base.h | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index 2de5b3dc7..cf2786763 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -280,6 +280,69 @@ extern const char* OH_PLAYER_BUFFERING_TYPE; */ extern const char* OH_PLAYER_BUFFERING_VALUE; +/** + * @brief Key to get seek position, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_SEEK_POSITION; + +/** + * @brief Key to get playback speed, value type is AVPlaybackSpeed. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_PLAYBACK_SPEED; + +/** + * @brief Key to get bitrate, value type is uint32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_BITRATE; + +/** + * @brief Key to get current position, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_CURRENT_POSITION; + +/** + * @brief Key to get duration, value type is int64_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_DURATION; + +/** + * @brief Key to get video width, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_VIDEO_WIDTH; + +/** + * @brief Key to get video height, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_VIDEO_HEIGHT; + +/** + * @brief Key to get message type, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_MESSAGE_TYPE; + +/** + * @brief Key to get is live stream, value type is int32_t. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @since 12 + */ +extern const char* OH_PLAYER_IS_LIVE_STREAM; + /** * @brief Called when a player message or alarm is received. * @syscap SystemCapability.Multimedia.Media.AVPlayer -- Gitee From 59cbdb5a0f6a98466c0d4349e48f8f01a1e314dd Mon Sep 17 00:00:00 2001 From: Chen Guodong Date: Tue, 13 Aug 2024 10:10:18 +0800 Subject: [PATCH 9/9] Remove bitrate count. Signed-off-by: Chen Guodong --- multimedia/player_framework/avplayer_base.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/multimedia/player_framework/avplayer_base.h b/multimedia/player_framework/avplayer_base.h index cf2786763..192d6eadd 100644 --- a/multimedia/player_framework/avplayer_base.h +++ b/multimedia/player_framework/avplayer_base.h @@ -216,14 +216,6 @@ extern const char* OH_PLAYER_STATE_CHANGE_REASON; */ extern const char* OH_PLAYER_VOLUME; -/** - * @brief Key to get bitrate count, value type is uint32_t. - * @syscap SystemCapability.Multimedia.Media.AVPlayer - * @since 12 - * @version 1.0 - */ -extern const char* OH_PLAYER_BITRATE_COUNT; - /** * @brief Key to get bitrate count, value type is uint32_t array. * @syscap SystemCapability.Multimedia.Media.AVPlayer -- Gitee