Name: gst-plugins-emulator
-Version: 0.1.0
+Version: 0.1.1
Release: 2
Summary: GStreamer Streaming-media framework plug-in for Tizen emulator.
Group: TO_BE/FILLED_IN
# sources used to compile this plug-in
libgstemul_la_SOURCES = gstemul.c \
gstemulutils.c \
- gstemulnewdec.c \
- gstemulnewenc.c \
+ gstemuldec.c \
+ gstemulenc.c \
gstemulapi.c \
gstemuldev.c \
gstemulapi2.c
int version = 0;
int data_length = 0;
int ret = TRUE;
+ int i, elem_cnt = 0;
void *buffer = NULL;
- GList *element = NULL;
- CodecIOParams params;
+// GList *element = NULL;
+ CodecElement *elem = NULL;
fd = open (CODEC_DEV, O_RDWR);
if (fd < 0) {
perror ("failure memory mapping.");
}
-#if 0
- memset(¶ms, 0, sizeof(params));
- params.api_index = CODEC_ELEMENT_INIT;
- if (write (fd, ¶ms, 1) < 0) {
- perror ("failed to copy data to qemu");
- }
-#endif
-
- CODEC_LOG (DEBUG, "request a device to get codec element.\n");
+// CODEC_LOG (DEBUG, "request a device to get codec element.\n");
ioctl(fd, CODEC_CMD_GET_ELEMENT, NULL);
- // TODO: source clean-up.
-#if 0
- do {
- CodecElement *elm = NULL;
-
- elm = g_malloc0 (sizeof(CodecElement));
- if (!elm) {
- CODEC_LOG (ERR, "Failed to allocate memory.\n");
- ret = FALSE;
- break;
- }
-
-// memcpy (&data_length, (uint8_t *)buffer + size, sizeof(data_length));
- data_length = *(int*)(((uint8_t *)buffer + size));
-
- printf("[%s][%d] data_length = %d\n", __func__, __LINE__, data_length);
-
- size += sizeof(data_length);
- if (data_length == 0) {
- break;
- }
- memcpy (elm, (uint8_t *)buffer + size, data_length);
- size += data_length;
-#if 0
- printf("[%p] codec: %s, %s, %s %s\n", elm,
- elm->name, elm->longname,
- elm->media_type ? "Audio" : "Video",
- elm->codec_type ? "Encoder" : "Decoder");
-#endif
- element = g_list_append (element, elm);
- } while (1);
-#endif
+ memcpy(&data_length, (uint8_t *)buffer, sizeof(data_length));
+ size += sizeof(data_length);
- CodecElement *elem = NULL;
- {
- memcpy(&data_length, (uint8_t *)buffer, sizeof(data_length));
- size += sizeof(data_length);
- printf("[%s][%d] data_length = %d\n", __func__, __LINE__, data_length);
-
- elem = g_malloc0 (data_length);
- if (!elem) {
- CODEC_LOG (ERR, "Failed to allocate memory.\n");
- ret = FALSE;
- munmap (buffer, 4096);
- close (fd);
- return ret;
- }
-
- memcpy (elem, (uint8_t *)buffer + size, data_length);
+// printf("[gst-emul][%d] data_length = %d\n", __LINE__, data_length);
+
+ elem = g_malloc0 (data_length);
+ if (!elem) {
+ CODEC_LOG (ERR, "Failed to allocate memory.\n");
+ ret = FALSE;
+ munmap (buffer, 4096);
+ close (fd);
+ return ret;
}
- {
- int i;
- int elem_cnt = data_length / sizeof(CodecElement);
- for (i = 0; i < elem_cnt; i++) {
- element = g_list_append (element, &elem[i]);
- }
+ memcpy (elem, (uint8_t *)buffer + size, data_length);
+
+ elem_cnt = data_length / sizeof(CodecElement);
+ for (i = 0; i < elem_cnt; i++) {
+// element = g_list_append (element, &elem[i]);
+ codec_element = g_list_append (codec_element, &elem[i]);
}
- codec_element = element;
+// codec_element = element;
munmap (buffer, 4096);
close (fd);
return FALSE;
}
+#if 0
while ((codec_element = g_list_next (codec_element))) {
g_list_free (codec_element);
}
+#endif
return TRUE;
}
{
CodecIOParams ioparam;
-// memset(&ioparam, 0, sizeof(ioparam));
ioparam.api_index = api_index;
ioparam.ctx_index = ctx_index;
ioparam.mem_offset = dev->mem_info.offset;
info.start = (gpointer)((uint32_t)device_mem + mem_offset);
info.offset = mem_offset;
- CODEC_LOG (DEBUG, "leave: %s\n", __func__);
CODEC_LOG (DEBUG, "caramis0 = 0x%x\n", mem_offset);
+ CODEC_LOG (DEBUG, "leave: %s\n", __func__);
return info;
}
}
ioctl(fd, CODEC_CMD_GET_CONTEXT_INDEX, &ctx->index);
- CODEC_LOG (DEBUG, "recv context index: %d\n", ctx->index);
+ CODEC_LOG (DEBUG, "get context index: %d\n", ctx->index);
ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &mem_offset);
emul_avcodec_init_to (ctx, codec, mmapbuf + mem_offset);
int fd;
uint8_t *mmapbuf = NULL;
int len = 0;
-// int copyback, usable;
uint32_t mem_offset = 0;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
return;
}
-#if 0
- ioctl (fd, CODEC_CMD_ADD_TASK_QUEUE, NULL);
-
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[copy_frame] waiting before write.\n");
- usleep (500);
- continue;
- }
- break;
- }
-
- emul_codec_write_to_qemu (ctx->index, CODEC_PICTURE_COPY, dev);
-
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[copy_frame] waiting after write.\n");
- usleep (500);
- continue;
- }
- memcpy (pict, mmapbuf, pict_size);
- break;
- }
- ioctl (fd, CODEC_CMD_REMOVE_TASK_QUEUE, ©back);
-#endif
-
dev->mem_info.offset = (uint32_t)pict - (uint32_t)device_mem;
CODEC_LOG (DEBUG, "[%s] mem_offset = 0x%x\n", __func__, dev->mem_info.offset);
emul_codec_write_to_qemu (ctx->index, CODEC_PICTURE_COPY, dev);
// ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &mem_offset);
ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM2, &(dev->mem_info.offset));
- CODEC_LOG (DEBUG, "caramis1 = 0x%x\n", __func__, mem_offset);
+ CODEC_LOG (DEBUG, "[%s] caramis1 = 0x%x\n", __func__, mem_offset);
#if 0
memcpy (pict, mmapbuf, pict_size);
return -1;
}
-#if 0
- ioctl (fd, CODEC_CMD_ADD_TASK_QUEUE, NULL);
-
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[decode_audio] waiting before write.\n");
- usleep (500);
- continue;
- }
-
- emul_avcodec_decode_audio_to (in_buf, in_size, mmapbuf);
- break;
- }
-
- emul_codec_write_to_qemu (ctx->index, CODEC_DECODE_AUDIO, dev);
-
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[decode_audio] waiting after write.\n");
- usleep (500);
- continue;
- }
-
- len =
- emul_avcodec_decode_audio_from (ctx, frame_size_ptr, samples, mmapbuf);
- break;
- }
- ioctl (fd, CODEC_CMD_REMOVE_TASK_QUEUE, ©back);
-#endif
-
ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &mem_offset);
emul_avcodec_decode_audio_to (in_buf, in_size, mmapbuf + mem_offset);
int fd;
void *mmapbuf;
int len = 0;
- int copyback, usable;
+ uint32_t mem_offset = 0;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
return -1;
}
-// ioctl (fd, CODEC_CMD_ADD_TASK_QUEUE, NULL);
-#if 0
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[encode_video] waiting before write.\n");
- usleep (500);
- continue;
- }
-
- emul_avcodec_encode_video_to (in_buf, in_size, in_timestamp, mmapbuf);
- break;
- }
+ ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &mem_offset);
+ CODEC_LOG (DEBUG, "[%s] mem_offset = 0x%x\n", __func__, mem_offset);
+ emul_avcodec_encode_video_to (in_buf, in_size, in_timestamp, mmapbuf);
+ dev->mem_info.offset = mem_offset;
emul_codec_write_to_qemu (ctx->index, CODEC_ENCODE_VIDEO, dev);
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[encode_video] waiting after write.\n");
- usleep (500);
- continue;
- }
+ ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &mem_offset);
+ CODEC_LOG (DEBUG, "[%s] mem_offset = 0x%x\n", __func__, mem_offset);
+ len = emul_avcodec_encode_video_from (out_buf, out_size, mmapbuf);
- len = emul_avcodec_encode_video_from (out_buf, out_size, mmapbuf);
- break;
- }
- ioctl (fd, CODEC_CMD_REMOVE_TASK_QUEUE, ©back);
-#endif
+ ioctl (fd, CODEC_CMD_REMOVE_TASK_QUEUE, &mem_offset);
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
return len;
int in_size, CodecDevice *dev)
{
int fd;
- void *mmapbuf;
+ void *mmapbuf = NULL;
int len = 0;
- int copyback, usable;
+ uint32_t mem_offset = 0;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
return -1;
}
-// ioctl (fd, CODEC_CMD_ADD_TASK_QUEUE, NULL);
-#if 0
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[encode_audio] waiting before write.\n");
- usleep (500);
- continue;
- }
-
- emul_avcodec_encode_audio_to (out_size, in_size, in_buf, mmapbuf);
- break;
- }
+ ioctl (fd, CODEC_CMD_COPY_TO_DEVICE_MEM, &mem_offset);
+ CODEC_LOG (DEBUG, "[%s] mem_offset = 0x%x\n", __func__, mem_offset);
+ emul_avcodec_encode_audio_to (out_size, in_size, in_buf, mmapbuf);
+ dev->mem_info.offset = mem_offset;
emul_codec_write_to_qemu (ctx->index, CODEC_ENCODE_AUDIO, dev);
- while (1) {
- ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &usable);
- if (usable) {
- CODEC_LOG (DEBUG, "[encode_audio] waiting after write.\n");
- usleep (500);
- continue;
- }
- len = emul_avcodec_encode_audio_from (out_buf, out_size, mmapbuf);
- break;
- }
- ioctl (fd, CODEC_CMD_REMOVE_TASK_QUEUE, ©back);
-#endif
+ ioctl (fd, CODEC_CMD_COPY_FROM_DEVICE_MEM, &mem_offset);
+ CODEC_LOG (DEBUG, "[%s] mem_offset = 0x%x\n", __func__, mem_offset);
+ len = emul_avcodec_encode_audio_from (out_buf, out_size, mmapbuf);
+
+ ioctl (fd, CODEC_CMD_REMOVE_TASK_QUEUE, &mem_offset);
CODEC_LOG (DEBUG, "leave: %s\n", __func__);
return len;
#include "gstemulapi.h"
#include "gstemuldev.h"
-#define GST_EMULDEC_PARAMS_QDATA g_quark_from_static_string("emuldec-params")
+#define GST_EMULDEC_PARAMS_QDATA g_quark_from_static_string("marudec-params")
/* indicate dts, pts, offset in the stream */
typedef struct
GstCaps *sinkcaps, *srccaps;
GstPadTemplate *sinktempl, *srctempl;
CodecElement *codec;
- gchar *longname, *classification;
+ gchar *longname, *classification, *description;
codec =
(CodecElement *)g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
classification = g_strdup_printf ("Codec/Decoder/%s",
(codec->media_type == AVMEDIA_TYPE_VIDEO) ?
"Video" : "Audio");
+ description = g_strdup_printf("%s Decoder", codec->name);
gst_element_class_set_details_simple (element_class,
- longname, // longname
- classification, // classification
- "accelerated codec for Tizen Emulator", // description
- "Kitae Kim <kt920.kim@samsung.com>"); // author
+ longname,
+ classification,
+ description,
+ "Kitae Kim <kt920.kim@samsung.com>");
g_free (longname);
g_free (classification);
+ g_free (description);
sinkcaps = gst_emul_codecname_to_caps (codec->name, NULL, FALSE);
if (!sinkcaps) {
oclass->codec, emuldec->dev) < 0) {
gst_emuldec_close (emuldec);
GST_DEBUG_OBJECT (emuldec,
- "tzdec_%s: Failed to open codec", oclass->codec->name);
+ "maru_%sdec: Failed to open codec", oclass->codec->name);
}
emuldec->opened = TRUE;
if (len < 0 || have_data < 0) {
GST_WARNING_OBJECT (emuldec,
- "tzdec_%s: decoding error (len: %d, have_data: %d)",
+ "maru_%sdec: decoding error (len: %d, have_data: %d)",
oclass->codec->name, len, have_data);
*got_data = 0;
return len;
// not_negotiated
oclass = (GstEmulDecClass *) (G_OBJECT_GET_CLASS (emuldec));
GST_ELEMENT_ERROR (emuldec, CORE, NEGOTIATION, (NULL),
- ("tzdec_%s: input format was not set before data start",
+ ("maru_%sdec: input format was not set before data start",
oclass->codec->name));
gst_buffer_unref (buffer);
return GST_FLOW_NOT_NEGOTIATED;
GType type;
gchar *type_name;
- gint rank = GST_RANK_PRIMARY;
- gboolean ret = TRUE;
+ gint rank = GST_RANK_NONE;
GList *elem = element;
CodecElement *codec = NULL;
do {
codec = (CodecElement *)elem->data;
if (!codec) {
- ret = FALSE;
- break;
+ return FALSE;
}
if (codec->codec_type != CODEC_TYPE_DECODE) {
continue;
}
- type_name = g_strdup_printf ("tzdec_%s", codec->name);
+ type_name = g_strdup_printf ("maru_%sdec", codec->name);
type = g_type_from_name (type_name);
if (!type) {
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);
g_free (type_name);
} while ((elem = g_list_next (elem)));
- return ret;
+ return TRUE;
}
#include "gstemuldev.h"
#include <gst/base/gstadapter.h>
-#define GST_EMULENC_PARAMS_QDATA g_quark_from_static_string("emulenc-params")
+#define GST_EMULENC_PARAMS_QDATA g_quark_from_static_string("maruenc-params")
typedef struct _GstEmulEnc
{
GstPadTemplate *sinktempl = NULL, *srctempl = NULL;
GstCaps *sinkcaps = NULL, *srccaps = NULL;
CodecElement *codec;
- gchar *longname, *classification;
+ gchar *longname, *classification, *description;
codec =
(CodecElement *)g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
longname = g_strdup_printf ("%s Encoder", codec->longname);
classification = g_strdup_printf ("Codec/Encoder/%s",
(codec->media_type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
+ description = g_strdup_printf ("%s Encoder", codec->name);
gst_element_class_set_details_simple (element_class,
longname,
classification,
- "accelerated codec for Tizen Emulator",
+ description,
+// "accelerated codec for Tizen Emulator",
"Kitae Kim <kt920.kim@samsung.com>");
g_free (longname);
// open codec
if (gst_emul_avcodec_open (emulenc->context,
oclass->codec, emulenc->dev) < 0) {
- GST_DEBUG_OBJECT (emulenc, "tzenc_%s: Failed to open codec",
+ GST_DEBUG_OBJECT (emulenc, "maru_%senc: Failed to open codec",
oclass->codec->name);
return FALSE;
}
if (pix_fmt != emulenc->context->video.pix_fmt) {
gst_emul_avcodec_close (emulenc->context, emulenc->dev);
GST_DEBUG_OBJECT (emulenc,
- "tzenc_%s: AV wants different colorspace (%d given, %d wanted)",
+ "maru_%senc: AV wants different colorspace (%d given, %d wanted)",
oclass->codec->name, pix_fmt, emulenc->context->video.pix_fmt);
return FALSE;
}
if (oclass->codec->media_type == AVMEDIA_TYPE_VIDEO
&& pix_fmt == PIX_FMT_NONE) {
- GST_DEBUG_OBJECT (emulenc, "tzenc_%s: Failed to determine input format",
+ GST_DEBUG_OBJECT (emulenc, "maru_%senc: Failed to determine input format",
oclass->codec->name);
return FALSE;
}
GstEmulEncClass *oclass =
(GstEmulEncClass *) (G_OBJECT_GET_CLASS (emulenc));
GST_ERROR_OBJECT (emulenc,
- "tzenc_%s: failed to encode buffer", oclass->codec->name);
+ "maru_%senc: failed to encode buffer", oclass->codec->name);
gst_buffer_unref (buffer);
return GST_FLOW_OK;
}
GstEmulEncClass *oclass =
(GstEmulEncClass *) (G_OBJECT_GET_CLASS (emulenc));
GST_WARNING_OBJECT (emulenc,
- "tzenc_%s: failed to flush buffer", oclass->codec->name);
+ "maru_%senc: failed to flush buffer", oclass->codec->name);
break;
}
GType type;
gchar *type_name;
- gint rank = GST_RANK_PRIMARY;
+ gint rank = GST_RANK_NONE;
gboolean ret = TRUE;
GList *elem = element;
CodecElement *codec = NULL;
continue;
}
- type_name = g_strdup_printf ("tzenc_%s", codec->name);
+ type_name = g_strdup_printf ("maru_%senc", codec->name);
type = g_type_from_name (type_name);
if (!type) {
type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0);