static mc_ret_e _mc_gst_destroy_pipeline(mc_gst_core_t *core);
static void __mc_gst_buffer_add(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer data);
static int __mc_output_buffer_finalize_cb(media_packet_h packet, int error_code, void *user_data);
-static int _mc_gst_update_caps(mc_gst_core_t *core, GstMCBuffer *buff, bool codec_config);
+static int _mc_gst_update_caps(mc_gst_core_t *core, GstMCBuffer *mcbuffer, bool codec_config);
static gboolean _mc_update_packet_info(mc_gst_core_t *core, media_format_h fmt);
-static GstMCBuffer *_mc_gst_media_packet_to_gstbuffer(mc_gst_core_t *core, media_packet_h pkt, bool codec_config);
-static int _mc_gst_gstbuffer_to_appsrc(mc_gst_core_t *core, GstMCBuffer *buff);
+static GstMCBuffer *_mc_gst_media_packet_to_gstbuffer(mc_gst_core_t *core, media_packet_h packet, bool codec_config);
+static int _mc_gst_gstbuffer_to_appsrc(mc_gst_core_t *core, GstMCBuffer *mcbuffer);
static gchar *__mc_get_gst_input_format(media_packet_h packet, bool is_hw);
static media_packet_h __mc_gst_make_media_packet(mc_gst_core_t *core, unsigned char *data, int size);
static gboolean __mc_gst_bus_callback(GstBus *bus, GstMessage *msg, gpointer data);
static GstBusSyncReply __mc_gst_bus_sync_callback(GstBus *bus, GstMessage *msg, gpointer data);
-static MMVideoBuffer *__mc_gst_make_tbm_buffer(mc_gst_core_t *core, media_packet_h pkt);
-static GstMCBuffer *gst_mediacodec_buffer_new(mc_gst_core_t *core, media_packet_h pkt, uint64_t size);
+static MMVideoBuffer *__mc_gst_make_tbm_buffer(mc_gst_core_t *core, media_packet_h packet);
+static GstMCBuffer *gst_mediacodec_buffer_new(mc_gst_core_t *core, media_packet_h packet, uint64_t size);
static void gst_mediacodec_buffer_finalize(GstMCBuffer *buffer);
-static int __mc_set_caps_streamheader(mc_gst_core_t *core, GstMCBuffer *buff, guint streamheader_size);
-static int __mc_set_caps_codecdata(mc_gst_core_t *core, GstMCBuffer *buff, guint codecdata_size);
-static void __mc_push_output_to_queue(mc_gst_core_t *core, media_packet_h out_pkt);
-static int __mc_gst_create_eos_packet(media_format_h fmt, media_packet_h *out_pkt);
-static void _mc_gst_handle_input_buffer_used(mc_gst_core_t *core, media_packet_h pkt);
+static int __mc_set_caps_streamheader(mc_gst_core_t *core, GstMCBuffer *mcbuffer, guint streamheader_size);
+static int __mc_set_caps_codecdata(mc_gst_core_t *core, GstMCBuffer *mcbuffer, guint codecdata_size);
+static void __mc_push_output_to_queue(mc_gst_core_t *core, media_packet_h out_packet);
+static int __mc_gst_create_eos_packet(media_format_h fmt, media_packet_h *out_packet);
+static void _mc_gst_handle_input_buffer_used(mc_gst_core_t *core, media_packet_h packet);
static gint __gst_handle_stream_error(mc_gst_core_t *core, GError *error, GstMessage *message);
static gint __gst_transform_gsterror(mc_gst_core_t *core, GstMessage *message, GError *error);
/*
* fill_inbuf virtual functions
*/
-int __mc_fill_input_buffer(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *buff)
+int __mc_fill_input_buffer(mc_gst_core_t *core, media_packet_h packet, GstMCBuffer *mcbuffer)
{
- return core->vtable[fill_inbuf](core, pkt, buff);
+ return core->vtable[fill_inbuf](core, packet, mcbuffer);
}
-int __mc_fill_inbuf_with_mm_video_buffer(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *mc_buffer)
+int __mc_fill_inbuf_with_mm_video_buffer(mc_gst_core_t *core, media_packet_h packet, GstMCBuffer *mcbuffer)
{
int ret = MC_ERROR_NONE;
void *buf_data = NULL;
uint64_t buf_size = 0;
- ret = media_packet_get_buffer_size(pkt, &buf_size);
+ ret = media_packet_get_buffer_size(packet, &buf_size);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGW("buffer size get fail");
+ LOGW("buffer size get failed");
return MC_ERROR;
}
- ret = media_packet_get_buffer_data_ptr(pkt, &buf_data);
+ ret = media_packet_get_buffer_data_ptr(packet, &buf_data);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGW("buffer data get fail");
+ LOGW("buffer data get failed");
return MC_ERROR;
}
- mm_vbuffer = __mc_gst_make_tbm_buffer(core, mc_buffer->pkt);
+ mm_vbuffer = __mc_gst_make_tbm_buffer(core, mcbuffer->packet);
if (mm_vbuffer != NULL) {
- gst_buffer_prepend_memory(mc_buffer->buffer,
+ gst_buffer_prepend_memory(mcbuffer->buffer,
gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, mm_vbuffer, sizeof(*mm_vbuffer), 0,
sizeof(*mm_vbuffer), mm_vbuffer, free));
- LOGD("scmn_mm_vbuffer is appended, %d, %d", sizeof(*mm_vbuffer), gst_buffer_n_memory(mc_buffer->buffer));
+ LOGD("mm_vbuffer appended, %d, %d", sizeof(*mm_vbuffer), gst_buffer_n_memory(mcbuffer->buffer));
}
if (buf_data != NULL) {
- gst_buffer_prepend_memory(mc_buffer->buffer,
+ gst_buffer_prepend_memory(mcbuffer->buffer,
gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, buf_data, buf_size, 0,
- buf_size, mc_buffer, (GDestroyNotify)gst_mediacodec_buffer_finalize));
- LOGD("packet data apended, %d, %d", buf_size, gst_buffer_n_memory(mc_buffer->buffer));
+ buf_size, mcbuffer, (GDestroyNotify)gst_mediacodec_buffer_finalize));
+ LOGD("packet data apended, %d, %d", buf_size, gst_buffer_n_memory(mcbuffer->buffer));
}
return ret;
}
-int __mc_fill_input_buffer_with_packet(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *mc_buffer)
+int __mc_fill_input_buffer_with_packet(mc_gst_core_t *core, media_packet_h packet, GstMCBuffer *mcbuffer)
{
int ret = MC_ERROR_NONE;
void *buf_data = NULL;
uint64_t buf_size = 0;
- ret = media_packet_get_buffer_size(pkt, &buf_size);
+ ret = media_packet_get_buffer_size(packet, &buf_size);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGW("buffer size get fail");
+ LOGW("buffer size get failed");
return MC_ERROR;
}
- ret = media_packet_get_buffer_data_ptr(pkt, &buf_data);
+ ret = media_packet_get_buffer_data_ptr(packet, &buf_data);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGW("buffer data get fail");
+ LOGW("buffer data get failed");
return MC_ERROR;
}
if (buf_data != NULL) {
- gst_buffer_append_memory(mc_buffer->buffer,
+ gst_buffer_append_memory(mcbuffer->buffer,
gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, buf_data, buf_size, 0,
- buf_size, mc_buffer, (GDestroyNotify)gst_mediacodec_buffer_finalize));
+ buf_size, mcbuffer, (GDestroyNotify)gst_mediacodec_buffer_finalize));
LOGD("packet data apended");
}
return ret;
}
-int __mc_fill_input_buffer_with_venc_packet(mc_gst_core_t *core, media_packet_h pkt, GstMCBuffer *mc_buffer)
+int __mc_fill_input_buffer_with_venc_packet(mc_gst_core_t *core, media_packet_h packet, GstMCBuffer *mcbuffer)
{
int ret = MC_ERROR_NONE;
void *uv_ptr = NULL;
width = enc_info->width;
height = enc_info->height;
- ret = media_packet_get_number_of_video_planes(pkt, &plane_num);
+ ret = media_packet_get_number_of_video_planes(packet, &plane_num);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("media_packet_get_number_of_video_planes failed");
return MC_ERROR;
}
- ret = media_packet_get_video_plane_data_ptr(pkt, 0, &y_ptr);
+ ret = media_packet_get_video_plane_data_ptr(packet, 0, &y_ptr);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("media_packet_get_video_plane_data_ptr failed");
return MC_ERROR;
}
- ret = media_packet_get_video_stride_width(pkt, 0, &stride_width);
+ ret = media_packet_get_video_stride_width(packet, 0, &stride_width);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("media_packet_get_video_stride_width failed");
return MC_ERROR;
}
- ret = media_packet_get_video_stride_height(pkt, 0, &stride_height);
+ ret = media_packet_get_video_stride_height(packet, 0, &stride_height);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("media_packet_get_video_stride_width failed");
return MC_ERROR;
}
if (!core->is_hw) {
-
if (width == stride_width) {
- mc_buffer->buf_size += stride_width * stride_height;
+ mcbuffer->buf_size += stride_width * stride_height;
for (i = 1; i < plane_num; i++) {
- media_packet_get_video_plane_data_ptr(pkt, i, &uv_ptr);
- media_packet_get_video_stride_width(pkt, i, &stride_width);
- media_packet_get_video_stride_height(pkt, i, &stride_height);
+ media_packet_get_video_plane_data_ptr(packet, i, &uv_ptr);
+ media_packet_get_video_stride_width(packet, i, &stride_width);
+ media_packet_get_video_stride_height(packet, i, &stride_height);
buf_size = stride_width * stride_height;
- memcpy(y_ptr + mc_buffer->buf_size, uv_ptr, buf_size);
- mc_buffer->buf_size += buf_size;
- LOGD("plane : %d, buf_size : %d, total : %d", i, buf_size, mc_buffer->buf_size);
-
+ memcpy(y_ptr + mcbuffer->buf_size, uv_ptr, buf_size);
+ mcbuffer->buf_size += buf_size;
+ LOGD("plane : %d, buf_size : %d, total : %d", i, buf_size, mcbuffer->buf_size);
}
} else {
for (j = 0; j < height; j++) {
- memcpy(y_ptr + mc_buffer->buf_size, y_ptr + stride, width);
- mc_buffer->buf_size += width;
+ memcpy(y_ptr + mcbuffer->buf_size, y_ptr + stride, width);
+ mcbuffer->buf_size += width;
stride += stride_width;
}
stride = 0;
for (i = 1; i < plane_num; i++) {
- media_packet_get_video_plane_data_ptr(pkt, i, &uv_ptr);
- media_packet_get_video_stride_width(pkt, i, &stride_width);
- media_packet_get_video_stride_height(pkt, i, &stride_height);
+ media_packet_get_video_plane_data_ptr(packet, i, &uv_ptr);
+ media_packet_get_video_stride_width(packet, i, &stride_width);
+ media_packet_get_video_stride_height(packet, i, &stride_height);
for (j = 0; j < height>>1; j++) {
- memcpy(y_ptr + mc_buffer->buf_size, uv_ptr + stride, width>>1);
- mc_buffer->buf_size += width>>1;
+ memcpy(y_ptr + mcbuffer->buf_size, uv_ptr + stride, width>>1);
+ mcbuffer->buf_size += width>>1;
stride += stride_width;
}
- memcpy(y_ptr + mc_buffer->buf_size, uv_ptr, buf_size);
- LOGD("plane : %d, buf_size : %d, total : %d", i, buf_size, mc_buffer->buf_size);
- mc_buffer->buf_size += buf_size;
+ memcpy(y_ptr + mcbuffer->buf_size, uv_ptr, buf_size);
+ LOGD("plane : %d, buf_size : %d, total : %d", i, buf_size, mcbuffer->buf_size);
+ mcbuffer->buf_size += buf_size;
}
}
} else {
MMVideoBuffer *mm_video_buffer = NULL;
- mm_video_buffer = __mc_gst_make_tbm_buffer(core, pkt);
+ mm_video_buffer = __mc_gst_make_tbm_buffer(core, packet);
- gst_buffer_prepend_memory(mc_buffer->buffer,
+ gst_buffer_prepend_memory(mcbuffer->buffer,
gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, mm_video_buffer, sizeof(MMVideoBuffer), 0,
sizeof(MMVideoBuffer), mm_video_buffer, free));
- LOGD("mm_video_buffer is appended, %d, %d", sizeof(MMVideoBuffer), gst_buffer_n_memory(mc_buffer->buffer));
+ LOGD("mm_video_buffer appended, %d, %d", sizeof(MMVideoBuffer), gst_buffer_n_memory(mcbuffer->buffer));
}
- gst_buffer_prepend_memory(mc_buffer->buffer,
- gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, y_ptr, mc_buffer->buf_size, 0,
- mc_buffer->buf_size, mc_buffer, (GDestroyNotify)gst_mediacodec_buffer_finalize));
+ gst_buffer_prepend_memory(mcbuffer->buffer,
+ gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, y_ptr, mcbuffer->buf_size, 0,
+ mcbuffer->buf_size, mcbuffer, (GDestroyNotify)gst_mediacodec_buffer_finalize));
return ret;
}
* fill_outbuf virtual functions
*/
-int __mc_fill_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt)
+int __mc_fill_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_packet)
{
- return core->vtable[fill_outbuf](core, data, size, out_pkt);
+ return core->vtable[fill_outbuf](core, data, size, out_packet);
}
-int __mc_fill_vdec_packet_with_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *pkt)
+int __mc_fill_vdec_packet_with_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *packet)
{
int i;
int stride_width;
if (tsurf) {
media_packet_create_from_tbm_surface(core->output_fmt, tsurf,
- (media_packet_finalize_cb)__mc_output_buffer_finalize_cb, core, pkt);
+ (media_packet_finalize_cb)__mc_output_buffer_finalize_cb, core, packet);
}
return MC_ERROR_NONE;
}
-int __mc_fill_packet_with_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt)
+int __mc_fill_packet_with_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_packet)
{
- void *pkt_data = NULL;
+ void *packet_data = NULL;
int ret = MC_ERROR_NONE;
g_return_val_if_fail(core != NULL, MC_PARAM_ERROR);
if (core->encoder && core->codec_id == MEDIACODEC_AAC)
media_format_set_audio_aac_type(core->output_fmt, FALSE);
- ret = media_packet_create_alloc(core->output_fmt, __mc_output_buffer_finalize_cb, core, out_pkt);
+ ret = media_packet_create_alloc(core->output_fmt, __mc_output_buffer_finalize_cb, core, out_packet);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("media_packet_create_alloc failed");
return MC_ERROR;
}
- media_packet_set_buffer_size(*out_pkt, size);
- media_packet_get_buffer_data_ptr(*out_pkt, &pkt_data);
- memcpy(pkt_data, data, size);
+ media_packet_set_buffer_size(*out_packet, size);
+ media_packet_get_buffer_data_ptr(*out_packet, &packet_data);
+ memcpy(packet_data, data, size);
return MC_ERROR_NONE;
}
-int __mc_fill_venc_packet_with_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_pkt)
+int __mc_fill_venc_packet_with_output_buffer(mc_gst_core_t *core, void *data, int size, media_packet_h *out_packet)
{
- void *pkt_data = NULL;
+ void *packet_data = NULL;
bool codec_config = FALSE;
bool sync_flag = FALSE;
bool slice = FALSE;
}
LOGD("codec_config : %d, sync_flag : %d, slice : %d", codec_config, sync_flag, slice);
- ret = media_packet_create_alloc(core->output_fmt, __mc_output_buffer_finalize_cb, core, out_pkt);
+ ret = media_packet_create_alloc(core->output_fmt, __mc_output_buffer_finalize_cb, core, out_packet);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("media_packet_create_alloc failed");
return MC_ERROR;
}
- media_packet_set_buffer_size(*out_pkt, size);
- media_packet_get_buffer_data_ptr(*out_pkt, &pkt_data);
- memcpy(pkt_data, data, size);
+ media_packet_set_buffer_size(*out_packet, size);
+ media_packet_get_buffer_data_ptr(*out_packet, &packet_data);
+ memcpy(packet_data, data, size);
core->need_sync_flag = sync_flag ? 1 : 0;
core->need_codec_data = codec_config ? 1 : 0;
return caps;
}
-int __mc_set_caps_streamheader(mc_gst_core_t *core, GstMCBuffer*buff, guint streamheader_size)
+int __mc_set_caps_streamheader(mc_gst_core_t *core, GstMCBuffer *mcbuffer, guint streamheader_size)
{
int ret = MEDIA_PACKET_ERROR_NONE;
void *buf_data = NULL;
guint8 *tmp_buf = NULL;
GstMapInfo map;
- ret = media_packet_get_buffer_size(buff->pkt, &buf_size);
+ ret = media_packet_get_buffer_size(mcbuffer->packet, &buf_size);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGW("buffer size get fail");
+ LOGW("buffer size get failed");
return ret;
}
- ret = media_packet_get_buffer_data_ptr(buff->pkt, &buf_data);
+ ret = media_packet_get_buffer_data_ptr(mcbuffer->packet, &buf_data);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGW("buffer data get fail");
+ LOGW("buffer data get failed");
return ret;
}
}
/* Update gstbuffer's data ptr and size for using previous streamheader.*/
- LOGD("BEFORE : buff->buffer of size %" G_GSIZE_FORMAT "", gst_buffer_get_size(buff->buffer));
- gst_buffer_remove_memory_range(buff->buffer, streamheader_size, -1);
- gst_buffer_set_size(buff->buffer, buf_size - streamheader_size);
- LOGD("AFTER : buff->buffer of size %" G_GSIZE_FORMAT "", gst_buffer_get_size(buff->buffer));
+ LOGD("BEFORE : mcbuffer->buffer of size %" G_GSIZE_FORMAT "", gst_buffer_get_size(mcbuffer->buffer));
+ gst_buffer_remove_memory_range(mcbuffer->buffer, streamheader_size, -1);
+ gst_buffer_set_size(mcbuffer->buffer, buf_size - streamheader_size);
+ LOGD("AFTER : mcbuffer->buffer of size %" G_GSIZE_FORMAT "", gst_buffer_get_size(mcbuffer->buffer));
return ret;
}
-int __mc_get_codecdata_size(mc_gst_core_t *core, GstMCBuffer *buff, unsigned int *size)
+int __mc_get_codecdata_size(mc_gst_core_t *core, GstMCBuffer *mcbuffer, unsigned int *size)
{
void *data = NULL;
uint64_t data_size = 0;
uint64_t codec_size = 0;
int ret = MC_ERROR_NONE;
- media_packet_get_buffer_size(buff->pkt, &data_size);
- media_packet_get_buffer_data_ptr(buff->pkt, &data);
+ media_packet_get_buffer_size(mcbuffer->packet, &data_size);
+ media_packet_get_buffer_data_ptr(mcbuffer->packet, &data);
switch (core->codec_id) {
case MEDIACODEC_H264:
return ret;
}
-int __mc_set_caps_codecdata(mc_gst_core_t *core, GstMCBuffer *buff, guint fixed_size)
+int __mc_set_caps_codecdata(mc_gst_core_t *core, GstMCBuffer *mcbuffer, guint fixed_size)
{
int ret = MC_ERROR_NONE;
void *codec_data = NULL;
guint8 *data = NULL;
GstMapInfo map;
- media_packet_get_codec_data(buff->pkt, &codec_data, &codec_data_size);
+ media_packet_get_codec_data(mcbuffer->packet, &codec_data, &codec_data_size);
if (codec_data != NULL) { /* get the codec data from media_packet_get_codec_data() */
data = g_malloc0(codec_data_size);
uint64_t buffer_size = 0;
void *buff_data = NULL;
- media_packet_get_buffer_size(buff->pkt, &buffer_size);
- media_packet_get_buffer_data_ptr(buff->pkt, &buff_data);
+ media_packet_get_buffer_size(mcbuffer->packet, &buffer_size);
+ media_packet_get_buffer_data_ptr(mcbuffer->packet, &buff_data);
/* For audio, it's necessary to change the offset value of buffer after extracting csd */
/* it's not necessary to set csd to caps in case of annex-b */
if (buffer_size > fixed_size) {
data = g_malloc0(fixed_size);
- gst_buffer_map(buff->buffer, &map, GST_MAP_READ);
+ gst_buffer_map(mcbuffer->buffer, &map, GST_MAP_READ);
memcpy(data, map.data, fixed_size);
codecdata_buffer = gst_buffer_new_wrapped(data, fixed_size);
- gst_buffer_unmap(buff->buffer, &map);
+ gst_buffer_unmap(mcbuffer->buffer, &map);
gst_caps_set_simple(core->caps, "codec_data", GST_TYPE_BUFFER, codecdata_buffer, NULL);
gst_buffer_unref(codecdata_buffer);
- gst_buffer_replace_memory(buff->buffer, 0,
+ gst_buffer_replace_memory(mcbuffer->buffer, 0,
gst_memory_new_wrapped(GST_MEMORY_FLAG_READONLY, buff_data + fixed_size , buffer_size - fixed_size, 0,
- buffer_size - fixed_size, buff, NULL));
+ buffer_size - fixed_size, mcbuffer, NULL));
- LOGD("set codec data from packet: %" G_GSIZE_FORMAT "", gst_buffer_get_size(buff->buffer));
+ LOGD("set codec data from packet: %" G_GSIZE_FORMAT "", gst_buffer_get_size(mcbuffer->buffer));
}
}
return ret;
core->ports[1] = NULL;
}
- LOGD("gst_core(%p) is destroyed", core);
+ LOGD("gst_core(%p) destroyed", core);
g_free(core);
MEDIACODEC_FLEAVE();
g_mutex_init(&port->mutex);
port->queue = g_queue_new();
- LOGD("gst_port(%p) is created", port);
+ LOGD("gst_port(%p) created", port);
MEDIACODEC_FLEAVE();
return port;
g_mutex_clear(&port->mutex);
g_queue_free(port->queue);
- LOGD("gst_port(%p) is freed", port);
+ LOGD("gst_port(%p) freed", port);
g_free(port);
MEDIACODEC_FLEAVE();
return is_updated;
}
-static int _mc_gst_update_caps(mc_gst_core_t *core, GstMCBuffer *buff, bool codec_config)
+static int _mc_gst_update_caps(mc_gst_core_t *core, GstMCBuffer *mcbuffer, bool codec_config)
{
MEDIACODEC_FENTER();
g_return_val_if_fail(core != NULL, MC_PARAM_ERROR);
- g_return_val_if_fail(buff != NULL, MC_PARAM_ERROR);
+ g_return_val_if_fail(mcbuffer != NULL, MC_PARAM_ERROR);
int ret = MC_ERROR_NONE;
if (core->encoder) {
mc_encoder_info_t *enc_info = (mc_encoder_info_t *)core->codec_info;
- core->format = __mc_get_gst_input_format(buff->pkt, core->is_hw);
+ core->format = __mc_get_gst_input_format(mcbuffer->packet, core->is_hw);
gst_caps_set_simple(core->caps,
"format", G_TYPE_STRING, core->format,
"width", G_TYPE_INT, enc_info->width,
"height", G_TYPE_INT, dec_info->height,
NULL);
- ret = __mc_set_caps_codecdata(core, buff, CODECDATA_NOT_USE);
+ ret = __mc_set_caps_codecdata(core, mcbuffer, CODECDATA_NOT_USE);
if (ret != MC_ERROR_NONE) {
LOGW("__mc_set_caps_codecdata failed");
}
case MEDIACODEC_AAC:
case MEDIACODEC_AAC_HE:
case MEDIACODEC_AAC_HE_PS:
- ret = __mc_set_caps_codecdata(core, buff, AAC_CODECDATA_SIZE);
+ ret = __mc_set_caps_codecdata(core, mcbuffer, AAC_CODECDATA_SIZE);
if (ret != MC_ERROR_NONE) {
LOGW("__mc_set_caps_codecdata failed");
}
case MEDIACODEC_WMAV2:
case MEDIACODEC_WMAPRO:
case MEDIACODEC_WMALSL:
- ret = __mc_set_caps_codecdata(core, buff, WMA_CODECDATA_SIZE);
+ ret = __mc_set_caps_codecdata(core, mcbuffer, WMA_CODECDATA_SIZE);
if (ret != MC_ERROR_NONE) {
LOGW("__mc_set_caps_codecdata failed");
}
break;
case MEDIACODEC_VORBIS:
case MEDIACODEC_FLAC:
- ret = __mc_set_caps_streamheader(core, buff, VORBIS_CODECDATA_SIZE);
+ ret = __mc_set_caps_streamheader(core, mcbuffer, VORBIS_CODECDATA_SIZE);
if (ret != MC_ERROR_NONE) {
LOGW("__mc_set_caps_streamheader failed");
}
bool eos = FALSE;
media_format_h fmt = NULL;
media_packet_h in_buf = NULL;
- GstMCBuffer *buff = NULL;
+ GstMCBuffer *mcbuffer = NULL;
bool initiative = true;
MEDIACODEC_FENTER();
goto LEAVE;
}
- buff = _mc_gst_media_packet_to_gstbuffer(core, in_buf, codec_config);
- if (!buff) {
+ mcbuffer = _mc_gst_media_packet_to_gstbuffer(core, in_buf, codec_config);
+ if (!mcbuffer) {
LOGW("gstbuffer can't make");
goto ERROR;
}
- /* buff took the ownership of the in_buf, so set in_buf to NULL to aviod double unref */
+ /* mcbuffer took the ownership of the in_buf, so set in_buf to NULL to aviod double unref */
in_buf = NULL;
if (codec_config)
if (initiative) {
GstPad *pad;
- ret = _mc_gst_update_caps(core, buff, codec_config);
+ ret = _mc_gst_update_caps(core, mcbuffer, codec_config);
if (ret != MC_ERROR_NONE) {
LOGE("failed to update caps");
- /* unref buff->buffer will invoke the finalize() of GstMcBuffer */
- gst_buffer_unref(buff->buffer);
+ /* unref mcbuff->buffer will invoke the finalize() of GstMcBuffer */
+ gst_buffer_unref(mcbuffer->buffer);
goto ERROR;
}
}
/* inject buffer */
- ret = _mc_gst_gstbuffer_to_appsrc(core, buff);
+ ret = _mc_gst_gstbuffer_to_appsrc(core, mcbuffer);
if (ret != GST_FLOW_OK) {
LOGE("Failed to push gst buffer");
goto ERROR;
return MC_ERROR_NONE;
}
-static int _mc_gst_gstbuffer_to_appsrc(mc_gst_core_t *core, GstMCBuffer *buff)
+static int _mc_gst_gstbuffer_to_appsrc(mc_gst_core_t *core, GstMCBuffer *mcbuffer)
{
MEDIACODEC_FENTER();
int ret = MC_ERROR_NONE;
LOGD("pushed buffer to appsrc : %p, buffer of size %" G_GSIZE_FORMAT "",
- buff->buffer, gst_buffer_get_size(buff->buffer));
+ mcbuffer->buffer, gst_buffer_get_size(mcbuffer->buffer));
- ret = gst_app_src_push_buffer(GST_APP_SRC(core->appsrc), buff->buffer);
+ ret = gst_app_src_push_buffer(GST_APP_SRC(core->appsrc), mcbuffer->buffer);
return ret;
}
int ret = MC_ERROR_NONE;
mc_gst_core_t *core = NULL;
- media_packet_h out_pkt = NULL;
+ media_packet_h out_packet = NULL;
gint64 end_time = -1;
gboolean signalled;
}
if (signalled)
- out_pkt = g_queue_pop_head(core->ports[1]->queue);
+ out_packet = g_queue_pop_head(core->ports[1]->queue);
else {
LOGW("Failed to get buffer");
ret = MC_OUTPUT_BUFFER_EMPTY;
}
- *outbuf = out_pkt;
- LOGI("@%p v(%d)e(%d) got buffer :%p", core, core->video, core->encoder, out_pkt);
+ *outbuf = out_packet;
+ LOGI("@%p v(%d)e(%d) got buffer :%p", core, core->video, core->encoder, out_packet);
g_mutex_unlock(&core->ports[1]->mutex);
return MC_ERROR;
}
-void __mc_push_output_to_queue(mc_gst_core_t *core, media_packet_h out_pkt)
+void __mc_push_output_to_queue(mc_gst_core_t *core, media_packet_h out_packet)
{
g_mutex_lock(&core->ports[1]->mutex);
/* push it to output buffer queue */
- g_queue_push_tail(core->ports[1]->queue, out_pkt);
+ g_queue_push_tail(core->ports[1]->queue, out_packet);
g_cond_broadcast(&core->out_buffer_cond);
g_atomic_int_inc(&core->ftb_count);
GstBuffer *buffer = NULL;
- media_packet_get_extra(out_pkt, (void**)&buffer);
+ media_packet_get_extra(out_packet, (void**)&buffer);
if (buffer) {
LOGD("dq : v(%d)e(%d) %d TIMESTAMP = %"GST_TIME_FORMAT " DURATION = %"GST_TIME_FORMAT, core->video, core->encoder,
core->ftb_count, GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)), GST_TIME_ARGS(GST_BUFFER_DURATION(buffer)));
if (core->user_cb[_MEDIACODEC_EVENT_TYPE_FILLBUFFER]) {
((mc_fill_buffer_cb) core->user_cb[_MEDIACODEC_EVENT_TYPE_FILLBUFFER])
- (out_pkt, core->user_data[_MEDIACODEC_EVENT_TYPE_FILLBUFFER]);
+ (out_packet, core->user_data[_MEDIACODEC_EVENT_TYPE_FILLBUFFER]);
}
}
guint n;
GstMemory *mem;
GstMapInfo map = GST_MAP_INFO_INIT;
- media_packet_h out_pkt = NULL;
+ media_packet_h out_packet = NULL;
MEDIACODEC_FENTER();
gst_memory_map(mem, &map, GST_MAP_READ);
LOGD("n : %d, map.data : %p, map.size : %d", n, map.data, map.size);
- out_pkt = __mc_gst_make_media_packet(core, map.data, map.size);
+ out_packet = __mc_gst_make_media_packet(core, map.data, map.size);
- LOGI("@%p(%d) out_pkt : %p", core, core->encoder, out_pkt);
+ LOGI("@%p(%d) out_packet : %p", core, core->encoder, out_packet);
gst_memory_unmap(mem, &map);
- if (out_pkt) {
- media_packet_set_extra(out_pkt, buffer);
- media_packet_set_pts(out_pkt, GST_BUFFER_TIMESTAMP(buffer));
- media_packet_set_duration(out_pkt, GST_BUFFER_DURATION(buffer));
+ if (out_packet) {
+ media_packet_set_extra(out_packet, buffer);
+ media_packet_set_pts(out_packet, GST_BUFFER_TIMESTAMP(buffer));
+ media_packet_set_duration(out_packet, GST_BUFFER_DURATION(buffer));
if (core->need_codec_data) {
- media_packet_set_flags(out_pkt, MEDIA_PACKET_CODEC_CONFIG);
+ media_packet_set_flags(out_packet, MEDIA_PACKET_CODEC_CONFIG);
core->need_codec_data = false;
}
if (core->need_sync_flag) {
- media_packet_set_flags(out_pkt, MEDIA_PACKET_SYNC_FRAME);
+ media_packet_set_flags(out_packet, MEDIA_PACKET_SYNC_FRAME);
core->need_sync_flag = false;
}
- __mc_push_output_to_queue(core, out_pkt);
+ __mc_push_output_to_queue(core, out_packet);
} else {
gst_buffer_unref(buffer);
LOGE("Failed to dequeue output packet");
return format;
}
-GstMCBuffer *_mc_gst_media_packet_to_gstbuffer(mc_gst_core_t *core, media_packet_h pkt, bool codec_config)
+GstMCBuffer *_mc_gst_media_packet_to_gstbuffer(mc_gst_core_t *core, media_packet_h packet, bool codec_config)
{
int ret = MEDIA_PACKET_ERROR_NONE;
- GstMCBuffer *mc_buffer = NULL;
+ GstMCBuffer *mcbuffer = NULL;
void *buf_data = NULL;
uint64_t buf_size = 0;
uint64_t pts = 0;
uint64_t dur = 0;
- ret = media_packet_get_buffer_size(pkt, &buf_size);
+ ret = media_packet_get_buffer_size(packet, &buf_size);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("buffer size get fail");
return NULL;
}
- ret = media_packet_get_buffer_data_ptr(pkt, &buf_data);
+ ret = media_packet_get_buffer_data_ptr(packet, &buf_data);
if (ret != MEDIA_PACKET_ERROR_NONE) {
LOGW("buffer data get fail");
return NULL;
}
- mc_buffer = gst_mediacodec_buffer_new(core, pkt, buf_size);
- if (mc_buffer == NULL) {
+ mcbuffer = gst_mediacodec_buffer_new(core, packet, buf_size);
+ if (mcbuffer == NULL) {
LOGW("failed to create inbuf");
return NULL;
}
- LOGD("pkt :v(%d)e(%d) %p, buf_size : %d", core->video, core->encoder, pkt, (int)buf_size);
+ LOGD("packet :v(%d)e(%d) %p, buf_size : %d", core->video, core->encoder, packet, (int)buf_size);
- ret = __mc_fill_input_buffer(core, pkt, mc_buffer);
+ ret = __mc_fill_input_buffer(core, packet, mcbuffer);
if (ret != MC_ERROR_NONE) {
LOGW("failed to fill inbuf: %s (ox%08x)", _mc_error_to_string(ret), ret);
/*
- * if __mc_fill_input_buffer() failed, no memory appended to mc_buffer->buffer, so gst_mediacodec_buffer_finalize()
+ * if __mc_fill_input_buffer() failed, no memory appended to mcbuffer->buffer, so gst_mediacodec_buffer_finalize()
* will not be invoked
*/
- gst_buffer_unref(mc_buffer->buffer);
- free(mc_buffer);
+ gst_buffer_unref(mcbuffer->buffer);
+ free(mcbuffer);
return NULL;
}
/* pts */
- media_packet_get_pts(pkt, &pts);
- GST_BUFFER_PTS(mc_buffer->buffer) = pts;
+ media_packet_get_pts(packet, &pts);
+ GST_BUFFER_PTS(mcbuffer->buffer) = pts;
/* duration */
- media_packet_get_duration(pkt, &dur);
- GST_BUFFER_DURATION(mc_buffer->buffer) = dur;
+ media_packet_get_duration(packet, &dur);
+ GST_BUFFER_DURATION(mcbuffer->buffer) = dur;
- return mc_buffer;
+ return mcbuffer;
}
media_packet_h __mc_gst_make_media_packet(mc_gst_core_t *core, unsigned char *data, int size)
{
int ret = MEDIA_PACKET_ERROR_NONE;
- media_packet_h pkt = NULL;
+ media_packet_h packet = NULL;
- ret = __mc_fill_output_buffer(core, data, size, &pkt);
+ ret = __mc_fill_output_buffer(core, data, size, &packet);
if (ret != MC_ERROR_NONE) {
LOGW("failed to fill outbuf: %s (ox%08x)", _mc_error_to_string(ret), ret);
return NULL;
}
- return pkt;
+ return packet;
}
-int __mc_gst_create_eos_packet(media_format_h fmt, media_packet_h *out_pkt)
+int __mc_gst_create_eos_packet(media_format_h fmt, media_packet_h *out_packet)
{
media_packet_h mediabuf = NULL;
int ret = MC_ERROR_NONE;
goto ERROR;
}
- *out_pkt = mediabuf;
+ *out_packet = mediabuf;
MEDIACODEC_FLEAVE();
return ret;
ERROR:
if (mediabuf)
media_packet_destroy(mediabuf);
- *out_pkt = NULL;
+ *out_packet = NULL;
MEDIACODEC_FLEAVE();
return ret;
}
-void _mc_gst_handle_input_buffer_used(mc_gst_core_t *core, media_packet_h pkt)
+void _mc_gst_handle_input_buffer_used(mc_gst_core_t *core, media_packet_h packet)
{
g_atomic_int_dec_and_test(&core->etb_count);
if (core && core->user_cb[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER]) {
((mc_empty_buffer_cb)core->user_cb[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER])
- (pkt, core->user_data[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER]);
+ (packet, core->user_data[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER]);
}
if (core)
- LOGD("@v(%d)e(%d) input port emptied buffer(%d): %p", core->video, core->encoder, core->etb_count, pkt);
+ LOGD("@v(%d)e(%d) input port emptied buffer(%d): %p", core->video, core->encoder, core->etb_count, packet);
}
gboolean __mc_gst_bus_callback(GstBus *bus, GstMessage *msg, gpointer data)
case GST_MESSAGE_EOS:
_mc_send_eos_signal(core);
- media_packet_h out_pkt = NULL;
- if (MC_ERROR_NONE == __mc_gst_create_eos_packet(core->output_fmt, &out_pkt)) {
- __mc_push_output_to_queue(core, out_pkt);
+ media_packet_h out_packet = NULL;
+ if (MC_ERROR_NONE == __mc_gst_create_eos_packet(core->output_fmt, &out_packet)) {
+ __mc_push_output_to_queue(core, out_packet);
LOGD("send eos packet.");
} else {
LOGE("failed to create eos packet.");
return reply;
}
-static MMVideoBuffer *__mc_gst_make_tbm_buffer(mc_gst_core_t *core, media_packet_h pkt)
+static MMVideoBuffer *__mc_gst_make_tbm_buffer(mc_gst_core_t *core, media_packet_h packet)
{
int i;
int num_bos;
tbm_surface_info_s surface_info;
tbm_bo_handle handle_bo;
- if (!pkt) {
+ if (!packet) {
LOGE("output is null");
return NULL;
}
}
memset(mm_vbuffer, 0x00, sizeof(MMVideoBuffer));
- media_packet_get_tbm_surface(pkt, &surface);
+ media_packet_get_tbm_surface(packet, &surface);
num_bos = tbm_surface_internal_get_num_bos(surface);
int err = tbm_surface_get_info((tbm_surface_h)surface, &surface_info);
if (err != TBM_SURFACE_ERROR_NONE) {
return mm_vbuffer;
}
-static void gst_mediacodec_buffer_finalize(GstMCBuffer *mc_buffer)
+static void gst_mediacodec_buffer_finalize(GstMCBuffer *mcbuffer)
{
MEDIACODEC_FENTER();
- if (!mc_buffer)
+ if (!mcbuffer)
return;
- mc_gst_core_t *core = (mc_gst_core_t *)mc_buffer->core;
+ mc_gst_core_t *core = (mc_gst_core_t *)mcbuffer->core;
- _mc_gst_handle_input_buffer_used(core, mc_buffer->pkt);
+ _mc_gst_handle_input_buffer_used(core, mcbuffer->packet);
- free(mc_buffer);
- mc_buffer = NULL;
+ free(mcbuffer);
+ mcbuffer = NULL;
MEDIACODEC_FLEAVE();
return;
}
-static GstMCBuffer *gst_mediacodec_buffer_new(mc_gst_core_t *core, media_packet_h pkt, uint64_t size)
+static GstMCBuffer *gst_mediacodec_buffer_new(mc_gst_core_t *core, media_packet_h packet, uint64_t size)
{
- GstMCBuffer *mc_buffer = NULL;
+ GstMCBuffer *mcbuffer = NULL;
- mc_buffer = (GstMCBuffer *)malloc(sizeof(*mc_buffer));
+ mcbuffer = (GstMCBuffer *)malloc(sizeof(*mcbuffer));
- if (mc_buffer == NULL) {
+ if (mcbuffer == NULL) {
LOGE("malloc fail");
return NULL;
}
- mc_buffer->buffer = gst_buffer_new();
- mc_buffer->buf_size = 0;
+ mcbuffer->buffer = gst_buffer_new();
+ mcbuffer->buf_size = 0;
- LOGD("creating buffer : %p, %p", mc_buffer, mc_buffer->buffer);
- mc_buffer->core = core;
- mc_buffer->pkt = pkt;
+ LOGD("creating buffer : %p, %p", mcbuffer, mcbuffer->buffer);
+ mcbuffer->core = core;
+ mcbuffer->packet = packet;
- return mc_buffer;
+ return mcbuffer;
}
static gint __gst_handle_core_error(mc_gst_core_t *core, int code)
static void _mc_gst_set_flush_input(mc_gst_core_t *core)
{
- media_packet_h pkt = NULL;
+ media_packet_h packet = NULL;
MEDIACODEC_FENTER();
- LOGI("_mc_gst_set_flush_input is called");
+ LOGI("_mc_gst_set_flush_input called");
while (!mc_async_queue_is_empty(core->available_queue->input)) {
- pkt = mc_async_queue_pop_forced(core->available_queue->input);
+ packet = mc_async_queue_pop_forced(core->available_queue->input);
g_atomic_int_dec_and_test(&core->etb_count);
- LOGD("%p poped(%d)", pkt, core->etb_count);
+ LOGD("%p poped(%d)", packet, core->etb_count);
- _mc_gst_handle_input_buffer_used(core, pkt);
+ _mc_gst_handle_input_buffer_used(core, packet);
}
mc_async_queue_flush(core->available_queue->input);
static void _mc_gst_set_flush_output(mc_gst_core_t *core)
{
- media_packet_h pkt = NULL;
+ media_packet_h packet = NULL;
MEDIACODEC_FENTER();
g_mutex_lock(&core->ports[1]->mutex);
while (!g_queue_is_empty(core->ports[1]->queue)) {
- pkt = g_queue_pop_head(core->ports[1]->queue);
+ packet = g_queue_pop_head(core->ports[1]->queue);
g_atomic_int_dec_and_test(&core->ftb_count);
- LOGD("%p poped(%d)", pkt, core->ftb_count);
- if (pkt) {
- media_packet_destroy(pkt);
- LOGD("outpkt destroyed");
- pkt = NULL;
+ LOGD("%p poped(%d)", packet, core->ftb_count);
+ if (packet) {
+ media_packet_destroy(packet);
+ LOGD("outpacket destroyed");
+ packet = NULL;
}
}
g_mutex_unlock(&core->ports[1]->mutex);
return mime;
}
-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)
{
int curr_size;
int max_size, min_size;
media_packet_pool_get_size(pool, &min_size, &max_size, &curr_size);
LOGD("curr_size is %d min_size is %d and max_size is %d \n", curr_size, min_size, max_size);
- *pkt_pool = pool;
+ *packet_pool = pool;
return MC_ERROR_NONE;
}