Tizen Native API
Media Format

Functions

int media_format_create (media_format_h *fmt)
 Creates a media format.
int media_format_get_video_info (media_format_h fmt, media_format_mimetype_e *mimetype, int *width, int *height, int *avg_bps, int *max_bps)
 Gets video information of media format.
int media_format_get_audio_info (media_format_h fmt, media_format_mimetype_e *mimetype, int *channel, int *samplerate, int *bit, int *avg_bps)
 Gets audio information of media format.
int media_format_get_audio_aac_type (media_format_h fmt, bool *is_adts)
 Gets audio aac type of media format.
int media_format_set_video_mime (media_format_h fmt, media_format_mimetype_e mimetype)
 Sets video MIME type of media format.
int media_format_set_video_width (media_format_h fmt, int width)
 Sets video width of media format.
int media_format_set_video_height (media_format_h fmt, int height)
 Sets video height of media format.
int media_format_set_video_avg_bps (media_format_h fmt, int avg_bps)
 Sets video avg_bps of media format.
int media_format_set_video_max_bps (media_format_h fmt, int max_bps)
 Sets video max_bps of media format.
int media_format_set_audio_mime (media_format_h fmt, media_format_mimetype_e mimetype)
 Sets audio MIME type of media format.
int media_format_set_audio_channel (media_format_h fmt, int channel)
 Sets audio channel of media format.
int media_format_set_audio_samplerate (media_format_h fmt, int samplerate)
 Sets audio samplerate of media format.
int media_format_set_audio_bit (media_format_h fmt, int bit)
 Sets audio bit of media format.
int media_format_set_audio_avg_bps (media_format_h fmt, int avg_bps)
 Sets audio avg_bps of media format.
int media_format_set_audio_aac_type (media_format_h fmt, bool is_adts)
 Sets audio aac type of media format.
int media_format_ref (media_format_h fmt)
 Increase reference count of media_format_h object.
int media_format_unref (media_format_h fmt)
 Decrease reference count of media_format_h object.
int media_format_is_writable (media_format_h fmt, bool *is_writable)
 Check whether the media_format_h is writable or not.
int media_format_make_writable (media_format_h fmt, media_format_h *out_fmt)
 Returns a writable copy of media_format_h.

Typedefs

typedef struct media_format_s * media_format_h
 Media Format handle type.

The Media Format APIs provides functions for specify video or audio information.

Required Header

#include <media_format.h>


Typedef Documentation

typedef struct media_format_s* media_format_h

Media Format handle type.

Since :
2.3

Enumeration Type Documentation

Enumeration for media color model.

Since :
2.3
Enumerator:
MEDIA_COLOR_MODEL_NONE 

media format color model is NONE

MEDIA_COLOR_MODEL_RGB 

media format color model is RGB

MEDIA_COLOR_MODEL_YUV 

media format color model is YUV

Enumeration for media format data type.

Since :
2.3
Enumerator:
MEDIA_FORMAT_ENCODED 

media format data type is encoded type

MEDIA_FORMAT_RAW 

media format data type is raw type

Enumerations of media format error.

Since :
2.3
Enumerator:
MEDIA_FORMAT_ERROR_NONE 

Successful

MEDIA_FORMAT_ERROR_OUT_OF_MEMORY 

Out of memory

MEDIA_FORMAT_ERROR_INVALID_PARAMETER 

Invalid parameter

MEDIA_FORMAT_ERROR_INVALID_OPERATION 

Invalid operation

MEDIA_FORMAT_ERROR_FILE_NO_SPACE_ON_DEVICE 

No space left on device

Enumeration for media format MIME type.

Since :
2.3
Enumerator:
MEDIA_FORMAT_L16 

media format mime type is L16, AUDIO

MEDIA_FORMAT_ALAW 

media format mime type is ALAW, AUDIO

MEDIA_FORMAT_ULAW 

media format mime type is ULAW, AUDIO

MEDIA_FORMAT_AMR 

media format mime type is AMR, AUDIO, indicates MEDIA_FORMAT_AMR_NB (Since tizen 2.4)

