Add new API for text mime type, audio aac header type, set codec data 38/52638/3 accepted/tizen/mobile/20151208.124239 accepted/tizen/tv/20151208.124254 accepted/tizen/wearable/20151208.124311 submit/tizen/20151207.233907
authorJihae Yi <jihae.yi@samsung.com>
Wed, 25 Nov 2015 08:34:56 +0000 (17:34 +0900)
committerJihae Yi <jihae.yi@samsung.com>
Mon, 7 Dec 2015 06:36:37 +0000 (15:36 +0900)
Change-Id: Ic3f151efd1e7e14f76123dd2967eff9e1a3c8c65

include/media_format.h
include/media_format_private.h
include/media_packet.h
include/media_packet_internal.h
src/media_format.c
src/media_packet.c
src/media_packet_internal.c

index 410e808919c588451dd686fe7a16b6840ee1e442..379a686dea6f37f4d25186f522c49056f7fa7d56 100755 (executable)
@@ -42,7 +42,7 @@ extern "C" {
 typedef struct media_format_s *media_format_h;
 
 /**
- * @brief Enumerations of  media format error
+ * @brief Enumerations of  media format error.
  * @since_tizen 2.3
  */
 typedef enum {
@@ -100,17 +100,39 @@ typedef enum {
        MEDIA_FORMAT_WMAPRO = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A2),                /**< media format mime type is WMAVPRO,  AUDIO, (Since 2.4) */
        MEDIA_FORMAT_WMALSL = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_ENCODED | 0x10A3),                /**< media format mime type is WMAVLSL,  AUDIO, (Since 2.4) */
 
-       MEDIA_FORMAT_PCM = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1510),                       /**< media format mime type is PCM, AUDIO*/
-       MEDIA_FORMAT_PCMA = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1520),                      /**< media format mime type is PCM A-law, AUDIO*/
+       MEDIA_FORMAT_PCM = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1510),                       /**< media format mime type is PCM, AUDIO, indicates MEDIA_FORMAT_PCM_S16LE (Since 3.0) */
+       MEDIA_FORMAT_PCM_S16LE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1510),                 /**< media format mime type is PCM signed 16-bit little-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_S24LE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1511),                 /**< media format mime type is PCM signed 24-bit little-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_S32LE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1512),                 /**< media format mime type is PCM signed 32-bit little-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_S16BE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1513),                 /**< media format mime type is PCM signed 16-bit big-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_S24BE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1514),                 /**< media format mime type is PCM signed 24-bit big-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_S32BE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1515),                 /**< media format mime type is PCM signed 32-bit big-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_F32LE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1516),                 /**< media format mime type is PCM 32-bit floating point little-endian, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_PCM_F32BE = (MEDIA_FORMAT_AUDIO | MEDIA_FORMAT_RAW | 0x1517),                 /**< media format mime type is PCM 32-bit floating point big-endian, AUDIO, (Since 3.0) */
+       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_H263_BLP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2022),             /**< media format mime type is H263 Baseline Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_H320_CEP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2023),                 /**< media format mime type is H263 H.320 Coding Efficiency Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_BCP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2024),             /**< media format mime type is H263 Backward-Compatibility Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_ISW2P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2025),                 /**< media format mime type is H263 Interactive and Streaming Wireless Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_ISW3P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2026),                 /**< media format mime type is H263 Interactive and Streaming Wireless Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_CHCP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2027),             /**< media format mime type is H263 Conversation High Compression Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_C_INTERNETP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2028),             /**< media format mime type is H263 Conversational Internet Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_C_INTERLACEP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2029),             /**< media format mime type is H263 Conversational Interlace Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_H263_HLP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x202A),             /**< media format mime type is H263 High Latency Profile, VIDEO, (Since 3.0) */
        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_H264_EXTP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2033),           /**< media format mime type is H264 Extended Profile, VIDEO (Since 3.0) */
+       MEDIA_FORMAT_H264_H10P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2034),           /**< media format mime type is H264 High10 Profile, VIDEO (Since 3.0) */
+       MEDIA_FORMAT_H264_H422P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2035),           /**< media format mime type is H264 High422 Profile, VIDEO (Since 3.0) */
+       MEDIA_FORMAT_H264_H444P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2036),           /**< media format mime type is H264 High444 Profile, VIDEO (Since 3.0) */
+       MEDIA_FORMAT_H264_C444P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2037),           /**< media format mime type is H264 CAVLC444 Profile, VIDEO (Since 3.0) */
        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 */
