Name: gst-plugins-emulator
-Version: 0.2.7
+Version: 0.2.11
Release: 0
Summary: GStreamer Decoder and Encoder Plugins for Emulator
Group: Multimedia/Libraries
-/*
- * Emulator
- *
- * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * KiTae Kim <kt920.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* object definition and other useful things.
*/
-/*
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
+/* Modifications by Samsung Electronics Co., Ltd.
+ * 1. Get available Video/Audio Codecs from Qemu
*/
#include "gstmaru.h"
fd = open (CODEC_DEV, O_RDWR);
if (fd < 0) {
- // perror ("[gst-maru] failed to open codec device");
+ perror ("[gst-maru] failed to open codec device");
GST_ERROR ("failed to open codec device");
return FALSE;
}
ioctl (fd, CODEC_CMD_GET_VERSION, &version);
if (version != CODEC_VER) {
- // CODEC_LOG (INFO, "version conflict between device: %d, plugin: %d\n", version, CODEC_VER);
GST_LOG ("version conflict between device: %d, plugin: %d", version, CODEC_VER);
close (fd);
return FALSE;
buffer = mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (buffer == MAP_FAILED) {
- // perror ("[gst-maru] failure memory mapping.");
+ perror ("[gst-maru] memory mapping failure");
GST_ERROR ("memory mapping failure");
close (fd);
return FALSE;
}
- // CODEC_LOG (DEBUG, "request a device to get codec element.\n");
GST_DEBUG ("request a device to get codec element");
if (ioctl(fd, CODEC_CMD_GET_ELEMENT, &data_length) < 0) {
- // perror ("[gst-maru] failed to get codec elements");
+ perror ("[gst-maru] failed to get codec elements");
GST_ERROR ("failed to get codec elements");
munmap (buffer, 4096);
close (fd);
return FALSE;
}
- // CODEC_LOG (DEBUG, "sizeof codec elements. %d\n", data_length);
GST_DEBUG ("total size of codec elements %d", data_length);
elem = g_malloc0 (data_length);
if (!elem) {
- // CODEC_LOG (ERR, "Failed to allocate memory.\n");
GST_ERROR ("failed to allocate memory for codec elements");
munmap (buffer, 4096);
close (fd);
}
if (ioctl(fd, CODEC_CMD_GET_ELEMENT_DATA, elem) < 0) {
- // CODEC_LOG (ERR, "failed to get codec elements\n");
GST_ERROR ("failed to get codec elements");
munmap (buffer, 4096);
close (fd);
"tizen-emul",
"Codecs for Tizen Emulator",
plugin_init,
- "0.2.8",
+ "0.2.11",
"LGPL",
"gst-plugins-emulator",
"http://www.tizen.org"
-/*
- * GStreamer codec plugin for Tizen Emulator.
- *
- * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * KiTae Kim <kt920.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
*/
-// #include "gstmaru.h"
+/* Modifications by Samsung Electronics Co., Ltd.
+ * 1. Provide a hardware buffer in order to avoid additional memcpy operations.
+ */
+
#include "gstmarudevice.h"
#include "gstmaruutils.h"
#include "gstmaruinterface.h"
-// #include "gstmarudevice.h"
#define GST_MARUDEC_PARAMS_QDATA g_quark_from_static_string("marudec-params")
/* indicate dts, pts, offset in the stream */
-
#define GST_TS_INFO_NONE &ts_info_none
static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
-/*
- * GStreamer codec plugin for Tizen Emulator.
- *
- * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * KiTae Kim <kt920.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
*/
#include "gstmarudevice.h"
ctx->video.ticks_per_frame = 1;
ctx->bit_rate = DEFAULT_VIDEO_BITRATE;
-// ctx->strict_std_compliance = -1;
ctx->video.pix_fmt = pixfmt;
GST_DEBUG ("Attempting to open codec");
GstMaruEnc *maruenc = (GstMaruEnc *) (GST_PAD_PARENT (pad));
GstBuffer *outbuf = NULL;
gint ret_size = 0, frame_size = 0;
- int ret = 0;
+ int coded_frame = 0, is_keyframe = 0;
uint32_t mem_offset = 0;
uint8_t *working_buf = NULL;
- int coded_frame, is_keyframe;
-
GST_DEBUG_OBJECT (maruenc,
"Received buffer of time %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
}
res = codec_encode_audio (maruenc->context, audio_out, max_size,
- audio_in, in_size, maruenc->dev);
+ audio_in, in_size, timestamp, maruenc->dev);
if (res < 0) {
GST_ERROR_OBJECT (maruenc, "Failed to encode buffer: %d", res);
gst_maruenc_chain_audio (GstPad *pad, GstBuffer *buffer)
{
GstMaruEnc *maruenc;
-// GstMaruEncClass *oclass;
+ // GstMaruEncClass *oclass;
GstClockTime timestamp, duration;
guint in_size, frame_size;
gint osize;
CodecContext *ctx;
maruenc = (GstMaruEnc *) (GST_OBJECT_PARENT (pad));
-// oclass = (GstMaruEncClass *) G_OBJECT_GET_CLASS (maruenc);
+ // oclass = (GstMaruEncClass *) G_OBJECT_GET_CLASS (maruenc);
ctx = maruenc->context;
ctx->index, device_mem + opaque.buffer_size);
len = codec_decode_audio_data_from (have_data, samples,
- &ctx->audio, device_mem + opaque.buffer_size);
+ &ctx->audio, device_mem + opaque.buffer_size);
GST_DEBUG ("decode_audio 3. ctx_id: %d len: %d", ctx->index, len);
int
codec_encode_audio (CodecContext *ctx, uint8_t *out_buf,
int max_size, uint8_t *in_buf,
- int in_size, CodecDevice *dev)
+ int in_size, int64_t timestamp,
+ CodecDevice *dev)
{
- int len = 0, ret = 0;
+ int ret = 0;
gpointer buffer = NULL;
CodecBufferId opaque;
return -1;
}
- codec_encode_audio_data_to (in_size, max_size, in_buf, buffer);
+ codec_encode_audio_data_to (in_size, max_size, in_buf, timestamp, buffer);
dev->mem_info.offset = GET_OFFSET(buffer);
_codec_invoke_qemu (ctx->index, CODEC_ENCODE_AUDIO, GET_OFFSET(buffer), dev->fd);
GST_DEBUG ("encode_audio. mem_offset = 0x%x", opaque.buffer_size);
- len = codec_encode_audio_data_from (out_buf, device_mem + opaque.buffer_size);
+ ret = codec_encode_audio_data_from (out_buf, device_mem + opaque.buffer_size);
release_device_mem(dev->fd, device_mem + opaque.buffer_size);
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
- return len;
+ return ret;
}
int
codec_encode_audio (CodecContext *ctx, uint8_t *out_buf,
int out_size, uint8_t *in_buf,
- int in_size, CodecDevice *dev);
+ int in_size, int64_t timestamp,
+ CodecDevice *dev);
void
codec_picture_copy (CodecContext *ctx, uint8_t *pict,
memcpy (&resample_size, buffer + size, sizeof(resample_size));
size += sizeof(resample_size);
memcpy (samples, buffer + size, resample_size);
+ size += resample_size;
}
-// return len;
+ // return len;
return resample_size;
}
}
void
-codec_encode_audio_data_to (int in_size, int max_size, uint8_t *in_buf, gpointer buffer)
+codec_encode_audio_data_to (int in_size, int max_size, uint8_t *in_buf, int64_t timestamp, gpointer buffer)
{
int size = 0;
size = sizeof(size);
memcpy (buffer + size, &in_size, sizeof(in_size));
size += sizeof(in_size);
- memcpy (buffer + size, &max_size, sizeof(max_size));
- size += sizeof(max_size);
+
+ memcpy (buffer + size, ×tamp, sizeof(timestamp));
+ size += sizeof(timestamp);
if (in_size > 0) {
memcpy (buffer + size, in_buf, in_size);
int
codec_encode_audio_data_from (uint8_t *out_buf, gpointer buffer)
{
- int len = 0, size = 0;
+ int ret = 0, outbuf_size = 0, size = 0;
- memcpy (&len, buffer, sizeof(len));
- size = sizeof(len);
- if (len > 0) {
- memcpy (out_buf, buffer + size, len);
+ memcpy (&ret, buffer, sizeof(ret));
+ size = sizeof(ret);
+ if (ret == 0) {
+ memcpy (&outbuf_size, buffer + size, sizeof(outbuf_size));
+ size += sizeof(outbuf_size);
+ if (outbuf_size > 0) {
+ memcpy (out_buf, buffer + size, outbuf_size);
+ }
}
- GST_DEBUG ("encode_audio. outbuf size: %d", len);
+ GST_DEBUG ("encode_audio. ret: %d outbuf size: %d", ret, outbuf_size);
- return len;
+ return outbuf_size;
}
int codec_encode_video_data_from (uint8_t *, int *, int *, gpointer);
-void codec_encode_audio_data_to (int in_size, int max_size, uint8_t *in_buf, gpointer buffer);
+void codec_encode_audio_data_to (int, int, uint8_t *, int64_t, gpointer);
-int codec_encode_audio_data_from (uint8_t *out_buf, gpointer buffer);
+int codec_encode_audio_data_from (uint8_t *, gpointer);
#endif
-/*
- * GStreamer codec plugin for Tizen Emulator.
- *
- * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * KiTae Kim <kt920.kim@samsung.com>
- * SeokYeon Hwang <syeon.hwang@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
*/
#include "gstmaruutils.h"
GstCaps *caps = NULL;
GST_DEBUG ("context: %p, codec: %s, encode: %d, codec: %p",
- ctx, name, encode, codec);
+ ctx, name, encode, codec);
if (ctx) {
caps = gst_maru_smpfmt_to_caps (ctx->audio.sample_fmt, ctx, name);
caps = gst_caps_new_empty ();
for (i = 0; codec->sample_fmts[i] != -1; i++) {
+ int8_t sample_fmt = -1;
+
+ sample_fmt = codec->sample_fmts[i];
+ if (!strcmp(name, "aac") && encode) {
+ sample_fmt = SAMPLE_FMT_S16;
+ GST_DEBUG ("convert sample_fmt. codec %s, encode %d, sample_fmt %d",
+ name, encode, sample_fmt);
+ }
+
temp =
- gst_maru_smpfmt_to_caps (codec->sample_fmts[i], ctx, name);
+ gst_maru_smpfmt_to_caps (sample_fmt, ctx, name);
if (temp != NULL) {
gst_caps_append (caps, temp);
}
gst_structure_get_int (str, "channels", &ctx->audio.channels);
gst_structure_get_int (str, "rate", &ctx->audio.sample_rate);
gst_structure_get_int (str, "block_align", &ctx->audio.block_align);
-// gst_structure_get_int (str, "bitrate", &ctx->audio.bit_rate);
gst_structure_get_int (str, "bitrate", &ctx->bit_rate);
if (!raw) {
G_TYPE_INT, version, "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
"bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
} else {
- GST_ERROR("failed to new caps for %s.\n", name);
+ GST_ERROR("failed to new caps for %s", name);
+ }
+
+ if (caps != NULL) {
+ if (ctx && ctx->codecdata_size > 0) {
+ GstBuffer *data = gst_buffer_new_and_alloc (ctx->codecdata_size);
+
+ memcpy (GST_BUFFER_DATA(data), ctx->codecdata, ctx->codecdata_size);
+ gst_caps_set_simple (caps, "codec_data", GST_TYPE_BUFFER, data, NULL);
+
+ gst_buffer_unref (data);
+ }
+ GST_LOG ("caps for codec %s %" GST_PTR_FORMAT, name, caps);
+ } else {
+ GST_LOG ("No caps found for codec %s", name);
}
return caps;
#define __GST_MARU_UTIL_H__
#include "gstmaru.h"
-
-// libav
#include "audioconvert.h"
/* Audio channel masks */