[farsight2/master] Make session_new return a GError **

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:19:05 PST 2008


---
 gst-libs/gst/farsight/fs-base-conference.c  |   11 ++++++++---
 gst-libs/gst/farsight/fs-base-conference.h  |    3 ++-
 gst-libs/gst/farsight/fs-conference-iface.c |    5 +++--
 gst-libs/gst/farsight/fs-conference-iface.h |    6 ++++--
 gst/fsrtpconference/fs-rtp-conference.c     |   13 ++++++++++---
 gst/fsrtpconference/fs-rtp-session.c        |   21 +++++++++++++++------
 gst/fsrtpconference/fs-rtp-session.h        |    4 +++-
 7 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/gst-libs/gst/farsight/fs-base-conference.c b/gst-libs/gst/farsight/fs-base-conference.c
index c3c458b..14f74fc 100644
--- a/gst-libs/gst/farsight/fs-base-conference.c
+++ b/gst-libs/gst/farsight/fs-base-conference.c
@@ -37,6 +37,7 @@
 #endif
 
 #include "fs-base-conference.h"
+#include "fs-session.h"
 
 GST_DEBUG_CATEGORY_STATIC (fs_base_conference_debug);
 #define GST_CAT_DEFAULT fs_base_conference_debug
@@ -125,7 +126,8 @@ static void fs_base_conference_get_property (GObject *object, guint prop_id,
                                              GValue *value, GParamSpec *pspec);
 
 static FsSession *fs_base_conference_new_session (FsConference *conf,
-                                                  FsMediaType media_type);
+                                                  FsMediaType media_type,
+                                                  GError **error);
 static FsParticipant *fs_base_conference_new_participant (FsConference *conf,
                                                           gchar *cname);
 