@@ -119,6 +141,8 @@ typedef enum {
        MEDIA_FORMAT_MPEG4_SP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2070),      /**< media format mime type is MPEG4_SP, VIDEO */
        MEDIA_FORMAT_MPEG4_ASP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2071),     /**< media format mime type is MPEG4_ASP, VIDEO */
        MEDIA_FORMAT_HEVC = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2080),                  /**< media format mime type is HEVC, VIDEO, (Since 2.4) */
+       MEDIA_FORMAT_HEVC_MP = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2081),              /**< media format mime type is HEVC Main Profile, VIDEO, (Since 3.0) */
+       MEDIA_FORMAT_HEVC_M10P = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2082),                  /**< media format mime type is HEVC Main10 Profile, VIDEO, (Since 3.0) */
        MEDIA_FORMAT_VP8 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x2090),                   /**< media format mime type is VP8, VIDEO, (Since 2.4) */
        MEDIA_FORMAT_VP9 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20A0),                   /**< media format mime type is VP9, VIDEO, (Since 2.4) */
        MEDIA_FORMAT_VC1 = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_ENCODED | 0x20B0),                   /**< media format mime type is VC1, VIDEO, (Since 2.4) */
@@ -136,6 +160,7 @@ typedef enum {
        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_BGRA = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x25e0),                      /**< media format mime type is BGRA, VIDEO, (Since 3.0) */
 
        /* CONTAINER VIDEO */
        MEDIA_FORMAT_CONTAINER_MP4 = (MEDIA_FORMAT_CONTAINER | 0x3010),                                    /**< media format mime type is MP4 container, VIDEO, (Since 3.0) */
@@ -150,8 +175,12 @@ typedef enum {
        MEDIA_FORMAT_CONTAINER_WAV = (MEDIA_FORMAT_CONTAINER | 0x4010),                                    /**< media format mime type is WAV container, AUDIO, (Since 3.0) */
        MEDIA_FORMAT_CONTAINER_OGG = (MEDIA_FORMAT_CONTAINER | 0x4020),                                    /**< media format mime type is OGG container, AUDIO, (Since 3.0) */
        MEDIA_FORMAT_CONTAINER_AAC_ADTS = (MEDIA_FORMAT_CONTAINER | 0x4030),                       /**< media format mime type is AAC_ADTS container, AUDIO, (Since 3.0) */
+       MEDIA_FORMAT_CONTAINER_AAC_ADIF = (MEDIA_FORMAT_CONTAINER | 0x4031),                       /**< media format mime type is AAC_ADIF container, AUDIO, (Since 3.0) */
 
-       MEDIA_FORMAT_NATIVE_VIDEO = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x7000),      /**< media format mime type is HW dependent , VIDEO, (Since 2.4) */
+       MEDIA_FORMAT_NATIVE_VIDEO = (MEDIA_FORMAT_VIDEO | MEDIA_FORMAT_RAW | 0x7000),      /**< media format mime type is HW dependent, VIDEO, (Since 2.4) */
+       /* Text */
+       MEDIA_FORMAT_TEXT_MP4 = (MEDIA_FORMAT_TEXT | MEDIA_FORMAT_ENCODED | 0x8010),            /**< media format mime type is MP4, TEXT, (Since 3.0) */
+       MEDIA_FORMAT_TEXT_3GP = (MEDIA_FORMAT_TEXT | MEDIA_FORMAT_ENCODED | 0x8020),            /**< media format mime type is 3GP, TEXT, (Since 3.0) */
 
        MEDIA_FORMAT_MAX                                                                                                                                   /**< media format mime type is MEDIA_FORMAT_MAX, Do not use */
 } media_format_mimetype_e;
