[farsight2/master] msn: Check required element before allowing subelement creation
Olivier Crête
olivier.crete at collabora.co.uk
Sun Jul 12 12:00:55 PDT 2009
---
gst/fsmsnconference/fs-msn-cam-recv-conference.c | 9 ++++
gst/fsmsnconference/fs-msn-cam-send-conference.c | 9 ++++
gst/fsmsnconference/fs-msn-conference.c | 16 ++++++++
gst/fsmsnconference/fs-msn-conference.h | 2 +
gst/fsmsnconference/fs-msn-stream.c | 46 ++-------------------
5 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/gst/fsmsnconference/fs-msn-cam-recv-conference.c b/gst/fsmsnconference/fs-msn-cam-recv-conference.c
index 12824ae..617566c 100644
--- a/gst/fsmsnconference/fs-msn-cam-recv-conference.c
+++ b/gst/fsmsnconference/fs-msn-cam-recv-conference.c
@@ -97,9 +97,18 @@ fs_msn_cam_recv_conference_init (FsMsnCamRecvConference *self,
FsMsnCamRecvConferenceClass *bclass)
{
FsMsnConference *conf = FS_MSN_CONFERENCE (self);
+ GstElementFactory *fact = NULL;
GST_DEBUG_OBJECT (conf, "fs_msn_cam_recv_conference_init");
conf->max_direction = FS_DIRECTION_RECV;
+
+ fact = gst_element_factory_find ("mimenc");
+ if (fact)
+ gst_object_unref (fact);
+ else
+ g_set_error (&conf->missing_element_error,
+ FS_ERROR, FS_ERROR_CONSTRUCTION,
+ "mimenc missing");
}
diff --git a/gst/fsmsnconference/fs-msn-cam-send-conference.c b/gst/fsmsnconference/fs-msn-cam-send-conference.c
index d63180f..5784013 100644
--- a/gst/fsmsnconference/fs-msn-cam-send-conference.c
+++ b/gst/fsmsnconference/fs-msn-cam-send-conference.c
@@ -97,9 +97,18 @@ fs_msn_cam_send_conference_init (FsMsnCamSendConference *self,
FsMsnCamSendConferenceClass *bclass)
{
FsMsnConference *conf = FS_MSN_CONFERENCE (self);
+ GstElementFactory *fact = NULL;
GST_DEBUG_OBJECT (conf, "fs_msn_cam_send_conference_init");
conf->max_direction = FS_DIRECTION_SEND;
+
+ fact = gst_element_factory_find ("mimenc");
+ if (fact)
+ gst_object_unref (fact);
+ else
+ g_set_error (&conf->missing_element_error,
+ FS_ERROR, FS_ERROR_CONSTRUCTION,
+ "mimenc missing");
}
diff --git a/gst/fsmsnconference/fs-msn-conference.c b/gst/fsmsnconference/fs-msn-conference.c
index 4eb499c..f751a10 100644
--- a/gst/fsmsnconference/fs-msn-conference.c
+++ b/gst/fsmsnconference/fs-msn-conference.c
@@ -132,6 +132,8 @@ fs_msn_conference_dispose (GObject * object)
self->priv->disposed = TRUE;
+ g_clear_error (&self->missing_element_error);
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -206,6 +208,13 @@ fs_msn_conference_new_session (FsBaseConference *conf,
FsMsnConference *self = FS_MSN_CONFERENCE (conf);
FsMsnSession *new_session = NULL;
+ if (self->missing_element_error)
+ {
+ if (error)
+ *error = g_error_copy (self->missing_element_error);
+ return NULL;
+ }
+
if (media_type != FS_MEDIA_TYPE_VIDEO)
{
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
@@ -246,6 +255,13 @@ fs_msn_conference_new_participant (FsBaseConference *conf,
FsMsnConference *self = FS_MSN_CONFERENCE (conf);
FsMsnParticipant *new_participant = NULL;
+ if (self->missing_element_error)
+ {
+ if (error)
+ *error = g_error_copy (self->missing_element_error);
+ return NULL;
+ }
+
GST_OBJECT_LOCK (self);
if (self->priv->participant)
{
diff --git a/gst/fsmsnconference/fs-msn-conference.h b/gst/fsmsnconference/fs-msn-conference.h
index fd4876a..0493906 100644
--- a/gst/fsmsnconference/fs-msn-conference.h
+++ b/gst/fsmsnconference/fs-msn-conference.h
@@ -56,6 +56,8 @@ struct _FsMsnConference
FsMsnConferencePrivate *priv;
FsStreamDirection max_direction;
+
+ GError *missing_element_error;
};
struct _FsMsnConferenceClass
diff --git a/gst/fsmsnconference/fs-msn-stream.c b/gst/fsmsnconference/fs-msn-stream.c
index 763a5ea..85c3132 100644
--- a/gst/fsmsnconference/fs-msn-stream.c
+++ b/gst/fsmsnconference/fs-msn-stream.c
@@ -450,50 +450,14 @@ static void
fs_msn_stream_constructed (GObject *object)
{
FsMsnStream *self = FS_MSN_STREAM_CAST (object);
- gboolean producer = FALSE;
-
- if (self->priv->conference->max_direction == FS_DIRECTION_SEND)
- {
- GstElementFactory *fact = NULL;
-
- producer = TRUE;
- fact = gst_element_factory_find ("mimenc");
- if (fact)
- {
- gst_object_unref (fact);
- }
- else
- {
- g_set_error (&self->priv->construction_error,
- FS_ERROR, FS_ERROR_CONSTRUCTION,
- "mimenc missing");
- return;
- }
- }
- else if (self->priv->conference->max_direction == FS_DIRECTION_RECV)
- {
- GstElementFactory *fact = NULL;
+ gboolean producer;
+ if (self->priv->conference->max_direction == FS_DIRECTION_RECV)
producer = FALSE;
- fact = gst_element_factory_find ("mimdec");
- if (fact)
- {
- gst_object_unref (fact);
- }
- else
- {
- g_set_error (&self->priv->construction_error,
- FS_ERROR, FS_ERROR_CONSTRUCTION,
- "mimdec missing");
- return;
- }
- }
+ else if (self->priv->conference->max_direction == FS_DIRECTION_SEND)
+ producer = TRUE;
else
- {
- self->priv->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_INVALID_ARGUMENTS,
- "Direction must be sending OR receiving");
- }
+ g_assert_not_reached ();
self->priv->connection = fs_msn_connection_new (self->priv->session_id,
producer, self->priv->initial_port);
--
1.5.6.5
More information about the farsight-commits
mailing list