[farsight2/master] Don't make special sources return GErrors, their errors are internal and will be reported by GST_ERROR
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:24:16 PST 2008
---
gst/fsrtpconference/fs-rtp-dtmf-event-source.c | 38 +++++-----------
gst/fsrtpconference/fs-rtp-dtmf-sound-source.c | 56 ++++++++----------------
gst/fsrtpconference/fs-rtp-session.c | 22 ++++------
gst/fsrtpconference/fs-rtp-special-source.c | 55 ++++++-----------------
gst/fsrtpconference/fs-rtp-special-source.h | 11 ++---
5 files changed, 57 insertions(+), 125 deletions(-)
diff --git a/gst/fsrtpconference/fs-rtp-dtmf-event-source.c b/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
index ccbe0b9..3956860 100644
--- a/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
+++ b/gst/fsrtpconference/fs-rtp-dtmf-event-source.c
@@ -64,8 +64,7 @@ G_DEFINE_TYPE (FsRtpDtmfEventSource, fs_rtp_dtmf_event_source,
static GstElement *
fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
GList *negotiated_codecs,
- FsCodec *selected_codec,
- GError **error);
+ FsCodec *selected_codec);
static gboolean fs_rtp_dtmf_event_source_class_want_source (
@@ -245,8 +244,7 @@ fs_rtp_dtmf_event_source_class_want_source (FsRtpSpecialSourceClass *klass,
static GstElement *
fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
GList *negotiated_codecs,
- FsCodec *selected_codec,
- GError **error)
+ FsCodec *selected_codec)
{
FsCodec *telephony_codec = NULL;
GstCaps *caps = NULL;
@@ -259,26 +257,19 @@ fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
telephony_codec = get_telephone_event_codec (negotiated_codecs,
selected_codec->clock_rate);
- if (!telephony_codec)
- {
- g_set_error (error, FS_ERROR, FS_ERROR_INTERNAL,
- "Could not find a telephone-event for the current codec's clock-rate");
- return NULL;
- }
+ g_return_val_if_fail (telephony_codec, NULL);
bin = gst_bin_new (NULL);
dtmfsrc = gst_element_factory_make ("rtpdtmfsrc", NULL);
if (!dtmfsrc)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not make rtpdtmfsrc");
+ GST_ERROR ("Could not make rtpdtmfsrc");
goto error;
}
if (!gst_bin_add (GST_BIN (bin), dtmfsrc))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add rtpdtmfsrc to bin");
+ GST_ERROR ("Could not add rtpdtmfsrc to bin");
gst_object_unref (dtmfsrc);
goto error;
}
@@ -286,14 +277,12 @@ fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
capsfilter = gst_element_factory_make ("capsfilter", NULL);
if (!capsfilter)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not make capsfilter");
+ GST_ERROR ("Could not make capsfilter");
goto error;
}
if (!gst_bin_add (GST_BIN (bin), capsfilter))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add capsfilter to bin");
+ GST_ERROR ("Could not add capsfilter to bin");
gst_object_unref (capsfilter);
goto error;
}
@@ -309,29 +298,26 @@ fs_rtp_dtmf_event_source_build (FsRtpSpecialSource *source,
if (!gst_element_link_pads (dtmfsrc, "src", capsfilter, "sink"))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not link the rtpdtmfsrc and its capsfilter");
+ GST_ERROR ("Could not link the rtpdtmfsrc and its capsfilter");
goto error;
}
pad = gst_element_get_static_pad (capsfilter, "src");
if (!pad)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not get \"src\" pad from capsfilter");
+ GST_ERROR ("Could not get \"src\" pad from capsfilter");
goto error;
}
ghostpad = gst_ghost_pad_new ("src", pad);
if (!ghostpad)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not create a ghostpad for capsfilter src pad for rtpdtmfsrc");
+ GST_ERROR ("Could not create a ghostpad for capsfilter src pad for"
+ " rtpdtmfsrc");
goto error;
}
if (!gst_element_add_pad (bin, ghostpad))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not get \"src\" ghostpad to dtmf source bin");
+ GST_ERROR ("Could not get \"src\" ghostpad to dtmf source bin");
gst_object_unref (pad);
goto error;
}
diff --git a/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c b/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
index f73a4ce..aa0ab5b 100644
--- a/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
+++ b/gst/fsrtpconference/fs-rtp-dtmf-sound-source.c
@@ -64,8 +64,7 @@ G_DEFINE_TYPE(FsRtpDtmfSoundSource, fs_rtp_dtmf_sound_source,
static GstElement *
fs_rtp_dtmf_sound_source_build (FsRtpSpecialSource *source,
GList *negotiated_codecs,
- FsCodec *selected_codec,
- GError **error);
+ FsCodec *selected_codec);
static gboolean fs_rtp_dtmf_sound_source_class_want_source (
@@ -190,8 +189,7 @@ fs_rtp_dtmf_sound_source_class_want_source (FsRtpSpecialSourceClass *klass,
static GstElement *
fs_rtp_dtmf_sound_source_build (FsRtpSpecialSource *source,
GList *negotiated_codecs,
- FsCodec *selected_codec,
- GError **error)
+ FsCodec *selected_codec)
{
FsCodec *telephony_codec = NULL;
GstCaps *caps = NULL;
@@ -208,26 +206,19 @@ fs_rtp_dtmf_sound_source_build (FsRtpSpecialSource *source,
telephony_codec = get_pcm_law_sound_codec (negotiated_codecs,
&encoder_name, &payloader_name);
- if (!telephony_codec)
- {
- g_set_error (error, FS_ERROR, FS_ERROR_INTERNAL,
- "Could not find a pcma/pcmu to send dtmf on");
- return NULL;
- }
+ g_return_val_if_fail (telephony_codec, NULL);
bin = gst_bin_new (NULL);
dtmfsrc = gst_element_factory_make ("dtmfsrc", NULL);
if (!dtmfsrc)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not make rtpdtmfsrc");
+ GST_ERROR ("Could not make rtpdtmfsrc");
goto error;
}
if (!gst_bin_add (GST_BIN (bin), dtmfsrc))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add rtpdtmfsrc to bin");
+ GST_ERROR ("Could not add rtpdtmfsrc to bin");
gst_object_unref (dtmfsrc);
goto error;
}
@@ -235,58 +226,50 @@ fs_rtp_dtmf_sound_source_build (FsRtpSpecialSource *source,
encoder = gst_element_factory_make (encoder_name, NULL);
if (!encoder)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not make %s", encoder_name);
+ GST_ERROR ("Could not make %s", encoder_name);
goto error;
}
if (!gst_bin_add (GST_BIN (bin), encoder))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add %s to bin", encoder_name);
+ GST_ERROR ("Could not add %s to bin", encoder_name);
gst_object_unref (dtmfsrc);
goto error;
}
if (!gst_element_link_pads (dtmfsrc, "src", encoder, "sink"))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not link the rtpdtmfsrc and %s", encoder_name);
+ GST_ERROR ("Could not link the rtpdtmfsrc and %s", encoder_name);
goto error;
}
payloader = gst_element_factory_make (payloader_name, NULL);
if (!payloader)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not make %s", payloader_name);
+ GST_ERROR ("Could not make %s", payloader_name);
goto error;
}
if (!gst_bin_add (GST_BIN (bin), payloader))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add %s to bin", payloader_name);
+ GST_ERROR ("Could not add %s to bin", payloader_name);
gst_object_unref (dtmfsrc);
goto error;
}
if (!gst_element_link_pads (encoder, "src", payloader, "sink"))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not link the %s and %s", encoder_name, payloader_name);
+ GST_ERROR ("Could not link the %s and %s", encoder_name, payloader_name);
goto error;
}
capsfilter = gst_element_factory_make ("capsfilter", NULL);
if (!capsfilter)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not make capsfilter");
+ GST_ERROR ("Could not make capsfilter");
goto error;
}
if (!gst_bin_add (GST_BIN (bin), capsfilter))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add capsfilter to bin");
+ GST_ERROR ("Could not add capsfilter to bin");
gst_object_unref (capsfilter);
goto error;
}
@@ -302,29 +285,26 @@ fs_rtp_dtmf_sound_source_build (FsRtpSpecialSource *source,
if (!gst_element_link_pads (payloader, "src", capsfilter, "sink"))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not link the %s and its capsfilter", payloader_name);
+ GST_ERROR ("Could not link the %s and its capsfilter", payloader_name);
goto error;
}
pad = gst_element_get_static_pad (capsfilter, "src");
if (!pad)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not get \"src\" pad from capsfilter");
+ GST_ERROR ("Could not get \"src\" pad from capsfilter");
goto error;
}
ghostpad = gst_ghost_pad_new ("src", pad);
if (!ghostpad)
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not create a ghostpad for capsfilter src pad for dtmfsrc");
+ GST_ERROR ("Could not create a ghostpad for capsfilter src pad"
+ " for dtmfsrc");
goto error;
}
if (!gst_element_add_pad (bin, ghostpad))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not get \"src\" ghostpad to dtmf sound source bin");
+ GST_ERROR ("Could not get \"src\" ghostpad to dtmf sound source bin");
gst_object_unref (pad);
goto error;
}
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 0007844..f7da3f4 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -2899,11 +2899,12 @@ _send_src_pad_blocked_callback (GstPad *pad, gboolean blocked,
self->priv->extra_sources,
self->priv->codec_associations, codec,
GST_ELEMENT (self->priv->conference),
- self->priv->rtpmuxer, &error);
+ self->priv->rtpmuxer);
if (error)
{
- fs_session_emit_error (FS_SESSION (self), error->code,
- "Could not remove unused special sources: %s", error->message);
+ fs_session_emit_error (FS_SESSION (self), FS_ERROR_INTERNAL,
+ "Could not remove unused special sources",
+ "Could not remove unused special sources");
goto done;
}
@@ -2927,11 +2928,12 @@ _send_src_pad_blocked_callback (GstPad *pad, gboolean blocked,
self->priv->extra_sources,
self->priv->codec_associations, codec,
GST_ELEMENT (self->priv->conference),
- self->priv->rtpmuxer, &error);
+ self->priv->rtpmuxer);
if (error)
{
- fs_session_emit_error (FS_SESSION (self), error->code,
- "Could not create special sources: %s", error->message);
+ fs_session_emit_error (FS_SESSION (self), FS_ERROR_INTERNAL,
+ "Could not create special sources",
+ "Could not create special sources");
goto done;
}
@@ -2966,7 +2968,6 @@ static gboolean
fs_rtp_session_verify_send_codec_bin_locked (FsRtpSession *self, GError **error)
{
GstElement *codecbin = NULL;
- GError *local_gerror = NULL;
FsCodec *codec = NULL;
CodecBlueprint *bp = NULL;
@@ -3000,12 +3001,7 @@ fs_rtp_session_verify_send_codec_bin_locked (FsRtpSession *self, GError **error)
self->priv->extra_sources,
self->priv->codec_associations, codec,
GST_ELEMENT (self->priv->conference),
- self->priv->rtpmuxer, &local_gerror);
- if (local_gerror)
- {
- g_propagate_error (error, local_gerror);
- goto error;
- }
+ self->priv->rtpmuxer);
}
done:
diff --git a/gst/fsrtpconference/fs-rtp-special-source.c b/gst/fsrtpconference/fs-rtp-special-source.c
index 56e85f8..770069d 100644
--- a/gst/fsrtpconference/fs-rtp-special-source.c
+++ b/gst/fsrtpconference/fs-rtp-special-source.c
@@ -102,8 +102,7 @@ fs_rtp_special_source_new (FsRtpSpecialSourceClass *klass,
GList *negotiated_codecs,
FsCodec *selected_codec,
GstElement *bin,
- GstElement *rtpmuxer,
- GError **error);
+ GstElement *rtpmuxer);
static gboolean
fs_rtp_special_source_update (FsRtpSpecialSource *source,
GList *negotiated_codecs,
@@ -388,7 +387,6 @@ _source_order_compare_func (gconstpointer item1,gconstpointer item2)
* @send_codec: The currently selected send codec
* @bin: The #GstBin to add the stuff to
* @rtpmuxer: The rtpmux element
- * @error: NULL or the local of a #GError
*
* This function removes any special source that are not compatible with the
* currently selected send codec.
@@ -401,8 +399,7 @@ fs_rtp_special_sources_remove (
GList *negotiated_codecs,
FsCodec *send_codec,
GstElement *bin,
- GstElement *rtpmuxer,
- GError **error)
+ GstElement *rtpmuxer)
{
GList *klass_item = NULL;
@@ -449,7 +446,6 @@ fs_rtp_special_sources_remove (
* @send_codec: The currently selected send codec
* @bin: The #GstBin to add the stuff to
* @rtpmuxer: The rtpmux element
- * @error: NULL or the local of a #GError
*
* This function add special sources that don't already exist but are needed
*
@@ -461,8 +457,7 @@ fs_rtp_special_sources_create (
GList *negotiated_codecs,
FsCodec *send_codec,
GstElement *bin,
- GstElement *rtpmuxer,
- GError **error)
+ GstElement *rtpmuxer)
{
GList *klass_item = NULL;
@@ -491,7 +486,7 @@ fs_rtp_special_sources_create (
send_codec))
{
obj = fs_rtp_special_source_new (klass, negotiated_codecs, send_codec,
- bin, rtpmuxer, error);
+ bin, rtpmuxer);
if (!obj)
goto error;
current_extra_sources = g_list_insert_sorted (current_extra_sources,
@@ -509,49 +504,29 @@ fs_rtp_special_source_new (FsRtpSpecialSourceClass *klass,
GList *negotiated_codecs,
FsCodec *selected_codec,
GstElement *bin,
- GstElement *rtpmuxer,
- GError **error)
+ GstElement *rtpmuxer)
{
FsRtpSpecialSource *source = NULL;
- if (!klass->build)
- {
- g_set_error (error, FS_ERROR, FS_ERROR_NOT_IMPLEMENTED,
- "Could not build new %s source", G_OBJECT_CLASS_NAME (klass));
- return NULL;
- }
+ g_return_val_if_fail (klass, NULL);
+ g_return_val_if_fail (klass->build, NULL);
+ g_return_val_if_fail (GST_IS_BIN (bin), NULL);
+ g_return_val_if_fail (GST_IS_ELEMENT (rtpmuxer), NULL);
source = g_object_new (G_OBJECT_CLASS_TYPE (klass),
"bin", bin,
"rtpmuxer", rtpmuxer,
NULL);
- g_assert (source);
-
-
- if (!source->priv->outer_bin)
- {
- g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "Invalid bin set");
- goto error;
- }
-
- if (!source->priv->rtpmuxer)
- {
- g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "Invalid rtpmuxer set");
- goto error;
- }
+ g_return_val_if_fail (source, NULL);
- source->priv->src = klass->build (source, negotiated_codecs, selected_codec,
- error);
+ source->priv->src = klass->build (source, negotiated_codecs, selected_codec);
if (!source->priv->src)
goto error;
if (!gst_bin_add (GST_BIN (source->priv->outer_bin), source->priv->src))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add bin to outer bin");
+ GST_ERROR ("Could not add bin to outer bin");
gst_object_unref (source->priv->src);
source->priv->src = NULL;
goto error;
@@ -560,16 +535,14 @@ fs_rtp_special_source_new (FsRtpSpecialSourceClass *klass,
if (!gst_element_link_pads (source->priv->src, "src",
rtpmuxer, NULL))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not link rtpdtmfsrc src to muxer sink");
+ GST_ERROR ("Could not link rtpdtmfsrc src to muxer sink");
goto error_added;
}
if (!gst_element_sync_state_with_parent (source->priv->src))
{
- g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not sync capsfilter state with its parent");
+ GST_ERROR ("Could not sync capsfilter state with its parent");
goto error_added;
}
diff --git a/gst/fsrtpconference/fs-rtp-special-source.h b/gst/fsrtpconference/fs-rtp-special-source.h
index b35a297..138c81e 100644
--- a/gst/fsrtpconference/fs-rtp-special-source.h
+++ b/gst/fsrtpconference/fs-rtp-special-source.h
@@ -57,7 +57,7 @@ typedef struct _FsRtpSpecialSourcePrivate FsRtpSpecialSourcePrivate;
/**
* FsRtpSpecialSourceClass:
* @build: The method builds the source #GstElement from the list of negotiated
- * codecs and selected codecs, it returns %NULL and sets the #GError on error
+ * codecs and selected codecs, it returns %NULL on error
* @update: This optional method can update the content of the current source
* if its possible. If the source can not be modified, it returns %FALSE (and
* a new source will be created)
@@ -81,8 +81,7 @@ struct _FsRtpSpecialSourceClass
GstElement* (*build) (FsRtpSpecialSource *source,
GList *negotiated_codecs,
- FsCodec *selected_codec,
- GError **error);
+ FsCodec *selected_codec);
gboolean (*update) (FsRtpSpecialSource *source,
GList *negotiated_codecs,
@@ -122,8 +121,7 @@ fs_rtp_special_sources_remove (
GList *negotiated_codecs,
FsCodec *send_codec,
GstElement *bin,
- GstElement *rtpmuxer,
- GError **error);
+ GstElement *rtpmuxer);
GList *
fs_rtp_special_sources_create (
@@ -131,8 +129,7 @@ fs_rtp_special_sources_create (
GList *negotiated_codecs,
FsCodec *send_codec,
GstElement *bin,
- GstElement *rtpmuxer,
- GError **error);
+ GstElement *rtpmuxer);
GList *
fs_rtp_special_sources_destroy (GList *current_extra_sources);
--
1.5.6.5
More information about the farsight-commits
mailing list