@@ -167,10 +196,32 @@ typedef enum {
 } media_format_color_model_e;
 
 /**
- * @brief Creates a media format
+ * @brief Enumeration for media format aac header type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+       MEDIA_FORMAT_AAC_HEADER_NONE,              /**< media format aac header type is RAW, no header */
+       MEDIA_FORMAT_AAC_HEADER_ADTS,              /**< media format aac header type is ADTS header */
+       MEDIA_FORMAT_AAC_HEADER_ADIF,              /**< media format aac header type is ADIF header */
+       MEDIA_FORMAT_AAC_HEADER_UNKNOWN,                  /**< media format aac header type is UNKNOWN */
+} media_format_aac_header_type_e;
+
+/**
+ * @brief Enumeration for media format text type.
+ * @since_tizen 3.0
+ */
+typedef enum {
+       MEDIA_FORMAT_TEXT_TYPE_NONE,    /**< media format text type is none */
+       MEDIA_FORMAT_TEXT_TYPE_TIMED_TEXT_MP4,    /**< media format text type is MPEG-4 Timed Text */
+       MEDIA_FORMAT_TEXT_TYPE_TIMED_TEXT_3GPP,    /**< media format text type is 3GPP Timed Text */
+       MEDIA_FORMAT_TEXT_TYPE_UNKNOWN,    /**< media format text type is unknown */
+} media_format_text_type_e;
+
+/**
+ * @brief Creates a media format.
  * @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()
+                    For destroying media_format_h handle, use media_format_unref().
  * @param[out] fmt allocated media_format_h
  *
  * @return @c 0 on success,
@@ -185,7 +236,7 @@ typedef enum {
 int media_format_create(media_format_h * fmt);
 
 /**
- * @brief Gets format type of media format
+ * @brief Gets format type of media format.
  * @since_tizen 3.0
  * @param[in] fmt The media_format_h to get format type
  * @param[out] formattype The media_format_type_e, ex) MEDIA_FORMAT_AUDIO
@@ -199,7 +250,7 @@ int media_format_create(media_format_h * fmt);
 int media_format_get_type(media_format_h fmt, media_format_type_e * formattype);
 
 /**
- * @brief Gets container MIME type of media format
+ * @brief Gets container MIME type of media format.
  * @since_tizen 3.0
  * @param[in] fmt The media_format_h to get container mime type
  * @param[out] mimetype The media_format_mimetype_e, ex) MEDIA_FORMAT_CONTAINER_MP4
@@ -214,9 +265,25 @@ int media_format_get_type(media_format_h fmt, media_format_type_e * formattype);
 int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e * mimetype);
 
 /**
- * @brief Gets video information of media format
+ * @brief Gets text track information of media format.
+ * @since_tizen 3.0
+ * @param[in] fmt The media_format_h to get text information
+ * @param[out] mimetype The media_format_mimetype_e, ex) MEDIA_FORMAT_TEXT_MP4
+ * @param[out] type The media_format_text_type_e
+ *
+ * @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_text_mime()
+ */
+int media_format_get_text_info(media_format_h fmt, media_format_mimetype_e * mimetype, media_format_text_type_e * type);
+
+/**
+ * @brief Gets video information of media format.
  * @since_tizen 2.3
- * @details   returns mimetype, width, height, average bps, max bps of this media format
+ * @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
  * @param[out] width width of the video
@@ -238,9 +305,9 @@ int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e
 int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e * mimetype, int *width, int *height, int *avg_bps, int *max_bps);
 
 /**
- * @brief Gets audio information of media format
+ * @brief Gets audio information of media format.
  * @since_tizen 2.3
- * @details   returns mimetype, channels, height, samplerate bps, max bps of this media format
+ * @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
  * @param[out] channel channel of the audio
@@ -262,7 +329,7 @@ int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e * mi
 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
+ * @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
@@ -277,7 +344,22 @@ int media_format_get_audio_info(media_format_h fmt, media_format_mimetype_e * mi
 int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts);
 
 /**
- * @brief Gets video frame rate of media format
+ * @brief Gets audio aac header type of media format.
+ * @since_tizen 3.0
+ * @param[in] fmt The media_format_h to get audio information
+ * @param[out] aac_header_type The media_format_aac_header_type_e, ex) MEDIA_FORMAT_AAC_HEADER_ADTS
+ *
+ * @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_header_type()
+ */
+int media_format_get_audio_aac_header_type(media_format_h fmt, media_format_aac_header_type_e * aac_header_type);
+
+/**
+ * @brief Gets video frame rate of media format.
  * @since_tizen 3.0
  * @param[in] fmt The media_format_h to get
  * @param[out] frame_rate The video frame rate
@@ -291,7 +373,7 @@ int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts);
 int media_format_get_video_frame_rate(media_format_h fmt, int *frame_rate);
 
 /**
- * @brief Sets container MIME type of media format
+ * @brief Sets container MIME type of media format.
  * @since_tizen 3.0
  * @param[in] fmt The media_format_h to set
  * @param[in] mimetype The media_format_mimetype_e, ex) MEDIA_FORMAT_MP4
@@ -306,9 +388,36 @@ int media_format_get_video_frame_rate(media_format_h fmt, int *frame_rate);
 int media_format_set_container_mime(media_format_h fmt, media_format_mimetype_e mimetype);
 
 /**
- * @brief Sets video MIME type of media format
+ * @brief Sets text MIME type of media format.
+ * @since_tizen 3.0
+ * @param[in] fmt The media_format_h to set
+ * @param[in] mimetype The media_format_mimetype_e, ex) MEDIA_FORMAT_TEXT*
+ * @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_text_info()
+ */
+int media_format_set_text_mime(media_format_h fmt, media_format_mimetype_e mimetype);
+
+/**
+ * @brief Sets text type of media format.
+ * @since_tizen 3.0
+ * @param[in] fmt The media_format_h to set
+ * @param[in] type The text type
+ * @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_text_info()
+ */
+int media_format_set_text_type(media_format_h fmt, media_format_text_type_e type);
+
+/**
+ * @brief Sets video MIME type of media format.
  * @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
  *
@@ -322,9 +431,8 @@ int media_format_set_container_mime(media_format_h fmt, media_format_mimetype_e
 int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mimetype);
 
 /**
- * @brief Sets video width of media format
+ * @brief Sets video width of media format.
  * @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()
@@ -339,9 +447,8 @@ int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mime
 int media_format_set_video_width(media_format_h fmt, int width);
 
 /**
- * @brief Sets video height of media format
+ * @brief Sets video height of media format.
  * @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()
@@ -356,9 +463,8 @@ int media_format_set_video_width(media_format_h fmt, int width);
 int media_format_set_video_height(media_format_h fmt, int height);
 
 /**
- * @brief Sets video avg_bps of media format
+ * @brief Sets video avg_bps of media format.
  * @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()
@@ -373,9 +479,9 @@ int media_format_set_video_height(media_format_h fmt, int height);
 int media_format_set_video_avg_bps(media_format_h fmt, int avg_bps);
 
 /**
- * @brief Sets video max_bps of media format
+ * @brief Sets video max_bps of media format.
  * @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()
@@ -390,7 +496,7 @@ int media_format_set_video_avg_bps(media_format_h fmt, int avg_bps);
 int media_format_set_video_max_bps(media_format_h fmt, int max_bps);
 
 /**
- * @brief Sets video frame rate of media format
+ * @brief Sets video frame rate of media format.
  * @since_tizen 3.0
  * @param[in] fmt The media_format_h to set
  * @param[in] frame_rate The video frame rate
@@ -405,9 +511,8 @@ int media_format_set_video_max_bps(media_format_h fmt, int max_bps);
 int media_format_set_video_frame_rate(media_format_h fmt, int frame_rate);
 
 /**
- * @brief Sets audio MIME type of media format
+ * @brief Sets audio MIME type of media format.
  * @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
  *
@@ -421,9 +526,8 @@ int media_format_set_video_frame_rate(media_format_h fmt, int frame_rate);
 int media_format_set_audio_mime(media_format_h fmt, media_format_mimetype_e mimetype);
 
 /**
- * @brief Sets audio channel of media format
+ * @brief Sets audio channel of media format.
  * @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()
@@ -438,9 +542,8 @@ int media_format_set_audio_mime(media_format_h fmt, media_format_mimetype_e mime
 int media_format_set_audio_channel(media_format_h fmt, int channel);
 
 /**
- * @brief Sets audio samplerate of media format
+ * @brief Sets audio samplerate of media format.
  * @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()
@@ -455,7 +558,7 @@ int media_format_set_audio_channel(media_format_h fmt, int channel);
 int media_format_set_audio_samplerate(media_format_h fmt, int samplerate);
 
  /**
- * @brief Sets audio bit of media format
+ * @brief Sets audio bit of media format.
  * @since_tizen 2.3
  * @details   Sets audio bit resolution of this media format
  * @param[in] fmt media_format_h to set
@@ -472,9 +575,8 @@ int media_format_set_audio_samplerate(media_format_h fmt, int samplerate);
 int media_format_set_audio_bit(media_format_h fmt, int bit);
 
  /**
- * @brief Sets audio avg_bps of media format
+ * @brief Sets audio avg_bps of media format.
  * @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()
@@ -489,7 +591,7 @@ 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
+ * @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
@@ -506,7 +608,22 @@ int media_format_set_audio_avg_bps(media_format_h fmt, int avg_bps);
 int media_format_set_audio_aac_type(media_format_h fmt, bool is_adts);
 
 /**
- * @brief Increase reference count of media_format_h object
+ * @brief Sets audio aac header type of media format.
+ * @since_tizen 3.0
+ * @param[in] fmt The media_format_h to get audio information
+ * @param[in] aac_header_type The media_format_aac_header_type_e, ex) MEDIA_FORMAT_AAC_HEADER_ADTS
+ *
+ * @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_header_type()
+ */
+int media_format_set_audio_aac_header_type(media_format_h fmt, media_format_aac_header_type_e aac_header_type);
+
+/**
+ * @brief Increase reference count of media_format_h object.
  * @since_tizen 2.3
  * @details    increase ref_count of media_format_h
  * @param[in] fmt exist media_format_h
@@ -522,9 +639,8 @@ int media_format_set_audio_aac_type(media_format_h fmt, bool is_adts);
 int media_format_ref(media_format_h fmt);
 
 /**
- * @brief Decrease reference count of media_format_h object
+ * @brief Decrease reference count of media_format_h object.
  * @since_tizen 2.3
- * @details    decrease ref_count of media_format_h
  * @param[in] fmt exist media_format_h
  *
  * @return @c 0 on success,
@@ -540,7 +656,6 @@ int media_format_unref(media_format_h fmt);
 /**
  * @brief Check whether the media_format_h is writable or not.
  * @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
  *
@@ -554,7 +669,7 @@ int media_format_unref(media_format_h fmt);
 int media_format_is_writable(media_format_h fmt, bool * is_writable);
 
  /**
- * @brief Returns a writable copy of media_format_h
+ * @brief Returns a writable copy of media_format_h.
  * @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.
index e66f421a788642b3788625314fbe3cfd45bc503f..065ed96cfcac0452f50837783d0b43444b357d8e 100755 (executable)
@@ -66,7 +66,7 @@ extern "C" {
  * @brief Check whether given media format is for text or not
  * @since_tizen 2.3
  */
