2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 /* First, include the header file for the plugin, to bring in the
22 * object definition and other useful things.
25 /* Modifications by Samsung Electronics Co., Ltd.
26 * 1. Get available Video/Audio Codecs from Qemu
30 #include "gstmaruutils.h"
31 #include "gstmaruinterface.h"
33 GST_DEBUG_CATEGORY (maru_debug);
35 #define GST_TYPE_MARUDEC \
36 (gst_maru_dec_get_type())
37 #define GST_MARUDEC(obj) \
38 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MARUDEC,GstMaruDec))
39 #define GST_MARUDEC_CLASS(klass) \
40 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MARUDEC,GstMaruDecClass))
41 #define GST_IS_MARUDEC(obj) \
42 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MARUDEC))
43 #define GST_IS_MARUDEC_CLASS(klass) \
44 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MARUDEC))
46 gboolean gst_marudec_register (GstPlugin *plugin, GList *element);
47 gboolean gst_maruenc_register (GstPlugin *plugin, GList *element);
49 static GList *elements = NULL;
50 static gboolean codec_element_init = FALSE;
51 static GMutex gst_maru_mutex;
56 gst_maru_codec_element_init ()
58 int fd = 0, ret = TRUE;
59 void *buffer = MAP_FAILED;
61 codec_element_init = TRUE;
63 fd = open (CODEC_DEV, O_RDWR);
65 perror ("[gst-maru] failed to open codec device");
66 GST_ERROR ("failed to open codec device");
73 device_version = interface_version_3->get_device_version(fd);
74 if (device_version < 0) {
76 device_version = interface_version_2->get_device_version(fd);
78 if (device_version < 0) {
79 perror ("[gst-maru] Incompatible device version");
80 GST_ERROR ("Incompatible device version");
86 if (device_version < 3) {
87 interface = interface_version_2;
88 } else if (device_version >= 3 && device_version < 4) {
89 interface = interface_version_3;
91 perror ("[gst-maru] Incompatible device version");
92 GST_ERROR ("Incompatible device version");
98 if ((elements = interface->prepare_elements(fd)) == NULL) {
99 perror ("[gst-maru] cannot prepare elements");
100 GST_ERROR ("cannot prepare elements");
105 // try to mmap device memory
106 buffer = mmap (NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
107 if (buffer == MAP_FAILED) {
108 perror ("[gst-maru] memory mapping failure");
109 GST_ERROR ("memory mapping failure");
114 if (buffer != MAP_FAILED) {
115 munmap (buffer, 4096);
125 plugin_init (GstPlugin *plugin)
127 GST_DEBUG_CATEGORY_INIT (maru_debug,
128 "tizen-emul", 0, "Tizen Emulator Codec Elements");
130 gst_maru_init_pix_fmt_info ();
132 g_mutex_lock (&gst_maru_mutex);
133 if (!codec_element_init) {
134 if (!gst_maru_codec_element_init ()) {
135 g_mutex_unlock (&gst_maru_mutex);
137 GST_ERROR ("failed to get codec elements from QEMU");
141 g_mutex_unlock (&gst_maru_mutex);
143 if (!gst_marudec_register (plugin, elements)) {
144 GST_ERROR ("failed to register decoder elements");
147 if (!gst_maruenc_register (plugin, elements)) {
148 GST_ERROR ("failed to register encoder elements");
156 #define PACKAGE "gst-plugins-emulator"
163 "Codecs for Tizen Emulator",
167 "gst-plugins-emulator",
168 "http://www.tizen.org"