2020-02-03 15:06:46 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2020 Collabora Ltd.
|
|
|
|
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-09 16:31:11 +00:00
|
|
|
#include "gstv4l2codecdevice.h"
|
|
|
|
#include "gstv4l2codech264dec.h"
|
2020-04-24 20:15:25 +00:00
|
|
|
#include "gstv4l2codecvp8dec.h"
|
2020-02-09 16:31:11 +00:00
|
|
|
#include "gstv4l2decoder.h"
|
|
|
|
#include "linux/h264-ctrls.h"
|
2020-04-24 20:15:25 +00:00
|
|
|
#include "linux/vp8-ctrls.h"
|
2020-02-09 16:31:11 +00:00
|
|
|
#include "linux/media.h"
|
2020-02-03 15:06:46 +00:00
|
|
|
|
2020-02-04 20:52:45 +00:00
|
|
|
#define GST_CAT_DEFAULT gstv4l2codecs_debug
|
|
|
|
GST_DEBUG_CATEGORY (gstv4l2codecs_debug);
|
|
|
|
|
2020-02-09 16:31:11 +00:00
|
|
|
static void
|
|
|
|
register_video_decoder (GstPlugin * plugin, GstV4l2CodecDevice * device)
|
|
|
|
{
|
|
|
|
GstV4l2Decoder *decoder = gst_v4l2_decoder_new (device);
|
|
|
|
gint i;
|
|
|
|
guint32 fmt;
|
|
|
|
|
|
|
|
if (!gst_v4l2_decoder_open (decoder)) {
|
|
|
|
g_object_unref (decoder);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; gst_v4l2_decoder_enum_sink_fmt (decoder, i, &fmt); i++) {
|
|
|
|
switch (fmt) {
|
|
|
|
case V4L2_PIX_FMT_H264_SLICE:
|
|
|
|
GST_INFO_OBJECT (decoder, "Registering %s as H264 Decoder",
|
|
|
|
device->name);
|
|
|
|
gst_v4l2_codec_h264_dec_register (plugin, device, GST_RANK_PRIMARY + 1);
|
|
|
|
break;
|
2020-04-24 20:15:25 +00:00
|
|
|
case V4L2_PIX_FMT_VP8_FRAME:
|
|
|
|
GST_INFO_OBJECT (decoder, "Registering %s as VP8 Decoder",
|
|
|
|
device->name);
|
|
|
|
gst_v4l2_codec_vp8_dec_register (plugin, device, GST_RANK_PRIMARY + 1);
|
|
|
|
break;
|
2020-02-09 16:31:11 +00:00
|
|
|
default:
|
|
|
|
GST_FIXME_OBJECT (decoder, "%" GST_FOURCC_FORMAT " is not supported.",
|
|
|
|
GST_FOURCC_ARGS (fmt));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (decoder);
|
|
|
|
}
|
|
|
|
|
2020-02-03 15:06:46 +00:00
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
2020-02-09 16:31:11 +00:00
|
|
|
GList *devices, *d;
|
2020-03-26 19:38:47 +00:00
|
|
|
const gchar *paths[] = { "/dev", NULL };
|
|
|
|
const gchar *names[] = { "media", NULL };
|
2020-02-09 16:31:11 +00:00
|
|
|
|
2020-02-04 20:52:45 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gstv4l2codecs_debug, "v4l2codecs", 0,
|
|
|
|
"V4L2 CODECs general debug");
|
2020-02-09 16:31:11 +00:00
|
|
|
|
2020-03-26 19:38:47 +00:00
|
|
|
/* Add some dependency, so the dynamic features get updated upon changes in
|
|
|
|
* /dev/media* */
|
|
|
|
gst_plugin_add_dependency (plugin,
|
|
|
|
NULL, paths, names, GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX);
|
|
|
|
|
2020-02-09 16:31:11 +00:00
|
|
|
devices = gst_v4l2_codec_find_devices ();
|
|
|
|
for (d = devices; d; d = g_list_next (d)) {
|
|
|
|
GstV4l2CodecDevice *device = d->data;
|
|
|
|
|
|
|
|
if (device->function == MEDIA_ENT_F_PROC_VIDEO_DECODER)
|
|
|
|
register_video_decoder (plugin, device);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_v4l2_codec_device_list_free (devices);
|
2020-02-03 15:06:46 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
v4l2codecs,
|
|
|
|
"V4L2 CODEC Accelerators plugin",
|
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|