4 * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
7 * KiTae Kim <kt920.kim@samsung.com>
8 * SeokYeon Hwang <syeon.hwang@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
27 /* First, include the header file for the plugin, to bring in the
28 * object definition and other useful things.
40 GST_DEBUG_CATEGORY (maru_debug);
42 #define GST_TYPE_MARUDEC \
43 (gst_maru_dec_get_type())
44 #define GST_MARUDEC(obj) \
45 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MARUDEC,GstMaruDec))
46 #define GST_MARUDEC_CLASS(klass) \
47 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MARUDEC,GstMaruDecClass))
48 #define GST_IS_MARUDEC(obj) \
49 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MARUDEC))
50 #define GST_IS_MARUDEC_CLASS(klass) \
51 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MARUDEC))
53 gboolean gst_marudec_register (GstPlugin *plugin, GList *element);
54 gboolean gst_maruenc_register (GstPlugin *plugin, GList *element);
56 static GList *codec_element = NULL;
59 gst_maru_codec_element_init ()
66 CodecElement *elem = NULL;
68 fd = open (CODEC_DEV, O_RDWR);
70 perror ("[gst-maru] failed to open codec device");
74 ioctl (fd, CODEC_CMD_GET_VERSION, &version);
75 if (version != CODEC_VER) {
76 CODEC_LOG (INFO, "version conflict between device: %d, plugin: %d\n",
82 buffer = mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
84 perror ("[gst-maru] failure memory mapping.");
89 CODEC_LOG (DEBUG, "request a device to get codec element.\n");
90 if (ioctl(fd, CODEC_CMD_GET_ELEMENT, NULL) < 0) {
91 perror ("[gst-maru] failed to get codec elements");
92 munmap (buffer, 4096);
97 memcpy(&data_length, (uint8_t *)buffer, sizeof(data_length));
98 size += sizeof(data_length);
100 elem = g_malloc0 (data_length);
102 CODEC_LOG (ERR, "Failed to allocate memory.\n");
103 munmap (buffer, 4096);
108 memcpy (elem, (uint8_t *)buffer + size, data_length);
110 elem_cnt = data_length / sizeof(CodecElement);
111 for (i = 0; i < elem_cnt; i++) {
112 codec_element = g_list_append (codec_element, &elem[i]);
115 munmap (buffer, 4096);
122 plugin_init (GstPlugin *plugin)
124 GST_DEBUG_CATEGORY_INIT (maru_debug,
125 "tizen-maru", 0, "Tizen Emulator Codec Elements");
127 gst_maru_init_pix_fmt_info ();
129 if (!gst_maru_codec_element_init ()) {
130 GST_ERROR ("failed to get codec elements from QEMU");
134 if (!gst_marudec_register (plugin, codec_element)) {
135 GST_ERROR ("failed to register decoder elements");
138 if (!gst_maruenc_register (plugin, codec_element)) {
139 GST_ERROR ("failed to register encoder elements");
144 while ((codec_element = g_list_next (codec_element))) {
145 g_list_free (codec_element);
153 #define PACKAGE "gst-plugins-maruator"
160 "Codecs for Tizen Emulator",
164 "gst-plugins-emulator",