gstreamer/ext/gio/gstgio.c
Sebastian Dröge ec7afb6f84 Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00

214 lines
5.9 KiB
C

/* GStreamer
*
* Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
* Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
*
* 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 "gstgio.h"
#include "gstgiosink.h"
#include "gstgiosrc.h"
#include "gstgiostreamsink.h"
#include "gstgiostreamsrc.h"
GST_DEBUG_CATEGORY_STATIC (gst_gio_debug);
#define GST_CAT_DEFAULT gst_gio_debug
/* @func_name: Name of the GIO function, for debugging messages.
* @err: Error location. *err may be NULL, but err must be non-NULL.
* @ret: Flow return location. May be NULL. Is set to either #GST_FLOW_ERROR
* or #GST_FLOW_WRONG_STATE.
*
* Returns: TRUE to indicate a handled error. Error at given location err will
* be freed and *err will be set to NULL. A FALSE return indicates an unhandled
* error: The err location is unchanged and guaranteed to be != NULL. ret, if
* given, is set to GST_FLOW_ERROR.
*/
gboolean
gst_gio_error (gpointer element, const gchar * func_name, GError ** err,
GstFlowReturn * ret)
{
gboolean handled = TRUE;
if (ret)
*ret = GST_FLOW_ERROR;
if (GST_GIO_ERROR_MATCHES (*err, CANCELLED)) {
GST_DEBUG_OBJECT (element, "blocking I/O call cancelled (%s)", func_name);
if (ret)
*ret = GST_FLOW_WRONG_STATE;
} else if (*err != NULL) {
handled = FALSE;
} else {
GST_ELEMENT_ERROR (element, LIBRARY, FAILED, (NULL),
("%s call failed without error set", func_name));
}
if (handled)
g_clear_error (err);
return handled;
}
GstFlowReturn
gst_gio_seek (gpointer element, GSeekable * stream, guint64 offset,
GCancellable * cancel)
{
gboolean success;
GstFlowReturn ret;
GError *err = NULL;
GST_LOG_OBJECT (element, "seeking to offset %" G_GINT64_FORMAT, offset);
success = g_seekable_seek (stream, offset, G_SEEK_SET, cancel, &err);
if (success)
ret = GST_FLOW_OK;
else if (!gst_gio_error (element, "g_seekable_seek", &err, &ret)) {
GST_ELEMENT_ERROR (element, RESOURCE, SEEK, (NULL),
("Could not seek: %s", err->message));
g_clear_error (&err);
}
return ret;
}
static gchar **
gst_gio_get_supported_protocols (void)
{
return g_strdupv ((gchar **)
g_vfs_get_supported_uri_schemes (g_vfs_get_default ()));
}
static GstURIType
gst_gio_uri_handler_get_type_sink (void)
{
return GST_URI_SINK;
}
static GstURIType
gst_gio_uri_handler_get_type_src (void)
{
return GST_URI_SRC;
}
static gchar **
gst_gio_uri_handler_get_protocols (void)
{
static gchar **protocols = NULL;
if (!protocols)
protocols = gst_gio_get_supported_protocols ();
return protocols;
}
static const gchar *
gst_gio_uri_handler_get_uri (GstURIHandler * handler)
{
GstElement *element = GST_ELEMENT (handler);
const gchar *uri;
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
g_object_get (G_OBJECT (element), "location", &uri, NULL);
return uri;
}
static gboolean
gst_gio_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
{
GstElement *element = GST_ELEMENT (handler);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
if (GST_STATE (element) == GST_STATE_PLAYING ||
GST_STATE (element) == GST_STATE_PAUSED)
return FALSE;
g_object_set (G_OBJECT (element), "location", uri, NULL);
return TRUE;
}
static void
gst_gio_uri_handler_init (gpointer g_iface, gpointer iface_data)
{
GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
gboolean sink = GPOINTER_TO_INT (iface_data); /* See in do_init below. */
if (sink)
iface->get_type = gst_gio_uri_handler_get_type_sink;
else
iface->get_type = gst_gio_uri_handler_get_type_src;
iface->get_protocols = gst_gio_uri_handler_get_protocols;
iface->get_uri = gst_gio_uri_handler_get_uri;
iface->set_uri = gst_gio_uri_handler_set_uri;
}
void
gst_gio_uri_handler_do_init (GType type)
{
GInterfaceInfo uri_handler_info = {
gst_gio_uri_handler_init,
NULL,
NULL
};
/* Store information for uri_handler_init to use for distinguishing the
* element types. This lets us use a single interface implementation for both
* classes. */
uri_handler_info.interface_data = GINT_TO_POINTER (g_type_is_a (type,
GST_TYPE_BASE_SINK));
g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_handler_info);
}
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean ret = TRUE;
GST_DEBUG_CATEGORY_INIT (gst_gio_debug, "gio", 0, "GIO elements");
/* FIXME: Rank is MARGINAL for now, should be at least SECONDARY+1 in the future
* to replace gnomevfssink/src. For testing purposes PRIMARY+1 one makes sense
* so it gets autoplugged and preferred over filesrc/sink. */
ret &= gst_element_register (plugin, "giosink", GST_RANK_MARGINAL,
GST_TYPE_GIO_SINK);
ret &= gst_element_register (plugin, "giosrc", GST_RANK_MARGINAL,
GST_TYPE_GIO_SRC);
ret &= gst_element_register (plugin, "giostreamsink", GST_RANK_NONE,
GST_TYPE_GIO_STREAM_SINK);
ret &= gst_element_register (plugin, "giostreamsrc", GST_RANK_NONE,
GST_TYPE_GIO_STREAM_SRC);
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "gio",
"GIO elements", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
GST_PACKAGE_ORIGIN)