-#define MEDIA_FORMAT_IS_TEXT(x_fmt) (false)
+#define MEDIA_FORMAT_IS_TEXT(x_fmt) (MEDIA_FORMAT_CAST(x_fmt)->mimetype & MEDIA_FORMAT_TEXT)
 
 /**
  * @brief Check whether given media format is for raw type or not
@@ -126,8 +126,17 @@ typedef struct _media_fomat_audio_spec_s {
        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_aac_header_type_e aac_header_type;                  /**< media format audio aac header type */
 } media_format_audio_spec_s;
 
+/**
+ * @brief Media format for configuring text.
+ * @since_tizen 3.0
+ */
+typedef struct _media_fomat_text_spec_s {
+       media_format_text_type_e type;                   /**< media format text (or subtile) codec type */
+} media_format_text_spec_s;
+
 /**
  * @brief Structure of media format.
  * @since_tizen 2.3
@@ -139,6 +148,7 @@ typedef struct _media_format_s {
        union {
                media_format_audio_spec_s audio;                  /**< media format struct audio of media_format_audio_spec_s */
                media_format_video_spec_s video;                  /**< media format struct video of media_format_video_spec_s */
+               media_format_text_spec_s text;                  /**< media format struct video of media_format_text_spec_s (Since 3.0) */
        } detail;
 
 } media_format_s;
