#define __TIZEN_MEDIA_CODEC_PORT_GST_H__
#include <unistd.h>
-#include <tizen.h>
#include <media_codec.h>
#include <media_codec_private.h>
#include <media_codec_port.h>
#include <media_codec_bitstream.h>
-#include <tbm_type.h>
#include <tbm_surface.h>
-#include <tbm_bufmgr.h>
#include <tbm_surface_internal.h>
#include <gst/video/video-format.h>
+#include <gst/allocators/gsttizenmemory.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GST_INIT_STRUCTURE(param) \
- memset(&(param), 0, sizeof(param));
-
-#define MEDIACODEC_ELEMENT_SET_STATE( x_element, x_state ) \
- do { \
- LOGD("setting state [%s:%d] to [%s]\n", #x_state, x_state, GST_ELEMENT_NAME( x_element ) ); \
- if ( GST_STATE_CHANGE_FAILURE == gst_element_set_state ( x_element, x_state) ) \
- { \
- LOGE("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME( x_element )); \
- goto STATE_CHANGE_FAILED; \
- } \
- } while (0)
+ memset(&(param), 0, sizeof(param));
+
#define SCMN_IMGB_MAX_PLANE 4
#define TBM_API_CHANGE
-#define DEFAULT_POOL_SIZE 20
+#define DEFAULT_DEC_POOL_SIZE 20
+#define DEFAULT_ENC_POOL_SIZE 13
+#define CODECDATA_NOT_USE 0x7FFFFFFF
+#define AAC_CODECDATA_SIZE 16
+#define WMA_CODECDATA_SIZE 64
+#define VORBIS_CODECDATA_SIZE 4096
+#define MAXINUM_QNUM 20
+#define THRESHOLD_QNUM 5
/* gst port layer */
+typedef struct _mc_gst_port_def_t mc_gst_port_def_t;
typedef struct _mc_gst_port_t mc_gst_port_t;
typedef struct _mc_gst_core_t mc_gst_core_t;
typedef struct _GstMCBuffer GstMCBuffer;
+
typedef enum {
- BUF_SHARE_METHOD_PADDR = 0,
- BUF_SHARE_METHOD_FD,
- BUF_SHARE_METHOD_TIZEN_BUFFER,
- BUF_SHARE_METHOD_FLUSH_BUFFER
-} buf_share_method_t;
-
-#ifdef TIZEN_PROFILE_LITE
-struct ion_mmu_data {
- int master_id;
- int fd_buffer;
- unsigned long iova_addr;
- size_t iova_size;
+ in_port_index = 0,
+ out_port_index
+} port_index_e;
+
+
+struct _mc_gst_port_def_t {
+ gchar *mime_type;
+ media_format_mimetype_e coding_type;
+ union {
+ mc_audio_port_definition_t audio;
+ mc_video_port_definition_t video;
+ } info;
};
-#endif
-struct _mc_gst_port_t
-{
- mc_gst_core_t *core;
- unsigned int num_buffers;
- unsigned int buffer_size;
- unsigned int index;
- bool is_allocated;
- media_packet_h *buffers;
- //GSem
- GQueue *queue;
- GMutex mutex;
- GCond buffer_cond;
+struct _mc_gst_port_t {
+ mc_gst_core_t *core;
+ guint num_buffers;
+ guint buffer_size;
+ guint index;
+ gboolean is_allocated;
+ GQueue *queue;
+ GMutex mutex;
+ GCond buffer_cond;
+ mc_gst_port_def_t port_def;
};
-struct _mc_gst_core_t
-{
- int(**vtable)();
- const char *mime;
- //int format;
- gchar *format;
- GstElement* pipeline;
- GstElement* appsrc;
- GstElement* capsfilter;
- GstElement* parser;
- GstElement* fakesink;
- GstElement* codec;
- MMVideoBuffer *psimgb;
- tbm_bufmgr bufmgr;
- int drm_fd;
-
- GMainContext *thread_default;
- gulong signal_handoff;
- gint bus_whatch_id;
- gint probe_id;
-
- GMutex eos_mutex;
- GMutex eos_wait_mutex;
- GMutex prepare_lock;
- GMutex drain_lock;
- GCond eos_cond;
- GCond eos_waiting_cond;
-
- GstState state;
- bool output_allocated;
- bool encoder;
- bool video;
- bool is_hw;
- bool eos;
- bool eos_waiting;
- bool codec_config;
- bool need_feed;
- bool need_codec_data;
- bool need_sync_flag;
- bool unprepare_flag;
- unsigned int prepare_count;
- unsigned int num_live_buffers;
- unsigned int queued_count;
- unsigned int dequeued_count;
-
-
- mediacodec_codec_type_e codec_id;
- media_format_mimetype_e out_mime;
- media_format_h output_fmt;
- mc_gst_port_t *ports[2];
- mc_bitstream_t bits;
-
- mc_aqueue_t *available_queue;
- GQueue *output_queue;
-
- void *codec_info;
- unsigned char codec_data[100];
- int codec_data_size;
-
- void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
- void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
-
+struct _mc_gst_core_t {
+ gint(**vtable)();
+ const gchar *mime;
+ GstElement *pipeline;
+ GstElement *appsrc;
+ GstElement *audioconvert;
+ GstElement *audioresample;
+ GstElement *videoscale;
+ GstElement *videoconvert;
+ GstElement *capsfilter;
+ GstElement *parser;
+ GstElement *fakesink;
+ GstElement *codec;
+ GstCaps *caps;
+ tbm_bufmgr bufmgr;
+ gint drm_fd;
+
+ GMainContext *thread_default;
+ gulong signal_handoff;
+ gint bus_watch_id;
+ gint probe_id;
+
+ GMutex eos_mutex;
+ GMutex eos_wait_mutex;
+ GMutex prepare_lock;
+ GMutex drain_lock;
+ GCond buffer_cond;
+ GCond out_buffer_cond;
+ GCond eos_cond;
+ GCond eos_waiting_cond;
+
+ gboolean output_allocated;
+ gboolean encoder;
+ gboolean video;
+ gboolean is_hw;
+ gboolean eos;
+ gboolean eos_waiting;
+ gboolean codec_config;
+ gboolean need_drain;
+ gboolean need_feed;
+ gboolean need_codec_data;
+ gboolean need_sync_flag;
+ gboolean unprepare_flag;
+ guint prepare_count;
+ guint num_live_buffers;
+ guint etb_count;
+ gint64 offset;
+
+ mediacodec_codec_type_e codec_id;
+ media_format_mimetype_e out_mime;
+ media_format_h output_fmt;
+ mc_gst_port_t *ports[2];
+ mc_bitstream_t bits;
+ mc_codec_type_t *codec_type;
+
+ mc_aqueue_t *available_queue;
+ GQueue *output_queue;
+
+ GstBuffer *codec_data;
+ gboolean (*mc_caps_new)(mc_gst_core_t *, mediacodec_codec_type_e, gint);
+ GstAllocator *allocator;
+
+ void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
+ void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
+
+ GstVideoInfo *video_info;
+
+ mc_extra_converter_t *extra_converter;
};
-struct _GstMCBuffer
-{
- GstBuffer *buffer;
- int buf_size;
- mc_gst_core_t* core;
- media_packet_h pkt;
- bool has_imgb;
+struct _GstMCBuffer {
+ GstBuffer *buffer;
+ gint buf_size;
+ mc_gst_core_t* core;
+ media_packet_h packet;
+ void *ext_mem;
+ gboolean has_tbm;
};
-enum { fill_inbuf, fill_outbuf, create_caps };
-
-//int __mc_link_elements(mc_gst_core_t *core);
-int __mc_fill_input_buffer(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *buff);
-int __mc_fill_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt);
-int __mc_create_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, bool codec_config);
-
-//int __mc_venc_link(mc_gst_core_t *core);
-//int __mc_general_link(mc_gst_core_t *core);
-
-int __mc_fill_inbuf_with_mm_video_buffer(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *buff);
-int __mc_fill_inbuf_with_packet(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *buff);
-int __mc_fill_inbuf_with_venc_packet(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *mc_buffer);
-
-int __mc_fill_packet_with_outbuf(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt);
-int __mc_fill_venc_packet_with_outbuf(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt);
-int __mc_fill_video_packet_with_mm_video_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt);
-int __mc_fill_vdec_packet_with_outbuf(mc_gst_core_t *core, void *data, int size, media_packet_h *pkt);
-
-int __mc_vdec_h264_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_venc_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_vdec_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_vdec_h263_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_vdec_mpeg4_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_h264dec_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_sprddec_mpeg4_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_hw_h264enc_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_sprddec_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_sprdenc_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_sprdenc_mpeg4_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_aenc_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_aac_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_aenc_aac_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_aacv12_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_mp3_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_amrnb_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_amrwb_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_aenc_amrnb_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_vorbis_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_flac_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-int __mc_adec_wma_caps(mc_gst_core_t *core, GstCaps **caps, GstMCBuffer* buff, gboolean codec_config);
-
-void _mc_create_codec_map_from_ini(mc_handle_t *mc_handle, 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);
-mc_gst_core_t *mc_gst_core_new();
-void mc_gst_core_free(mc_gst_core_t *core);
-
-mc_gst_port_t *mc_gst_port_new(mc_gst_core_t *core);
-void mc_gst_port_free(mc_gst_port_t *port);
-
+enum { fill_inbuf, fill_outbuf };
mc_ret_e mc_gst_prepare(mc_handle_t *mc_handle);
mc_ret_e mc_gst_unprepare(mc_handle_t *mc_handle);
-mc_ret_e mc_gst_process_input(mc_handle_t *mc_handle, media_packet_h inbuf, uint64_t timeOutUs);
-mc_ret_e mc_gst_get_output(mc_handle_t *mc_handle, media_packet_h *outbuf, uint64_t timeOutUs);
+mc_ret_e mc_gst_process_input(mc_handle_t *mc_handle, media_packet_h inbuf, uint64_t timeout_us);
+mc_ret_e mc_gst_get_output(mc_handle_t *mc_handle, media_packet_h *outbuf, uint64_t timeout_us);
mc_ret_e mc_gst_flush_buffers(mc_handle_t *mc_handle);
-mc_ret_e mc_gst_get_packet_pool(mc_handle_t *mc_handle, media_packet_pool_h *pkt_pool);
+mc_ret_e mc_gst_get_packet_pool(mc_handle_t *mc_handle, media_packet_pool_h *packet_pool);
+
+mc_ret_e mc_gst_set_property_array_int(GstElement *element, const gchar *property_name, gint *array, guint array_length);
#ifdef __cplusplus
}