diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 16:22:27 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-10-24 16:22:27 +0900 |
commit | 484b0e67b12324b0b1257ea5ec3fb00bfd50b2c0 (patch) | |
tree | 084cdd97ef3c897de811377de00a7868af58fde0 | |
parent | f412b83af8df235cee2d5dec9c34f96e0719e4bb (diff) | |
download | capi-media-tool-tizen_2.4.tar.gz capi-media-tool-tizen_2.4.tar.bz2 capi-media-tool-tizen_2.4.zip |
tizen 2.4 releasetizen_2.4_mobile_releasesubmit/tizen_2.4/20151028.063521accepted/tizen/2.4/mobile/20151029.034910tizen_2.4accepted/tizen_2.4_mobile
-rwxr-xr-x | CMakeLists.txt | 2 | ||||
-rwxr-xr-x | include/media_format.h | 217 | ||||
-rwxr-xr-x | include/media_format_private.h | 25 | ||||
-rwxr-xr-x | include/media_packet.h | 288 | ||||
-rwxr-xr-x | include/media_packet_internal.h | 63 | ||||
-rwxr-xr-x | include/media_packet_private.h | 25 | ||||
-rwxr-xr-x | packaging/capi-media-tool.spec | 5 | ||||
-rwxr-xr-x | src/media_format.c | 46 | ||||
-rwxr-xr-x | src/media_packet.c | 536 | ||||
-rwxr-xr-x | src/media_packet_internal.c | 55 | ||||
-rwxr-xr-x | test/media_packet_test.c | 175 |
11 files changed, 1120 insertions, 317 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e75836..05117a0 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -w") +SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -w -Werror -Wcast-qual -Wextra -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") diff --git a/include/media_format.h b/include/media_format.h index 53d4d82..617061e 100755 --- a/include/media_format.h +++ b/include/media_format.h @@ -19,6 +19,7 @@ #include <stdbool.h> #include <stdint.h> +#include <tizen.h> #ifdef __cplusplus extern "C" { @@ -36,14 +37,14 @@ extern "C" { /** * @brief Media Format handle type. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef struct media_format_s* media_format_h; /** * @brief Enumerations of media format error - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef enum { @@ -57,7 +58,7 @@ typedef enum /** * @brief Enumeration for media format type. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef enum { MEDIA_FORMAT_NONE = 0x00000000, /**< media format type is NONE */ @@ -69,7 +70,7 @@ typedef enum { /** * @brief Enumeration for media format data type. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef enum { MEDIA_FORMAT_ENCODED = 0x10000000, /**< media format data type is encoded type */ @@ -78,7 +79,7 @@ typedef enum { /** * @brief Enumeration for media format MIME type. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ /* TODO : More an more audio/video types are needed !!!! */ @@ -87,53 +88,70 @@ typedef enum { */ typedef enum { /* Audio */ - MEDIA_FORMAT_L16 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1010), /**< media format mime type is L16, 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 */ + MEDIA_FORMAT_AMR = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1040), /**< media format mime type is AMR, AUDIO, indicates MEDIA_FORMAT_AMR_NB (Since tizen 2.4) */ + MEDIA_FORMAT_AMR_NB = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1040), /**< media format mime type is AMR_NB, AUDIO , (Since tizen 2.4) */ + MEDIA_FORMAT_AMR_WB = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1041), /**< media format mime type is AMR_WB, AUDIO, (Since tizen 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*/ - MEDIA_FORMAT_MP3 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1070), /**< media format mime type is MP3, AUDIO*/ - - 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 */ + MEDIA_FORMAT_AAC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1060), /**< media format mime type is AAC, AUDIO, indicates MEDIA_FORMAT_AAC_LC (Since tizen 2.4) */ + MEDIA_FORMAT_AAC_LC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1060), /**< media format mime type is AAC_LC, AUDIO, (Since tizen 2.4) */ + MEDIA_FORMAT_AAC_HE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1061), /**< media format mime type is AAC_HE, AUDIO, (Since tizen 2.4) */ + MEDIA_FORMAT_AAC_HE_PS = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1062), /**< media format mime type is AAC_HE_PS, AUDIO, (Since tizen 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 tizen 2.4) */ + MEDIA_FORMAT_FLAC = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x1090), /**< media format mime type is FLAC, AUDIO, (Since tizen 2.4) */ + MEDIA_FORMAT_WMAV1 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A0), /**< media format mime type is WMAV1, AUDIO, (Since tizen 2.4) */ + MEDIA_FORMAT_WMAV2 = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A1), /**< media format mime type is WMAV2, AUDIO, (Since tizen 2.4) */ + MEDIA_FORMAT_WMAPRO = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A2), /**< media format mime type is WMAVPRO, AUDIO, (Since tizen 2.4) */ + MEDIA_FORMAT_WMALSL = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A3), /**< media format mime type is WMAVLSL, AUDIO, (Since tizen 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_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 */ + 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 tizen 2.4) */ + MEDIA_FORMAT_VP8 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2090), /**< media format mime type is VP8, VIDEO, (Since tizen 2.4) */ + MEDIA_FORMAT_VP9 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20A0), /**< media format mime type is VP9, VIDEO, (Since tizen 2.4) */ + MEDIA_FORMAT_VC1 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20B0), /**< media format mime type is VC1, VIDEO, (Since tizen 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 */ + + MEDIA_FORMAT_NATIVE_VIDEO = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x3000), /**< media format mime type is HW dependent , VIDEO, (Since tizen 2.4) */ MEDIA_FORMAT_MAX /**< media format mime type is MEDIA_FORMAT_MAX, Do not use */ } media_format_mimetype_e; /** * @brief Enumeration for media color model. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef enum { MEDIA_COLOR_MODEL_NONE, /**< media format color model is NONE */ @@ -144,10 +162,13 @@ typedef enum { /** * @brief Creates a media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details It creates media format. and reference count will be set to 1 For destroying media_format_h handle, use media_format_unref() * @param[out] fmt allocated media_format_h + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory @@ -159,7 +180,7 @@ int media_format_create(media_format_h* fmt); /** * @brief Gets video information of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details returns mimetype, width, height, average bps, max bps of this media format * @param[in] fmt media_format_h to get video information * @param[out] mimetype media_format_mimetype_e , ex) MEDIA_FORMAT_H264_HP @@ -167,6 +188,9 @@ int media_format_create(media_format_h* fmt); * @param[out] height height of the video * @param[out] avg_bps average bps of the video * @param[out] max_bps max bps of the video + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -180,7 +204,7 @@ int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e* mim /** * @brief Gets audio information of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details returns mimetype, channels, height, samplerate bps, max bps of this media format * @param[in] fmt media_format_h to get audio information * @param[out] mimetype media_format_mimetype_e , ex) MEDIA_FORMAT_PCM @@ -188,6 +212,9 @@ int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e* mim * @param[out] samplerate sampling rate of the audio * @param[out] bit bit resolution of the audio * @param[out] avg_bps average bps of the audio + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -200,11 +227,29 @@ int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e* mim 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 + * @since_tizen 2.4 + * @param[in] fmt media_format_h to get audio information + * @param[out] is_adts aac adts flag of the audio + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_FORMAT_ERROR_NONE Successful + * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter + * @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); + +/** * @brief Sets video MIME type of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets MIME type * @param[in] fmt media_format_h to set * @param[in] mimetype media_format_mimetype_e , ex) MEDIA_FORMAT_H264_HP + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -214,11 +259,14 @@ int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mime /** * @brief Sets video width of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets video width * @param[in] fmt media_format_h to set * @param[in] width width of the video * @pre must set video MIME type by media_format_set_video_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -229,11 +277,14 @@ int media_format_set_video_width(media_format_h fmt, int width); /** * @brief Sets video height of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets video height * @param[in] fmt media_format_h to set * @param[in] height height of the video * @pre must set video MIME type by media_format_set_video_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -243,11 +294,14 @@ int media_format_set_video_height(media_format_h fmt, int height); /** * @brief Sets video avg_bps of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets avg_bps * @param[in] fmt media_format_h to set * @param[in] avg_bps average bps of the video * @pre must set video MIME type by media_format_set_video_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -257,11 +311,14 @@ int media_format_set_video_avg_bps(media_format_h fmt, int avg_bps); /** * @brief Sets video max_bps of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets max_bps * @param[in] fmt media_format_h to set * @param[in] max_bps max bps of the video * @pre must set video MIME type by media_format_set_video_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -271,10 +328,13 @@ int media_format_set_video_max_bps(media_format_h fmt, int max_bps); /** * @brief Sets audio MIME type of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets MIME type * @param[in] fmt media_format_h to set audio information * @param[in] mimetype media_format_mimetype_e , ex) MEDIA_FORMAT_PCM + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -284,11 +344,14 @@ int media_format_set_audio_mime(media_format_h fmt, media_format_mimetype_e mime /** * @brief Sets audio channel of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets audio channel * @param[in] fmt media_format_h to set audio information * @param[in] channel channel of the audio * @pre must set audio MIME type by media_format_set_audio_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -298,11 +361,14 @@ int media_format_set_audio_channel(media_format_h fmt, int channel); /** * @brief Sets audio samplerate of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets audio samplerate of this media format * @param[in] fmt media_format_h to set * @param[in] samplerate sampling rate of the audio * @pre must set audio MIME type by media_format_set_audio_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -312,11 +378,14 @@ int media_format_set_audio_samplerate(media_format_h fmt, int samplerate); /** * @brief Sets audio bit of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets audio bit resolution of this media format * @param[in] fmt media_format_h to set * @param[in] bit bit of the audio * @pre must set audio MIME type by media_format_set_audio_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -326,11 +395,14 @@ int media_format_set_audio_bit(media_format_h fmt, int bit); /** * @brief Sets audio avg_bps of media format - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Sets audio avg_bps of this media format * @param[in] fmt media_format_h to set * @param[in] avg_bps avg_bps of the audio * @pre must set audio MIME type by media_format_set_audio_mime() + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation @@ -338,11 +410,31 @@ int media_format_set_audio_bit(media_format_h fmt, int bit); */ int media_format_set_audio_avg_bps(media_format_h fmt, int avg_bps); + /** + * @brief Sets audio aac type of media format + * @since_tizen 2.4 + * @details Sets audio aac data type of this media format + * @param[in] fmt media_format_h to set + * @param[in] is_adts aac adts flag of the audio + * @pre must set audio MIME type by media_format_set_audio_mime() + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_FORMAT_ERROR_NONE Successful + * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_FORMAT_ERROR_INVALID_OPERATION Invalid operation + * @see media_format_get_audio_aac_type() + */ +int media_format_set_audio_aac_type(media_format_h fmt, bool is_adts); + /** * @brief Increase reference count of media_format_h object - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details increase ref_count of media_format_h * @param[in] fmt exist media_format_h + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory @@ -353,9 +445,12 @@ int media_format_ref(media_format_h fmt); /** * @brief Decrease reference count of media_format_h object - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details decrease ref_count of media_format_h * @param[in] fmt exist media_format_h + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory @@ -366,10 +461,13 @@ int media_format_unref(media_format_h fmt); /** * @brief Check whether the media_format_h is writable or not. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details Check the number of media_format's ref_count * @param[in] fmt exist media_format_h * @param[out] is_writable if ref_count is 1, return true. if not, return false + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory @@ -379,15 +477,18 @@ int media_format_is_writable(media_format_h fmt, bool* is_writable); /** * @brief Returns a writable copy of media_format_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @details If there is only one reference count on fmt, the caller must be the owner, * and so this function will return the object unchanged. * while, if there is more than one reference count on the object, a new object will be returned. * The caller will own a reference to the returned object. * In a nutshell, this function unrefs the fmt and refs the out_fmt returned. * Don't access fmt after calling this function. - * @param[in] fmt exist media_format_h , don't access it after calling this function. - * @param[out] out_fmt new copied media_format_h, the caller is owner of this object. + * @param[in] fmt exist media_format_h , don't access it after calling this function + * @param[out] out_fmt new copied media_format_h, the caller is owner of this object + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_FORMAT_ERROR_NONE Successful * @retval #MEDIA_FORMAT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_FORMAT_ERROR_OUT_OF_MEMORY Out of memory diff --git a/include/media_format_private.h b/include/media_format_private.h index c44b1b7..25209ea 100755 --- a/include/media_format_private.h +++ b/include/media_format_private.h @@ -53,61 +53,61 @@ extern "C" { /** * @brief Check whether given media format is for audio or not - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_IS_AUDIO(x_fmt) (MEDIA_FORMAT_CAST(x_fmt)->mimetype & MEDIA_FORMAT_AUDIO) /** * @brief Check whether given media format is for video or not - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_IS_VIDEO(x_fmt) (MEDIA_FORMAT_CAST(x_fmt)->mimetype & MEDIA_FORMAT_VIDEO) /** * @brief Check whether given media format is for text or not - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_IS_TEXT(x_fmt) (false) /** * @brief Check whether given media format is for raw type or not - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_IS_RAW(x_fmt) (MEDIA_FORMAT_CAST(x_fmt)->mimetype & MEDIA_FORMAT_RAW) /** * @brief Check whether given media format is for encoded type or not - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_IS_ENCODED(x_fmt) (MEDIA_FORMAT_CAST(x_fmt)->mimetype & MEDIA_FORMAT_ENCODED) /** * @brief Gets the number of media format ref_count - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_GET_REFCOUNT(x_fmt) (g_atomic_int_get(&(MEDIA_FORMAT_CAST(x_fmt))->ref_count)) /** * @brief Check whether given media format is writable or not - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_IS_WRITABLE(x_fmt) (MEDIA_FORMAT_GET_REFCOUNT(x_fmt) == 1) /** * @brief increase the media format's ref_count - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_INC_REFCOUNT(x_fmt) (g_atomic_int_inc(&(MEDIA_FORMAT_CAST(x_fmt))->ref_count)) /** * @brief decrease the media format's ref_count and return true if ref_count become zero. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_FORMAT_DEC_REFCOUNT_TEST(x_fmt) (g_atomic_int_dec_and_test(&(MEDIA_FORMAT_CAST(x_fmt))->ref_count)) /** * @brief Media format for configuring video codec. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef struct _media_format_video_spec_s { int width; /**< media format video width */ @@ -118,18 +118,19 @@ typedef struct _media_format_video_spec_s { /** * @brief Media format for configuring audio codec. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef struct _media_fomat_audio_spec_s { int channel; /**< media format audio's the number of channels */ int samplerate; /**< media format audio sampling rate */ int bit; /**< media format audio's the bit resolution */ int avg_bps; /**< media format audio max bps */ + bool is_adts; /**< media format audio aac adts flag */ } media_format_audio_spec_s; /** * @brief Structure of media format. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef struct _media_format_s { diff --git a/include/media_packet.h b/include/media_packet.h index 8c60d20..a6f5c1b 100755 --- a/include/media_packet.h +++ b/include/media_packet.h @@ -41,13 +41,13 @@ extern "C" { /** * @brief The Media Packet handle. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef struct media_packet_s *media_packet_h; /** * @brief Enumeration for media packet error. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef enum { @@ -60,7 +60,7 @@ typedef enum /** * @brief Enumeration for media buffer flag. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ typedef enum { @@ -71,7 +71,7 @@ typedef enum /** * @brief Enumeration for the return values of media packet finalize call back functions. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * @see media_packet_finalize_cb() */ typedef enum _finalize_cb_ret @@ -84,7 +84,7 @@ typedef enum _finalize_cb_ret * @brief Called when the media packet is destroyed. * @details It will be invoked when media_packet_destroy() is called. * - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] error_code The error code of #media_packet_error_e @@ -107,7 +107,7 @@ typedef int (*media_packet_finalize_cb)(media_packet_h packet, int error_code, v * @brief Creates a media packet handle and allocates buffer. * @details The buffer will be allocated to heap or tbm_surface. * - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @remarks The @c packet must be released by using media_packet_destroy(). * @param[in] fmt The allocated #media_format_h by caller @@ -115,6 +115,8 @@ typedef int (*media_packet_finalize_cb)(media_packet_h packet, int error_code, v * @param[in] fcb_data The user data to be passed to the media_packet_finalize_cb() function * @param[out] packet A new handle for media packet * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_OUT_OF_MEMORY Out of memory @@ -162,7 +164,7 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, * @brief Creates a media packet handle. * @details It creates only media packet handle without allocated buffer. * - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @remarks The @c packet must be released by using media_packet_destroy(). * @param[in] fmt The allocated #media_format_h by caller @@ -170,6 +172,8 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, * @param[in] fcb_data The user data to be passed to the media_packet_finalize_cb() function * @param[out] packet A new handle for media packet * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_OUT_OF_MEMORY Out of memory @@ -217,7 +221,7 @@ int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void * * @brief Copies a media packet handle. * @details It re-creates only media packet handle with exist media packet handle. * - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @remarks The @c new_packet must be released by using media_packet_destroy(). * @param[in] org_packet The existing media packet handle @@ -225,6 +229,8 @@ int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void * * @param[in] fcb_data The user data to be passed to the media_packet_finalize_cb() function * @param[out] new_packet A new handle for media packet * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_OUT_OF_MEMORY Out of memory @@ -239,10 +245,12 @@ int media_packet_copy(media_packet_h org_packet, media_packet_finalize_cb fcb, v * @brief Allocates buffer with media packet handle. * @details Before using media_packet_alloc(), media packet handle must be exist. * - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The existing media packet handle * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_OUT_OF_MEMORY Out of memory @@ -256,7 +264,7 @@ int media_packet_alloc(media_packet_h packet); /** * @brief Creates media packet handle and allocates buffer with #tbm_surface_h. * - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @remarks The @c packet must be released by using media_packet_destroy(). * @param[in] fmt The allocated #media_format_h by caller @@ -264,6 +272,9 @@ int media_packet_alloc(media_packet_h packet); * @param[in] fcb The media_packet_finalize_cb() to register * @param[in] fcb_data The user data to be passed to the media_packet_finalize_cb() function * @param[out] packet A new handle for media packet + * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_OUT_OF_MEMORY Out of memory @@ -308,17 +319,77 @@ int media_packet_alloc(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); /** + * @brief Creates media packet handle with already allocated external buffer. + * @details It does not support video's #MEDIA_FORMAT_RAW type. + * + * @since_tizen 2.4 + * + * @remarks The @c packet must be released by using media_packet_destroy(). + * @param[in] fmt The allocated #media_format_h by caller + * @param[in] mem_ptr The memory pointer which is created by external module + * @param[in] fcb The media_packet_finalize_cb() to register + * @param[in] fcb_data The user data to be passed to the media_packet_finalize_cb() function + * @param[out] packet A new handle for media packet + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + * + * @pre Must have media_format_h instance by media_format_create() + * @post Must do media_format_unref() + * + * @see media_packet_destroy() + * @see media_packet_finalize_cb() + * @see media_format_unref() + * @par Example + @code + #include <media_packet.h> + + { + media_format_h fmt; + media_packet_h packet; + + media_format_create(&fmt); + media_format_set_video_mime(fmt, MEDIA_FORMAT_H264_HP); + media_format_set_video_width(fmt, 640); + media_format_set_video_height(fmt, 480); + media_format_set_video_avg_bps(fmt, 10000000); + media_format_set_video_max_bps(fmt, 15000000); + + media_packet_create_from_external_memory (fmt, mem_ptr, size, _finalize_callback, fcb_data, &packet); + media_format_unref(fmt); + + ... + media_packet_destroy(packet); + } + + int _finalize_callback(media_packet_h packet, int err, void* userdata) + { + ... + return MEDIA_PACKET_FINALIZE; + } + + @endcode + */ +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); + +/** * @brief Gets #media_format_h of media packet - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] fmt The media format of media packet * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * * @see media_format_unref() - * @par Example + * @par Example @code #include <media_packet.h> @@ -338,11 +409,13 @@ int media_packet_get_format(media_packet_h packet, media_format_h *fmt); /** * @brief Sets #media_format_h of media packet - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] fmt The #media_format_h to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @@ -367,11 +440,13 @@ int media_packet_set_format(media_packet_h packet, media_format_h fmt); /** * @brief Sets PTS of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] pts The PTS value to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -380,11 +455,13 @@ int media_packet_set_pts(media_packet_h packet, uint64_t pts); /** * @brief Sets DTS of media packet handle. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] dts The DTS value to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -393,11 +470,13 @@ int media_packet_set_dts(media_packet_h packet, uint64_t dts); /** * @brief Sets PTS of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] duration The duration value to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -406,11 +485,13 @@ int media_packet_set_duration(media_packet_h packet, uint64_t duration); /** * @brief Sets buffer size of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] size The buffer size value to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -419,11 +500,13 @@ int media_packet_set_buffer_size(media_packet_h packet, uint64_t size); /** * @brief Gets PTS of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] pts The PTS value to get * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter @@ -432,11 +515,13 @@ int media_packet_get_pts(media_packet_h packet, uint64_t *pts); /** * @brief Gets DTS of media packet - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] dts The DTS value to get * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -445,11 +530,13 @@ int media_packet_get_dts(media_packet_h packet, uint64_t *dts); /** * @brief Gets duration of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] duration The duration value to get * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -458,11 +545,13 @@ int media_packet_get_duration(media_packet_h packet, uint64_t *duration); /** * @brief Gets buffer size of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] size The buffer size value to get * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -471,11 +560,13 @@ int media_packet_get_buffer_size(media_packet_h packet, uint64_t *size); /** * @brief Gets buffer data pointer of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] data The allocated buffer data pointer * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -484,11 +575,13 @@ int media_packet_get_buffer_data_ptr(media_packet_h packet, void **data); /** * @brief Gets TBM surface data of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] surface The tbm_surface data pointer * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -497,11 +590,13 @@ int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h *surface); /** * @brief Sets extra data of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] extra The extra data to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -510,11 +605,13 @@ int media_packet_set_extra(media_packet_h packet, void *extra); /** * @brief Gets extra data of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] extra The extra data to get * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -523,12 +620,14 @@ int media_packet_get_extra(media_packet_h packet, void **extra); /** * @brief Checks whether the given media packet is for video. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_video @c true if the given media packet is for video, * otherwise @c false if the given media packet is not for video * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -540,12 +639,14 @@ int media_packet_is_video(media_packet_h packet, bool *is_video); /** * @brief Checks whether the given media packet is for audio. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_audio @c true if the given media packet is for audio, * otherwise @c false if the given media packet is not for audio * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -556,12 +657,14 @@ int media_packet_is_audio(media_packet_h packet, bool *is_audio); /** * @brief Checks whether the given media packet is encoded type. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_encoded @c true if the given media packet is encoded, * otherwise @c false if the given media packet is not encoded * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -573,12 +676,14 @@ int media_packet_is_encoded(media_packet_h packet, bool *is_encoded); /** * @brief Checks whether the given media packet is raw type. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_raw @c true if the given media packet is for raw video, * otherwise @c false if the given media packet is not for raw video * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -590,11 +695,13 @@ int media_packet_is_raw(media_packet_h packet, bool *is_raw); /** * @brief Sets #media_buffer_flags_e of media packet. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] flags The media_buffer_flags_e of media packet to set * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -606,11 +713,13 @@ int media_packet_set_flags(media_packet_h packet, media_buffer_flags_e flags); /** * @brief Unsets media_buffer_flags_e of media packet - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[in] flags The media_buffer_flags_e of media packet to unset * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -622,12 +731,14 @@ int media_packet_unset_flags(media_packet_h packet, media_buffer_flags_e flags); /** * @brief Checks whether the given media packet is codec data. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_codec_config @c true if the given media packet is for codec data, * otherwise @c false if the given media packet is not for codec data * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -639,12 +750,14 @@ int media_packet_is_codec_config(media_packet_h packet, bool *is_codec_config); /** * @brief Checks whether the given media packet is eos. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_eos @c true if the given media packet is for eos, * otherwise @c false if the given media packet is not for eos * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -656,12 +769,14 @@ int media_packet_is_end_of_stream(media_packet_h packet, bool *is_eos); /** * @brief Checks whether the given media packet is sync frame. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] is_sync @c true if the given media packet is for sync frame, * otherwise @c false if the given media packet is not for sync frame * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -673,12 +788,14 @@ int media_packet_is_sync_frame(media_packet_h packet, bool *is_sync); /** * @brief Checks whether the allocated buffer is tbm surface or not. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The media packet handle * @param[out] has_tbm_surface @c true if the given media packet's allocated buffer is tbm surface, * otherwise @c false if the given media packet's allocated buffer is not tbm surface * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -686,12 +803,110 @@ int media_packet_is_sync_frame(media_packet_h packet, bool *is_sync); int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool* has_tbm_surface); /** + * @brief Gets the number of planes from tbm surface in the given media packet. + * @details Use only if the media_format_h is #MEDIA_FORMAT_RAW and #MEDIA_FORMAT_VIDEO. + * It means that media_packet_h's buffer is allocated on tbm_surface. + * If not sure of that, use media_packet_is_video() and media_packet_is_raw() or media_packet_has_tbm_surface_buffer(). + * + * @since_tizen 2.4 + * + * @param[in] packet The media packet handle + * @param[out] num The number of planes from tbm_surface + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + */ +int media_packet_get_number_of_video_planes(media_packet_h packet, uint32_t* num); + +/** + * @brief Gets stride width from tbm surface in the given media packet. + * @details Use only if the media_format_h is #MEDIA_FORMAT_RAW and #MEDIA_FORMAT_VIDEO. + * It means that media_packet_h's buffer is allocated on tbm_surface. + * If not sure of that, use media_packet_is_video() and media_packet_is_raw() or media_packet_has_tbm_surface_buffer(). + * + * @since_tizen 2.4 + * + * @param[in] packet The media packet handle + * @param[in] plane_idx The plane index value + * @param[out] stride_w the stride value from tbm_surface + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + */ +int media_packet_get_video_stride_width(media_packet_h packet, int plane_idx, int *stride_width); + +/** + * @brief Gets stride height from tbm surface in the given media packet. + * @details Use only if the media_format_h is #MEDIA_FORMAT_RAW and #MEDIA_FORMAT_VIDEO. + * It means that media_packet_h's buffer is allocated on tbm_surface. + * If not sure of that, use media_packet_is_video() and media_packet_is_raw() or media_packet_has_tbm_surface_buffer(). + * + * @since_tizen 2.4 + * + * @param[in] packet The media packet handle + * @param[in] plane_idx The plane index value + * @param[out] stride_h The stride height value from tbm_surface + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + */ +int media_packet_get_video_stride_height(media_packet_h packet, int plane_idx, int *stride_height); + +/** + * @brief Gets plane data pointer from tbm surface in the given media packet. + * @details Use only if the media_format_h is #MEDIA_FORMAT_RAW and #MEDIA_FORMAT_VIDEO. + * It means that media_packet_h's buffer is allocated on tbm_surface. + * If not sure of that, use media_packet_is_video() and media_packet_is_raw() or media_packet_has_tbm_surface_buffer(). + * + * @since_tizen 2.4 + * + * @remarks The @c plane_data_ptr must not be released by using free(). Note that It is released by media_packet_destory() or tbm_surface_destroy(). + * @param[in] packet The media packet handle + * @param[in] plane_idx The plane index value + * @param[out] plane_data_ptr The plane data pointer from tbm_surface + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + */ +int media_packet_get_video_plane_data_ptr(media_packet_h packet, int plane_idx, void **plane_data_ptr); + +/** + * @brief Gets codec data and the codec data size of media packet. + * @since_tizen 2.4 + * + * @param[in] packet The media packet handle + * @param[out] codec_data The codec data to get + * @param[out] codec_data_size The codec data size to get + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + */ +int media_packet_get_codec_data(media_packet_h packet, void** codec_data, unsigned int* codec_data_size); + +/** * @brief Destroys the media packet handle. * @details The registered finalize_callback() function will be invoked to destroy the media packet handle. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 * * @param[in] packet The handle to media packet to be destroyed * + * @return @c 0 on success, + * otherwise a negative error value * @retval #MEDIA_PACKET_ERROR_NONE Successful * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation @@ -700,6 +915,7 @@ int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool* has_tbm_sur * @see media_packet_create() * @see media_packet_copy() * @see media_packet_create_from_tbm_surface() + * @see media_packet_create_from_external_memory() */ int media_packet_destroy(media_packet_h packet); diff --git a/include/media_packet_internal.h b/include/media_packet_internal.h new file mode 100755 index 0000000..65ab7e6 --- /dev/null +++ b/include/media_packet_internal.h @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __TIZEN_MEDIA_PACKET_INTERNAL_H__ +#define __TIZEN_MEDIA_PACKET_INTERNAL_H__ + +#include <media_packet.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file media_packet_internal.h + * @brief This file contains the capi media tool internal API. + */ + +/** + * @addtogroup CAPI_MEDIA_TOOL_MODULE + * @{ + */ + + +/** + * @internal + * @brief Sets codec data and the codec data size of media packet. + * @since_tizen 2.4 + * + * @param[in] packet The media packet handle + * @param[in] codec_data The codec data to set + * @param[in] codec_data_size The codec data size to set + * + * @return @c 0 on success, + * otherwise a negative error value + * @retval #MEDIA_PACKET_ERROR_NONE Successful + * @retval #MEDIA_PACKET_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_PACKET_ERROR_INVALID_OPERATION Invalid operation + */ +int media_packet_set_codec_data(media_packet_h packet, void* codec_data, unsigned int codec_data_size); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_MEDIA_PACKET_INTERNAL_H__ */ diff --git a/include/media_packet_private.h b/include/media_packet_private.h index e9d9176..332a571 100755 --- a/include/media_packet_private.h +++ b/include/media_packet_private.h @@ -41,61 +41,61 @@ extern "C" { /** * @brief Gets pts of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_PTS(arg) (MEDIA_PACKET_CAST(arg)->pts) /** * @brief Gets dts of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_DTS(arg) (MEDIA_PACKET_CAST(arg)->dts) /** * @brief Gets duration of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_DURATION(arg) (MEDIA_PACKET_CAST(arg)->duration) /** * @brief Gets size of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_SIZE(arg) (MEDIA_PACKET_CAST(arg)->size) /** * @brief Gets data of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_DATA(arg) (MEDIA_PACKET_CAST(arg)->data) /** * @brief Gets the buffer flags of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_FLAGS(arg) (MEDIA_PACKET_CAST(arg)->flags) /** * @brief Gets the buffer config flag of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_CODEC_CONFIG_DATA(arg) (((MEDIA_PACKET_CAST(arg)->flags) >> 0) & 0x001) /** * @brief Gets the buffer eos flag of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_CODEC_END_OF_STREAM(arg) (((MEDIA_PACKET_CAST(arg)->flags) >> 1) & 0x001) /** * @brief Gets the buffer sync flag of media_packet_h - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_CODEC_SYNC_FRAME(arg) (((MEDIA_PACKET_CAST(arg)->flags) >> 2) & 0x001) /** * @brief Casting to media_packet_s - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.3 */ #define MEDIA_PACKET_CAST(obj) ((media_packet_s*)(obj)) @@ -105,6 +105,7 @@ typedef enum { MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE, MEDIA_BUFFER_TYPE_NORMAL, MEDIA_BUFFER_TYPE_AUTO, + MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY, MEDIA_BUFFER_TYPE_MAX } media_buffer_type_e; @@ -119,7 +120,9 @@ typedef struct _media_packet_s{ media_packet_finalize_cb finalizecb_func; void* userdata; bool is_allocated; - void *extradata; + void* extradata; + void* codec_data; + unsigned int codec_data_size; media_format_s* format; media_buffer_type_e type; diff --git a/packaging/capi-media-tool.spec b/packaging/capi-media-tool.spec index c78819f..dac37f3 100755 --- a/packaging/capi-media-tool.spec +++ b/packaging/capi-media-tool.spec @@ -47,8 +47,7 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} mkdir -p %{buildroot}/usr/share/license mkdir -p %{buildroot}/usr/bin -mkdir -p %{buildroot}/opt/usr/devel -cp test/media_packet_test %{buildroot}/opt/usr/devel +cp test/media_packet_test %{buildroot}/usr/bin/ cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} %make_install @@ -63,7 +62,7 @@ cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} %manifest capi-media-tool.manifest %{_libdir}/libcapi-media-tool.so.* %{_datadir}/license/%{name} -/opt/usr/devel/* +/usr/bin/* #%{_bindir}/* %files devel diff --git a/src/media_format.c b/src/media_format.c index e7a7fe8..41a4b37 100755 --- a/src/media_format.c +++ b/src/media_format.c @@ -111,6 +111,26 @@ int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e* mim return ret; } +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); + + 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 (is_adts) + *is_adts = fmt_handle->detail.audio.is_adts; + + return ret; +} + int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mimetype) { int ret = MEDIA_FORMAT_ERROR_NONE; @@ -366,6 +386,32 @@ int media_format_set_audio_avg_bps(media_format_h fmt, int avg_bps) 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); + + 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; + + 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; + + return ret; +} + int media_format_ref(media_format_h fmt) { int ret = MEDIA_FORMAT_ERROR_NONE; diff --git a/src/media_packet.c b/src/media_packet.c index 9487a00..92c10fa 100755 --- a/src/media_packet.c +++ b/src/media_packet.c @@ -53,7 +53,6 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb, 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) @@ -377,6 +376,7 @@ int _pkt_alloc_buffer(media_packet_s* pkt) 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) @@ -478,13 +478,25 @@ static uint64_t _pkt_calculate_video_buffer_size(media_packet_s* pkt) return buffersize; } - -#define PCM_MAX_FRM_SIZE (2048) -#define PCM_MIN_FRM_SIZE (1024) +#define PCM_MAX_FRM_SIZE (4608) /* FLAC PCM have max 4608*/ +#define PCM_MIN_FRM_SIZE (1024) #define AAC_MAX_SAMPLE_SIZE (1024) #define MP3_MAX_SAMPLE_SIZE (1152) -#define MPEG_MAX_FRM_SIZE (6144/4) /* 1536 */ -#define MPEG_MIN_NCH (2) +#define AMR_MAX_SAMPLE_SIZE (320) /* AMR-NB(160), WB (320) */ +#define OGG_MAX_SAMPLE_SIZE (2048) +#define FLAC_MAX_SAMPLE_SIZE (65536) /* FIXME - full size = sample * ch * resolution */ +#define WMA_MAX_SAMPLE_SIZE (10240) /* FIXME - full size = sample * ch * resolution */ + +#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) /* FIXME - Need */ +#define FLAC_MAX_FRM_SIZE (4096) /* FIXME - Need */ +#define WMA_MAX_FRM_SIZE (2048) /* FIXME - Need */ + +#define PCM_MAX_NCH (2) +#define MPEG_MIN_NCH (2) +#define AMR_MAX_NCH (1) +#define WMA_MAX_NCH (2) static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s* pkt) { @@ -500,13 +512,31 @@ static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s* pkt) switch (pkt->format->mimetype) { case MEDIA_FORMAT_PCM: - buffersize = (PCM_MAX_FRM_SIZE * channel) * (uint64_t)(bit /8); + buffersize = (PCM_MAX_FRM_SIZE * PCM_MAX_NCH) * (uint64_t)(bit /8); break; - case MEDIA_FORMAT_AAC: + 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)*/ break; /* TODO : extenstion format */ + case MEDIA_FORMAT_AMR_NB: + case MEDIA_FORMAT_AMR_WB: + buffersize = (AMR_MAX_FRM_SIZE * AMR_MAX_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/ + break; + case MEDIA_FORMAT_VORBIS: + buffersize = (OGG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/ + break; + case MEDIA_FORMAT_FLAC: + buffersize = (FLAC_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/ + break; + case MEDIA_FORMAT_WMAV1: + case MEDIA_FORMAT_WMAV2: + case MEDIA_FORMAT_WMAPRO: + case MEDIA_FORMAT_WMALSL: + buffersize = (WMA_MAX_FRM_SIZE * WMA_MAX_NCH) * (uint64_t)(2); /* 2 = (16bit/8)*/ + break; default: LOGE("Not supported format\n"); return 0; @@ -528,7 +558,11 @@ int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surfa MEDIA_PACKET_INSTANCE_CHECK(fmt); MEDIA_PACKET_INSTANCE_CHECK(surface); MEDIA_PACKET_NULL_ARG_CHECK(packet); - /* TODO : need more validation on fmt */ + 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) @@ -589,6 +623,69 @@ fail: 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) +{ + media_packet_s* handle; + int ret = MEDIA_PACKET_ERROR_NONE; + + if (mem_ptr == NULL) + 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); + + 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; + } + + 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; + + /* alloc handle->format */ + handle->format = MEDIA_FORMAT_CAST(fmt); + + /* set external allocated memory & external memory size */ + handle->size = size; + handle->data = mem_ptr; + + /* 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; + +} + int media_packet_get_buffer_data_ptr(media_packet_h packet, void **data) { media_packet_s* handle; @@ -602,7 +699,6 @@ int media_packet_get_buffer_data_ptr(media_packet_h packet, void **data) *data = handle->data; return ret; - } int media_packet_get_tbm_surface(media_packet_h packet, tbm_surface_h *surface) @@ -988,6 +1084,236 @@ int media_packet_has_tbm_surface_buffer(media_packet_h packet, bool* has_tbm_sur return ret; } +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; +} + +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; +} + +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; + +} + +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; +} + +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_INSTANCE_CHECK(packet); + MEDIA_PACKET_NULL_ARG_CHECK(codec_data); + MEDIA_PACKET_NULL_ARG_CHECK(codec_data_size); + + handle = (media_packet_s*) packet; + + 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; + + LOGE("There is no codec data..\n"); + ret = MEDIA_PACKET_ERROR_INVALID_OPERATION; + } + + return ret; +} + int media_packet_destroy(media_packet_h packet) { media_packet_s* handle; @@ -1026,9 +1352,17 @@ int media_packet_destroy(media_packet_h packet) handle->data = NULL; } } - else if (handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE) + else if (handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_TBM_SURFACE || handle->type == MEDIA_BUFFER_TYPE_EXTERNAL_MEMORY) { - // there is nothing to do + // 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 */ @@ -1132,181 +1466,3 @@ static void _aligned_free_normal_buffer_type (void* buffer_ptr) ptr = NULL; } -#if 0 -int media_tool_create(mediatool_h *mediatool) -{ - MediaTool_s *handle; - int ret; - handle = (MediaTool_s*)malloc(sizeof(MediaTool_s)); - - if (handle != NULL) - memset(handle, 0, sizeof(MediaTool_s)); - else - return MEDIA_TOOL_ERROR_OUT_OF_MEMORY; - - //TODO : make _media_tool_create function - //ret = _media_tool_create(&handle->mediatool_handle); - if(ret != MEDIA_TOOL_ERROR_NONE) - { - free(handle); - handle = NULL; - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - } - else - { - *mediatool = (mediatool_h*)handle; - handle->refcount = 1; - return MEDIA_TOOL_ERROR_NONE; - } -} - -int media_tool_destroy(mediatool_h mediatool) -{ - MediaTool_s* handle = (MediaTool_s *) mediatool; - int ret; - - if (handle == NULL) - return MEDIA_TOOL_ERROR_INVALID_PARAMETER; - - //TODO : make _media_tool_create function - ret = _media_tool_destroy(handle->mediatool_handle); - if (ret != MEDIA_TOOL_ERROR_NONE) - { - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - } - else - { - free(handle); - handle = NULL; - return MEDIA_TOOL_ERROR_NONE; - } -} - -int media_tool_is_Iframe(mediatool_h mediatool, bool *isIFrame) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - if (handle == NULL) - return MEDIA_TOOL_ERROR_INVALID_PARAMETER; - - *isIFrame = handle->videocodecformat->isIFrame; - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_set_buffer(mediatool_h mediatool, MediaToolBufferPrivate_s* privBuffer) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - handle->bufferpriv = (MediaToolBufferPrivate_s *)malloc(sizeof(MediaToolBufferPrivate_s)); - - if (handle->bufferpriv != NULL) - memset(handle->bufferpriv, 0, sizeof(MediaToolBufferPrivate_s)); - else - return MEDIA_TOOL_ERROR_OUT_OF_MEMORY; - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_get_buffer(mediatool_h mediatool, MediaToolBufferPrivate_s** privBuffer) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - if (handle->bufferpriv == NULL) - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - - memcpy(*privBuffer, handle->bufferpriv, sizeof(handle->bufferpriv)); - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_set_video_codec_format(mediatool_h mediatool, VideoCodecFormat_s* videoCodecFormat) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - handle->videocodecformat = (VideoCodecFormat_s *)malloc(sizeof(VideoCodecFormat_s)); - - if (handle->videocodecformat != NULL) - memset(handle->videocodecformat, 0, sizeof(VideoCodecFormat_s)); - else - return MEDIA_TOOL_ERROR_OUT_OF_MEMORY; - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_get_video_codec_format(mediatool_h mediatool, VideoCodecFormat_s** videoCodecFormat) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - if (handle->videocodecformat == NULL) - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - - memcpy(*videoCodecFormat, handle->videocodecformat, sizeof(handle->videocodecformat)); - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_set_audio_codec_format(mediatool_h mediatool, AudioCodecFormat_s* audioCodecFormat) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - handle->audiocodecformat = (AudioCodecFormat_s *)malloc(sizeof(AudioCodecFormat_s)); - - if (handle->audiocodecformat != NULL) - memset(handle->audiocodecformat, 0, sizeof(AudioCodecFormat_s)); - else - return MEDIA_TOOL_ERROR_OUT_OF_MEMORY; - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_get_audio_codec_format(mediatool_h mediatool, AudioCodecFormat_s** audioCodecFormat) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - int ret; - if (handle->audiocodecformat == NULL) - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - - memcpy(*audioCodecFormat, handle->audiocodecformat, sizeof(handle->audiocodecformat)); - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_ref(mediatool_h mediatool) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - - if (handle == NULL) - return MEDIA_TOOL_ERROR_INVALID_PARAMETER; - - if (!(handle->refcount> 0)) - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - - g_atomic_int_inc (&handle->refcount); - - return MEDIA_TOOL_ERROR_NONE; -} - -int media_tool_unref(mediatool_h mediatool) -{ - MediaTool_s *handle = (MediaTool_s *) mediatool; - - if (handle == NULL) - return MEDIA_TOOL_ERROR_INVALID_PARAMETER; - - if (!(handle->refcount> 0)) - return MEDIA_TOOL_ERROR_INVALID_OPERATION; - - int zero; - - zero = g_atomic_int_dec_and_test (&handle->refcount); - if (zero) - { - free(handle); - handle = NULL; - } - return MEDIA_TOOL_ERROR_NONE; -} - -#endif - diff --git a/src/media_packet_internal.c b/src/media_packet_internal.c new file mode 100755 index 0000000..402e9d4 --- /dev/null +++ b/src/media_packet_internal.c @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <dlog.h> +#include <media_format.h> +#include <media_packet.h> +#include <media_packet_internal.h> +#include <media_packet_private.h> +#include <media_format_private.h> + +int media_packet_set_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_INSTANCE_CHECK(packet); + + handle = (media_packet_s*) packet; + + LOGI("Set: codec data = %p, codec_data_size = %u\n", codec_data, codec_data_size); + + handle->codec_data = (void*)malloc(codec_data_size); + if (handle->codec_data != NULL) + { + memset(handle->codec_data, 0 , codec_data_size); + } + 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; + } + + memcpy(handle->codec_data, codec_data, codec_data_size); + handle->codec_data_size = codec_data_size; + + return ret; +} + diff --git a/test/media_packet_test.c b/test/media_packet_test.c index ade3cde..e460bff 100755 --- a/test/media_packet_test.c +++ b/test/media_packet_test.c @@ -20,7 +20,7 @@ #include <media_packet_private.h> #include <media_format.h> #include <media_format_private.h> - +#include <media_packet_internal.h> #include <appcore-efl.h> @@ -45,6 +45,7 @@ enum CURRENT_STATUS_FORMAT_SET_AUDIO_SAMPLERATE, CURRENT_STATUS_FORMAT_SET_AUDIO_BIT, CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS, + CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE, }; @@ -57,6 +58,11 @@ int media_format_idx = -1; bool is_only_created_handle; bool is_excute_create; +unsigned char codec_data[0x04] = {0x00, 0x01, 0x02, 0x03}; +unsigned int codec_data_size = 4; +unsigned char* codec_data_ptr = codec_data; + + /***********************************************/ /*** Test API part /***********************************************/ @@ -232,6 +238,17 @@ static void _media_format_set_audio_avg_bps(int avg_bps) g_print("media_format_set_audio_avg_bps is failed...!!\n"); } +static void _media_format_set_audio_aac_type(bool is_adts) +{ + int ret; + ret = media_format_set_audio_aac_type(g_media_format[media_format_idx], is_adts); + + if (ret == MEDIA_FORMAT_ERROR_NONE) + g_print("media_format_set_audio_aac_type is succeeded!!\n"); + else + g_print("media_format_set_audio_aac_type is failed...!!\n"); +} + static void _create_format_320_240_es(void) { @@ -538,7 +555,7 @@ static void _media_packet_get_buffer_size(void) if (media_packet_get_buffer_size(g_media_packet[0],&size) == MEDIA_PACKET_ERROR_NONE) { g_print("media_packet_get_buffer_size is sucess!!"); - g_print("\t\t[media_packet]===> size = %llu", size); + g_print("\t\t[media_packet]===> size = %llu\n", size); } else { @@ -553,7 +570,7 @@ static void _media_packet_get_duration(void) if (media_packet_get_duration(g_media_packet[0], &duration) == MEDIA_PACKET_ERROR_NONE) { g_print("media_packet_get_duration is sucess!!"); - g_print("\t\t[media_packet]===> duration = %llu", duration); + g_print("\t\t[media_packet]===> duration = %llu\n", duration); } else { @@ -575,7 +592,7 @@ static void _media_packet_get_buffer_data_ptr(void) if (media_packet_get_buffer_data_ptr(g_media_packet[0], &ptr) == MEDIA_PACKET_ERROR_NONE) { g_print("media_packet_get_buffer_data_ptr is sucess!!"); - g_print("\t\t[media_packet]===> buffer_data_ptr = %p", ptr); + g_print("\t\t[media_packet]===> buffer_data_ptr = %p\n", ptr); } else { @@ -591,7 +608,7 @@ static void _media_packet_get_tbm_surface() if (media_packet_get_tbm_surface(g_media_packet[0], &tbm_surface) == MEDIA_PACKET_ERROR_NONE) { g_print("media_packet_get_tbm_surface is sucess!!"); - g_print("\t\t[media_packet]===> tbm_surface = %p", (void*)tbm_surface); + g_print("\t\t[media_packet]===> tbm_surface = %p\n", (void*)tbm_surface); } else { @@ -599,6 +616,104 @@ static void _media_packet_get_tbm_surface() } } +static void _media_packet_get_number_of_video_planes() +{ + uint32_t num = 0; + if (media_packet_get_number_of_video_planes(g_media_packet[0], &num)== MEDIA_PACKET_ERROR_NONE) + { + g_print("media_packet_get_number_of_video_planes is sucess!!\n"); + g_print("\t\t[media_packet]===> number of planes = %ld\n", num); + + } + else + { + g_print("media_packet_get_number_of_video_planes is failed..."); + } +} + +static void _media_packet_get_video_stride_width() +{ + int stride_w; + if (media_packet_get_video_stride_width(g_media_packet[0], 0, &stride_w)== MEDIA_PACKET_ERROR_NONE) + { + g_print("media_packet_get_video_stride_width is sucess!!\n"); + g_print("\t\t[media_packet]===> stride width = %d\n", stride_w); + + } + else + { + g_print("media_packet_get_video_stride_width is failed..."); + } +} + +static void _media_packet_get_video_stride_height() +{ + int stride_h; + if (media_packet_get_video_stride_height(g_media_packet[0], 0, &stride_h)== MEDIA_PACKET_ERROR_NONE) + { + g_print("media_packet_get_video_stride_height is sucess!!\n"); + g_print("\t\t[media_packet]===> stride height = %d\n", stride_h); + + } + else + { + g_print("media_packet_get_video_stride_height is failed..."); + } +} + +static void _media_packet_get_video_plane_data_ptr() +{ + void* ptr; + if (media_packet_get_video_plane_data_ptr(g_media_packet[0], 0, &ptr)== MEDIA_PACKET_ERROR_NONE) + { + g_print("media_packet_get_video_plane_data_ptr is sucess!!\n"); + g_print("\t\t[media_packet]===> ptr = %p\n", ptr); + + } + else + { + g_print("_media_packet_get_plane_data_ptr is failed..."); + } +} + +static void _media_packet_set_codec_data() +{ + if (media_packet_set_codec_data(g_media_packet[0], (void*)codec_data_ptr, codec_data_size) == MEDIA_PACKET_ERROR_NONE) + { + g_print("media_packet_set_codec_data is sucess..!\n"); + } + else + { + g_print("media_packet_set_codec_data is failed...\n"); + } +} + +static void _media_packet_get_codec_data() +{ + unsigned char* get_codec_data; + unsigned int get_codec_data_size; + + if (media_packet_get_codec_data(g_media_packet[0], &get_codec_data, &get_codec_data_size) == MEDIA_PACKET_ERROR_NONE) + { + g_print("media_packet_get_codec_data is sucess ... !\n"); + g_print("codec_data_size = %u\n", get_codec_data_size); + + if (get_codec_data_size == 0) + return; + + int i; + for (i=0 ; i < get_codec_data_size; i++) + { + g_print("codec_data[%d] ", i); + g_print(" = 0x%x\n", get_codec_data[i]); + } + } + else + { + g_print("media_packet_get_codec_data is failed...\n"); + } +} + static void _media_packet_set_duration(uint64_t duration) { if (media_packet_set_duration(g_media_packet[0], duration) == MEDIA_PACKET_ERROR_NONE) @@ -806,7 +921,7 @@ static void _media_format_get_audio_info(void) if (media_format_get_audio_info(g_media_format[0], &mime, &channel, &samplerate, &bit, &avg_bps)== MEDIA_FORMAT_ERROR_NONE) { g_print("media_format_get_audio_info is sucess!\n"); - g_print("\t\t[media_format_get_audio_info]mime:0x%x, channel :%d, samplerate :%d, bit: %d, avg_bps:%d \n", mime, channel, samplerate, bit, avg_bps); + g_print("\t\t[media_format_get_audio_info]mime:0x%x, channel :%d, samplerate :%d, bit: %d, avg_bps:%d, is_adts:%d \n", mime, channel, samplerate, bit, avg_bps); g_print("packet format ref_count: %d", MEDIA_FORMAT_GET_REFCOUNT(g_media_format[0])); } else @@ -1032,6 +1147,31 @@ void _interpret_main_menu(char *cmd) { g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_BIT; } + else if (strncmp(cmd, "gnp", 3) == 0) + { + _media_packet_get_number_of_video_planes(); + } + else if (strncmp(cmd, "gsw", 3) == 0) + { + _media_packet_get_video_stride_width(); + } + else if (strncmp(cmd, "gsh", 3) == 0) + { + _media_packet_get_video_stride_height(); + } + else if (strncmp(cmd, "gpp", 3) == 0) + { + _media_packet_get_video_plane_data_ptr(); + } + else if (strncmp(cmd, "scd", 3) == 0) + { + _media_packet_set_codec_data(); + } + else if (strncmp(cmd, "gcd", 3) == 0) + { + _media_packet_get_codec_data(); + } + } else if (len == 4) { @@ -1055,6 +1195,10 @@ void _interpret_main_menu(char *cmd) { g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_AVG_BPS; } + else if (strncmp(cmd, "saat", 4) == 0) + { + g_menu_state = CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE; + } } @@ -1122,6 +1266,10 @@ static void displaymenu(void) { g_print("input audio average bps:\n"); } + else if (g_menu_state == CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE) + { + g_print("input audio aac type (0 or 1):\n"); + } else { g_print("*** unknown status.\n"); @@ -1251,6 +1399,13 @@ static void interpret (char *cmd) reset_menu_state(); } break; + case CURRENT_STATUS_FORMAT_SET_AUDIO_AAC_TYPE: + { + bool is_ats = atoi(cmd); + _media_format_set_audio_aac_type(is_ats); + reset_menu_state(); + } + break; case CURRENT_STATUS_DURATION: { uint64_t duration = atoi(cmd); @@ -1288,6 +1443,7 @@ void display_sub_basic() g_print("sas. media_format_set_audio_samplerate\t"); g_print("sab. media_format_set_audio_bit \t"); g_print("saab. media_format_set_audio_avg_bps\t"); + g_print("saat. media_format_set_audio_aac_type\t"); g_print("\n"); g_print("fgv. media_format_get_video_info \t"); g_print("fga. media_format_get_audio_info \t\t"); @@ -1318,6 +1474,13 @@ void display_sub_basic() g_print("\n"); g_print("gs. media_packet_get_buffer_size\t"); g_print("\n"); + g_print("gnp. media_packet_get_number_of_video_planes\t"); + g_print("gsw. media_packet_get_video_stride_width\t"); + g_print("gsh. media_packet_get_video_stride_height\t"); + g_print("gpp. media_packet_get_video_plane_data_ptr\t"); + g_print("\n"); + g_print("scd. media_packet_set_codec_data\t"); + g_print("gcd. media_packet_get_codec_data\t"); g_print("\n"); g_print("d. media_packet_destroy \n"); g_print("q. quit test suite(if exist alive media_format, do media_format_unref)"); |