index 70050dded4813c507654a76818f72c3abc2813b1..7788e63af42483daf21e51bc274bdcd96ff63886 100755 (executable)
@@ -652,6 +652,24 @@ int media_packet_is_video(media_packet_h packet, bool * is_video);
  */
 int media_packet_is_audio(media_packet_h packet, bool * is_audio);
 
+/**
+ * @brief Checks whether the given media packet is for text.
+ * @since_tizen 3.0
+ *
+ * @param[in]  packet    The media packet handle
+ * @param[out] is_text  @c true if the given media packet is for text,
+ *                       otherwise @c false if the given media packet is not for text
+ *
+ * @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
+ * @see media_format_mimetype_e
+ * @see media_format_type_e
+ */
+int media_packet_is_text(media_packet_h packet, bool * is_text);
+
 /**
  * @brief Checks whether the given media packet is encoded type.
  * @since_tizen 2.3
@@ -913,6 +931,22 @@ int media_packet_get_video_plane_data_ptr(media_packet_h packet, int plane_idx,
  */
 int media_packet_get_codec_data(media_packet_h packet, void **codec_data, unsigned int *codec_data_size);
 
+/**
+ * @brief Sets codec data and the codec data size of media packet.
+ * @since_tizen 3.0
+ *
+ * @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);
+
 /**
  * @brief Destroys the media packet handle.
  * @details  The registered finalize_callback() function will be invoked to destroy the media packet handle.
index d0f7ad332eff28adc9845dde62302056a883fb48..ab9a8b6ed9b2262b00b4df444b7b01034a78c0c1 100755 (executable)
@@ -33,23 +33,6 @@ extern "C" {
  * @{
  */
 
