* @brief Media Format handle type.
* @since_tizen 2.3
*/
-typedef struct media_format_s* media_format_h;
-
+typedef struct media_format_s *media_format_h;
/**
* @brief Enumerations of media format error
* @since_tizen 2.3
*/
-typedef enum
-{
- MEDIA_FORMAT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- MEDIA_FORMAT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- MEDIA_FORMAT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- MEDIA_FORMAT_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
- MEDIA_FORMAT_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
+typedef enum {
+ MEDIA_FORMAT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ MEDIA_FORMAT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ MEDIA_FORMAT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ MEDIA_FORMAT_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ MEDIA_FORMAT_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
} media_format_error_e;
-
/**
* @brief Enumeration for media format type.
* @since_tizen 2.3
*/
typedef enum {
- MEDIA_FORMAT_NONE = 0x00000000, /**< media format type is NONE */
- MEDIA_FORMAT_AUDIO = 0x00100000, /**< media format type is AUDIO */
- MEDIA_FORMAT_VIDEO = 0x00200000, /**< media format type is VIDEO */
- MEDIA_FORMAT_CONTAINER = 0x00400000, /**< media format type is CONTAINER */
- MEDIA_FORMAT_TEXT = 0x00800000, /**< media format type is TEXT */
- MEDIA_FORMAT_UNKNOWN = 0x08000000, /**< media format type is UNKNOWN */
+ MEDIA_FORMAT_NONE = 0x00000000, /**< media format type is NONE */
+ MEDIA_FORMAT_AUDIO = 0x00100000, /**< media format type is AUDIO */
+ MEDIA_FORMAT_VIDEO = 0x00200000, /**< media format type is VIDEO */
+ MEDIA_FORMAT_CONTAINER = 0x00400000, /**< media format type is CONTAINER */
+ MEDIA_FORMAT_TEXT = 0x00800000, /**< media format type is TEXT */
+ MEDIA_FORMAT_UNKNOWN = 0x08000000, /**< media format type is UNKNOWN */
} media_format_type_e;
/**
* @since_tizen 2.3
*/
typedef enum {
- MEDIA_FORMAT_ENCODED = 0x10000000, /**< media format data type is encoded type */
- MEDIA_FORMAT_RAW = 0x20000000, /**< media format data type is raw type */
+ MEDIA_FORMAT_ENCODED = 0x10000000, /**< media format data type is encoded type */
+ MEDIA_FORMAT_RAW = 0x20000000, /**< media format data type is raw type */
} media_format_data_type_e;
/**
* @since_tizen 2.3
*/
typedef enum {
- /* Audio */
- MEDIA_FORMAT_L16 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1010), /**< media format mime type is L16, AUDIO*/
- MEDIA_FORMAT_ALAW = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1020), /**< media format mime type is ALAW, AUDIO*/
- MEDIA_FORMAT_ULAW = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1030), /**< media format mime type is ULAW, AUDIO */
- MEDIA_FORMAT_AMR = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1040), /**< media format mime type is AMR, AUDIO, indicates MEDIA_FORMAT_AMR_NB (Since 2.4) */
- MEDIA_FORMAT_AMR_NB = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1040), /**< media format mime type is AMR_NB, AUDIO , (Since 2.4) */
- MEDIA_FORMAT_AMR_WB = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1041), /**< media format mime type is AMR_WB, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_G729 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1050), /**< media format mime type is G729, AUDIO*/
- MEDIA_FORMAT_AAC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1060), /**< media format mime type is AAC, AUDIO, indicates MEDIA_FORMAT_AAC_LC (Since 2.4) */
- MEDIA_FORMAT_AAC_LC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1060), /**< media format mime type is AAC_LC, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_AAC_HE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1061), /**< media format mime type is AAC_HE, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_AAC_HE_PS = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1062), /**< media format mime type is AAC_HE_PS, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_MP3 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1070), /**< media format mime type is MP3, AUDIO*/
- MEDIA_FORMAT_VORBIS = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1080), /**< media format mime type is VORBIS, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_FLAC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1090), /**< media format mime type is FLAC, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_WMAV1 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A0), /**< media format mime type is WMAV1, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_WMAV2 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A1), /**< media format mime type is WMAV2, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_WMAPRO = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A2), /**< media format mime type is WMAVPRO, AUDIO, (Since 2.4) */
- MEDIA_FORMAT_WMALSL = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A3), /**< media format mime type is WMAVLSL, AUDIO, (Since 2.4) */
-
- MEDIA_FORMAT_PCM = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1510), /**< media format mime type is PCM, AUDIO*/
- MEDIA_FORMAT_PCMA = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1520), /**< media format mime type is PCM A-law, AUDIO*/
- MEDIA_FORMAT_PCMU = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1530), /**< media format mime type is PCM U-law, AUDIO */
-
-
- /* Video */
- MEDIA_FORMAT_H261 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2010), /**< media format mime type is H261, VIDEO */
- MEDIA_FORMAT_H263 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2020), /**< media format mime type is H263, VIDEO */
- MEDIA_FORMAT_H263P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2021), /**< media format mime type is H263P, VIDEO */
- MEDIA_FORMAT_H264_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2030), /**< media format mime type is H264_SP, VIDEO */
- MEDIA_FORMAT_H264_MP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2031), /**< media format mime type is H264_MP, VIDEO */
- MEDIA_FORMAT_H264_HP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2032), /**< media format mime type is H264_HP, VIDEO */
- MEDIA_FORMAT_MJPEG = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2040), /**< media format mime type is MJPEG, VIDEO */
- MEDIA_FORMAT_MPEG1 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2050), /**< media format mime type is MPEG1, VIDEO */
- MEDIA_FORMAT_MPEG2_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2060), /**< media format mime type is MPEG2_SP, VIDEO */
- MEDIA_FORMAT_MPEG2_MP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2061), /**< media format mime type is MPEG2_MP, VIDEO */
- MEDIA_FORMAT_MPEG2_HP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2062), /**< media format mime type is MPEG2_HP, VIDEO */
- MEDIA_FORMAT_MPEG4_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2070), /**< media format mime type is MPEG4_SP, VIDEO */
- MEDIA_FORMAT_MPEG4_ASP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2071), /**< media format mime type is MPEG4_ASP, VIDEO */
- MEDIA_FORMAT_HEVC = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2080), /**< media format mime type is HEVC, VIDEO, (Since 2.4) */
- MEDIA_FORMAT_VP8 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2090), /**< media format mime type is VP8, VIDEO, (Since 2.4) */
- MEDIA_FORMAT_VP9 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20A0), /**< media format mime type is VP9, VIDEO, (Since 2.4) */
- MEDIA_FORMAT_VC1 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20B0), /**< media format mime type is VC1, VIDEO, (Since 2.4) */
-
- MEDIA_FORMAT_I420 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2510), /**< media format mime type is I420, VIDEO */
- MEDIA_FORMAT_NV12 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2520), /**< media format mime type is NV12, VIDEO */
- MEDIA_FORMAT_NV12T = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2530), /**< media format mime type is NV12T, VIDEO */
- MEDIA_FORMAT_YV12 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2540), /**< media format mime type is YV12, VIDEO */
- MEDIA_FORMAT_NV21 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2550), /**< media format mime type is NV21, VIDEO */
- MEDIA_FORMAT_NV16 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2560), /**< media format mime type is NV16, VIDEO */
- MEDIA_FORMAT_YUYV = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2570), /**< media format mime type is YUYV, VIDEO */
- MEDIA_FORMAT_UYVY = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2580), /**< media format mime type is UYVY, VIDEO */
- MEDIA_FORMAT_422P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2590), /**< media format mime type is 422P, VIDEO */
- MEDIA_FORMAT_RGB565 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25a0), /**< media format mime type is RGB565, VIDEO */
- MEDIA_FORMAT_RGB888 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25b0), /**< media format mime type is RGB888, VIDEO */
- MEDIA_FORMAT_RGBA = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25c0), /**< media format mime type is RGBA, VIDEO */
- MEDIA_FORMAT_ARGB = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25d0), /**< media format mime type is ARGB, VIDEO */
-
- /* CONTAINER VIDEO */
- MEDIA_FORMAT_CONTAINER_MP4 = (MEDIA_FORMAT_CONTAINER | 0x3010), /**< media format mime type is MP4 container, VIDEO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_AVI = (MEDIA_FORMAT_CONTAINER | 0x3020), /**< media format mime type is AVI container, VIDEO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_MPEG2TS = (MEDIA_FORMAT_CONTAINER | 0x3030), /**< media format mime type is MPEG2TS container, VIDEO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_MPEG2PS = (MEDIA_FORMAT_CONTAINER | 0x3040), /**< media format mime type is MPEG2PS container, VIDEO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_MATROSKA = (MEDIA_FORMAT_CONTAINER | 0x3050), /**< media format mime type is MATROSKA container, VIDEO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_WEBM = (MEDIA_FORMAT_CONTAINER | 0x3060), /**< media format mime type is WEBM container, VIDEO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_3GP = (MEDIA_FORMAT_CONTAINER | 0x3070), /**< media format mime type is 3GP container, VIDEO, (Since 3.0) */
-
- /*CONTAINER AUDIO */
- MEDIA_FORMAT_CONTAINER_WAV = (MEDIA_FORMAT_CONTAINER | 0x4010), /**< media format mime type is WAV container, AUDIO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_OGG = (MEDIA_FORMAT_CONTAINER | 0x4020), /**< media format mime type is OGG container, AUDIO, (Since 3.0) */
- MEDIA_FORMAT_CONTAINER_AAC_ADTS = (MEDIA_FORMAT_CONTAINER | 0x4030), /**< media format mime type is AAC_ADTS container, AUDIO, (Since 3.0) */
-
-
- MEDIA_FORMAT_NATIVE_VIDEO = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x7000), /**< media format mime type is HW dependent , VIDEO, (Since 2.4) */
-
- MEDIA_FORMAT_MAX /**< media format mime type is MEDIA_FORMAT_MAX, Do not use */
+ /* Audio */
+ MEDIA_FORMAT_L16 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1010), /**< media format mime type is L16, AUDIO*/
+ MEDIA_FORMAT_ALAW = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1020), /**< media format mime type is ALAW, AUDIO*/
+ MEDIA_FORMAT_ULAW = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1030), /**< media format mime type is ULAW, AUDIO */
+ MEDIA_FORMAT_AMR = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1040), /**< media format mime type is AMR, AUDIO, indicates MEDIA_FORMAT_AMR_NB (Since 2.4) */
+ MEDIA_FORMAT_AMR_NB = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1040), /**< media format mime type is AMR_NB, AUDIO , (Since 2.4) */
+ MEDIA_FORMAT_AMR_WB = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1041), /**< media format mime type is AMR_WB, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_G729 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1050), /**< media format mime type is G729, AUDIO*/
+ MEDIA_FORMAT_AAC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1060), /**< media format mime type is AAC, AUDIO, indicates MEDIA_FORMAT_AAC_LC (Since 2.4) */
+ MEDIA_FORMAT_AAC_LC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1060), /**< media format mime type is AAC_LC, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_AAC_HE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1061), /**< media format mime type is AAC_HE, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_AAC_HE_PS = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1062), /**< media format mime type is AAC_HE_PS, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_MP3 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1070), /**< media format mime type is MP3, AUDIO*/
+ MEDIA_FORMAT_VORBIS = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1080), /**< media format mime type is VORBIS, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_FLAC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1090), /**< media format mime type is FLAC, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_WMAV1 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A0), /**< media format mime type is WMAV1, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_WMAV2 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A1), /**< media format mime type is WMAV2, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_WMAPRO = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A2), /**< media format mime type is WMAVPRO, AUDIO, (Since 2.4) */
+ MEDIA_FORMAT_WMALSL = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A3), /**< media format mime type is WMAVLSL, AUDIO, (Since 2.4) */
+
+ MEDIA_FORMAT_PCM = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1510), /**< media format mime type is PCM, AUDIO*/
+ MEDIA_FORMAT_PCMA = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1520), /**< media format mime type is PCM A-law, AUDIO*/
+ MEDIA_FORMAT_PCMU = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1530), /**< media format mime type is PCM U-law, AUDIO */
+
+ /* Video */
+ MEDIA_FORMAT_H261 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2010), /**< media format mime type is H261, VIDEO */
+ MEDIA_FORMAT_H263 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2020), /**< media format mime type is H263, VIDEO */
+ MEDIA_FORMAT_H263P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2021), /**< media format mime type is H263P, VIDEO */
+ MEDIA_FORMAT_H264_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2030), /**< media format mime type is H264_SP, VIDEO */
+ MEDIA_FORMAT_H264_MP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2031), /**< media format mime type is H264_MP, VIDEO */
+ MEDIA_FORMAT_H264_HP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2032), /**< media format mime type is H264_HP, VIDEO */
+ MEDIA_FORMAT_MJPEG = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2040), /**< media format mime type is MJPEG, VIDEO */
+ MEDIA_FORMAT_MPEG1 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2050), /**< media format mime type is MPEG1, VIDEO */
+ MEDIA_FORMAT_MPEG2_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2060), /**< media format mime type is MPEG2_SP, VIDEO */
+ MEDIA_FORMAT_MPEG2_MP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2061), /**< media format mime type is MPEG2_MP, VIDEO */
+ MEDIA_FORMAT_MPEG2_HP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2062), /**< media format mime type is MPEG2_HP, VIDEO */
+ MEDIA_FORMAT_MPEG4_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2070), /**< media format mime type is MPEG4_SP, VIDEO */
+ MEDIA_FORMAT_MPEG4_ASP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2071), /**< media format mime type is MPEG4_ASP, VIDEO */
+ MEDIA_FORMAT_HEVC = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2080), /**< media format mime type is HEVC, VIDEO, (Since 2.4) */
+ MEDIA_FORMAT_VP8 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2090), /**< media format mime type is VP8, VIDEO, (Since 2.4) */
+ MEDIA_FORMAT_VP9 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20A0), /**< media format mime type is VP9, VIDEO, (Since 2.4) */
+ MEDIA_FORMAT_VC1 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20B0), /**< media format mime type is VC1, VIDEO, (Since 2.4) */
+
+ MEDIA_FORMAT_I420 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2510), /**< media format mime type is I420, VIDEO */
+ MEDIA_FORMAT_NV12 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2520), /**< media format mime type is NV12, VIDEO */
+ MEDIA_FORMAT_NV12T = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2530), /**< media format mime type is NV12T, VIDEO */
+ MEDIA_FORMAT_YV12 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2540), /**< media format mime type is YV12, VIDEO */
+ MEDIA_FORMAT_NV21 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2550), /**< media format mime type is NV21, VIDEO */
+ MEDIA_FORMAT_NV16 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2560), /**< media format mime type is NV16, VIDEO */
+ MEDIA_FORMAT_YUYV = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2570), /**< media format mime type is YUYV, VIDEO */
+ MEDIA_FORMAT_UYVY = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2580), /**< media format mime type is UYVY, VIDEO */
+ MEDIA_FORMAT_422P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x2590), /**< media format mime type is 422P, VIDEO */
+ MEDIA_FORMAT_RGB565 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25a0), /**< media format mime type is RGB565, VIDEO */
+ MEDIA_FORMAT_RGB888 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25b0), /**< media format mime type is RGB888, VIDEO */
+ MEDIA_FORMAT_RGBA = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25c0), /**< media format mime type is RGBA, VIDEO */
+ MEDIA_FORMAT_ARGB = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25d0), /**< media format mime type is ARGB, VIDEO */
+
+ /* CONTAINER VIDEO */
+ MEDIA_FORMAT_CONTAINER_MP4 = (MEDIA_FORMAT_CONTAINER | 0x3010), /**< media format mime type is MP4 container, VIDEO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_AVI = (MEDIA_FORMAT_CONTAINER | 0x3020), /**< media format mime type is AVI container, VIDEO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_MPEG2TS = (MEDIA_FORMAT_CONTAINER | 0x3030), /**< media format mime type is MPEG2TS container, VIDEO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_MPEG2PS = (MEDIA_FORMAT_CONTAINER | 0x3040), /**< media format mime type is MPEG2PS container, VIDEO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_MATROSKA = (MEDIA_FORMAT_CONTAINER | 0x3050), /**< media format mime type is MATROSKA container, VIDEO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_WEBM = (MEDIA_FORMAT_CONTAINER | 0x3060), /**< media format mime type is WEBM container, VIDEO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_3GP = (MEDIA_FORMAT_CONTAINER | 0x3070), /**< media format mime type is 3GP container, VIDEO, (Since 3.0) */
+
+ /*CONTAINER AUDIO */
+ MEDIA_FORMAT_CONTAINER_WAV = (MEDIA_FORMAT_CONTAINER | 0x4010), /**< media format mime type is WAV container, AUDIO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_OGG = (MEDIA_FORMAT_CONTAINER | 0x4020), /**< media format mime type is OGG container, AUDIO, (Since 3.0) */
+ MEDIA_FORMAT_CONTAINER_AAC_ADTS = (MEDIA_FORMAT_CONTAINER | 0x4030), /**< media format mime type is AAC_ADTS container, AUDIO, (Since 3.0) */
+
+ MEDIA_FORMAT_NATIVE_VIDEO = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x7000), /**< media format mime type is HW dependent , VIDEO, (Since 2.4) */
+
+ MEDIA_FORMAT_MAX /**< media format mime type is MEDIA_FORMAT_MAX, Do not use */
} media_format_mimetype_e;
/**
* @since_tizen 2.3
*/
typedef enum {
- 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 */
+ 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 */
} media_format_color_model_e;
-
/**
* @brief Creates a media format
* @since_tizen 2.3
* @see media_format_ref()
* @see media_format_unref()
*/
-int media_format_create(media_format_h* fmt);
+int media_format_create(media_format_h * fmt);
/**
* @brief Gets format type of media format
* @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation
*/
-int media_format_get_type(media_format_h fmt, media_format_type_e* formattype);
+int media_format_get_type(media_format_h fmt, media_format_type_e * formattype);
/**
* @brief Gets container MIME type of media format
* @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation
* @see media_format_set_container_mime()
*/
-int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e* mimetype);
+int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e * mimetype);
/**
* @brief Gets video information of media format
* @see media_format_set_video_avg_bps()
* @see media_format_set_video_max_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);
+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);
/**
* @brief Gets audio information of media format
* @see media_format_set_audio_bit()
* @see media_format_set_audio_avg_bps()
*/
-int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e* mimetype, int* channel, int* samplerate, int* bit, int* avg_bps);
+int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e * mimetype, int *channel, int *samplerate, int *bit, int *avg_bps);
/**
* @brief Gets audio aac type of media format
* @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation
* @see media_format_set_audio_aac_type()
*/
-int media_format_get_audio_aac_type(media_format_h fmt, bool* is_adts);
+int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts);
/**
* @brief Gets video frame rate of media format
* @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation
*/
-int media_format_get_video_frame_rate(media_format_h fmt, int* frame_rate);
+int media_format_get_video_frame_rate(media_format_h fmt, int *frame_rate);
/**
* @brief Sets container MIME type of media format
*/
int media_format_set_video_width(media_format_h fmt, int width);
-
/**
* @brief Sets video height of media format
* @since_tizen 2.3
* @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation
*/
-int media_format_is_writable(media_format_h fmt, bool* is_writable);
+int media_format_is_writable(media_format_h fmt, bool * is_writable);
/**
* @brief Returns a writable copy of media_format_h
* @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory
* @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation
*/
-int media_format_make_writable(media_format_h fmt, media_format_h* out_fmt);
-
+int media_format_make_writable(media_format_h fmt, media_format_h * out_fmt);
/**
* @}
}
#endif
-#endif /* __TIZEN_MEDIA_FORMAT_H__ */
+#endif /* __TIZEN_MEDIA_FORMAT_H__ */
#include <media_format.h>
#include <media_format_private.h>
-static void _media_format_destroy(media_format_s* fmt);
+static void _media_format_destroy(media_format_s * fmt);
-int media_format_create(media_format_h* fmt)
+int media_format_create(media_format_h * fmt)
{
- MEDIA_FORMAT_NULL_ARG_CHECK(fmt);
- int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_NULL_ARG_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)malloc(sizeof(media_format_s));
- if (fmt_handle)
- {
- memset(fmt_handle, 0, sizeof(media_format_s));
- }
- else
- {
- return MEDIA_FORMAT_ERROR_OUT_OF_MEMORY;
- }
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) malloc(sizeof(media_format_s));
+ if (fmt_handle) {
+ memset(fmt_handle, 0, sizeof(media_format_s));
+ } else {
+ return MEDIA_FORMAT_ERROR_OUT_OF_MEMORY;
+ }
- fmt_handle->ref_count = 1;
+ fmt_handle->ref_count = 1;
- *fmt = (media_format_h)fmt_handle;
+ *fmt = (media_format_h) fmt_handle;
- LOGI("The new format handle: %p \n", *fmt);
+ LOGI("The new format handle: %p \n", *fmt);
- return ret;
+ return ret;
}
-static void _media_format_destroy(media_format_s* fmt)
+static void _media_format_destroy(media_format_s * fmt)
{
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- free(fmt);
- fmt = NULL;
+ free(fmt);
+ fmt = NULL;
}
-int media_format_get_type(media_format_h fmt, media_format_type_e* formattype)
+int media_format_get_type(media_format_h fmt, media_format_type_e * formattype)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
-
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
-
- if (!formattype)
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
-
- if (fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)
- *formattype = MEDIA_FORMAT_AUDIO;
- else if (fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)
- *formattype = MEDIA_FORMAT_VIDEO;
- else if (fmt_handle->mimetype & MEDIA_FORMAT_CONTAINER)
- *formattype = MEDIA_FORMAT_CONTAINER;
- else if (fmt_handle->mimetype & MEDIA_FORMAT_TEXT)
- *formattype = MEDIA_FORMAT_TEXT;
- else
- {
- LOGE("The format handle is not for AUDIO / VIDEO / CONTAINER / TEXT..\n");
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
-
- return ret;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
+
+ if (!formattype)
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+
+ if (fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)
+ *formattype = MEDIA_FORMAT_AUDIO;
+ else if (fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)
+ *formattype = MEDIA_FORMAT_VIDEO;
+ else if (fmt_handle->mimetype & MEDIA_FORMAT_CONTAINER)
+ *formattype = MEDIA_FORMAT_CONTAINER;
+ else if (fmt_handle->mimetype & MEDIA_FORMAT_TEXT)
+ *formattype = MEDIA_FORMAT_TEXT;
+ else {
+ LOGE("The format handle is not for AUDIO / VIDEO / CONTAINER / TEXT..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
+
+ return ret;
}
-int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e* mimetype)
+int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e * mimetype)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_CONTAINER))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_CONTAINER..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_CONTAINER)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_CONTAINER..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- if (mimetype)
- *mimetype = fmt_handle->mimetype;
+ if (mimetype)
+ *mimetype = fmt_handle->mimetype;
- return ret;
+ return ret;
}
-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)
+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)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
-
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
-
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
-
- if (mimetype)
- *mimetype = fmt_handle->mimetype;
- if (width)
- *width = fmt_handle->detail.video.width;
- if (height)
- *height = fmt_handle->detail.video.height;
- if (avg_bps)
- *avg_bps = fmt_handle->detail.video.avg_bps;
- if (max_bps)
- *max_bps = fmt_handle->detail.video.max_bps;
-
- return ret;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
+
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
+
+ if (mimetype)
+ *mimetype = fmt_handle->mimetype;
+ if (width)
+ *width = fmt_handle->detail.video.width;
+ if (height)
+ *height = fmt_handle->detail.video.height;
+ if (avg_bps)
+ *avg_bps = fmt_handle->detail.video.avg_bps;
+ if (max_bps)
+ *max_bps = fmt_handle->detail.video.max_bps;
+
+ return ret;
}
-int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e* mimetype, int* channel, int* samplerate, int* bit, int* avg_bps)
+int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e * mimetype, int *channel, int *samplerate, int *bit, int *avg_bps)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
-
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
-
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
- if (mimetype)
- *mimetype = fmt_handle->mimetype;
- if (channel)
- *channel = fmt_handle->detail.audio.channel;
- if (samplerate)
- *samplerate = fmt_handle->detail.audio.samplerate;
- if (bit)
- *bit = fmt_handle->detail.audio.bit;
- if (avg_bps)
- *avg_bps = fmt_handle->detail.audio.avg_bps;
-
- return ret;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
+
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
+ if (mimetype)
+ *mimetype = fmt_handle->mimetype;
+ if (channel)
+ *channel = fmt_handle->detail.audio.channel;
+ if (samplerate)
+ *samplerate = fmt_handle->detail.audio.samplerate;
+ if (bit)
+ *bit = fmt_handle->detail.audio.bit;
+ if (avg_bps)
+ *avg_bps = fmt_handle->detail.audio.avg_bps;
+
+ return ret;
}
-int media_format_get_audio_aac_type(media_format_h fmt, bool* is_adts)
+int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype == MEDIA_FORMAT_AAC_LC || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE_PS))
- {
- LOGE("The format handle is not aac format..\n");
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!(fmt_handle->mimetype == MEDIA_FORMAT_AAC_LC || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE || fmt_handle->mimetype == MEDIA_FORMAT_AAC_HE_PS)) {
+ LOGE("The format handle is not aac format..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- if (is_adts)
- *is_adts = fmt_handle->detail.audio.is_adts;
+ if (is_adts)
+ *is_adts = fmt_handle->detail.audio.is_adts;
- return ret;
+ return ret;
}
-int media_format_get_video_frame_rate(media_format_h fmt, int* frame_rate)
+int media_format_get_video_frame_rate(media_format_h fmt, int *frame_rate)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- if (frame_rate)
- *frame_rate = fmt_handle->detail.video.frame_rate;
+ if (frame_rate)
+ *frame_rate = fmt_handle->detail.video.frame_rate;
- return ret;
+ return ret;
}
int media_format_set_container_mime(media_format_h fmt, media_format_mimetype_e mimetype)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("The format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("The format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(mimetype & MEDIA_FORMAT_CONTAINER))
- {
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(mimetype & MEDIA_FORMAT_CONTAINER)) {
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->mimetype = mimetype;
+ fmt_handle->mimetype = mimetype;
- return ret;
+ return ret;
}
int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mimetype)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("The format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("The format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(mimetype & MEDIA_FORMAT_VIDEO))
- {
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(mimetype & MEDIA_FORMAT_VIDEO)) {
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->mimetype = mimetype;
+ fmt_handle->mimetype = mimetype;
- return ret;
+ return ret;
}
int media_format_set_video_width(media_format_h fmt, int width)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.video.width = width;
+ fmt_handle->detail.video.width = width;
- return ret;
+ return ret;
}
int media_format_set_video_height(media_format_h fmt, int height)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("The format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("The format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.video.height = height;
+ fmt_handle->detail.video.height = height;
- return ret;
+ return ret;
}
int media_format_set_video_avg_bps(media_format_h fmt, int avg_bps)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("The format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("The format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.video.avg_bps = avg_bps;
+ fmt_handle->detail.video.avg_bps = avg_bps;
- return ret;
+ return ret;
}
int media_format_set_video_max_bps(media_format_h fmt, int max_bps)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("The format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("The format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.video.max_bps = max_bps;
+ fmt_handle->detail.video.max_bps = max_bps;
- return ret;
+ return ret;
}
int media_format_set_video_frame_rate(media_format_h fmt, int frame_rate)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("The format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("The format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_VIDEO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_VIDEO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.video.frame_rate = frame_rate;
+ fmt_handle->detail.video.frame_rate = frame_rate;
- return ret;
+ return ret;
}
int media_format_set_audio_mime(media_format_h fmt, media_format_mimetype_e mimetype)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->mimetype = mimetype;
+ fmt_handle->mimetype = mimetype;
- return ret;
+ return ret;
}
int media_format_set_audio_channel(media_format_h fmt, int channel)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.audio.channel = channel;
+ fmt_handle->detail.audio.channel = channel;
- return ret;
+ return ret;
}
int media_format_set_audio_samplerate(media_format_h fmt, int samplerate)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.audio.samplerate = samplerate;
+ fmt_handle->detail.audio.samplerate = samplerate;
- return ret;
+ return ret;
}
int media_format_set_audio_bit(media_format_h fmt, int bit)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.audio.bit = bit;
+ fmt_handle->detail.audio.bit = bit;
- return ret;
+ return ret;
}
int media_format_set_audio_avg_bps(media_format_h fmt, int avg_bps)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.audio.avg_bps = avg_bps;
+ fmt_handle->detail.audio.avg_bps = avg_bps;
- return ret;
+ return ret;
}
int media_format_set_audio_aac_type(media_format_h fmt, bool is_adts)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (!MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- LOGE("the format can not be changed..\n", __FUNCTION__);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ LOGE("the format can not be changed..\n", __FUNCTION__);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO))
- {
- LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
- return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
- }
+ if (!(fmt_handle->mimetype & MEDIA_FORMAT_AUDIO)) {
+ LOGE("The format handle is not for MEDIA_FORMAT_AUDIO..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+ }
- fmt_handle->detail.audio.is_adts = is_adts;
+ fmt_handle->detail.audio.is_adts = is_adts;
- return ret;
+ return ret;
}
int media_format_ref(media_format_h fmt)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
- if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0)
- {
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
+ if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0) {
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
- g_atomic_int_inc(&fmt_handle->ref_count);
+ g_atomic_int_inc(&fmt_handle->ref_count);
- return ret;
+ return ret;
}
int media_format_unref(media_format_h fmt)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- bool is_zero;
-
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
-
- if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0)
- {
- LOGE("The format ref_count is less than 0..\n");
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
-
- is_zero = g_atomic_int_dec_and_test(&fmt_handle->ref_count);
- if (is_zero)
- {
- LOGI("The format handle(%p) will be destroyed..\n", fmt);
- /* if reference count become 0 , free fmt. */
- _media_format_destroy(fmt_handle);
- }
-
- return ret;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ bool is_zero;
+
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
+
+ if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0) {
+ LOGE("The format ref_count is less than 0..\n");
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
+
+ is_zero = g_atomic_int_dec_and_test(&fmt_handle->ref_count);
+ if (is_zero) {
+ LOGI("The format handle(%p) will be destroyed..\n", fmt);
+ /* if reference count become 0 , free fmt. */
+ _media_format_destroy(fmt_handle);
+ }
+
+ return ret;
}
-int media_format_is_writable(media_format_h fmt, bool* is_writable)
+int media_format_is_writable(media_format_h fmt, bool * is_writable)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
- if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0)
- {
- LOGE("The format ref_count is less than 0..\n.");
- ret = MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
-
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
-
- if (g_atomic_int_get(&fmt_handle->ref_count) == 1)
- {
- /* if reference count is 1, the caller must be owner. */
- *is_writable = true;
- }
- else
- {
- *is_writable = false;
- }
-
- return ret;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+ if (MEDIA_FORMAT_GET_REFCOUNT(fmt) <= 0) {
+ LOGE("The format ref_count is less than 0..\n.");
+ ret = MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
+
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
+
+ if (g_atomic_int_get(&fmt_handle->ref_count) == 1) {
+ /* if reference count is 1, the caller must be owner. */
+ *is_writable = true;
+ } else {
+ *is_writable = false;
+ }
+
+ return ret;
}
-int media_format_make_writable(media_format_h fmt, media_format_h* out_fmt)
+int media_format_make_writable(media_format_h fmt, media_format_h * out_fmt)
{
- int ret = MEDIA_FORMAT_ERROR_NONE;
- MEDIA_FORMAT_INSTANCE_CHECK(fmt);
-
- media_format_s* fmt_handle;
- fmt_handle = (media_format_s*)fmt;
-
- if (MEDIA_FORMAT_IS_WRITABLE(fmt))
- {
- /* If there is only one reference count on @fmt, the caller must be the owner */
- *out_fmt = fmt;
- }
- else
- {
- /* If there is more than one reference on the object, a new media_format_h object will be returned.
- The caller's reference on @fmt will be removed, and instead the caller will own a reference to the returned object.*/
- media_format_s* copy;
- copy = (media_format_s*)malloc(sizeof(media_format_s));
- if (copy)
- {
- memset(copy, 0, sizeof(media_format_s));
- }
- else
- {
- return MEDIA_FORMAT_ERROR_OUT_OF_MEMORY;
- }
-
- memcpy(copy, fmt_handle, sizeof(media_format_s));
- copy->ref_count = 1;
-
- if (media_format_unref(fmt) != MEDIA_FORMAT_ERROR_NONE)
- {
- free(copy);
- return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
- }
-
- *out_fmt = (media_format_h)copy;
- LOGI("the copied new format handle: %p\n", *out_fmt);
-
- }
-
- return ret;
+ int ret = MEDIA_FORMAT_ERROR_NONE;
+ MEDIA_FORMAT_INSTANCE_CHECK(fmt);
+
+ media_format_s *fmt_handle;
+ fmt_handle = (media_format_s *) fmt;
+
+ if (MEDIA_FORMAT_IS_WRITABLE(fmt)) {
+ /* If there is only one reference count on @fmt, the caller must be the owner */
+ *out_fmt = fmt;
+ } else {
+ /* If there is more than one reference on the object, a new media_format_h object will be returned.
+ The caller's reference on @fmt will be removed, and instead the caller will own a reference to the returned object. */
+ media_format_s *copy;
+ copy = (media_format_s *) malloc(sizeof(media_format_s));
+ if (copy) {
+ memset(copy, 0, sizeof(media_format_s));
+ } else {
+ return MEDIA_FORMAT_ERROR_OUT_OF_MEMORY;
+ }
+
+ memcpy(copy, fmt_handle, sizeof(media_format_s));
+ copy->ref_count = 1;
+
+ if (media_format_unref(fmt) != MEDIA_FORMAT_ERROR_NONE) {
+ free(copy);
+ return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+ }
+
+ *out_fmt = (media_format_h) copy;
+ LOGI("the copied new format handle: %p\n", *out_fmt);
+
+ }
+
+ return ret;
}
-
-
/* NOTE : static internal functions does not check anything on incomming parameters
* Caller should takecare it
*/
-static int _pkt_alloc_buffer(media_packet_s* pkt);
-static uint64_t _pkt_calculate_video_buffer_size(media_packet_s* pkt);
-static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s* pkt);
+static int _pkt_alloc_buffer(media_packet_s * pkt);
+static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt);
+static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt);
static uint32_t _convert_to_tbm_surface_format(media_format_mimetype_e format_type);
-static void* _aligned_malloc_normal_buffer_type (uint64_t size, int alignment);
-static void _aligned_free_normal_buffer_type (void* buffer_ptr);
+static void *_aligned_malloc_normal_buffer_type(uint64_t size, int alignment);
+static void _aligned_free_normal_buffer_type(void *buffer_ptr);
-
-int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
+int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
{
- media_packet_s* handle = NULL;
- int ret = MEDIA_PACKET_ERROR_NONE;
-
- MEDIA_PACKET_INSTANCE_CHECK(fmt);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
- if (MEDIA_FORMAT_GET_REFCOUNT(fmt) < 1)
- {
- LOGE("The media format handle is corrupted or Not set media info");
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
-
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt))
- {
- LOGE("The media format handle is not specified. set video info or audio info...");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- handle = (media_packet_s*)malloc(sizeof(media_packet_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(media_packet_s));
- else
- {
- LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
- ret = MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- goto fail;
- }
-
- /* TODO : need to consider to give application to select buffer type(tbm or heap) */
-
- /* check if tbm surface is needed.
- * This time, Only raw video format is considered to be allocated in TBM
- */
- if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt))
- {
- handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
- }
- else
- {
- handle->type = MEDIA_BUFFER_TYPE_NORMAL;
- }
-
- /* take fmt */
- handle->format = MEDIA_FORMAT_CAST(fmt);
-
- /* alloc buffer */
- int err = _pkt_alloc_buffer(handle);
- if (err != MEDIA_PACKET_ERROR_NONE)
- {
- LOGE("[%s] failed _pkt_alloc_buffer(), err = (0x%08x)", __FUNCTION__, err);
- ret = err;
- goto fail;
- }
-
- /* allocated buffer */
- handle->is_allocated = true;
-
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
-
- /* increase format reference count */
- media_format_ref((media_format_h)handle->format);
-
- /* take handle */
- *packet = (media_packet_h)handle;
- LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
- return ret;
-
-fail:
-
- if (handle)
- {
- free(handle);
- handle = NULL;
- }
-
- *packet = NULL;
- return ret;
+ media_packet_s *handle = NULL;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+
+ MEDIA_PACKET_INSTANCE_CHECK(fmt);
+ MEDIA_PACKET_NULL_ARG_CHECK(packet);
+ if (MEDIA_FORMAT_GET_REFCOUNT(fmt) < 1) {
+ LOGE("The media format handle is corrupted or Not set media info");
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
+ LOGE("The media format handle is not specified. set video info or audio info...");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+ if (handle != NULL)
+ memset(handle, 0, sizeof(media_packet_s));
+ else {
+ LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
+ ret = MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ goto fail;
+ }
+
+ /* TODO : need to consider to give application to select buffer type(tbm or heap) */
+
+ /* check if tbm surface is needed.
+ * This time, Only raw video format is considered to be allocated in TBM
+ */
+ if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt)) {
+ handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
+ } else {
+ handle->type = MEDIA_BUFFER_TYPE_NORMAL;
+ }
+
+ /* take fmt */
+ handle->format = MEDIA_FORMAT_CAST(fmt);
+
+ /* alloc buffer */
+ int err = _pkt_alloc_buffer(handle);
+ if (err != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("[%s] failed _pkt_alloc_buffer(), err = (0x%08x)", __FUNCTION__, err);
+ ret = err;
+ goto fail;
+ }
+
+ /* allocated buffer */
+ handle->is_allocated = true;
+
+ /* set finalized callback and user data */
+ handle->finalizecb_func = fcb;
+ handle->userdata = fcb_data;
+
+ /* increase format reference count */
+ media_format_ref((media_format_h) handle->format);
+
+ /* take handle */
+ *packet = (media_packet_h) handle;
+ LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
+ return ret;
+
+ fail:
+
+ if (handle) {
+ free(handle);
+ handle = NULL;
+ }
+
+ *packet = NULL;
+ return ret;
}
-int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
+int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
{
- media_packet_s* handle = NULL;
- int ret = MEDIA_PACKET_ERROR_NONE;
-
- MEDIA_PACKET_INSTANCE_CHECK(fmt);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
- if (MEDIA_FORMAT_GET_REFCOUNT(fmt) < 1)
- {
- LOGE("The media format handle is corrupted or Not set media info");
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
-
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt))
- {
- LOGE("The media format handle is not specified. set video info or audio info...");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- /* TODO : need more validation on fmt */
-
- handle = (media_packet_s*)malloc(sizeof(media_packet_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(media_packet_s));
- else
- {
- LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
-
- /* TODO : need to consider to give application to select buffer type(tbm or heap) */
-
- /* check if tbm surface is needed.
- * This time, Only raw video format is considered to be allocated in TBM
- */
- if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt))
- {
- handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
- }
- else
- {
- handle->type = MEDIA_BUFFER_TYPE_NORMAL;
- }
-
- /* take fmt */
- handle->format = MEDIA_FORMAT_CAST(fmt);
-
- /* NOT allocated buffer */
- handle->is_allocated = false;
-
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
-
- /* increase format reference count */
- media_format_ref((media_format_h)handle->format);
-
- /* take handle */
- *packet = (media_packet_h)handle;
- LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
- return ret;
+ media_packet_s *handle = NULL;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+
+ MEDIA_PACKET_INSTANCE_CHECK(fmt);
+ MEDIA_PACKET_NULL_ARG_CHECK(packet);
+ if (MEDIA_FORMAT_GET_REFCOUNT(fmt) < 1) {
+ LOGE("The media format handle is corrupted or Not set media info");
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
+ LOGE("The media format handle is not specified. set video info or audio info...");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+ /* TODO : need more validation on fmt */
+
+ handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+ if (handle != NULL)
+ memset(handle, 0, sizeof(media_packet_s));
+ else {
+ LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ }
+
+ /* TODO : need to consider to give application to select buffer type(tbm or heap) */
+
+ /* check if tbm surface is needed.
+ * This time, Only raw video format is considered to be allocated in TBM
+ */
+ if (MEDIA_FORMAT_IS_VIDEO(fmt) && MEDIA_FORMAT_IS_RAW(fmt)) {
+ handle->type = MEDIA_BUFFER_TYPE_TBM_SURFACE;
+ } else {
+ handle->type = MEDIA_BUFFER_TYPE_NORMAL;
+ }
+
+ /* take fmt */
+ handle->format = MEDIA_FORMAT_CAST(fmt);
+
+ /* NOT allocated buffer */
+ handle->is_allocated = false;
+
+ /* set finalized callback and user data */
+ handle->finalizecb_func = fcb;
+ handle->userdata = fcb_data;
+
+ /* increase format reference count */
+ media_format_ref((media_format_h) handle->format);
+
+ /* take handle */
+ *packet = (media_packet_h) handle;
+ LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
+ return ret;
}
-int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h* new_packet)
+int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * new_packet)
{
- media_packet_s* handle;
- media_packet_s* org_handle;
+ media_packet_s *handle;
+ media_packet_s *org_handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(org_packet);
- MEDIA_PACKET_NULL_ARG_CHECK(new_packet);
+ MEDIA_PACKET_INSTANCE_CHECK(org_packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(new_packet);
- org_handle = (media_packet_s*)org_packet;
+ org_handle = (media_packet_s *) org_packet;
- handle = (media_packet_s*)malloc(sizeof(media_packet_s));
- if (handle != NULL)
- memset(handle, 0, sizeof(media_packet_s));
- else
- {
- LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
+ handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+ if (handle != NULL)
+ memset(handle, 0, sizeof(media_packet_s));
+ else {
+ LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ }
- /* copy handle*/
- memcpy(handle, org_handle, sizeof(media_packet_s));
+ /* copy handle */
+ memcpy(handle, org_handle, sizeof(media_packet_s));
- /* the caller can not get exist allocated buffer pointer */
- handle->data = NULL;
- handle->surface_data = NULL;
- handle->is_allocated = false;
- handle->size = 0;
+ /* the caller can not get exist allocated buffer pointer */
+ handle->data = NULL;
+ handle->surface_data = NULL;
+ handle->is_allocated = false;
+ handle->size = 0;
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
+ /* set finalized callback and user data */
+ handle->finalizecb_func = fcb;
+ handle->userdata = fcb_data;
- /* increase format reference count */
- media_format_ref((media_format_h)handle->format);
+ /* increase format reference count */
+ media_format_ref((media_format_h) handle->format);
- /* take handle */
- *new_packet = (media_packet_h)handle;
- LOGI("[%s] new handle : %p", __FUNCTION__, *new_packet);
- return ret;
+ /* take handle */
+ *new_packet = (media_packet_h) handle;
+ LOGI("[%s] new handle : %p", __FUNCTION__, *new_packet);
+ return ret;
}
int media_packet_alloc(media_packet_h packet)
{
- LOGI("[%s] start", __FUNCTION__);
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ LOGI("[%s] start", __FUNCTION__);
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- /* alloc buffer */
- int err = _pkt_alloc_buffer(handle);
- if (err != MEDIA_PACKET_ERROR_NONE)
- {
- LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
- ret = err;
- goto fail;
- }
+ /* alloc buffer */
+ int err = _pkt_alloc_buffer(handle);
+ if (err != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
+ ret = err;
+ goto fail;
+ }
- /* allocated buffer */
- handle->is_allocated = true;
+ /* allocated buffer */
+ handle->is_allocated = true;
- LOGI("[%s] end", __FUNCTION__);
- return ret;
+ LOGI("[%s] end", __FUNCTION__);
+ return ret;
-fail:
- if(handle)
- {
- free(handle);
- handle = NULL;
- }
- return ret;
+ fail:
+ if (handle) {
+ free(handle);
+ handle = NULL;
+ }
+ return ret;
}
-
-int _pkt_alloc_buffer(media_packet_s* pkt)
+int _pkt_alloc_buffer(media_packet_s * pkt)
{
- /* skip validating pkt */
- uint64_t buffersize = 0;
-
- /* need to use format,width,height to get buffer size for raw video frame */
- if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE)
- {
- buffersize = _pkt_calculate_video_buffer_size(pkt);
- pkt->size = buffersize;
- /* NOTE : size of buffer may not equal to w*h*bpp. Not sure we need to
- * do some verifying between given size and calculated size.
- */
- }
- else
- {
- buffersize = pkt->size;
- }
-
- if (pkt->type == MEDIA_BUFFER_TYPE_NORMAL)
- {
- /* need to use format,width,height to get buffer size */
- if (MEDIA_FORMAT_IS_VIDEO(pkt->format))
- {
- buffersize = _pkt_calculate_video_buffer_size(pkt);
- // 16bytes aligned malloc
- pkt->data = _aligned_malloc_normal_buffer_type(buffersize, 16);
- if (!pkt->data)
- {
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- buffersize = _pkt_calculate_audio_buffer_size(pkt);
- pkt->data = (void*)malloc(buffersize);
- if (!pkt->data)
- {
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
- }
- pkt->size = buffersize;
- }
- else if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE)
- {
-
- /* convert to tbm_format*/
- uint32_t tbm_format;
- tbm_format = _convert_to_tbm_surface_format(pkt->format->mimetype);
+ /* skip validating pkt */
+ uint64_t buffersize = 0;
+
+ /* need to use format,width,height to get buffer size for raw video frame */
+ if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
+ buffersize = _pkt_calculate_video_buffer_size(pkt);
+ pkt->size = buffersize;
+ /* NOTE : size of buffer may not equal to w*h*bpp. Not sure we need to
+ * do some verifying between given size and calculated size.
+ */
+ } else {
+ buffersize = pkt->size;
+ }
+
+ if (pkt->type == MEDIA_BUFFER_TYPE_NORMAL) {
+ /* need to use format,width,height to get buffer size */
+ if (MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
+ buffersize = _pkt_calculate_video_buffer_size(pkt);
+ // 16bytes aligned malloc
+ pkt->data = _aligned_malloc_normal_buffer_type(buffersize, 16);
+ if (!pkt->data) {
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ buffersize = _pkt_calculate_audio_buffer_size(pkt);
+ pkt->data = (void *)malloc(buffersize);
+ if (!pkt->data) {
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ }
+ }
+ pkt->size = buffersize;
+ } else if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
+
+ /* convert to tbm_format */
+ uint32_t tbm_format;
+ tbm_format = _convert_to_tbm_surface_format(pkt->format->mimetype);
#if 0
- /*check whether given tbm_format is supported or not*/
- uint32_t *supported_formats;
- uint32_t supported_format_num;
- bool is_supported_format;
- int i;
-
- if (tbm_surface_query_formats(&supported_formats, &supported_format_num))
- {
- is_supported_format = false;
- for (i = 0 ; i < supported_format_num ; i++)
- {
- if (supported_formats[i] == tbm_format)
- {
- is_supported_format = true;
- break;
- }
- }
-
- free (supported_formats);
- }
- else
- {
- /* tbm_surface_query_format returns error */
- LOGE("tbm_surface_query_format is failed..");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- /* if not supported tbm_format by backend, don't need to do tbm_surface_create() */
- if (!is_supported_format)
- {
- LOGE("the backend doesn't support 0x%x mimetype", pkt->format->mimetype);
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
+ /*check whether given tbm_format is supported or not */
+ uint32_t *supported_formats;
+ uint32_t supported_format_num;
+ bool is_supported_format;
+ int i;
+
+ if (tbm_surface_query_formats(&supported_formats, &supported_format_num)) {
+ is_supported_format = false;
+ for (i = 0; i < supported_format_num; i++) {
+ if (supported_formats[i] == tbm_format) {
+ is_supported_format = true;
+ break;
+ }
+ }
+
+ free(supported_formats);
+ } else {
+ /* tbm_surface_query_format returns error */
+ LOGE("tbm_surface_query_format is failed..");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ /* if not supported tbm_format by backend, don't need to do tbm_surface_create() */
+ if (!is_supported_format) {
+ LOGE("the backend doesn't support 0x%x mimetype", pkt->format->mimetype);
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
#endif
- /*create tbm_surface*/
- pkt->surface_data = (void*)tbm_surface_create(pkt->format->detail.video.width, pkt->format->detail.video.height, tbm_format);
- if (pkt->surface_data != NULL)
- {
-
- /* get tbm_surface_info */
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)pkt->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE)
- {
- pkt->data = surface_info.planes[0].ptr;
- pkt->size = (uint64_t)surface_info.size;
- LOGD("tbm_surface_created, pkt->size = %llu\n", pkt->size);
- }
- else
- {
- LOGE("tbm_surface_get_info() is failed.. err = 0x%08x \n", err);
- tbm_surface_destroy((tbm_surface_h)pkt->surface_data);
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- }
- else
- {
- LOGE("\n tbm_surface_create() is failed!! \n");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- }
- return MEDIA_PACKET_ERROR_NONE;
+ /*create tbm_surface */
+ pkt->surface_data = (void *)tbm_surface_create(pkt->format->detail.video.width, pkt->format->detail.video.height, tbm_format);
+ if (pkt->surface_data != NULL) {
+
+ /* get tbm_surface_info */
+ tbm_surface_info_s surface_info;
+ int err = tbm_surface_get_info((tbm_surface_h) pkt->surface_data, &surface_info);
+ if (err == TBM_SURFACE_ERROR_NONE) {
+ pkt->data = surface_info.planes[0].ptr;
+ pkt->size = (uint64_t) surface_info.size;
+ LOGD("tbm_surface_created, pkt->size = %llu\n", pkt->size);
+ } else {
+ LOGE("tbm_surface_get_info() is failed.. err = 0x%08x \n", err);
+ tbm_surface_destroy((tbm_surface_h) pkt->surface_data);
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ LOGE("\n tbm_surface_create() is failed!! \n");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ }
+ return MEDIA_PACKET_ERROR_NONE;
}
/* TODO : contact Kim Young Hun to make below api as a common */
/* TODO : rename below macro or make it able to use original from mm_transform */
#define _ROUND_UP_16(num) (((num)+15)&~15)
#define _GEN_MASK(x) ((1<<(x))-1)
-#define _ROUND_UP_X(v,x) (((v) + _GEN_MASK(x)) & ~_GEN_MASK(x))
-#define _DIV_ROUND_UP_X(v,x) (((v) + _GEN_MASK(x)) >> (x))
+#define _ROUND_UP_X(v, x) (((v) + _GEN_MASK(x)) & ~_GEN_MASK(x))
+#define _DIV_ROUND_UP_X(v, x) (((v) + _GEN_MASK(x)) >> (x))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-static uint64_t _pkt_calculate_video_buffer_size(media_packet_s* pkt)
+static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt)
{
- unsigned char x_chroma_shift = 0;
- unsigned char y_chroma_shift = 0;
- int size, w2, h2, size2;
- int stride, stride2;
- int width = 0;
- int height = 0;
- uint64_t buffersize = 0;
-
- if (MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
- width = pkt->format->detail.video.width;
- height = pkt->format->detail.video.height;
- }
-
- /* TODO : need to check type mapping again with mm_transform */
- switch (pkt->format->mimetype)
- {
-
- case MEDIA_FORMAT_I420:
- x_chroma_shift = 1;
- y_chroma_shift = 1;
- stride = _ROUND_UP_16 (width);
- h2 = _ROUND_UP_X (height, x_chroma_shift);
- size = stride * h2;
- w2 = _DIV_ROUND_UP_X (width, x_chroma_shift);
- stride2 = _ROUND_UP_16 (w2);
- h2 = _DIV_ROUND_UP_X (height, y_chroma_shift);
- size2 = stride2 * h2;
- buffersize = size + 2 * size2;
- break;
-
- case MEDIA_FORMAT_YUYV:
- case MEDIA_FORMAT_UYVY:
- case MEDIA_FORMAT_NV16:
- stride = _ROUND_UP_16 (width * 2);
- size = stride * height;
- buffersize = size;
- break;
-
- case MEDIA_FORMAT_RGB565:
- stride = _ROUND_UP_16 (width * 2);
- size = stride * height;
- buffersize = size;
- break;
-
- case MEDIA_FORMAT_RGB888:
- stride = _ROUND_UP_16 (width * 3);
- size = stride * height;
- buffersize = size;
- break;
-
- case MEDIA_FORMAT_ARGB:
- case MEDIA_FORMAT_RGBA:
- stride = width * 4;
- size = stride * height;
- buffersize = size;
- break;
-
- case MEDIA_FORMAT_NV12:
- case MEDIA_FORMAT_NV12T:
- case MEDIA_FORMAT_H261:
- case MEDIA_FORMAT_H263:
- case MEDIA_FORMAT_H263P:
- case MEDIA_FORMAT_H264_SP:
- case MEDIA_FORMAT_H264_MP:
- case MEDIA_FORMAT_H264_HP:
- case MEDIA_FORMAT_MJPEG:
- case MEDIA_FORMAT_MPEG1:
- case MEDIA_FORMAT_MPEG2_SP:
- case MEDIA_FORMAT_MPEG2_MP:
- case MEDIA_FORMAT_MPEG2_HP:
- case MEDIA_FORMAT_MPEG4_SP:
- case MEDIA_FORMAT_MPEG4_ASP:
- x_chroma_shift = 1;
- y_chroma_shift = 1;
- stride = _ROUND_UP_16 (width);
- h2 = _ROUND_UP_X (height, y_chroma_shift);
- size = stride * h2;
- w2 = 2 * _DIV_ROUND_UP_X (width, x_chroma_shift);
- stride2 = _ROUND_UP_16 (w2);
- h2 = _DIV_ROUND_UP_X (height, y_chroma_shift);
- size2 = stride2 * h2;
- buffersize = size + size2;
- break;
- default:
- LOGE("Not supported format\n");
- return 0;
- }
-
- LOGD("format 0x%x, buffersize %llu\n", pkt->format->mimetype, buffersize);
-
- return buffersize;
+ unsigned char x_chroma_shift = 0;
+ unsigned char y_chroma_shift = 0;
+ int size, w2, h2, size2;
+ int stride, stride2;
+ int width = 0;
+ int height = 0;
+ uint64_t buffersize = 0;
+
+ if (MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
+ width = pkt->format->detail.video.width;
+ height = pkt->format->detail.video.height;
+ }
+
+ /* TODO : need to check type mapping again with mm_transform */
+ switch (pkt->format->mimetype) {
+
+ case MEDIA_FORMAT_I420:
+ x_chroma_shift = 1;
+ y_chroma_shift = 1;
+ stride = _ROUND_UP_16(width);
+ h2 = _ROUND_UP_X(height, x_chroma_shift);
+ size = stride * h2;
+ w2 = _DIV_ROUND_UP_X(width, x_chroma_shift);
+ stride2 = _ROUND_UP_16(w2);
+ h2 = _DIV_ROUND_UP_X(height, y_chroma_shift);
+ size2 = stride2 * h2;
+ buffersize = size + 2 * size2;
+ break;
+
+ case MEDIA_FORMAT_YUYV:
+ case MEDIA_FORMAT_UYVY:
+ case MEDIA_FORMAT_NV16:
+ stride = _ROUND_UP_16(width * 2);
+ size = stride * height;
+ buffersize = size;
+ break;
+
+ case MEDIA_FORMAT_RGB565:
+ stride = _ROUND_UP_16(width * 2);
+ size = stride * height;
+ buffersize = size;
+ break;
+
+ case MEDIA_FORMAT_RGB888:
+ stride = _ROUND_UP_16(width * 3);
+ size = stride * height;
+ buffersize = size;
+ break;
+
+ case MEDIA_FORMAT_ARGB:
+ case MEDIA_FORMAT_RGBA:
+ stride = width * 4;
+ size = stride * height;
+ buffersize = size;
+ break;
+
+ case MEDIA_FORMAT_NV12:
+ case MEDIA_FORMAT_NV12T:
+ case MEDIA_FORMAT_H261:
+ case MEDIA_FORMAT_H263:
+ case MEDIA_FORMAT_H263P:
+ case MEDIA_FORMAT_H264_SP:
+ case MEDIA_FORMAT_H264_MP:
+ case MEDIA_FORMAT_H264_HP:
+ case MEDIA_FORMAT_MJPEG:
+ case MEDIA_FORMAT_MPEG1:
+ case MEDIA_FORMAT_MPEG2_SP:
+ case MEDIA_FORMAT_MPEG2_MP:
+ case MEDIA_FORMAT_MPEG2_HP:
+ case MEDIA_FORMAT_MPEG4_SP:
+ case MEDIA_FORMAT_MPEG4_ASP:
+ x_chroma_shift = 1;
+ y_chroma_shift = 1;
+ stride = _ROUND_UP_16(width);
+ h2 = _ROUND_UP_X(height, y_chroma_shift);
+ size = stride * h2;
+ w2 = 2 * _DIV_ROUND_UP_X(width, x_chroma_shift);
+ stride2 = _ROUND_UP_16(w2);
+ h2 = _DIV_ROUND_UP_X(height, y_chroma_shift);
+ size2 = stride2 * h2;
+ buffersize = size + size2;
+ break;
+ default:
+ LOGE("Not supported format\n");
+ return 0;
+ }
+
+ LOGD("format 0x%x, buffersize %llu\n", pkt->format->mimetype, buffersize);
+
+ return buffersize;
}
/* TODO : written by joungkook seo for audio */
#define PCM_MIN_FRM_SIZE (1024)
#define AAC_MAX_SAMPLE_SIZE (1024)
#define MP3_MAX_SAMPLE_SIZE (1152)
-#define AMR_MAX_SAMPLE_SIZE (320) /* AMR-NB(160), WB (320) */
+#define AMR_MAX_SAMPLE_SIZE (320) /* AMR-NB(160), WB (320) */
#define OGG_MAX_SAMPLE_SIZE (2048)
-#define MPEG_MAX_FRM_SIZE (6144/4) /* 1536 */
-#define AMR_MAX_FRM_SIZE (96) /* AMR-NB(32), WB (96) */
+#define MPEG_MAX_FRM_SIZE (6144/4) /* 1536 */
+#define AMR_MAX_FRM_SIZE (96) /* AMR-NB(32), WB (96) */
#define OGG_MAX_FRM_SIZE (2048)
#define MPEG_MIN_NCH (2)
-static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s* pkt)
+static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt)
{
- int channel = 0;
- int bit = 0;
- uint64_t buffersize = 0;
-
- if (!MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
- channel = pkt->format->detail.audio.channel;
- bit = pkt->format->detail.audio.bit;
- }
-
- switch (pkt->format->mimetype)
- {
- case MEDIA_FORMAT_PCM:
- buffersize = (PCM_MAX_FRM_SIZE * channel) * (uint64_t)(bit /8);
- break;
- case MEDIA_FORMAT_AAC_LC:
- case MEDIA_FORMAT_AAC_HE:
- case MEDIA_FORMAT_AAC_HE_PS:
- case MEDIA_FORMAT_MP3:
- buffersize = (MPEG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/
- /* TODO : extenstion format */
- case MEDIA_FORMAT_AMR_NB:
- case MEDIA_FORMAT_AMR_WB:
- buffersize = (AMR_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/
- case MEDIA_FORMAT_VORBIS:
- buffersize = (OGG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/
- break;
- default:
- LOGE("Not supported format\n");
- return 0;
- }
-
- LOGD("format 0x%x, buffersize %llu\n", pkt->format->mimetype, buffersize);
-
- return buffersize;
+ int channel = 0;
+ int bit = 0;
+ uint64_t buffersize = 0;
+
+ if (!MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
+ channel = pkt->format->detail.audio.channel;
+ bit = pkt->format->detail.audio.bit;
+ }
+
+ switch (pkt->format->mimetype) {
+ case MEDIA_FORMAT_PCM:
+ buffersize = (PCM_MAX_FRM_SIZE * channel) * (uint64_t) (bit / 8);
+ break;
+ case MEDIA_FORMAT_AAC_LC:
+ case MEDIA_FORMAT_AAC_HE:
+ case MEDIA_FORMAT_AAC_HE_PS:
+ case MEDIA_FORMAT_MP3:
+ buffersize = (MPEG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2); /* 2 = (16bit/8) */
+ /* TODO : extenstion format */
+ case MEDIA_FORMAT_AMR_NB:
+ case MEDIA_FORMAT_AMR_WB:
+ buffersize = (AMR_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2); /* 2 = (16bit/8) */
+ case MEDIA_FORMAT_VORBIS:
+ buffersize = (OGG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2); /* 2 = (16bit/8) */
+ break;
+ default:
+ LOGE("Not supported format\n");
+ return 0;
+ }
+
+ LOGD("format 0x%x, buffersize %llu\n", pkt->format->mimetype, buffersize);
+
+ return buffersize;
}
-int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surface, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
+int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surface, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
-
- if (surface == NULL)
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
-
- MEDIA_PACKET_INSTANCE_CHECK(fmt);
- MEDIA_PACKET_INSTANCE_CHECK(surface);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt))
- {
- LOGE("The media format handle is not specified. set video info or audio info...");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- handle = (media_packet_s*)malloc( sizeof(media_packet_s));
- if (handle != NULL)
- {
- memset(handle, 0 , sizeof(media_packet_s));
- }
- else
- {
- LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__,MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
-
- handle->type = MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE;
- handle->surface_data = (void*)surface;
-
- /* alloc handle->format */
- handle->format = MEDIA_FORMAT_CAST(fmt);
-
- /* get tbm_surface_info */
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE)
- {
- handle->data = surface_info.planes[0].ptr;
- handle->size = (uint64_t)surface_info.size;
- }
- else
- {
- LOGE("tbm_surface_get_info() is failed.. err =0x%08x", err);
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- goto fail;
- }
-
- /* allocated buffer */
- handle->is_allocated = true;
-
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
-
- /* increase format reference count */
- ret = media_format_ref((media_format_h)handle->format);
-
- /* take handle */
- *packet = (media_packet_h)handle;
- LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
- return ret;
-
-fail:
-
- if (handle)
- {
- free(handle);
- handle = NULL;
- }
-
- *packet = NULL;
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+
+ if (surface == NULL)
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+
+ MEDIA_PACKET_INSTANCE_CHECK(fmt);
+ MEDIA_PACKET_INSTANCE_CHECK(surface);
+ MEDIA_PACKET_NULL_ARG_CHECK(packet);
+ if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
+ LOGE("The media format handle is not specified. set video info or audio info...");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+ if (handle != NULL) {
+ memset(handle, 0, sizeof(media_packet_s));
+ } else {
+ LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->type = MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE;
+ handle->surface_data = (void *)surface;
+
+ /* alloc handle->format */
+ handle->format = MEDIA_FORMAT_CAST(fmt);
+
+ /* get tbm_surface_info */
+ tbm_surface_info_s surface_info;
+ int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+ if (err == TBM_SURFACE_ERROR_NONE) {
+ handle->data = surface_info.planes[0].ptr;
+ handle->size = (uint64_t) surface_info.size;
+ } else {
+ LOGE("tbm_surface_get_info() is failed.. err =0x%08x", err);
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ goto fail;
+ }
+
+ /* allocated buffer */
+ handle->is_allocated = true;
+
+ /* set finalized callback and user data */
+ handle->finalizecb_func = fcb;
+ handle->userdata = fcb_data;
+
+ /* increase format reference count */
+ ret = media_format_ref((media_format_h) handle->format);
+
+ /* take handle */
+ *packet = (media_packet_h) handle;
+ LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
+ return ret;
+
+ fail:
+
+ if (handle) {
+ free(handle);
+ handle = NULL;
+ }
+
+ *packet = NULL;
+ return ret;
}
-int media_packet_create_from_external_memory(media_format_h fmt, void *mem_ptr, uint64_t size, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h *packet)
+int media_packet_create_from_external_memory(media_format_h fmt, void *mem_ptr, uint64_t size, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- if (mem_ptr == NULL)
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ if (mem_ptr == NULL)
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- if (!(size > 0))
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ if (!(size > 0))
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- MEDIA_PACKET_INSTANCE_CHECK(fmt);
- MEDIA_PACKET_NULL_ARG_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(fmt);
+ MEDIA_PACKET_NULL_ARG_CHECK(packet);
- if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt))
- {
- LOGE("The media format handle is not specified. set video info or audio info...");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
+ if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
+ LOGE("The media format handle is not specified. set video info or audio info...");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
- if (MEDIA_FORMAT_IS_RAW(fmt) && MEDIA_FORMAT_IS_VIDEO(fmt))
- {
- LOGE("failed!. it supports only 'MEDIA_FORMAT_ENCODED' type.");
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
+ if (MEDIA_FORMAT_IS_RAW(fmt) && MEDIA_FORMAT_IS_VIDEO(fmt)) {
+ LOGE("failed!. it supports only 'MEDIA_FORMAT_ENCODED' type.");
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
- handle = (media_packet_s*)malloc( sizeof(media_packet_s));
- if (handle != NULL)
- {
- memset(handle, 0 , sizeof(media_packet_s));
- }
- else
- {
- LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)" ,__FUNCTION__,MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
- return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
- }
+ handle = (media_packet_s *) malloc(sizeof(media_packet_s));
+ if (handle != NULL) {
+ memset(handle, 0, sizeof(media_packet_s));
+ } else {
+ LOGE("[%s] MEDIA_PACKET_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_PACKET_ERROR_OUT_OF_MEMORY);
+ return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+ }
- handle->type = MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY;
+ handle->type = MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY;
- /* alloc handle->format */
- handle->format = MEDIA_FORMAT_CAST(fmt);
+ /* alloc handle->format */
+ handle->format = MEDIA_FORMAT_CAST(fmt);
- /* set external allocated memory & external memory size */
- handle->size = size;
- handle->data = mem_ptr;
+ /* set external allocated memory & external memory size */
+ handle->size = size;
+ handle->data = mem_ptr;
- /* allocated buffer */
- handle->is_allocated = true;
+ /* allocated buffer */
+ handle->is_allocated = true;
- /* set finalized callback and user data */
- handle->finalizecb_func = fcb;
- handle->userdata = fcb_data;
+ /* set finalized callback and user data */
+ handle->finalizecb_func = fcb;
+ handle->userdata = fcb_data;
- /* increase format reference count */
- ret = media_format_ref((media_format_h)handle->format);
+ /* increase format reference count */
+ ret = media_format_ref((media_format_h) handle->format);
- /* take handle */
- *packet = (media_packet_h)handle;
- LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
+ /* take handle */
+ *packet = (media_packet_h) handle;
+ LOGI("[%s] new handle : %p", __FUNCTION__, *packet);
- return ret;
+ return ret;
}
int media_packet_get_buffer_data_ptr(media_packet_h packet, void **data)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(data);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(data);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *data = handle->data;
+ *data = handle->data;
- return ret;
+ return ret;
}
-int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h *surface)
+int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h * surface)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(surface);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(surface);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *surface = (tbm_surface_h)handle->surface_data;
+ *surface = (tbm_surface_h) handle->surface_data;
- return ret;
+ return ret;
}
-int media_packet_get_format(media_packet_h packet, media_format_h *fmt)
+int media_packet_get_format(media_packet_h packet, media_format_h * fmt)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(fmt);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(fmt);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- /* ref exist format */
- media_format_ref((media_format_h)handle->format);
+ /* ref exist format */
+ media_format_ref((media_format_h) handle->format);
- *fmt = (media_format_h)handle->format;
+ *fmt = (media_format_h) handle->format;
- return ret;
+ return ret;
}
int media_packet_set_format(media_packet_h packet, media_format_h fmt)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(fmt);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(fmt);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- /* if trying to set same format, return*/
- if (handle->format == MEDIA_FORMAT_CAST(fmt))
- {
- LOGE("The packet handle already refers the format handle..\n");
- return MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
+ /* if trying to set same format, return */
+ if (handle->format == MEDIA_FORMAT_CAST(fmt)) {
+ LOGE("The packet handle already refers the format handle..\n");
+ return MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
- /* unref exist format */
- media_format_unref((media_format_h)handle->format);
+ /* unref exist format */
+ media_format_unref((media_format_h) handle->format);
- /* set as new format to packet */
- handle->format = MEDIA_FORMAT_CAST(fmt);
+ /* set as new format to packet */
+ handle->format = MEDIA_FORMAT_CAST(fmt);
- /* ref new format */
- media_format_ref(fmt);
+ /* ref new format */
+ media_format_ref(fmt);
- return ret;
+ return ret;
}
int media_packet_set_pts(media_packet_h packet, uint64_t pts)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->pts = pts;
+ handle->pts = pts;
- return ret;
+ return ret;
}
int media_packet_set_dts(media_packet_h packet, uint64_t dts)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->dts = dts;
+ handle->dts = dts;
- return ret;
+ return ret;
}
int media_packet_set_duration(media_packet_h packet, uint64_t duration)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->duration = duration;
+ handle->duration = duration;
- return ret;
+ return ret;
}
int media_packet_set_buffer_size(media_packet_h packet, uint64_t size)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->size = size;
+ handle->size = size;
- return ret;
+ return ret;
}
-int media_packet_get_pts(media_packet_h packet, uint64_t *pts)
+int media_packet_get_pts(media_packet_h packet, uint64_t * pts)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(pts);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(pts);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *pts = handle->pts;
+ *pts = handle->pts;
- return ret;
+ return ret;
}
-int media_packet_get_dts(media_packet_h packet, uint64_t *dts)
+int media_packet_get_dts(media_packet_h packet, uint64_t * dts)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(dts);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(dts);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *dts = handle->dts;
+ *dts = handle->dts;
- return ret;
+ return ret;
}
-int media_packet_get_duration(media_packet_h packet, uint64_t *duration)
+int media_packet_get_duration(media_packet_h packet, uint64_t * duration)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(duration);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(duration);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *duration = handle->duration;
+ *duration = handle->duration;
- return ret;
+ return ret;
}
-int media_packet_get_buffer_size(media_packet_h packet, uint64_t *size)
+int media_packet_get_buffer_size(media_packet_h packet, uint64_t * size)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(size);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(size);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *size = handle->size;
+ *size = handle->size;
- return ret;
+ return ret;
}
int media_packet_set_extra(media_packet_h packet, void *extra)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(extra);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(extra);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->extradata = extra;
+ handle->extradata = extra;
- return ret;
+ return ret;
}
int media_packet_get_extra(media_packet_h packet, void **extra)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(extra);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(extra);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *extra = handle->extradata;
+ *extra = handle->extradata;
- return ret;
+ return ret;
}
-int media_packet_is_video(media_packet_h packet, bool *is_video)
+int media_packet_is_video(media_packet_h packet, bool * is_video)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_video);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_video);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_FORMAT_IS_VIDEO(handle->format))
- *is_video = true;
- else
- *is_video = false;
+ if (MEDIA_FORMAT_IS_VIDEO(handle->format))
+ *is_video = true;
+ else
+ *is_video = false;
- return ret;
+ return ret;
}
-int media_packet_is_audio(media_packet_h packet, bool *is_audio)
+int media_packet_is_audio(media_packet_h packet, bool * is_audio)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_audio);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_audio);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_FORMAT_IS_AUDIO(handle->format))
- *is_audio = true;
- else
- *is_audio = false;
+ if (MEDIA_FORMAT_IS_AUDIO(handle->format))
+ *is_audio = true;
+ else
+ *is_audio = false;
- return ret;
+ return ret;
}
-int media_packet_is_encoded(media_packet_h packet, bool *is_encoded)
+int media_packet_is_encoded(media_packet_h packet, bool * is_encoded)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_encoded);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_encoded);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_FORMAT_IS_ENCODED(handle->format))
- *is_encoded = true;
- else
- *is_encoded = false;
+ if (MEDIA_FORMAT_IS_ENCODED(handle->format))
+ *is_encoded = true;
+ else
+ *is_encoded = false;
- return ret;
+ return ret;
}
-int media_packet_is_raw(media_packet_h packet, bool *is_raw)
+int media_packet_is_raw(media_packet_h packet, bool * is_raw)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_raw);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_raw);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_FORMAT_IS_RAW(handle->format))
- *is_raw = true;
- else
- *is_raw = false;
+ if (MEDIA_FORMAT_IS_RAW(handle->format))
+ *is_raw = true;
+ else
+ *is_raw = false;
- return ret;
+ return ret;
}
-int media_packet_get_flags(media_packet_h packet, media_buffer_flags_e *flags)
+int media_packet_get_flags(media_packet_h packet, media_buffer_flags_e * flags)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(flags);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(flags);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- *flags = handle->flags;
+ *flags = handle->flags;
- return ret;
+ return ret;
}
int media_packet_set_flags(media_packet_h packet, media_buffer_flags_e flags)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->flags |= flags;
+ handle->flags |= flags;
- return ret;
+ return ret;
}
int media_packet_unset_flags(media_packet_h packet, media_buffer_flags_e flags)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- handle->flags &= ~flags;
+ handle->flags &= ~flags;
- return ret;
+ return ret;
}
-int media_packet_is_codec_config(media_packet_h packet, bool *is_codec_config)
+int media_packet_is_codec_config(media_packet_h packet, bool * is_codec_config)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_codec_config);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_codec_config);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_PACKET_CODEC_CONFIG_DATA(packet))
- *is_codec_config = true;
- else
- *is_codec_config = false;
+ if (MEDIA_PACKET_CODEC_CONFIG_DATA(packet))
+ *is_codec_config = true;
+ else
+ *is_codec_config = false;
- return ret;
+ return ret;
}
-int media_packet_is_end_of_stream(media_packet_h packet, bool *is_eos)
+int media_packet_is_end_of_stream(media_packet_h packet, bool * is_eos)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_eos);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_eos);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_PACKET_CODEC_END_OF_STREAM(packet))
- *is_eos = true;
- else
- *is_eos = false;
+ if (MEDIA_PACKET_CODEC_END_OF_STREAM(packet))
+ *is_eos = true;
+ else
+ *is_eos = false;
- return ret;
+ return ret;
}
-int media_packet_is_sync_frame(media_packet_h packet, bool *is_sync)
+int media_packet_is_sync_frame(media_packet_h packet, bool * is_sync)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(is_sync);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(is_sync);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- if (MEDIA_PACKET_CODEC_SYNC_FRAME(packet))
- *is_sync = true;
- else
- *is_sync = false;
+ if (MEDIA_PACKET_CODEC_SYNC_FRAME(packet))
+ *is_sync = true;
+ else
+ *is_sync = false;
- return ret;
+ return ret;
}
-int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool* has_tbm_surface)
+int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool * has_tbm_surface)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(has_tbm_surface);
-
- handle = (media_packet_s*) packet;
-
- if ((handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE) && handle->surface_data)
- {
- *has_tbm_surface = true;
- }
- else
- {
- *has_tbm_surface = false;
- }
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(has_tbm_surface);
+
+ handle = (media_packet_s *) packet;
+
+ if ((handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE) && handle->surface_data) {
+ *has_tbm_surface = true;
+ } else {
+ *has_tbm_surface = false;
+ }
+ return ret;
}
-int media_packet_get_number_of_video_planes(media_packet_h packet, uint32_t* num)
+int media_packet_get_number_of_video_planes(media_packet_h packet, uint32_t * num)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
- bool has_tbm;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(num);
-
- handle = (media_packet_s*) packet;
-
- media_packet_has_tbm_surface_buffer(packet, &has_tbm);
-
- if (has_tbm)
- {
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE)
- {
- *num = surface_info.num_planes;
- LOGD(" surface_info the number of planes = %d\n", (int)surface_info.num_planes);
- }
- else
- {
- *num = 0;
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- }
- else
- {
- *num = 0;
- LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
-
- }
-
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+ bool has_tbm;
+
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(num);
+
+ handle = (media_packet_s *) packet;
+
+ media_packet_has_tbm_surface_buffer(packet, &has_tbm);
+
+ if (has_tbm) {
+ tbm_surface_info_s surface_info;
+ int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+ if (err == TBM_SURFACE_ERROR_NONE) {
+ *num = surface_info.num_planes;
+ LOGD(" surface_info the number of planes = %d\n", (int)surface_info.num_planes);
+ } else {
+ *num = 0;
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ *num = 0;
+ LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+
+ }
+
+ return ret;
}
int media_packet_get_video_stride_width(media_packet_h packet, int plane_idx, int *stride_width)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
- bool has_tbm;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(stride_width);
- if (plane_idx < 0)
- {
- LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
-
- handle = (media_packet_s*) packet;
-
- media_packet_has_tbm_surface_buffer(packet, &has_tbm);
-
- if (has_tbm)
- {
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE)
- {
-
- if (surface_info.num_planes > plane_idx)
- {
- *stride_width = surface_info.planes[plane_idx].stride;
- }
- else
- {
- LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
- *stride_width = 0;
- ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- *stride_width = 0;
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- }
- else
- {
- LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
- *stride_width = 0;
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+ bool has_tbm;
+
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(stride_width);
+ if (plane_idx < 0) {
+ LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = (media_packet_s *) packet;
+
+ media_packet_has_tbm_surface_buffer(packet, &has_tbm);
+
+ if (has_tbm) {
+ tbm_surface_info_s surface_info;
+ int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+ if (err == TBM_SURFACE_ERROR_NONE) {
+
+ if (surface_info.num_planes > plane_idx) {
+ *stride_width = surface_info.planes[plane_idx].stride;
+ } else {
+ LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
+ *stride_width = 0;
+ ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ *stride_width = 0;
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
+ *stride_width = 0;
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ return ret;
}
int media_packet_get_video_stride_height(media_packet_h packet, int plane_idx, int *stride_height)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
- bool has_tbm;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(stride_height);
- if (plane_idx < 0)
- {
- LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
-
-
- handle = (media_packet_s*) packet;
-
- media_packet_has_tbm_surface_buffer(packet, &has_tbm);
-
- if (has_tbm)
- {
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE)
- {
- if (surface_info.num_planes > plane_idx)
- {
- *stride_height = surface_info.planes[plane_idx].size/surface_info.planes[plane_idx].stride;
- }
- else
- {
- LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
- *stride_height = 0;
- ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- *stride_height = 0;
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- }
- else
- {
- LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
- *stride_height = 0;
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+ bool has_tbm;
+
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(stride_height);
+ if (plane_idx < 0) {
+ LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = (media_packet_s *) packet;
+
+ media_packet_has_tbm_surface_buffer(packet, &has_tbm);
+
+ if (has_tbm) {
+ tbm_surface_info_s surface_info;
+ int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+ if (err == TBM_SURFACE_ERROR_NONE) {
+ if (surface_info.num_planes > plane_idx) {
+ *stride_height = surface_info.planes[plane_idx].size / surface_info.planes[plane_idx].stride;
+ } else {
+ LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
+ *stride_height = 0;
+ ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ *stride_height = 0;
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ LOGE("The packet handle doesn't have tbm_surface buffer type...\n");
+ *stride_height = 0;
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ return ret;
}
int media_packet_get_video_plane_data_ptr(media_packet_h packet, int plane_idx, void **plane_data_ptr)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
- bool has_tbm;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(plane_data_ptr);
- if (plane_idx < 0)
- {
- LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
- return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
-
- handle = (media_packet_s*) packet;
-
- media_packet_has_tbm_surface_buffer(packet, &has_tbm);
-
- if (has_tbm)
- {
- tbm_surface_info_s surface_info;
- int err = tbm_surface_get_info((tbm_surface_h)handle->surface_data, &surface_info);
- if (err == TBM_SURFACE_ERROR_NONE)
- {
- if (surface_info.num_planes > plane_idx)
- {
- *plane_data_ptr = surface_info.planes[plane_idx].ptr;
- LOGD("the tbm_surface_info.planes[%d].ptr = %p\n", plane_idx, surface_info.planes[plane_idx].ptr);
- }
- else
- {
- LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
- *plane_data_ptr = NULL;
- ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
- *plane_data_ptr = NULL;
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
- }
- else
- {
- LOGI("The packet handle doesn't have tbm_surface buffer type...\n");
- *plane_data_ptr = NULL;
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
-
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+ bool has_tbm;
+
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(plane_data_ptr);
+ if (plane_idx < 0) {
+ LOGE("Invalid plane_idx : %d, must not be negative number\n", plane_idx);
+ return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = (media_packet_s *) packet;
+
+ media_packet_has_tbm_surface_buffer(packet, &has_tbm);
+
+ if (has_tbm) {
+ tbm_surface_info_s surface_info;
+ int err = tbm_surface_get_info((tbm_surface_h) handle->surface_data, &surface_info);
+ if (err == TBM_SURFACE_ERROR_NONE) {
+ if (surface_info.num_planes > plane_idx) {
+ *plane_data_ptr = surface_info.planes[plane_idx].ptr;
+ LOGD("the tbm_surface_info.planes[%d].ptr = %p\n", plane_idx, surface_info.planes[plane_idx].ptr);
+ } else {
+ LOGE("the plane_idx is invalid, The number of planes = %lu\n", surface_info.num_planes);
+ *plane_data_ptr = NULL;
+ ret = MEDIA_PACKET_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ LOGE("tbm_surface_get_info() is failed.. 0x%08x \n", err);
+ *plane_data_ptr = NULL;
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+ } else {
+ LOGI("The packet handle doesn't have tbm_surface buffer type...\n");
+ *plane_data_ptr = NULL;
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
+
+ return ret;
}
-int media_packet_get_codec_data(media_packet_h packet, void** codec_data, unsigned int* codec_data_size)
+int media_packet_get_codec_data(media_packet_h packet, void **codec_data, unsigned int *codec_data_size)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
- MEDIA_PACKET_INSTANCE_CHECK(packet);
- MEDIA_PACKET_NULL_ARG_CHECK(codec_data);
- MEDIA_PACKET_NULL_ARG_CHECK(codec_data_size);
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+ MEDIA_PACKET_NULL_ARG_CHECK(codec_data);
+ MEDIA_PACKET_NULL_ARG_CHECK(codec_data_size);
- handle = (media_packet_s*) packet;
+ handle = (media_packet_s *) packet;
- LOGI("Get: codec data = %p, codec_data_size = %u\n", handle->codec_data, handle->codec_data_size);
+ LOGI("Get: codec data = %p, codec_data_size = %u\n", handle->codec_data, handle->codec_data_size);
- if (handle->codec_data)
- {
- *codec_data_size = handle->codec_data_size;
- *codec_data = handle->codec_data;
- }
- else
- {
- *codec_data = NULL;
- *codec_data_size = 0;
+ if (handle->codec_data) {
+ *codec_data_size = handle->codec_data_size;
+ *codec_data = handle->codec_data;
+ } else {
+ *codec_data = NULL;
+ *codec_data_size = 0;
- LOGE("There is no codec data..\n");
- ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
- }
+ LOGE("There is no codec data..\n");
+ ret = MEDIA_PACKET_ERROR_INVALID_OPERATION;
+ }
- return ret;
+ return ret;
}
int media_packet_destroy(media_packet_h packet)
{
- media_packet_s* handle;
- int ret = MEDIA_PACKET_ERROR_NONE;
-
- MEDIA_PACKET_INSTANCE_CHECK(packet);
-
- handle = (media_packet_s*) packet;
-
- /* finailize callback */
- if (handle->finalizecb_func)
- {
- int finalize_cb_ret;
- finalize_cb_ret = handle->finalizecb_func((media_packet_h)handle, MEDIA_PACKET_ERROR_NONE, handle->userdata);
-
- /* creator do not want to destroy media packet handle*/
- if(finalize_cb_ret == MEDIA_PACKET_REUSE)
- {
- LOGI("the media packet handle will be reused.");
- return MEDIA_PACKET_ERROR_NONE;
- }
- }
-
- if(handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE)
- {
- if(handle->surface_data)
- {
- tbm_surface_destroy((tbm_surface_h)handle->surface_data);
- }
- }
- else if (handle->type == MEDIA_BUFFER_TYPE_NORMAL)
- {
- if(handle->data)
- {
- _aligned_free_normal_buffer_type(handle->data);
- handle->data = NULL;
- }
- }
- else if (handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY)
- {
- // there is nothing to do, Do not free the buffer which is created by external module.
- }
-
- /* free codec_data if it is allocated */
- if (handle->codec_data)
- {
- free(handle->codec_data);
- handle->codec_data = NULL;
- handle->codec_data_size = 0;
- }
-
- /* unreference media_format */
- media_format_unref(handle->format);
-
- LOGI("The packet handle(%p) is will be destroyed..\n", handle);
-
- free(handle);
- handle = NULL;
-
- return ret;
+ media_packet_s *handle;
+ int ret = MEDIA_PACKET_ERROR_NONE;
+
+ MEDIA_PACKET_INSTANCE_CHECK(packet);
+
+ handle = (media_packet_s *) packet;
+
+ /* finailize callback */
+ if (handle->finalizecb_func) {
+ int finalize_cb_ret;
+ finalize_cb_ret = handle->finalizecb_func((media_packet_h) handle, MEDIA_PACKET_ERROR_NONE, handle->userdata);
+
+ /* creator do not want to destroy media packet handle */
+ if (finalize_cb_ret == MEDIA_PACKET_REUSE) {
+ LOGI("the media packet handle will be reused.");
+ return MEDIA_PACKET_ERROR_NONE;
+ }
+ }
+
+ if (handle->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
+ if (handle->surface_data) {
+ tbm_surface_destroy((tbm_surface_h) handle->surface_data);
+ }
+ } else if (handle->type == MEDIA_BUFFER_TYPE_NORMAL) {
+ if (handle->data) {
+ _aligned_free_normal_buffer_type(handle->data);
+ handle->data = NULL;
+ }
+ } else if (handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY) {
+ // there is nothing to do, Do not free the buffer which is created by external module.
+ }
+
+ /* free codec_data if it is allocated */
+ if (handle->codec_data) {
+ free(handle->codec_data);
+ handle->codec_data = NULL;
+ handle->codec_data_size = 0;
+ }
+
+ /* unreference media_format */
+ media_format_unref(handle->format);
+
+ LOGI("The packet handle(%p) is will be destroyed..\n", handle);
+
+ free(handle);
+ handle = NULL;
+
+ return ret;
}
static uint32_t _convert_to_tbm_surface_format(media_format_mimetype_e format_type)
{
- uint32_t tbm_format;
-
- switch(format_type) {
- case MEDIA_FORMAT_NV12:
- case MEDIA_FORMAT_NV12T:
- tbm_format = TBM_FORMAT_NV12;
- break;
- case MEDIA_FORMAT_NV16:
- tbm_format = TBM_FORMAT_NV16;
- break;
- case MEDIA_FORMAT_NV21:
- tbm_format = TBM_FORMAT_NV21;
- break;
- case MEDIA_FORMAT_YUYV:
- tbm_format = TBM_FORMAT_YUYV;
- break;
- case MEDIA_FORMAT_UYVY:
- tbm_format = TBM_FORMAT_UYVY;
- break;
- case MEDIA_FORMAT_422P:
- tbm_format = TBM_FORMAT_YUV422;
- break;
- case MEDIA_FORMAT_I420:
- tbm_format = TBM_FORMAT_YUV420;
- break;
- case MEDIA_FORMAT_YV12:
- tbm_format = TBM_FORMAT_YVU420;
- break;
- case MEDIA_FORMAT_RGB565:
- tbm_format = TBM_FORMAT_RGB565;
- break;
- case MEDIA_FORMAT_RGB888:
- tbm_format = TBM_FORMAT_RGB888;
- break;
- case MEDIA_FORMAT_RGBA:
- tbm_format = TBM_FORMAT_RGBA8888;
- break;
- case MEDIA_FORMAT_ARGB:
- tbm_format = TBM_FORMAT_ARGB8888;
- break;
- default:
- LOGE("Invalid format mime type!");
- tbm_format = 0;
- break;
- }
-
- return tbm_format;
+ uint32_t tbm_format;
+
+ switch (format_type) {
+ case MEDIA_FORMAT_NV12:
+ case MEDIA_FORMAT_NV12T:
+ tbm_format = TBM_FORMAT_NV12;
+ break;
+ case MEDIA_FORMAT_NV16:
+ tbm_format = TBM_FORMAT_NV16;
+ break;
+ case MEDIA_FORMAT_NV21:
+ tbm_format = TBM_FORMAT_NV21;
+ break;
+ case MEDIA_FORMAT_YUYV:
+ tbm_format = TBM_FORMAT_YUYV;
+ break;
+ case MEDIA_FORMAT_UYVY:
+ tbm_format = TBM_FORMAT_UYVY;
+ break;
+ case MEDIA_FORMAT_422P:
+ tbm_format = TBM_FORMAT_YUV422;
+ break;
+ case MEDIA_FORMAT_I420:
+ tbm_format = TBM_FORMAT_YUV420;
+ break;
+ case MEDIA_FORMAT_YV12:
+ tbm_format = TBM_FORMAT_YVU420;
+ break;
+ case MEDIA_FORMAT_RGB565:
+ tbm_format = TBM_FORMAT_RGB565;
+ break;
+ case MEDIA_FORMAT_RGB888:
+ tbm_format = TBM_FORMAT_RGB888;
+ break;
+ case MEDIA_FORMAT_RGBA:
+ tbm_format = TBM_FORMAT_RGBA8888;
+ break;
+ case MEDIA_FORMAT_ARGB:
+ tbm_format = TBM_FORMAT_ARGB8888;
+ break;
+ default:
+ LOGE("Invalid format mime type!");
+ tbm_format = 0;
+ break;
+ }
+
+ return tbm_format;
}
-
-static void* _aligned_malloc_normal_buffer_type (uint64_t size, int alignment)
+static void *_aligned_malloc_normal_buffer_type(uint64_t size, int alignment)
{
- unsigned char* buffer_ptr;
- unsigned char* temp_ptr;
+ unsigned char *buffer_ptr;
+ unsigned char *temp_ptr;
- if((temp_ptr = (unsigned char*)malloc(size + alignment)) != NULL)
- {
- buffer_ptr = (unsigned char*)((unsigned long int)(temp_ptr + alignment - 1) & (~(unsigned long int)(alignment -1)));
+ if ((temp_ptr = (unsigned char *)malloc(size + alignment)) != NULL) {
+ buffer_ptr = (unsigned char *)((unsigned long int)(temp_ptr + alignment - 1) & (~(unsigned long int)(alignment - 1)));
- if(buffer_ptr == temp_ptr)
- {
- buffer_ptr += alignment;
- }
+ if (buffer_ptr == temp_ptr) {
+ buffer_ptr += alignment;
+ }
- *(buffer_ptr - 1) = (unsigned char)(buffer_ptr - temp_ptr);
- return (void*)buffer_ptr;
- }
+ *(buffer_ptr - 1) = (unsigned char)(buffer_ptr - temp_ptr);
+ return (void *)buffer_ptr;
+ }
- return NULL;
+ return NULL;
}
-static void _aligned_free_normal_buffer_type (void* buffer_ptr)
+static void _aligned_free_normal_buffer_type(void *buffer_ptr)
{
- unsigned char* ptr;
- if (buffer_ptr == NULL)
- return;
+ unsigned char *ptr;
+ if (buffer_ptr == NULL)
+ return;
- ptr = (unsigned char*)buffer_ptr;
+ ptr = (unsigned char *)buffer_ptr;
- // *(ptr - 1) holds the offset to the real allocated block
- // we sub that offset os we free the real pointer
- ptr -= *(ptr - 1);
+ // *(ptr - 1) holds the offset to the real allocated block
+ // we sub that offset os we free the real pointer
+ ptr -= *(ptr - 1);
- // Free the memory
- free(ptr);
- ptr = NULL;
+ // Free the memory
+ free(ptr);
+ ptr = NULL;
}
-