mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
patch over logic errors in osxvideosrc
apple's compiler carps, with reason, about some constructs in osxvideosrc.c fix them. also it seems that for some reason this required a gst-indent run. whee
This commit is contained in:
parent
1bd852073d
commit
f01ac09dfb
1 changed files with 129 additions and 127 deletions
|
@ -166,33 +166,36 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-yuv, "
|
||||
"format = (fourcc) UYVY, "
|
||||
"width = (int) [ 1, MAX ], "
|
||||
"height = (int) [ 1, MAX ], "
|
||||
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ], "
|
||||
//"framerate = (fraction) 0/1")
|
||||
"framerate = (fraction) 30/1")
|
||||
);
|
||||
|
||||
static void gst_osx_video_src_init_interfaces (GType type);
|
||||
static void gst_osx_video_src_type_add_device_property_probe_interface (GType type);
|
||||
static void
|
||||
gst_osx_video_src_init_interfaces (GType type);
|
||||
static void
|
||||
gst_osx_video_src_type_add_device_property_probe_interface (GType type);
|
||||
|
||||
GST_BOILERPLATE_FULL (GstOSXVideoSrc, gst_osx_video_src, GstPushSrc,
|
||||
GST_TYPE_PUSH_SRC, gst_osx_video_src_init_interfaces);
|
||||
|
||||
static void gst_osx_video_src_dispose (GObject * object);
|
||||
static void gst_osx_video_src_finalize (GstOSXVideoSrc * osx_video_src);
|
||||
static void gst_osx_video_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_osx_video_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static void gst_osx_video_src_set_property (GObject * object,
|
||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||
static void gst_osx_video_src_get_property (GObject * object,
|
||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||
|
||||
static GstStateChangeReturn gst_osx_video_src_change_state (
|
||||
GstElement * element, GstStateChange transition);
|
||||
static GstStateChangeReturn gst_osx_video_src_change_state (GstElement *
|
||||
element, GstStateChange transition);
|
||||
|
||||
static GstCaps *gst_osx_video_src_get_caps (GstBaseSrc * src);
|
||||
static gboolean gst_osx_video_src_set_caps (GstBaseSrc * src, GstCaps * caps);
|
||||
static gboolean gst_osx_video_src_set_caps (GstBaseSrc * src,
|
||||
GstCaps * caps);
|
||||
static gboolean gst_osx_video_src_start (GstBaseSrc * src);
|
||||
static gboolean gst_osx_video_src_stop (GstBaseSrc * src);
|
||||
static gboolean gst_osx_video_src_query (GstBaseSrc * bsrc, GstQuery * query);
|
||||
static gboolean gst_osx_video_src_query (GstBaseSrc * bsrc,
|
||||
GstQuery * query);
|
||||
static GstFlowReturn gst_osx_video_src_create (GstPushSrc * src,
|
||||
GstBuffer ** buf);
|
||||
static void gst_osx_video_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
|
||||
|
@ -200,8 +203,7 @@ static void gst_osx_video_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
|
|||
static gboolean prepare_capture (GstOSXVideoSrc * self);
|
||||
|
||||
/* \ = \\, : = \c */
|
||||
static GString *
|
||||
escape_string (const GString * in)
|
||||
static GString *escape_string (const GString * in)
|
||||
{
|
||||
GString *out;
|
||||
int n;
|
||||
|
@ -238,12 +240,10 @@ unescape_string (const GString * in)
|
|||
else {
|
||||
/* unknown code, we will eat the escape sequence */
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* string ends with backslash, we will eat it */
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
g_string_append_c (out, in->str[n]);
|
||||
}
|
||||
|
||||
|
@ -265,8 +265,7 @@ create_device_id (const gchar * sgname, int inputIndex)
|
|||
if (inputIndex >= 0) {
|
||||
out = g_string_new ("");
|
||||
g_string_printf (out, "%s:%d", nameenc->str, inputIndex);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* unspecified index */
|
||||
out = g_string_new (nameenc->str);
|
||||
}
|
||||
|
@ -283,7 +282,7 @@ parse_device_id (const gchar * id, gchar ** sgname, int * inputIndex)
|
|||
int numparts;
|
||||
GString *p1;
|
||||
GString *out1;
|
||||
int out2;
|
||||
int out2 = 0;
|
||||
|
||||
parts = g_strsplit (id, ":", -1);
|
||||
numparts = 0;
|
||||
|
@ -317,7 +316,8 @@ parse_device_id (const gchar * id, gchar ** sgname, int * inputIndex)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gchar *id;
|
||||
gchar *name;
|
||||
} video_device;
|
||||
|
@ -358,7 +358,7 @@ video_device_free_func (gpointer data, gpointer user_data)
|
|||
static GList *
|
||||
device_list (GstOSXVideoSrc * src)
|
||||
{
|
||||
SeqGrabComponent component;
|
||||
SeqGrabComponent component = NULL;
|
||||
SGChannel channel;
|
||||
SGDeviceList deviceList;
|
||||
SGDeviceName *deviceEntry;
|
||||
|
@ -378,13 +378,13 @@ device_list (GstOSXVideoSrc * src)
|
|||
/* if we already have a video channel allocated, use that */
|
||||
GST_DEBUG_OBJECT (src, "reusing existing channel for device_list");
|
||||
channel = src->video_chan;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* otherwise, allocate a temporary one */
|
||||
component = OpenDefaultComponent (SeqGrabComponentType, 0);
|
||||
if (!component) {
|
||||
err = paramErr;
|
||||
GST_ERROR_OBJECT (src, "OpenDefaultComponent failed. paramErr=%d", (int) err);
|
||||
GST_ERROR_OBJECT (src, "OpenDefaultComponent failed. paramErr=%d",
|
||||
(int) err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,8 @@ device_list (GstOSXVideoSrc * src)
|
|||
}
|
||||
}
|
||||
|
||||
err = SGGetChannelDeviceList (channel, sgDeviceListIncludeInputs, &deviceList);
|
||||
err =
|
||||
SGGetChannelDeviceList (channel, sgDeviceListIncludeInputs, &deviceList);
|
||||
if (err != noErr) {
|
||||
GST_ERROR_OBJECT (src, "SGGetChannelDeviceList returned %d", (int) err);
|
||||
goto end;
|
||||
|
@ -440,7 +441,8 @@ device_list (GstOSXVideoSrc * src)
|
|||
list = g_list_append (list, dev);
|
||||
|
||||
/* if this is the default device, note it */
|
||||
if (n == (*deviceList)->selectedIndex && i == (*inputList)->selectedIndex) {
|
||||
if (n == (*deviceList)->selectedIndex
|
||||
&& i == (*inputList)->selectedIndex) {
|
||||
default_dev = dev;
|
||||
}
|
||||
}
|
||||
|
@ -448,8 +450,7 @@ device_list (GstOSXVideoSrc * src)
|
|||
/* error */
|
||||
if (i == -1)
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* ### can a device have no defined inputs? */
|
||||
dev = video_device_alloc ();
|
||||
dev->id = create_device_id (sgname, -1);
|
||||
|
@ -475,7 +476,7 @@ device_list (GstOSXVideoSrc * src)
|
|||
}
|
||||
|
||||
end:
|
||||
if (!src->video_chan) {
|
||||
if (!src->video_chan && component) {
|
||||
err = CloseComponent (component);
|
||||
if (err != noErr)
|
||||
GST_WARNING_OBJECT (src, "CloseComponent returned %d", (int) err);
|
||||
|
@ -602,7 +603,8 @@ device_select (GstOSXVideoSrc * src)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_osx_video_src_iface_supported (GstImplementsInterface * iface, GType iface_type)
|
||||
gst_osx_video_src_iface_supported (GstImplementsInterface * iface,
|
||||
GType iface_type)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -697,8 +699,7 @@ gst_osx_video_src_class_init (GstOSXVideoSrcClass * klass)
|
|||
err = EnterMovies ();
|
||||
if (err == noErr) {
|
||||
klass->movies_enabled = TRUE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
klass->movies_enabled = FALSE;
|
||||
GST_ERROR ("EnterMovies returned %d", err);
|
||||
}
|
||||
|
@ -842,7 +843,8 @@ gst_osx_video_src_set_caps (GstBaseSrc * src, GstCaps * caps)
|
|||
|
||||
gst_structure_get_int (structure, "width", &width);
|
||||
gst_structure_get_int (structure, "height", &height);
|
||||
gst_structure_get_fraction (structure, "framerate", &framerate_num, &framerate_denom);
|
||||
gst_structure_get_fraction (structure, "framerate", &framerate_num,
|
||||
&framerate_denom);
|
||||
fps = (float) framerate_num / framerate_denom;
|
||||
|
||||
GST_DEBUG_OBJECT (src, "changing caps to %dx%d@%f", width, height, fps);
|
||||
|
@ -872,7 +874,6 @@ gst_osx_video_src_set_caps (GstBaseSrc * src, GstCaps * caps)
|
|||
GST_ERROR_OBJECT (self, "SGSetChannelBounds returned %d", (int) err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// ###: if we ever support choosing framerates, do something with this
|
||||
/*err = SGSetFrameRate (self->video_chan, FloatToFixed(fps));
|
||||
if (err != noErr) {
|
||||
|
@ -931,7 +932,8 @@ gst_osx_video_src_start (GstBaseSrc * src)
|
|||
self->seq_grab = OpenDefaultComponent (SeqGrabComponentType, 0);
|
||||
if (self->seq_grab == NULL) {
|
||||
err = paramErr;
|
||||
GST_ERROR_OBJECT (self, "OpenDefaultComponent failed. paramErr=%d", (int) err);
|
||||
GST_ERROR_OBJECT (self, "OpenDefaultComponent failed. paramErr=%d",
|
||||
(int) err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1044,8 +1046,7 @@ gst_osx_video_src_query (GstBaseSrc * bsrc, GstQuery * query)
|
|||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_osx_video_src_change_state (GstElement * element,
|
||||
GstStateChange transition)
|
||||
gst_osx_video_src_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstStateChangeReturn result;
|
||||
GstOSXVideoSrc *self;
|
||||
|
@ -1086,7 +1087,8 @@ gst_osx_video_src_change_state (GstElement * element,
|
|||
SGStop (self->seq_grab);
|
||||
SGRelease (self->seq_grab);
|
||||
DisposeHandle ((Handle) imageDesc);
|
||||
GST_ERROR_OBJECT (self, "SGGetChannelSampleDescription returned %d", (int) err);
|
||||
GST_ERROR_OBJECT (self, "SGGetChannelSampleDescription returned %d",
|
||||
(int) err);
|
||||
return GST_STATE_CHANGE_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1105,8 @@ gst_osx_video_src_change_state (GstElement * element,
|
|||
SGStop (self->seq_grab);
|
||||
SGRelease (self->seq_grab);
|
||||
DisposeHandle ((Handle) imageDesc);
|
||||
GST_ERROR_OBJECT (self, "DecompressSequenceBegin returned %d", (int) err);
|
||||
GST_ERROR_OBJECT (self, "DecompressSequenceBegin returned %d",
|
||||
(int) err);
|
||||
return GST_STATE_CHANGE_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1114,8 +1117,7 @@ gst_osx_video_src_change_state (GstElement * element,
|
|||
break;
|
||||
}
|
||||
|
||||
result = GST_ELEMENT_CLASS (parent_class)->change_state (element,
|
||||
transition);
|
||||
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
if (result == GST_STATE_CHANGE_FAILURE)
|
||||
return result;
|
||||
|
||||
|
@ -1270,8 +1272,7 @@ prepare_capture (GstOSXVideoSrc * self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
err = SGSetDataProc (self->seq_grab, NewSGDataUPP (data_proc),
|
||||
(long) self);
|
||||
err = SGSetDataProc (self->seq_grab, NewSGDataUPP (data_proc), (long) self);
|
||||
if (err != noErr) {
|
||||
GST_ERROR_OBJECT (self, "SGSetDataProc returned %d", (int) err);
|
||||
return FALSE;
|
||||
|
@ -1372,7 +1373,8 @@ probe_get_values (GstPropertyProbe * probe, guint prop_id,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_osx_video_src_property_probe_interface_init (GstPropertyProbeInterface * iface)
|
||||
gst_osx_video_src_property_probe_interface_init (GstPropertyProbeInterface *
|
||||
iface)
|
||||
{
|
||||
iface->get_properties = probe_get_properties;
|
||||
iface->probe_property = probe_probe_property;
|
||||
|
|
Loading…
Reference in a new issue