[farsight2/master] msn: Move session-id/initial-port setting from the session to the stream's creation

Olivier Crête olivier.crete at collabora.co.uk
Tue Jul 14 09:50:59 PDT 2009


---
 gst/fsmsnconference/fs-msn-session.c |   47 +--------------------------------
 gst/fsmsnconference/fs-msn-stream.c  |   42 ++++++++++++++++++++++--------
 gst/fsmsnconference/fs-msn-stream.h  |    4 +-
 tests/check/msn/conference.c         |   14 ++++++---
 4 files changed, 44 insertions(+), 63 deletions(-)

diff --git a/gst/fsmsnconference/fs-msn-session.c b/gst/fsmsnconference/fs-msn-session.c
index 259a901..0ab632b 100644
--- a/gst/fsmsnconference/fs-msn-session.c
+++ b/gst/fsmsnconference/fs-msn-session.c
@@ -62,9 +62,7 @@ enum
   PROP_CODECS_WITHOUT_CONFIG,
   PROP_CURRENT_SEND_CODEC,
   PROP_CODECS_READY,
-  PROP_CONFERENCE,
-  PROP_SESSION_ID,
-  PROP_INITIAL_PORT
+  PROP_CONFERENCE
 };
 
 
@@ -80,9 +78,6 @@ struct _FsMsnSessionPrivate
 
   GstPad *media_sink_pad;
 
-  guint session_id;
-  guint initial_port;
-
   GMutex *mutex; /* protects the conference */
 };
 
