#define GET_IS_DECODER(x) CHECK_BIT(x, 1)
#define GET_IS_HW(x) CHECK_BIT(x, 2)
#define GET_IS_SW(x) CHECK_BIT(x, 3)
-
-//#define GET_IS_OMX(x) CHECK_BIT(x, 4)
-//#define GET_IS_GEN(x) CHECK_BIT(x, 5)
+/*
+#define GET_IS_OMX(x) CHECK_BIT(x, 4)
+#define GET_IS_GEN(x) CHECK_BIT(x, 5)
+*/
#if 1
#define MEDIACODEC_FENTER();
#define MEDIACODEC_FLEAVE();
#else
-#define MEDIACODEC_FENTER(); LOGW("%s Enter",__FUNCTION__);
-#define MEDIACODEC_FLEAVE(); LOGW("%s Exit",__FUNCTION__);
+#define MEDIACODEC_FENTER(); LOGW("%s Enter", __FUNCTION__);
+#define MEDIACODEC_FLEAVE(); LOGW("%s Exit", __FUNCTION__);
#endif
/*---------------------------------------------------------------------------
/**
* @brief Enumerations of media codec port's retrun value
*/
-typedef enum
-{
- MC_ERROR_NONE = 0,
- MC_ERROR = -1, /**< codec happens error */
- MC_MEMORY_ERROR = -2, /**< codec memory is not enough */
- MC_PARAM_ERROR = -3, /**< codec parameter is error */
- MC_INVALID_ARG = -4, /** < codec has invalid arguments */
- MC_PERMISSION_DENIED = -5,
- MC_INVALID_STATUS = -6, /**< codec works at invalid status */
- MC_NOT_SUPPORTED = -7, /**< codec can't support this specific video format */
- MC_INVALID_IN_BUF = -8,
- MC_INVALID_OUT_BUF = -9,
- MC_INTERNAL_ERROR = -10,
- MC_HW_ERROR = -11, /**< codec happens hardware error */
- MC_NOT_INITIALIZED = -12,
- MC_INVALID_STREAM = -13,
- MC_CODEC_NOT_FOUND = -14,
- MC_ERROR_DECODE = -15,
- MC_OUTPUT_BUFFER_EMPTY = -16,
- MC_OUTPUT_BUFFER_OVERFLOW = -17, /**< codec output buffer is overflow */
- MC_MEMORY_ALLOCED = -18, /**< codec has got memory and can decode one frame */
- MC_COURRPTED_INI = -19,
+typedef enum {
+ MC_ERROR_NONE = 0,
+ MC_ERROR = -1, /**< codec happens error */
+ MC_MEMORY_ERROR = -2, /**< codec memory is not enough */
+ MC_PARAM_ERROR = -3, /**< codec parameter is error */
+ MC_INVALID_ARG = -4, /** < codec has invalid arguments */
+ MC_PERMISSION_DENIED = -5,
+ MC_INVALID_STATUS = -6, /**< codec works at invalid status */
+ MC_NOT_SUPPORTED = -7, /**< codec can't support this specific video format */
+ MC_INVALID_IN_BUF = -8,
+ MC_INVALID_OUT_BUF = -9,
+ MC_INTERNAL_ERROR = -10,
+ MC_HW_ERROR = -11, /**< codec happens hardware error */
+ MC_NOT_INITIALIZED = -12,
+ MC_INVALID_STREAM = -13,
+ MC_CODEC_NOT_FOUND = -14,
+ MC_ERROR_DECODE = -15,
+ MC_OUTPUT_BUFFER_EMPTY = -16,
+ MC_OUTPUT_BUFFER_OVERFLOW = -17, /**< codec output buffer is overflow */
+ MC_MEMORY_ALLOCED = -18, /**< codec has got memory and can decode one frame */
+ MC_COURRPTED_INI = -19,
+ MC_OUT_OF_MEMORY = -20, /**< when memory is not allocated */
} mc_ret_e;
+typedef enum {
+ NONE,
+ L16,
+ ALAW,
+ ULAW,
+ AMR_NB,
+ AMR_WB,
+ G729,
+ AAC_LC,
+ AAC_HE,
+ AAC_HE_PS,
+ MP3,
+ VORBIS,
+ FLAC,
+ WMAV1,
+ WMAV2,
+ WMAPRO,
+ WMALSL,
+ H261,
+ H263,
+ H264,
+ MJPEG,
+ MPEG1,
+ MPEG2,
+ MPEG4,
+ HEVC,
+ VP8,
+ VP9,
+ VC1,
+ CODEC_NR_ITEMS
+} codec_type_e;
+
/*---------------------------------------------------------------------------
| GLOBAL DATA TYPE DEFINITIONS: |
---------------------------------------------------------------------------*/
typedef void (*mc_supported_codec_cb)(mediacodec_codec_type_e codec_type, void *user_data);
typedef enum {
- _MEDIACODEC_EVENT_TYPE_COMPLETE,
- _MEDIACODEC_EVENT_TYPE_EMPTYBUFFER,
- _MEDIACODEC_EVENT_TYPE_FILLBUFFER,
- _MEDIACODEC_EVENT_TYPE_ERROR,
- _MEDIACODEC_EVENT_TYPE_EOS,
- _MEDIACODEC_EVENT_TYPE_BUFFER_STATUS,
- _MEDIACODEC_EVENT_TYPE_INTERNAL_FILLBUFFER,
- _MEDIACODEC_EVENT_TYPE_SUPPORTED_CODEC,
- _MEDIACODEC_EVENT_TYPE_NUM
+ _MEDIACODEC_EVENT_TYPE_COMPLETE,
+ _MEDIACODEC_EVENT_TYPE_EMPTYBUFFER,
+ _MEDIACODEC_EVENT_TYPE_FILLBUFFER,
+ _MEDIACODEC_EVENT_TYPE_ERROR,
+ _MEDIACODEC_EVENT_TYPE_EOS,
+ _MEDIACODEC_EVENT_TYPE_BUFFER_STATUS,
+ _MEDIACODEC_EVENT_TYPE_INTERNAL_FILLBUFFER,
+ _MEDIACODEC_EVENT_TYPE_SUPPORTED_CODEC,
+ _MEDIACODEC_EVENT_TYPE_NUM
} _mediacodec_event_e;
-typedef enum _mc_codec_port_type_e
-{
- CODEC_PORT_TYPE_GENERAL,
- CODEC_PORT_TYPE_OMX,
- CODEC_PORT_TYPE_GST,
- CODEC_PORT_TYPE_MAX,
+typedef enum _mc_codec_port_type_e {
+ CODEC_PORT_TYPE_GENERAL,
+ CODEC_PORT_TYPE_OMX,
+ CODEC_PORT_TYPE_GST,
+ CODEC_PORT_TYPE_MAX,
} mc_codec_port_type_e;
-typedef enum _mc_vendor_e
-{
- MC_VENDOR_DEFAULT,
- MC_VENDOR_SLSI_SEC,
- MC_VENDOR_SLSI_EXYNOS,
- MC_VENDOR_QCT,
- MC_VENDOR_SPRD
-} mc_vendor_e;
-
-struct _mc_decoder_info_t
-{
- int width;
- int height;
- int actwidth;
- int actheight;
-
- int samplerate;
- int channel;
- int bit;
-};
-
-struct _mc_encoder_info_t
-{
- int width;
- int height;
- int bitrate;
- int format;
- int fps;
- int qp_min;
- int qp_max;
- int vbvbuffer_size;
- int level;
- int profile;
-
- int samplerate;
- int channel;
- int bit;
-};
+typedef struct mc_audio_port_definition_t {
+ gint samplerate;
+ gint channel;
+ gint bit_depth;
+ gint bitrate;
+} mc_audio_port_definition_t;
+
+typedef struct mc_video_port_definition_t {
+ gchar *format;
+ gint width;
+ gint height;
+ gint stride;
+ gint bitrate;
+ gint framerate;
+} mc_video_port_definition_t;
/* Codec Private data */
-struct _mc_handle_t
-{
- int state; /**< mc current state */
- bool is_encoder;
- bool is_video;
- bool is_hw;
- bool is_prepared;
-
- GList *supported_codecs;
- mediacodec_port_type_e port_type;
- mediacodec_codec_type_e codec_id;
- mc_vendor_e vendor;
-
- void *ports[2];
- void *core;
-
- union
- {
- mc_decoder_info_t decoder;
- mc_encoder_info_t encoder;
- } info;
-
- /* for process done cb */
- void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
- void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
-
- mc_codec_map_t encoder_map[MEDIA_CODEC_MAX_CODEC_TYPE];
- mc_codec_map_t decoder_map[MEDIA_CODEC_MAX_CODEC_TYPE];
-
- int num_supported_codecs;
- int num_supported_decoder;
- int num_supported_encoder;
-
- mc_ini_t ini;
+struct _mc_handle_t {
+ int state; /**< mc current state */
+ bool is_encoder;
+ bool is_video;
+ bool is_hw;
+ bool is_prepared;
+
+ mediacodec_port_type_e port_type;
+ mediacodec_codec_type_e codec_id;
+
+ void *ports[2];
+ void *core;
+
+ union {
+ mc_audio_port_definition_t audio;
+ mc_video_port_definition_t video;
+ } info;
+
+ /* for process done cb */
+ void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
+ void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
+
+ mc_codec_map_t encoder_map[MEDIA_CODEC_MAX_CODEC_TYPE];
+ mc_codec_map_t decoder_map[MEDIA_CODEC_MAX_CODEC_TYPE];
+
+ int num_supported_decoder;
+ int num_supported_encoder;
+
+ mc_ini_t *ini;
};
/*===========================================================================================
int mc_set_adec_info(MMHandleType mediacodec, int samplerate, int channel, int bit);
int mc_set_aenc_info(MMHandleType mediacodec, int samplerate, int channel, int bit, int bitrate);
+int mc_configure(MMHandleType mediacodec, media_format_h format, int flags);
+
int mc_prepare(MMHandleType mediacodec);
int mc_unprepare(MMHandleType mediacodec);
int mc_flush_buffers(MMHandleType mediacodec);
int mc_get_supported_type(MMHandleType mediacodec, mediacodec_codec_type_e codec_type, bool encoder, int *support_type);
+int mc_get_packet_pool(MMHandleType mediacodec, media_packet_pool_h *pool);
+
int mc_set_empty_buffer_cb(MMHandleType mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data);
int mc_unset_empty_buffer_cb(MMHandleType mediacodec);
int mc_set_buffer_status_cb(MMHandleType mediacodec, mediacodec_buffer_status_cb callback, void* user_data);
int mc_unset_buffer_status_cb(MMHandleType mediacodec);
int mc_set_supported_codec_cb(MMHandleType mediacodec, mediacodec_supported_codec_cb callback, void* user_data);
-int _mediacodec_foreach_supported_codec(MMHandleType mediacodec, mediacodec_supported_codec_cb callback, void* user_data);
+int _mediacodec_foreach_supported_codec(mediacodec_supported_codec_cb callback, void* user_data);
+
+void _mc_create_codec_map_from_ini(mc_handle_t *mc_handle, mc_codec_spec_t *spec_emul);
+void _mc_create_codec_map_from_ini_static(mc_ini_t *ini, mc_codec_spec_t *spec_emul);
+void _mc_create_decoder_map_from_ini(mc_handle_t *mc_handle);
+void _mc_create_encoder_map_from_ini(mc_handle_t *mc_handle);
+
+const codec_type_e simple_to_codec_type_enumeration(codec_type_e codec_id);
+const codec_type_e codec_type_to_simple_enumeration(mediacodec_codec_type_e media_codec_id);
+
#ifdef __cplusplus
}
#endif