1 /*
2 * Copyright (C) 2017 Collabora Inc.
3 * Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
4 *
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.
9 *
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.
14 *
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., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <errno.h>
29 #include <unistd.h>
30 #include <string.h>
31
32 #include "gstv4l2object.h"
33 #include "gstv4l2vp8enc.h"
34 #include "gstv4l2vp8codec.h"
35
36 #include <string.h>
37 #include <gst/gst-i18n-plugin.h>
38
39 GST_DEBUG_CATEGORY_STATIC (gst_v4l2_vp8_enc_debug);
40 #define GST_CAT_DEFAULT gst_v4l2_vp8_enc_debug
41
42 static GstStaticCaps src_template_caps =
43 GST_STATIC_CAPS ("video/x-vp8, profile=(string) { 0, 1, 2, 3 }");
44
45 enum
46 {
47 PROP_0,
48 V4L2_STD_OBJECT_PROPS,
49 /* TODO */
50 };
51
52 #define gst_v4l2_vp8_enc_parent_class parent_class
53 G_DEFINE_TYPE (GstV4l2Vp8Enc, gst_v4l2_vp8_enc, GST_TYPE_V4L2_VIDEO_ENC);
54
55 static void
gst_v4l2_vp8_enc_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)56 gst_v4l2_vp8_enc_set_property (GObject * object,
57 guint prop_id, const GValue * value, GParamSpec * pspec)
58 {
59 /* TODO */
60 }
61
62 static void
gst_v4l2_vp8_enc_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)63 gst_v4l2_vp8_enc_get_property (GObject * object,
64 guint prop_id, GValue * value, GParamSpec * pspec)
65 {
66 /* TODO */
67 }
68
69 static void
gst_v4l2_vp8_enc_init(GstV4l2Vp8Enc * self)70 gst_v4l2_vp8_enc_init (GstV4l2Vp8Enc * self)
71 {
72 }
73
74 static void
gst_v4l2_vp8_enc_class_init(GstV4l2Vp8EncClass * klass)75 gst_v4l2_vp8_enc_class_init (GstV4l2Vp8EncClass * klass)
76 {
77 GstElementClass *element_class;
78 GObjectClass *gobject_class;
79 GstV4l2VideoEncClass *baseclass;
80
81 parent_class = g_type_class_peek_parent (klass);
82
83 element_class = (GstElementClass *) klass;
84 gobject_class = (GObjectClass *) klass;
85 baseclass = (GstV4l2VideoEncClass *) (klass);
86
87
88 GST_DEBUG_CATEGORY_INIT (gst_v4l2_vp8_enc_debug, "v4l2vp8enc", 0,
89 "V4L2 VP8 Encoder");
90
91 gst_element_class_set_static_metadata (element_class,
92 "V4L2 VP8 Encoder",
93 "Codec/Encoder/Video/Hardware",
94 "Encode VP8 video streams via V4L2 API",
95 "Nicolas Dufresne <nicolas.dufresne@collabora.com");
96
97 gobject_class->set_property =
98 GST_DEBUG_FUNCPTR (gst_v4l2_vp8_enc_set_property);
99 gobject_class->get_property =
100 GST_DEBUG_FUNCPTR (gst_v4l2_vp8_enc_get_property);
101
102 baseclass->codec_name = "VP8";
103 }
104
105 /* Probing functions */
106 gboolean
gst_v4l2_is_vp8_enc(GstCaps * sink_caps,GstCaps * src_caps)107 gst_v4l2_is_vp8_enc (GstCaps * sink_caps, GstCaps * src_caps)
108 {
109 return gst_v4l2_is_video_enc (sink_caps, src_caps,
110 gst_static_caps_get (&src_template_caps));
111 }
112
113 void
gst_v4l2_vp8_enc_register(GstPlugin * plugin,const gchar * basename,const gchar * device_path,gint video_fd,GstCaps * sink_caps,GstCaps * src_caps)114 gst_v4l2_vp8_enc_register (GstPlugin * plugin, const gchar * basename,
115 const gchar * device_path, gint video_fd, GstCaps * sink_caps,
116 GstCaps * src_caps)
117 {
118 const GstV4l2Codec *codec = gst_v4l2_vp8_get_codec ();
119 gst_v4l2_video_enc_register (plugin, GST_TYPE_V4L2_VP8_ENC,
120 "vp8", basename, device_path, codec, video_fd, sink_caps,
121 gst_static_caps_get (&src_template_caps), src_caps);
122 }
123