@@ -166,24 +161,6 @@ fs_msn_session_class_init (FsMsnSessionClass *klass)
           FS_TYPE_MSN_CONFERENCE,
           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-  g_object_class_install_property (gobject_class,
-      PROP_SESSION_ID,
-      g_param_spec_uint ("session-id",
-          "The session-id of the session",
-          "This is the session-id of the MSN session",
-          9000, 9999, 9000,
-          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-  g_object_class_install_property (gobject_class,
-      PROP_INITIAL_PORT,
-      g_param_spec_uint ("initial-port",
-          "The initial port to listen on",
-          "The initial port to try to listen on for incoming connection."
-          " If already used, port+1 is tried until one succeeds",
-          1025, 65535, 1025,
-          G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-
   gobject_class->dispose = fs_msn_session_dispose;
   gobject_class->finalize = fs_msn_session_finalize;
 
@@ -196,7 +173,6 @@ fs_msn_session_init (FsMsnSession *self)
   /* member init */
   self->priv = FS_MSN_SESSION_GET_PRIVATE (self);
   self->priv->construction_error = NULL;
-  self->priv->session_id = g_random_int_range (9000, 9999);
 
   self->priv->mutex = g_mutex_new ();
 
@@ -327,12 +303,6 @@ fs_msn_session_get_property (GObject *object,
         g_value_take_boxed (value, send_codec);
         break;
       }
-    case PROP_SESSION_ID:
-      g_value_set_uint (value, self->priv->session_id);
-      break;
-    case PROP_INITIAL_PORT:
-      g_value_set_uint (value, self->priv->initial_port);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -364,18 +334,6 @@ fs_msn_session_set_property (GObject *object,
     case PROP_CONFERENCE:
       self->priv->conference = FS_MSN_CONFERENCE (g_value_dup_object (value));
       break;
-    case PROP_SESSION_ID:
-      if (self->priv->stream)
-        GST_DEBUG ("Cannot change the session-id after a stream is created");
-      else
-        self->priv->session_id = g_value_get_uint (value);
-      break;
-    case PROP_INITIAL_PORT:
-      if (self->priv->stream)
-        GST_DEBUG ("Cannot change the initial-port after a stream is created");
-      else
-        self->priv->initial_port = g_value_get_uint (value);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -503,8 +461,7 @@ fs_msn_session_new_stream (FsSession *session,
   msnparticipant = FS_MSN_PARTICIPANT (participant);
 
   new_stream = FS_STREAM_CAST (fs_msn_stream_new (self, msnparticipant,
-          direction, conference,
-          self->priv->session_id, self->priv->initial_port, error));
+          direction, conference, n_parameters, parameters, error));
 
   if (new_stream)
   {
diff --git a/gst/fsmsnconference/fs-msn-stream.c b/gst/fsmsnconference/fs-msn-stream.c
index 70da910..c95b918 100644
--- a/gst/fsmsnconference/fs-msn-stream.c
+++ b/gst/fsmsnconference/fs-msn-stream.c
@@ -174,7 +174,6 @@ fs_msn_stream_class_init (FsMsnStreamClass *klass)
           "This is the session-id of the MSN session",
           9000, 9999, 9000,
           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
   g_object_class_install_property (gobject_class,
       PROP_INITIAL_PORT,
       g_param_spec_uint ("initial-port",
@@ -197,6 +196,8 @@ fs_msn_stream_init (FsMsnStream *self)
   self->priv->direction = FS_DIRECTION_NONE;
   self->priv->orig_direction = FS_DIRECTION_NONE;
 
+  self->priv->session_id = g_random_int_range (9000, 9999);
+
   self->priv->mutex = g_mutex_new ();
 }
 
@@ -833,18 +834,37 @@ fs_msn_stream_new (FsMsnSession *session,
     FsMsnParticipant *participant,
     FsStreamDirection direction,
     FsMsnConference *conference,
-    guint session_id,
-    guint initial_port,
+    guint n_parameters,
+    GParameter *parameters,
     GError **error)
 {
-  FsMsnStream *self = g_object_new (FS_TYPE_MSN_STREAM,
-      "session", session,
-      "participant", participant,
-      "direction", direction,
-      "conference", conference,
-      "session-id", session_id,
-      "initial-port", initial_port,
-      NULL);
+  FsMsnStream *self;
+  GParameter *params;
+
+  params = g_new0 (GParameter, n_parameters + 4);
+
+  params[0].name = "session";
+  g_value_init (&params[0].value, FS_TYPE_SESSION);
+  g_value_set_object (&params[0].value, session);
+
+  params[1].name = "participant";
+  g_value_init (&params[1].value, FS_TYPE_PARTICIPANT);
+  g_value_set_object (&params[1].value, participant);
+
+  params[2].name = "direction";
+  g_value_init (&params[2].value, FS_TYPE_STREAM_DIRECTION);
+  g_value_set_flags (&params[2].value, direction);
+
+  params[3].name = "conference";
+  g_value_init (&params[3].value, FS_TYPE_MSN_CONFERENCE);
+  g_value_set_object (&params[3].value, conference);
+
+  if (n_parameters)
+    memcpy (params+4, parameters, n_parameters * sizeof(GParameter));
+
+  self = g_object_newv (FS_TYPE_MSN_STREAM, n_parameters + 4, params);
+
+  g_free (params);
 
   if (!self)
   {
diff --git a/gst/fsmsnconference/fs-msn-stream.h b/gst/fsmsnconference/fs-msn-stream.h
index 5b7ca61..4030b41 100644
--- a/gst/fsmsnconference/fs-msn-stream.h
+++ b/gst/fsmsnconference/fs-msn-stream.h
@@ -77,8 +77,8 @@ FsMsnStream *fs_msn_stream_new (FsMsnSession *session,
     FsMsnParticipant *participant,
     FsStreamDirection direction,
     FsMsnConference *conference,
-    guint session_id,
-    guint initial_port,
+    guint n_parameters,
+    GParameter *parameters,
     GError **error);
 
 
diff --git a/tests/check/msn/conference.c b/tests/check/msn/conference.c
index 195510a..66cb295 100644
--- a/tests/check/msn/conference.c
+++ b/tests/check/msn/conference.c
@@ -208,6 +208,8 @@ setup_conference (FsStreamDirection dir, struct SimpleMsnConference *target)
   struct SimpleMsnConference *dat = g_new0 (struct SimpleMsnConference, 1);
   GError *error = NULL;
   GstBus *bus;
+  GParameter param = {NULL, {0}};
+  gint n_params = 0;
 
   dat->target = target;
   dat->direction = dir;
@@ -258,14 +260,16 @@ setup_conference (FsStreamDirection dir, struct SimpleMsnConference *target)
   if (target)
   {
     guint session_id = 0;
-
-    g_object_get (target->session, "session-id", &session_id, NULL);
+    n_params = 1;
+    g_object_get (target->stream, "session-id", &session_id, NULL);
     ts_fail_unless (session_id >= 9000 && session_id < 10000);
-    g_object_set (dat->session, "session-id", session_id, NULL);
+    param.name = "session-id";
+    g_value_init (&param.value, G_TYPE_UINT);
+    g_value_set_uint (&param.value, session_id);
   }
 
-  dat->stream = fs_session_new_stream (dat->session, dat->part, dir, NULL, 0,
-      NULL, &error);
+  dat->stream = fs_session_new_stream (dat->session, dat->part, dir, NULL,
+      n_params, &param, &error);
   ts_fail_unless (dat->stream != NULL);
   ts_fail_unless (error == NULL);
 
-- 
1.5.6.5




More information about the farsight-commits mailing list