3 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __TIZEN_MEDIA_CODEC_PORT_GST_H__
19 #define __TIZEN_MEDIA_CODEC_PORT_GST_H__
22 #include <media_codec.h>
23 #include <media_codec_private.h>
24 #include <media_codec_port.h>
25 #include <media_codec_bitstream.h>
27 #include <tbm_surface.h>
28 #include <tbm_surface_internal.h>
29 #include <gst/video/video-format.h>
30 #include <gst/allocators/gsttizenmemory.h>
36 #define GST_INIT_STRUCTURE(param) \
37 memset(&(param), 0, sizeof(param));
40 #define SCMN_IMGB_MAX_PLANE 4
41 #define TBM_API_CHANGE
42 #define DEFAULT_DEC_POOL_SIZE 20
43 #define DEFAULT_ENC_POOL_SIZE 13
44 #define CODECDATA_NOT_USE 0x7FFFFFFF
45 #define AAC_CODECDATA_SIZE 16
46 #define WMA_CODECDATA_SIZE 64
47 #define VORBIS_CODECDATA_SIZE 4096
48 #define MAXINUM_QNUM 20
49 #define THRESHOLD_QNUM 5
52 typedef struct _mc_gst_port_def_t mc_gst_port_def_t;
53 typedef struct _mc_gst_port_t mc_gst_port_t;
54 typedef struct _mc_gst_core_t mc_gst_core_t;
55 typedef struct _GstMCBuffer GstMCBuffer;
64 struct _mc_gst_port_def_t {
66 media_format_mimetype_e coding_type;
68 mc_audio_port_definition_t audio;
69 mc_video_port_definition_t video;
73 struct _mc_gst_port_t {
78 gboolean is_allocated;
82 mc_gst_port_def_t port_def;
85 struct _mc_gst_core_t {
90 GstElement *audioconvert;
91 GstElement *audioresample;
92 GstElement *videoscale;
93 GstElement *videoconvert;
94 GstElement *capsfilter;
102 GMainContext *thread_default;
103 gulong signal_handoff;
108 GMutex eos_wait_mutex;
112 GCond out_buffer_cond;
114 GCond eos_waiting_cond;
116 gboolean output_allocated;
121 gboolean eos_waiting;
122 gboolean codec_config;
125 gboolean need_codec_data;
126 gboolean need_sync_flag;
127 gboolean unprepare_flag;
129 guint num_live_buffers;
133 mediacodec_codec_type_e codec_id;
134 media_format_mimetype_e out_mime;
135 media_format_h output_fmt;
136 mc_gst_port_t *ports[2];
138 mc_codec_type_t *codec_type;
140 mc_aqueue_t *available_queue;
141 GQueue *output_queue;
143 GstBuffer *codec_data;
144 gboolean (*mc_caps_new)(mc_gst_core_t *, mediacodec_codec_type_e, gint);
145 GstAllocator *allocator;
147 void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
148 void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
150 GstVideoInfo *video_info;
153 struct _GstMCBuffer {
157 media_packet_h packet;
162 enum { fill_inbuf, fill_outbuf };
163 mc_ret_e mc_gst_prepare(mc_handle_t *mc_handle);
164 mc_ret_e mc_gst_unprepare(mc_handle_t *mc_handle);
166 mc_ret_e mc_gst_process_input(mc_handle_t *mc_handle, media_packet_h inbuf, uint64_t timeout_us);
167 mc_ret_e mc_gst_get_output(mc_handle_t *mc_handle, media_packet_h *outbuf, uint64_t timeout_us);
169 mc_ret_e mc_gst_flush_buffers(mc_handle_t *mc_handle);
171 mc_ret_e mc_gst_get_packet_pool(mc_handle_t *mc_handle, media_packet_pool_h *packet_pool);
177 #endif /* __TIZEN_MEDIA_CODEC_PORT_GST_H__ */