Tizen Native API  5.5
Stream Information

The Stream Information API provides functions to get audio and video stream information, such as codec type, video width or height, bit rate, and so on.

Required Header

#include <player.h>

Overview

The Player stream information API allows you to get media stream information, including:

Functions

int player_get_content_info (player_h player, player_content_info_e key, char **value)
 Gets the media content information.
int player_get_codec_info (player_h player, char **audio_codec, char **video_codec)
 Gets the audio and video codec information.
int player_get_audio_stream_info (player_h player, int *sample_rate, int *channel, int *bit_rate)
 Gets the audio stream information.
int player_get_video_stream_info (player_h player, int *fps, int *bit_rate)
 Gets the video stream information.
int player_get_video_size (player_h player, int *width, int *height)
 Gets the video display's height and width.
int player_get_album_art (player_h player, void **album_art, int *size)
 Gets the album art in the media resource.
int player_get_duration (player_h player, int *milliseconds)
 Gets the total running time of the associated media.
int player_get_duration_nsec (player_h player, int64_t *nanoseconds)
 Gets the total running time in nanoseconds of the associated media.
int player_set_video_stream_changed_cb (player_h player, player_video_stream_changed_cb callback, void *user_data)
 Sets a callback function to be invoked when video stream is changed.
int player_unset_video_stream_changed_cb (player_h player)
 Unsets the video stream changed callback function.

Typedefs

typedef void(* player_video_stream_changed_cb )(int width, int height, int fps, int bit_rate, void *user_data)
 Called to notify the video stream changed.

Typedef Documentation

typedef void(* player_video_stream_changed_cb)(int width, int height, int fps, int bit_rate, void *user_data)

Called to notify the video stream changed.

The video stream changing is detected just before rendering operation.

Since :
2.4
Parameters:
[in]widthThe width of the captured image
[in]heightThe height of the captured image
[in]fpsThe frame per second of the video
It can be 0 if there is no video stream information.
[in]bit_rateThe video bit rate [Hz]
It can be an invalid value if there is no video stream information.
[in]user_dataThe user data passed from the callback registration function
See also:
player_set_video_stream_changed_cb()

Enumeration Type Documentation

Enumeration for media stream content information.

Since :
2.3
Enumerator:
PLAYER_CONTENT_INFO_ALBUM 

Album

PLAYER_CONTENT_INFO_ARTIST 

Artist

PLAYER_CONTENT_INFO_AUTHOR 

Author

PLAYER_CONTENT_INFO_GENRE 

Genre

PLAYER_CONTENT_INFO_TITLE 

Title

PLAYER_CONTENT_INFO_YEAR 

Year


Function Documentation

int player_get_album_art ( player_h  player,
void **  album_art,
int *  size 
)

Gets the album art in the media resource.

Since :
2.3
Remarks:
You must not release album_art. The album_art is managed by the platform and will be released when the player is unprepared or destroyed by calling player_unprepare() or player_destroy().
Parameters:
[in]playerThe handle to the media player
[out]album_artThe encoded artwork image
[out]sizeThe encoded artwork size
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
int player_get_audio_stream_info ( player_h  player,
int *  sample_rate,
int *  channel,
int *  bit_rate 
)

Gets the audio stream information.

Since :
2.3
Remarks:
The playback type should be local playback or HTTP streaming playback.
Parameters:
[in]playerThe handle to the media player
[out]sample_rateThe audio sample rate [Hz]
Value can be invalid if there is no audio stream information.
[out]channelThe audio channel (1: mono, 2: stereo)
Value can be invalid if there is no audio stream information.
[out]bit_rateThe audio bit rate [Hz]
Value can be invalid if there is no audio stream information.
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
int player_get_codec_info ( player_h  player,
char **  audio_codec,
char **  video_codec 
)

Gets the audio and video codec information.

Since :
2.3
Remarks:
You must release audio_codec and video_codec using free().
The playback type should be local playback or HTTP streaming playback.
Parameters:
[in]playerThe handle to the media player
[out]audio_codecThe name of the audio codec
It can be NULL if there is no audio codec.
[out]video_codecThe name of the video codec
It can be NULL if there is no video codec.
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
int player_get_content_info ( player_h  player,
player_content_info_e  key,
char **  value 
)

Gets the media content information.

Since :
2.3
Remarks:
You must release value using free().
The playback type should be local playback or HTTP streaming playback.
Parameters:
[in]playerThe handle to the media player
[in]keyThe key attribute name to get
[out]valueThe value of the key attribute
It can be an empty string if there is no content information.
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_OUT_OF_MEMORYNot enough memory is available
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
int player_get_duration ( player_h  player,
int *  milliseconds 
)

Gets the total running time of the associated media.

Since :
2.3
Remarks:
The media source is associated with the player, using either player_set_uri() or player_set_memory_buffer().
The playback type should be local playback or HTTP streaming playback.
Parameters:
[in]playerThe handle to the media player
[out]millisecondsThe duration in milliseconds
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
See also:
player_set_uri()
player_set_memory_buffer()
player_get_duration_nsec()
int player_get_duration_nsec ( player_h  player,
int64_t *  nanoseconds 
)

Gets the total running time in nanoseconds of the associated media.

Since :
5.0
Parameters:
[in]playerThe handle to the media player
[out]nanosecondsThe duration time in nanoseconds
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
See also:
player_set_uri()
player_set_memory_buffer()
player_get_duration()
int player_get_video_size ( player_h  player,
int *  width,
int *  height 
)

Gets the video display's height and width.

Since :
2.3
Remarks:
The playback type should be local playback or HTTP streaming playback.
Parameters:
[in]playerThe handle to the media player
[out]widthThe width of the video
Value can be invalid if there is no video or no display is set.
[out]heightThe height of the video
Value can be invalid value if there is no video or no display is set.
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
int player_get_video_stream_info ( player_h  player,
int *  fps,
int *  bit_rate 
)

Gets the video stream information.

Since :
2.3
Remarks:
The playback type should be local playback or HTTP streaming playback.
Parameters:
[in]playerThe handle to the media player
[out]fpsThe frame per second of the video
It can be 0 if there is no video stream information.
[out]bit_rateThe video bit rate [Hz]
It can be an invalid value if there is no video stream information.
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
PLAYER_ERROR_INVALID_OPERATIONInvalid operation
PLAYER_ERROR_INVALID_STATEInvalid player state
Precondition:
The player state must be one of PLAYER_STATE_READY, PLAYER_STATE_PLAYING or PLAYER_STATE_PAUSED.
int player_set_video_stream_changed_cb ( player_h  player,
player_video_stream_changed_cb  callback,
void *  user_data 
)

Sets a callback function to be invoked when video stream is changed.

Since :
2.4
Remarks:
The stream changing is detected just before rendering operation.
The callback is called in a separate thread (not in the main loop).
This function must be called before calling the player_prepare() or player_prepare_async() to reflect the requirement when the player is building.
Parameters:
[in]playerThe handle to the media player
[in]callbackThe stream changed callback function to register
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_STATEInvalid player state
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
Precondition:
The player state must be set to PLAYER_STATE_IDLE by calling player_create() or player_unprepare().
Postcondition:
player_video_stream_changed_cb() will be invoked.
See also:
player_unset_video_stream_changed_cb()
player_video_stream_changed_cb()

Unsets the video stream changed callback function.

Since :
2.4
Parameters:
[in]playerThe handle to the media player
Returns:
0 on success, otherwise a negative error value
Return values:
PLAYER_ERROR_NONESuccessful
PLAYER_ERROR_INVALID_PARAMETERInvalid parameter
See also:
player_set_video_stream_changed_cb()