MEDIA_FORMAT_AMR_NB 

media format mime type is AMR_NB, AUDIO , (Since tizen 2.4)

MEDIA_FORMAT_AMR_WB 

media format mime type is AMR_WB, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_G729 

media format mime type is G729, AUDIO

MEDIA_FORMAT_AAC 

media format mime type is AAC, AUDIO, indicates MEDIA_FORMAT_AAC_LC (Since tizen 2.4)

MEDIA_FORMAT_AAC_LC 

media format mime type is AAC_LC, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_AAC_HE 

media format mime type is AAC_HE, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_AAC_HE_PS 

media format mime type is AAC_HE_PS, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_MP3 

media format mime type is MP3, AUDIO

MEDIA_FORMAT_VORBIS 

media format mime type is VORBIS, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_FLAC 

media format mime type is FLAC, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_WMAV1 

media format mime type is WMAV1, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_WMAV2 

media format mime type is WMAV2, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_WMAPRO 

media format mime type is WMAVPRO, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_WMALSL 

media format mime type is WMAVLSL, AUDIO, (Since tizen 2.4)

MEDIA_FORMAT_PCM 

media format mime type is PCM, AUDIO

MEDIA_FORMAT_PCMA 

media format mime type is PCM A-law, AUDIO

MEDIA_FORMAT_PCMU 

media format mime type is PCM U-law, AUDIO

MEDIA_FORMAT_H261 

media format mime type is H261, VIDEO

MEDIA_FORMAT_H263 

media format mime type is H263, VIDEO

MEDIA_FORMAT_H263P 

media format mime type is H263P, VIDEO

MEDIA_FORMAT_H264_SP 

media format mime type is H264_SP, VIDEO

MEDIA_FORMAT_H264_MP 

media format mime type is H264_MP, VIDEO

MEDIA_FORMAT_H264_HP 

media format mime type is H264_HP, VIDEO

MEDIA_FORMAT_MJPEG 

media format mime type is MJPEG, VIDEO

MEDIA_FORMAT_MPEG1 

media format mime type is MPEG1, VIDEO

MEDIA_FORMAT_MPEG2_SP 

media format mime type is MPEG2_SP, VIDEO

MEDIA_FORMAT_MPEG2_MP 

media format mime type is MPEG2_MP, VIDEO

MEDIA_FORMAT_MPEG2_HP 

media format mime type is MPEG2_HP, VIDEO

MEDIA_FORMAT_MPEG4_SP 

media format mime type is MPEG4_SP, VIDEO

MEDIA_FORMAT_MPEG4_ASP 

media format mime type is MPEG4_ASP, VIDEO

MEDIA_FORMAT_HEVC 

media format mime type is HEVC, VIDEO, (Since tizen 2.4)

MEDIA_FORMAT_VP8 

media format mime type is VP8, VIDEO, (Since tizen 2.4)

MEDIA_FORMAT_VP9 

media format mime type is VP9, VIDEO, (Since tizen 2.4)

MEDIA_FORMAT_VC1 

media format mime type is VC1, VIDEO, (Since tizen 2.4)

MEDIA_FORMAT_I420 

media format mime type is I420, VIDEO

MEDIA_FORMAT_NV12 

media format mime type is NV12, VIDEO

MEDIA_FORMAT_NV12T 

media format mime type is NV12T, VIDEO

MEDIA_FORMAT_YV12 

media format mime type is YV12, VIDEO

MEDIA_FORMAT_NV21 

media format mime type is NV21, VIDEO

MEDIA_FORMAT_NV16 

media format mime type is NV16, VIDEO

MEDIA_FORMAT_YUYV 

media format mime type is YUYV, VIDEO

MEDIA_FORMAT_UYVY 

media format mime type is UYVY, VIDEO

MEDIA_FORMAT_422P 

media format mime type is 422P, VIDEO

MEDIA_FORMAT_RGB565 

media format mime type is RGB565, VIDEO

MEDIA_FORMAT_RGB888 

media format mime type is RGB888, VIDEO

MEDIA_FORMAT_RGBA 