-/**
- * @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);
-
 /**
  * @}
  */
index f4cc1f1f0f5d385bec75047a99fcae3c709a9bfd..85aa403ea3bf22a4a36f2b9af808c7e98a659fdc 100755 (executable)
@@ -99,6 +99,27 @@ int media_format_get_container_mime(media_format_h fmt, media_format_mimetype_e
        return ret;
 }
 
+int media_format_get_text_info(media_format_h fmt, media_format_mimetype_e * mimetype, media_format_text_type_e * type)
+{
+       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_TEXT)) {
+               LOGE("The format handle is not for MEDIA_FORMAT_TEXT..\n");
+               return MEDIA_FORMAT_ERROR_INVALID_OPERATION;
+       }
+
+       if (mimetype)
+               *mimetype = fmt_handle->mimetype;
+       if (type)
+               *type = fmt_handle->detail.text.type;
+
+       return ret;
+}
+
 int media_format_get_video_info(media_format_h fmt, media_format_mimetype_e * mimetype, int *width, int *height, int *avg_bps, int *max_bps)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
@@ -171,6 +192,26 @@ int media_format_get_audio_aac_type(media_format_h fmt, bool * is_adts)
        return ret;
 }
 
+int media_format_get_audio_aac_header_type(media_format_h fmt, media_format_aac_header_type_e * aac_header_type)
+{
+
+       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 (aac_header_type)
+               *aac_header_type = fmt_handle->detail.audio.aac_header_type;
+
+       return ret;
+}
+
 int media_format_get_video_frame_rate(media_format_h fmt, int *frame_rate)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
@@ -212,6 +253,50 @@ int media_format_set_container_mime(media_format_h fmt, media_format_mimetype_e
        return ret;
 }
 
+int media_format_set_text_mime(media_format_h fmt, media_format_mimetype_e mimetype)
+{
+       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 (!(mimetype & MEDIA_FORMAT_TEXT)) {
+               return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+       }
+
+       fmt_handle->mimetype = mimetype;
+
+       return ret;
+}
+
+int media_format_set_text_type(media_format_h fmt, media_format_text_type_e type)
+{
+       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_TEXT)) {
+               return MEDIA_FORMAT_ERROR_INVALID_PARAMETER;
+       }
+
+       fmt_handle->detail.text.type = type;
+
+       return ret;
+}
+
 int media_format_set_video_mime(media_format_h fmt, media_format_mimetype_e mimetype)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
@@ -493,6 +578,30 @@ int media_format_set_audio_aac_type(media_format_h fmt, bool is_adts)
        return ret;
 }
 
+int media_format_set_audio_aac_header_type(media_format_h fmt, media_format_aac_header_type_e aac_header_type)
+{
+
+       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.aac_header_type = aac_header_type;
+
+       return ret;
+}
+
 int media_format_ref(media_format_h fmt)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
index 5b625bd16d0db28aa5ef34dba62b4053d21b0fbd..c26b82fd32a6459c12e1348e6c9963cfec1832f9 100755 (executable)
@@ -30,6 +30,7 @@
 static int _pkt_alloc_buffer(media_packet_s * pkt);
 static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt);
 static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt);
