1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/* GStreamer Raspberry Pi Camera Source Device Provider
* Copyright (C) 2014 Tim-Philipp Müller <tim@centricular.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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstrpicamsrcdeviceprovider.h"
#include <string.h>
#include "RaspiCapture.h"
/* FIXME: translations */
#define _(s) s
static GstRpiCamSrcDevice *gst_rpi_cam_src_device_new (void);
G_DEFINE_TYPE (GstRpiCamSrcDeviceProvider, gst_rpi_cam_src_device_provider,
GST_TYPE_DEVICE_PROVIDER);
static GList *gst_rpi_cam_src_device_provider_probe (GstDeviceProvider *
provider);
static void
gst_rpi_cam_src_device_provider_class_init (GstRpiCamSrcDeviceProviderClass *
klass)
{
GstDeviceProviderClass *dprovider_class = GST_DEVICE_PROVIDER_CLASS (klass);
dprovider_class->probe = gst_rpi_cam_src_device_provider_probe;
gst_device_provider_class_set_static_metadata (dprovider_class,
"Raspberry Pi Camera Source Device Provider", "Source/Video",
"Lists Raspberry Pi camera devices",
"Tim-Philipp Müller <tim@centricular.com>");
}
static void
gst_rpi_cam_src_device_provider_init (GstRpiCamSrcDeviceProvider * provider)
{
raspicapture_init ();
}
static GList *
gst_rpi_cam_src_device_provider_probe (GstDeviceProvider * provider)
{
GstRpiCamSrcDevice *device;
int supported = 0, detected = 0;
raspicamcontrol_get_camera (&supported, &detected);
if (!detected) {
GST_INFO ("No Raspberry Pi camera module detected.");
return NULL;
} else if (!supported) {
GST_WARNING
("Raspberry Pi camera module not supported, make sure to enable it.");
return NULL;
}
GST_INFO ("Raspberry Pi camera module detected and supported.");
device = gst_rpi_cam_src_device_new ();
return g_list_append (NULL, device);
}
G_DEFINE_TYPE (GstRpiCamSrcDevice, gst_rpi_cam_src_device, GST_TYPE_DEVICE);
static GstElement *gst_rpi_cam_src_device_create_element (GstDevice * device,
const gchar * name);
static void
gst_rpi_cam_src_device_class_init (GstRpiCamSrcDeviceClass * klass)
{
GstDeviceClass *device_class = GST_DEVICE_CLASS (klass);
device_class->create_element = gst_rpi_cam_src_device_create_element;
}
static void
gst_rpi_cam_src_device_init (GstRpiCamSrcDevice * device)
{
/* nothing to do here */
}
static GstElement *
gst_rpi_cam_src_device_create_element (GstDevice * device, const gchar * name)
{
return gst_element_factory_make ("rpicamsrc", name);
}
static GstRpiCamSrcDevice *
gst_rpi_cam_src_device_new (void)
{
GstRpiCamSrcDevice *device;
GValue profiles = G_VALUE_INIT;
GValue val = G_VALUE_INIT;
GstStructure *s;
GstCaps *caps;
/* FIXME: retrieve limits from the camera module, max width/height/fps etc. */
s = gst_structure_new ("video/x-h264",
"width", GST_TYPE_INT_RANGE, 1, 1920,
"height", GST_TYPE_INT_RANGE, 1, 1080,
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, RPICAMSRC_MAX_FPS, 1,
"stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au", NULL);
g_value_init (&profiles, GST_TYPE_LIST);
g_value_init (&val, G_TYPE_STRING);
g_value_set_static_string (&val, "high");
gst_value_list_append_value (&profiles, &val);
g_value_set_static_string (&val, "main");
gst_value_list_append_value (&profiles, &val);
g_value_set_static_string (&val, "constrained-baseline");
gst_value_list_append_value (&profiles, &val);
g_value_set_static_string (&val, "baseline");
gst_value_list_append_and_take_value (&profiles, &val);
gst_structure_take_value (s, "profiles", &profiles);
caps = gst_caps_new_full (s, NULL);
device = g_object_new (GST_TYPE_RPICAMSRC_DEVICE,
"display-name", _("Raspberry Pi Camera Module"),
"device-class", "Video/Source", "caps", caps, NULL);
gst_caps_unref (caps);
return device;
}
|