media format mime type is RGBA, VIDEO

MEDIA_FORMAT_ARGB 

media format mime type is ARGB, VIDEO

MEDIA_FORMAT_NATIVE_VIDEO 

media format mime type is HW dependent , VIDEO, (Since tizen 2.4)

MEDIA_FORMAT_MAX 

media format mime type is MEDIA_FORMAT_MAX, Do not use

Enumeration for media format type.

Since :
2.3
Enumerator:
MEDIA_FORMAT_NONE 

media format type is NONE

MEDIA_FORMAT_AUDIO 

media format type is AUDIO

MEDIA_FORMAT_VIDEO 

media format type is VIDEO

MEDIA_FORMAT_TEXT 

media format type is TEXT

MEDIA_FORMAT_UNKNOWN 

media format type is UNKNOWN


Function Documentation

Creates a media format.

Since :
2.3

It creates media format. and reference count will be set to 1 For destroying media_format_h handle, use media_format_unref()

Parameters:
[out]fmtallocated media_format_h
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_OUT_OF_MEMORYOut of memory
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_ref()
media_format_unref()
int media_format_get_audio_aac_type ( media_format_h  fmt,
bool *  is_adts 
)

Gets audio aac type of media format.

Since :
2.4
Parameters:
[in]fmtmedia_format_h to get audio information
[out]is_adtsaac adts flag of the audio
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_set_audio_aac_type()
int media_format_get_audio_info ( media_format_h  fmt,
media_format_mimetype_e mimetype,
int *  channel,
int *  samplerate,
int *  bit,
int *  avg_bps 
)

Gets audio information of media format.

Since :
2.3

returns mimetype, channels, height, samplerate bps, max bps of this media format

Parameters:
[in]fmtmedia_format_h to get audio information
[out]mimetypemedia_format_mimetype_e , ex) MEDIA_FORMAT_PCM
[out]channelchannel of the audio
[out]sampleratesampling rate of the audio
[out]bitbit resolution of the audio
[out]avg_bpsaverage bps of the audio
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_set_audio_mime()
media_format_set_audio_channel()
media_format_set_audio_samplerate()
media_format_set_audio_bit()
media_format_set_audio_avg_bps()
int media_format_get_video_info ( media_format_h  fmt,
media_format_mimetype_e mimetype,
int *  width,
int *  height,
int *  avg_bps,
int *  max_bps 
)

Gets video information of media format.

Since :
2.3

returns mimetype, width, height, average bps, max bps of this media format

Parameters:
[in]fmtmedia_format_h to get video information
[out]mimetypemedia_format_mimetype_e , ex) MEDIA_FORMAT_H264_HP
[out]widthwidth of the video
[out]heightheight of the video
[out]avg_bpsaverage bps of the video
[out]max_bpsmax bps of the video
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_set_video_mime()
media_format_set_video_width()
media_format_set_video_height()
media_format_set_video_avg_bps()
media_format_set_video_max_bps()
int media_format_is_writable ( media_format_h  fmt,
bool *  is_writable 
)

Check whether the media_format_h is writable or not.

Since :
2.3

Check the number of media_format's ref_count

Parameters:
[in]fmtexist media_format_h
[out]is_writableif ref_count is 1, return true. if not, return false
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_OUT_OF_MEMORYOut of memory
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation

Returns a writable copy of media_format_h.

Since :
2.3

If there is only one reference count on fmt, the caller must be the owner, and so this function will return the object unchanged. while, if there is more than one reference count on the object, a new object will be returned. The caller will own a reference to the returned object. In a nutshell, this function unrefs the fmt and refs the out_fmt returned. Don't access fmt after calling this function.

Parameters:
[in]fmtexist media_format_h , don't access it after calling this function
[out]out_fmtnew copied media_format_h, the caller is owner of this object
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_OUT_OF_MEMORYOut of memory
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation

Increase reference count of media_format_h object.

Since :
2.3

increase ref_count of media_format_h

Parameters:
[in]fmtexist media_format_h
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_OUT_OF_MEMORYOut of memory
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_unref()
int media_format_set_audio_aac_type ( media_format_h  fmt,
bool  is_adts 
)