+static uint64_t _pkt_calculate_text_buffer_size(media_packet_s * pkt);
 static uint32_t _convert_to_tbm_surface_format(media_format_mimetype_e format_type);
 static void *_aligned_malloc_normal_buffer_type(uint64_t size, int alignment);
 static void _aligned_free_normal_buffer_type(void *buffer_ptr);
@@ -46,8 +47,8 @@ int media_packet_create_alloc(media_format_h fmt, media_packet_finalize_cb fcb,
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
-               LOGE("The media format handle is not specified. set video info or audio info...");
+       if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt) && !MEDIA_FORMAT_IS_TEXT(fmt)) {
+               LOGE("The media format handle is not specified. set video info, audio info or text info...");
                return MEDIA_PACKET_ERROR_INVALID_OPERATION;
        }
 
@@ -120,8 +121,8 @@ int media_packet_create(media_format_h fmt, media_packet_finalize_cb fcb, void *
                return MEDIA_PACKET_ERROR_INVALID_PARAMETER;
        }
 
-       if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt)) {
-               LOGE("The media format handle is not specified. set video info or audio info...");
+       if (!MEDIA_FORMAT_IS_VIDEO(fmt) && !MEDIA_FORMAT_IS_AUDIO(fmt) && !MEDIA_FORMAT_IS_TEXT(fmt)) {
+               LOGE("The media format handle is not specified. set video info, audio info or text info...");
                return MEDIA_PACKET_ERROR_INVALID_OPERATION;
        }
        /* TODO : need more validation on fmt */
@@ -266,12 +267,18 @@ int _pkt_alloc_buffer(media_packet_s * pkt)
                        if (!pkt->data) {
                                return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
                        }
-               } else {
+               } else if (MEDIA_FORMAT_IS_AUDIO(pkt->format)) {
                        buffersize = _pkt_calculate_audio_buffer_size(pkt);
                        pkt->data = (void *)malloc(buffersize);
                        if (!pkt->data) {
                                return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
                        }
+               } else {
+                       buffersize = _pkt_calculate_text_buffer_size(pkt);
+                       pkt->data = (void *)malloc(buffersize);
+                       if (!pkt->data) {
+                               return MEDIA_PACKET_ERROR_OUT_OF_MEMORY;
+                       }
                }
                pkt->size = buffersize;
        } else if (pkt->type == MEDIA_BUFFER_TYPE_TBM_SURFACE) {
@@ -334,8 +341,6 @@ 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)
 #define _ROUND_UP_X(v, x) (((v) + _GEN_MASK(x)) & ~_GEN_MASK(x))
@@ -360,6 +365,7 @@ static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt)
        switch (pkt->format->mimetype) {
 
        case MEDIA_FORMAT_I420:
+       case MEDIA_FORMAT_YV12:
                x_chroma_shift = 1;
                y_chroma_shift = 1;
                stride = _ROUND_UP_16(width);
@@ -371,36 +377,30 @@ static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt)
                size2 = stride2 * h2;
                buffersize = size + 2 * size2;
                break;
-
        case MEDIA_FORMAT_YUYV:
        case MEDIA_FORMAT_UYVY:
        case MEDIA_FORMAT_NV16:
-               stride = _ROUND_UP_16(width * 2);
-               size = stride * height;
-               buffersize = size;
-               break;
-
        case MEDIA_FORMAT_RGB565:
+       case MEDIA_FORMAT_422P:
                stride = _ROUND_UP_16(width * 2);
                size = stride * height;
                buffersize = size;
                break;
-
        case MEDIA_FORMAT_RGB888:
                stride = _ROUND_UP_16(width * 3);
                size = stride * height;
                buffersize = size;
                break;
-
        case MEDIA_FORMAT_ARGB:
        case MEDIA_FORMAT_RGBA:
+       case MEDIA_FORMAT_BGRA:
                stride = width * 4;
                size = stride * height;
                buffersize = size;
                break;
-
        case MEDIA_FORMAT_NV12:
        case MEDIA_FORMAT_NV12T:
+       case MEDIA_FORMAT_NV21:
        case MEDIA_FORMAT_H261:
        case MEDIA_FORMAT_H263:
        case MEDIA_FORMAT_H263P:
@@ -435,20 +435,25 @@ static uint64_t _pkt_calculate_video_buffer_size(media_packet_s * pkt)
        return buffersize;
 }
 