@@ -228,7 +230,8 @@ void _remove_session_ptr (FsBaseConference *conf, FsSession *session)
 
 static FsSession *
 fs_base_conference_new_session (FsConference *conf,
-                                 FsMediaType media_type)
+                                FsMediaType media_type,
+                                GError **error)
 {
   FsBaseConferenceClass *klass = FS_BASE_CONFERENCE_GET_CLASS (conf);
   FsBaseConference *base_conf = FS_BASE_CONFERENCE (conf);
@@ -236,7 +239,7 @@ fs_base_conference_new_session (FsConference *conf,
   FsSession *new_session = NULL;
 
   if (klass->new_session) {
-    new_session = klass->new_session (base_conf, media_type);
+    new_session = klass->new_session (base_conf, media_type, error);
 
     if (!new_session)
       return NULL;
@@ -254,6 +257,8 @@ fs_base_conference_new_session (FsConference *conf,
         base_conf);
   } else {
     GST_WARNING_OBJECT (conf, "new_session not defined in element");
+    *error = g_error_new (FS_SESSION_ERROR,
+      FS_SESSION_ERROR_CONSTRUCTION, "new_session not defined in element");
   }
 
   return new_session;
diff --git a/gst-libs/gst/farsight/fs-base-conference.h b/gst-libs/gst/farsight/fs-base-conference.h
index f0b48c7..bb4c8f5 100644
--- a/gst-libs/gst/farsight/fs-base-conference.h
+++ b/gst-libs/gst/farsight/fs-base-conference.h
@@ -71,7 +71,8 @@ struct _FsBaseConferenceClass
   /*< public >*/
   /* virtual methods */
   FsSession *(*new_session) (FsBaseConference *conference,
-                             FsMediaType media_type);
+                             FsMediaType media_type,
+                             GError **error);
   FsParticipant *(*new_participant) (FsBaseConference *conference,
                                      gchar *cname);
 
diff --git a/gst-libs/gst/farsight/fs-conference-iface.c b/gst-libs/gst/farsight/fs-conference-iface.c
index cc1b103..c3094b5 100644
--- a/gst-libs/gst/farsight/fs-conference-iface.c
+++ b/gst-libs/gst/farsight/fs-conference-iface.c
@@ -90,13 +90,14 @@ fs_conference_iface_init (FsConferenceInterface * iface)
  * unref'd by the user when closing the session.
  */
 FsSession *
-fs_conference_new_session (FsConference *conference, FsMediaType media_type)
+fs_conference_new_session (FsConference *conference, FsMediaType media_type,
+                           GError **error)
 {
   FsConferenceInterface *iface =
       FS_CONFERENCE_GET_IFACE (conference);
 
   if (iface->new_session) {
-    return iface->new_session (conference, media_type);
+    return iface->new_session (conference, media_type, error);
   } else {
     GST_WARNING_OBJECT (conference, "new_session not defined in element");
   }
diff --git a/gst-libs/gst/farsight/fs-conference-iface.h b/gst-libs/gst/farsight/fs-conference-iface.h
index 7ab6cf8..c07e347 100644
--- a/gst-libs/gst/farsight/fs-conference-iface.h
+++ b/gst-libs/gst/farsight/fs-conference-iface.h
@@ -64,7 +64,8 @@ struct _FsConferenceInterface {
   GTypeInterface parent;
 
   /* virtual functions */
-  FsSession *(* new_session) (FsConference *conference, FsMediaType media_type);
+  FsSession *(* new_session) (FsConference *conference, FsMediaType media_type,
+                              GError **error);
 
   FsParticipant *(* new_participant) (FsConference *conference,
                                       gchar *cname);
@@ -77,7 +78,8 @@ GType fs_conference_get_type (void);
 
 /* virtual class function wrappers */
 FsSession *fs_conference_new_session (FsConference *conference,
-                                      FsMediaType media_type);
+                                      FsMediaType media_type,
+                                      GError **error);
 
 FsParticipant *fs_conference_new_participant (FsConference *conference,
                                               gchar *cname);
diff --git a/gst/fsrtpconference/fs-rtp-conference.c b/gst/fsrtpconference/fs-rtp-conference.c
index 3469430..4f9d953 100644
--- a/gst/fsrtpconference/fs-rtp-conference.c
+++ b/gst/fsrtpconference/fs-rtp-conference.c
@@ -95,7 +95,8 @@ GST_BOILERPLATE_FULL (FsRtpConference, fs_rtp_conference, FsBaseConference,
 
 static void fs_rtp_conference_finalize (GObject *object);
 static FsSession *fs_rtp_conference_new_session (FsBaseConference *conf,
-                                                 FsMediaType media_type);
+                                                 FsMediaType media_type,
+                                                 GError **error);
 static FsParticipant *fs_rtp_conference_new_participant (FsBaseConference *conf,
                                                          gchar *cname);
 
@@ -297,7 +298,8 @@ _remove_session (gpointer user_data,
 
 static FsSession *
 fs_rtp_conference_new_session (FsBaseConference *conf,
-                               FsMediaType media_type)
+                               FsMediaType media_type,
+                               GError **error)
 {
   FsRtpConference *self = FS_RTP_CONFERENCE (conf);
   FsSession *new_session = NULL;
@@ -309,7 +311,12 @@ fs_rtp_conference_new_session (FsBaseConference *conf,
   } while (fs_rtp_conference_get_session_by_id_locked (self, id));
   GST_OBJECT_UNLOCK (self);
 
-  new_session = FS_SESSION_CAST (fs_rtp_session_new (media_type, self, id));
+  new_session = FS_SESSION_CAST (fs_rtp_session_new (media_type, self, id,
+     error));
+
+  if (!new_session) {
+    return NULL;
+  }
 
   GST_OBJECT_LOCK (self);
   self->priv->sessions = g_list_append (self->priv->sessions, new_session);
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 17a577f..54fae13 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -387,13 +387,22 @@ fs_rtp_session_set_send_codec (FsSession *session, FsCodec *send_codec,
 }
 
 FsRtpSession *
-fs_rtp_session_new (FsMediaType media_type, GstElement *conference, guint id)
+fs_rtp_session_new (FsMediaType media_type, FsRtpConference *conference,
+                    guint id, GError **error)
 {
-  return g_object_new (FS_TYPE_RTP_SESSION,
-                       "media-type", media_type,
-                       "conference", conference,
-                       "id", id,
-                       NULL);
+  FsRtpSession *session = g_object_new (FS_TYPE_RTP_SESSION,
+    "media-type", media_type,
+    "conference", conference,
+    "id", id,
+    NULL);
+
+  if (session->priv->construction_error) {
+    *error = session->priv->construction_error;
+    g_object_unref (session);
+    return NULL;
+  }
+
+  return session;
 }
 
 
diff --git a/gst/fsrtpconference/fs-rtp-session.h b/gst/fsrtpconference/fs-rtp-session.h
index 53db95d..db14e0e 100644
--- a/gst/fsrtpconference/fs-rtp-session.h
+++ b/gst/fsrtpconference/fs-rtp-session.h
@@ -29,6 +29,8 @@
 
 #include <gst/farsight/fs-session.h>
 
+#include "fs-rtp-conference.h"
+
 G_BEGIN_DECLS
 
 /* TYPE MACROS */
@@ -69,7 +71,7 @@ GType fs_rtp_session_get_type (void);
 
 FsRtpSession *fs_rtp_session_new (FsMediaType media_type,
                                   FsRtpConference *conference,
-                                  guint id);
+                                  guint id, GError **error);
 
 GstCaps *fs_rtp_session_request_pt_map (FsRtpSession *session, guint pt);
 
-- 
1.5.6.5




More information about the farsight-commits mailing list