Sets audio aac type of media format.

Since :
2.4

Sets audio aac data type of this media format

Parameters:
[in]fmtmedia_format_h to set
[in]is_adtsaac adts flag of the audio
Precondition:
must set audio MIME type by media_format_set_audio_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_audio_aac_type()
int media_format_set_audio_avg_bps ( media_format_h  fmt,
int  avg_bps 
)

Sets audio avg_bps of media format.

Since :
2.3

Sets audio avg_bps of this media format

Parameters:
[in]fmtmedia_format_h to set
[in]avg_bpsavg_bps of the audio
Precondition:
must set audio MIME type by media_format_set_audio_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_audio()
int media_format_set_audio_bit ( media_format_h  fmt,
int  bit 
)

Sets audio bit of media format.

Since :
2.3

Sets audio bit resolution of this media format

Parameters:
[in]fmtmedia_format_h to set
[in]bitbit of the audio
Precondition:
must set audio MIME type by media_format_set_audio_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_audio()
int media_format_set_audio_channel ( media_format_h  fmt,
int  channel 
)

Sets audio channel of media format.

Since :
2.3

Sets audio channel

Parameters:
[in]fmtmedia_format_h to set audio information
[in]channelchannel of the audio
Precondition:
must set audio MIME type by media_format_set_audio_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_audio()

Sets audio MIME type of media format.

Since :
2.3

Sets MIME type

Parameters:
[in]fmtmedia_format_h to set audio information
[in]mimetypemedia_format_mimetype_e , ex) MEDIA_FORMAT_PCM
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_audio()
int media_format_set_audio_samplerate ( media_format_h  fmt,
int  samplerate 
)

Sets audio samplerate of media format.

Since :
2.3

Sets audio samplerate of this media format

Parameters:
[in]fmtmedia_format_h to set
[in]sampleratesampling rate of the audio
Precondition:
must set audio MIME type by media_format_set_audio_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_audio()
int media_format_set_video_avg_bps ( media_format_h  fmt,
int  avg_bps 
)

Sets video avg_bps of media format.

Since :
2.3

Sets avg_bps

Parameters:
[in]fmtmedia_format_h to set
[in]avg_bpsaverage bps of the video
Precondition:
must set video MIME type by media_format_set_video_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_video()
int media_format_set_video_height ( media_format_h  fmt,
int  height 
)

Sets video height of media format.

Since :
2.3

Sets video height

Parameters:
[in]fmtmedia_format_h to set
[in]heightheight of the video
Precondition:
must set video MIME type by media_format_set_video_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_video()
int media_format_set_video_max_bps ( media_format_h  fmt,
int  max_bps 
)

Sets video max_bps of media format.

Since :
2.3

Sets max_bps

Parameters:
[in]fmtmedia_format_h to set
[in]max_bpsmax bps of the video
Precondition:
must set video MIME type by media_format_set_video_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_video()

Sets video MIME type of media format.

Since :
2.3

Sets MIME type

Parameters:
[in]fmtmedia_format_h to set
[in]mimetypemedia_format_mimetype_e , ex) MEDIA_FORMAT_H264_HP
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_video()
int media_format_set_video_width ( media_format_h  fmt,
int  width 
)

Sets video width of media format.

Since :
2.3

Sets video width

Parameters:
[in]fmtmedia_format_h to set
[in]widthwidth of the video
Precondition:
must set video MIME type by media_format_set_video_mime()
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_get_video()

Decrease reference count of media_format_h object.

Since :
2.3

decrease ref_count of media_format_h

Parameters:
[in]fmtexist media_format_h
Returns:
0 on success, otherwise a negative error value
Return values:
MEDIA_FORMAT_ERROR_NONESuccessful
MEDIA_FORMAT_ERROR_INVALID_PARAMETERInvalid parameter
MEDIA_FORMAT_ERROR_OUT_OF_MEMORYOut of memory
MEDIA_FORMAT_ERROR_INVALID_OPERATIONInvalid operation
See also:
media_format_ref()