!1197 Add interfaces for NDK AVPlayer to implement OnError and OnInfo

Merge pull request !1197 from 袁景华/NdkAvplayerInterface
This commit is contained in:
openharmony_ci 2024-08-15 13:43:35 +00:00 committed by Gitee
commit 4f7fc77273
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 309 additions and 3 deletions

View File

@ -462,6 +462,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);
@ -563,6 +565,32 @@ 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 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.
* {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnInfoCallback failed.
* @since 12
*/
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 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.
* {@link AV_ERR_INVALID_VAL} if input player is null or player SetOnErrorCallback failed.
* @since 12
*/
OH_AVErrCode OH_AVPlayer_SetOnErrorCallback(OH_AVPlayer *player, OH_AVPlayerOnErrorCallback callback, void *userData);
#ifdef __cplusplus
}
#endif

View File

@ -27,6 +27,90 @@
{ "name": "OH_AVPlayer_SelectTrack" },
{ "name": "OH_AVPlayer_DeselectTrack" },
{ "name": "OH_AVPlayer_GetCurrentTrack" },
{
"first_introduced": "12",
"name": "OH_PLAYER_STATE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_STATE_CHANGE_REASON"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_VOLUME"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_BITRATE_ARRAY"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_AUDIO_INTERRUPT_TYPE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_AUDIO_INTERRUPT_FORCE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_AUDIO_INTERRUPT_HINT"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_BUFFERING_TYPE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_BUFFERING_VALUE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_SEEK_POSITION"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_PLAYBACK_SPEED"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_BITRATE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_CURRENT_POSITION"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_DURATION"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_VIDEO_WIDTH"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_VIDEO_HEIGHT"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_MESSAGE_TYPE"
},
{
"first_introduced": "12",
"name": "OH_PLAYER_IS_LIVE_STREAM"
},
{
"first_introduced": "12",
"name": "OH_AVPlayer_SetOnInfoCallback"
},
{
"first_introduced": "12",
"name": "OH_AVPlayer_SetOnErrorCallback"
},
{
"first_introduced": "12",
"name": "OH_AVPlayer_SetMediaKeySystemInfoCallback"

View File

@ -40,6 +40,8 @@
#include <stdint.h>
#include "native_avformat.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -113,13 +115,13 @@ typedef enum AVPlaybackSpeed {
* @brief Video playback at 0.5x normal speed.
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @since 12
*/
*/
AV_SPEED_FORWARD_0_50_X,
/**
* @brief Video playback at 1.5x normal speed.
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @since 12
*/
*/
AV_SPEED_FORWARD_1_50_X,
/**
* @brief Video playback at 3.0x normal speed.
@ -190,6 +192,169 @@ 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 {
/** 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;
/**
* @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 change reason, value type is int32_t.
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @since 12
* @version 1.0
*/
extern const char* OH_PLAYER_STATE_CHANGE_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 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 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 change reason, value type is int32_t.
* @syscap SystemCapability.Multimedia.Media.AVPlayer
* @since 12
* @version 1.0
*/
extern const char* OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON;
/**
* @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 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
@ -197,10 +362,24 @@ 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, only valid in callback function.
* @param userData Pointer to user specific data.
* @since 12
*/
typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoType type, OH_AVFormat* infoBody,
void *userData);
/**
* @brief Called when an error occurred for versions above api9
* @syscap SystemCapability.Multimedia.Media.AVPlayer
@ -208,10 +387,24 @@ typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type,
* @param errorCode Error code.
* @param errorMsg Error message.
* @since 11
* @deprecated since 12
* @useinstead {@link OH_AVPlayerOnInfoCallback} {@link OH_AVPlayerOnError}
* @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, only valid in callback function.
* @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
@ -220,6 +413,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_AVPlayerOnErrorCallback}
* @version 1.0
*/
typedef struct AVPlayerCallback {
@ -227,7 +422,6 @@ typedef struct AVPlayerCallback {
OH_AVPlayerOnError onError;
} AVPlayerCallback;
#ifdef __cplusplus
}
#endif