-/* TODO : written by joungkook seo for audio */
-/* TODO : rename below macro or make it able to use original from mm_transform */
-#define PCM_MAX_FRM_SIZE        (2048)
+#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 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)
+#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)
 {
@@ -456,27 +461,38 @@ static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt)
        int bit = 0;
        uint64_t buffersize = 0;
 
-       if (!MEDIA_FORMAT_IS_VIDEO(pkt->format)) {
+       if (MEDIA_FORMAT_IS_AUDIO(pkt->format)) {
                channel = pkt->format->detail.audio.channel;
                bit = pkt->format->detail.audio.bit;
        }
 
        switch (pkt->format->mimetype) {
        case MEDIA_FORMAT_PCM:
-               buffersize = (PCM_MAX_FRM_SIZE * channel) * (uint64_t) (bit / 8);
+               buffersize = (PCM_MAX_FRM_SIZE * PCM_MAX_NCH) * (uint64_t) (bit / 8);
                break;
        case MEDIA_FORMAT_AAC_LC:
        case MEDIA_FORMAT_AAC_HE:
        case MEDIA_FORMAT_AAC_HE_PS:
        case MEDIA_FORMAT_MP3:
                buffersize = (MPEG_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2);       /* 2 = (16bit/8) */
+               break;
                /* TODO : extenstion format */
        case MEDIA_FORMAT_AMR_NB:
        case MEDIA_FORMAT_AMR_WB:
-               buffersize = (AMR_MAX_FRM_SIZE * MPEG_MIN_NCH) * (uint64_t) (2);        /* 2 = (16bit/8) */
+               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;
@@ -487,6 +503,21 @@ static uint64_t _pkt_calculate_audio_buffer_size(media_packet_s * pkt)
        return buffersize;
 }
 
+#define TXT_MAX_FRM_SIZE (2048)
+static uint64_t _pkt_calculate_text_buffer_size(media_packet_s * pkt)
+{
+       uint64_t buffersize = 0;
+       switch (pkt->format->mimetype) {
+       case MEDIA_FORMAT_TEXT_MP4:
+               buffersize = TXT_MAX_FRM_SIZE;
+               break;
+       default:
+               LOGE("Not supported text format\n");
+               return 0;
+       }
+       return buffersize;
+}
+
 int media_packet_create_from_tbm_surface(media_format_h fmt, tbm_surface_h surface, media_packet_finalize_cb fcb, void *fcb_data, media_packet_h * packet)
 {
        media_packet_s *handle;
@@ -871,6 +902,24 @@ int media_packet_is_audio(media_packet_h packet, bool * is_audio)
        return ret;
 }
 
+int media_packet_is_text(media_packet_h packet, bool * is_text)
+{
+       media_packet_s *handle;
+       int ret = MEDIA_PACKET_ERROR_NONE;
+
+       MEDIA_PACKET_INSTANCE_CHECK(packet);
+       MEDIA_PACKET_NULL_ARG_CHECK(is_text);
+
+       handle = (media_packet_s *) packet;
+
+       if (MEDIA_FORMAT_IS_TEXT(handle->format))
+               *is_text = true;
+       else
+               *is_text = false;
+
+       return ret;
+}
+
 int media_packet_is_encoded(media_packet_h packet, bool * is_encoded)
 {
        media_packet_s *handle;
@@ -1212,6 +1261,31 @@ int media_packet_get_codec_data(media_packet_h packet, void **codec_data, unsign
        return ret;
 }
 
+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;
+}
+
 int media_packet_destroy(media_packet_h packet)
 {
        media_packet_s *handle;
@@ -1306,6 +1380,9 @@ static uint32_t _convert_to_tbm_surface_format(media_format_mimetype_e format_ty
        case MEDIA_FORMAT_ARGB:
                tbm_format = TBM_FORMAT_ARGB8888;
                break;
+       case MEDIA_FORMAT_BGRA:
+               tbm_format = TBM_FORMAT_BGRA8888;
+               break;
        default:
                LOGE("Invalid media format mime type!");
                tbm_format = 0;
index 24e909daa59277dfe662d6dfc53f7d26fca0a77f..81e223e011ed3c880f7e63df0e02cb425e5dc903 100755 (executable)
 #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;
-}