diff options
author | Olivier CrĂȘte <olivier.crete@collabora.co.uk> | 2011-02-09 11:25:04 +0000 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2011-10-11 15:39:40 -0400 |
commit | ba8b7d2818e7a78de47d40cc3aa4594458bb0193 (patch) | |
tree | b807f5d09bfdcd2e76142cfc3850a2a532447ff6 | |
parent | 49f40c71c2073c94c8f824e3bd1d7594211dc2e9 (diff) | |
download | farstream-ba8b7d2818e7a78de47d40cc3aa4594458bb0193.tar.gz |
session: Remove transmitter creation from fs_session_new_stream()
23 files changed, 101 insertions, 514 deletions
diff --git a/examples/commandline/simple-call-shm.c b/examples/commandline/simple-call-shm.c index a8d81f5a..7d4d61a0 100644 --- a/examples/commandline/simple-call-shm.c +++ b/examples/commandline/simple-call-shm.c @@ -135,6 +135,11 @@ add_audio_session (GstElement *pipeline, FsConference *conf, guint id, gst_object_unref (pad2); gst_object_unref (pad); + ses->stream = fs_session_new_stream (ses->session, part, FS_DIRECTION_BOTH, + &error); + print_error (error); + g_assert (ses->stream); + cand = fs_candidate_new ("", FS_COMPONENT_RTP, FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, send_socket, 0); cands = g_list_prepend (NULL, cand); @@ -143,11 +148,8 @@ add_audio_session (GstElement *pipeline, FsConference *conf, guint id, g_value_init (¶m.value, FS_TYPE_CANDIDATE_LIST); g_value_take_boxed (¶m.value, cands); - ses->stream = fs_session_new_stream (ses->session, part, FS_DIRECTION_BOTH, - "shm", 1, ¶m, &error); + res = fs_stream_set_transmitter (ses->stream, "shm", ¶m, 1, &error); print_error (error); - g_assert (ses->stream); - g_value_unset (¶m.value); g_signal_connect (ses->stream, "src-pad-added", diff --git a/examples/commandline/simple-call.c b/examples/commandline/simple-call.c index d4863e6a..e2206418 100644 --- a/examples/commandline/simple-call.c +++ b/examples/commandline/simple-call.c @@ -126,6 +126,11 @@ add_audio_session (GstElement *pipeline, FsConference *conf, guint id, gst_object_unref (pad); + ses->stream = fs_session_new_stream (ses->session, part, FS_DIRECTION_BOTH, + &error); + print_error (error); + g_assert (ses->stream); + cands = g_list_prepend (NULL, fs_candidate_new ("", FS_COMPONENT_RTP, FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, NULL, localport)); @@ -133,8 +138,7 @@ add_audio_session (GstElement *pipeline, FsConference *conf, guint id, g_value_init (¶m.value, FS_TYPE_CANDIDATE_LIST); g_value_take_boxed (¶m.value, cands); - ses->stream = fs_session_new_stream (ses->session, part, FS_DIRECTION_BOTH, - "rawudp", 1, ¶m, &error); + res = fs_stream_set_transmitter (ses->stream, "rawudp", ¶m, 1, &error); print_error (error); g_assert (ses->stream); diff --git a/gst-libs/gst/farsight/fs-session.c b/gst-libs/gst/farsight/fs-session.c index 7a541bf9..55be2b98 100644 --- a/gst-libs/gst/farsight/fs-session.c +++ b/gst-libs/gst/farsight/fs-session.c @@ -377,12 +377,6 @@ fs_session_error_forward (GObject *signal_src, * @participant: #FsParticipant of a participant for the new stream * @direction: #FsStreamDirection describing the direction of the new stream that will * be created for this participant - * @transmitter: Name of the type of transmitter to use for this session - * @stream_transmitter_n_parameters: Number of parametrs passed to the stream - * transmitter - * @stream_transmitter_parameters: (array length=stream_transmitter_n_parameters) (allow-none): - * an array of n_parameters #GParameter struct that will be passed - * to the newly-create #FsStreamTransmitter * @error: location of a #GError, or %NULL if no error occured * * This function creates a stream for the given participant into the active session. @@ -392,11 +386,10 @@ fs_session_error_forward (GObject *signal_src, * returns NULL. */ FsStream * -fs_session_new_stream (FsSession *session, FsParticipant *participant, - FsStreamDirection direction, const gchar *transmitter, - guint stream_transmitter_n_parameters, - GParameter *stream_transmitter_parameters, - GError **error) +fs_session_new_stream (FsSession *session, + FsParticipant *participant, + FsStreamDirection direction, + GError **error) { FsSessionClass *klass; FsStream *new_stream = NULL; @@ -406,9 +399,7 @@ fs_session_new_stream (FsSession *session, FsParticipant *participant, klass = FS_SESSION_GET_CLASS (session); g_return_val_if_fail (klass->new_stream, NULL); - new_stream = klass->new_stream (session, participant, direction, - transmitter, stream_transmitter_n_parameters, - stream_transmitter_parameters, error); + new_stream = klass->new_stream (session, participant, direction, error); if (!new_stream) return NULL; diff --git a/gst-libs/gst/farsight/fs-session.h b/gst-libs/gst/farsight/fs-session.h index 1277dcb1..e731d276 100644 --- a/gst-libs/gst/farsight/fs-session.h +++ b/gst-libs/gst/farsight/fs-session.h @@ -124,9 +124,6 @@ struct _FsSessionClass FsStream *(* new_stream) (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint stream_transmitter_n_parameters, - GParameter *stream_transmitter_parameters, GError **error); gboolean (* start_telephony_event) (FsSession *session, guint8 event, @@ -172,9 +169,6 @@ GType fs_session_get_type (void); FsStream *fs_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint stream_transmitter_n_parameters, - GParameter *stream_transmitter_parameters, GError **error); gboolean fs_session_start_telephony_event (FsSession *session, guint8 event, diff --git a/gst-libs/gst/farsight/fs-stream.c b/gst-libs/gst/farsight/fs-stream.c index e909e0cd..df4c3046 100644 --- a/gst-libs/gst/farsight/fs-stream.c +++ b/gst-libs/gst/farsight/fs-stream.c @@ -602,8 +602,10 @@ fs_stream_get_src_pads_iterator (FsStream *stream) * @transmitter: Name of the type of transmitter to use for this stream * @stream_transmitter_n_parameters: Number of parametrs passed to the stream * transmitter - * @stream_transmitter_parameters: an array of n_parameters #GParameter struct - * that will be passed to the newly-created #FsStreamTransmitter + * @stream_transmitter_parameters: + * (array length=stream_transmitter_n_parameters) (allow-none): + * an array of n_parameters #GParameter struct that will be passed + * to the newly-create #FsStreamTransmitter * @error: location of a #GError, or %NULL if no error occured * * Set the transmitter to use for this stream. This function will only succeed diff --git a/gst/fsmsnconference/fs-msn-session.c b/gst/fsmsnconference/fs-msn-session.c index 658f59ec..d57bc88b 100644 --- a/gst/fsmsnconference/fs-msn-session.c +++ b/gst/fsmsnconference/fs-msn-session.c @@ -118,9 +118,6 @@ static void fs_msn_session_constructed (GObject *object); static FsStream *fs_msn_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint n_parameters, - GParameter *parameters, GError **error); static GType @@ -458,9 +455,6 @@ static FsStream * fs_msn_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint n_parameters, - GParameter *parameters, GError **error) { FsMsnSession *self = FS_MSN_SESSION (session); @@ -487,23 +481,20 @@ 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, n_parameters, parameters, error)); + direction, conference)); - if (new_stream) + GST_OBJECT_LOCK (conference); + if (self->priv->stream) { - GST_OBJECT_LOCK (conference); - if (self->priv->stream) - { - g_object_unref (new_stream); - goto already_have_stream; - } - self->priv->stream = (FsMsnStream *) new_stream; - g_object_weak_ref (G_OBJECT (new_stream), _remove_stream, self); - - if (self->priv->tos) - fs_msn_stream_set_tos_locked (self->priv->stream, self->priv->tos); - GST_OBJECT_UNLOCK (conference); + g_object_unref (new_stream); + goto already_have_stream; } + self->priv->stream = (FsMsnStream *) new_stream; + g_object_weak_ref (G_OBJECT (new_stream), _remove_stream, self); + + fs_msn_stream_set_tos_locked (self->priv->stream, self->priv->tos); + GST_OBJECT_UNLOCK (conference); + gst_object_unref (conference); diff --git a/gst/fsmsnconference/fs-msn-stream.c b/gst/fsmsnconference/fs-msn-stream.c index 07f67e03..99c0f504 100644 --- a/gst/fsmsnconference/fs-msn-stream.c +++ b/gst/fsmsnconference/fs-msn-stream.c @@ -94,8 +94,6 @@ struct _FsMsnStreamPrivate GstPad *src_pad; FsMsnConnection *connection; - GError *construction_error; - guint session_id; guint initial_port; @@ -800,10 +798,7 @@ FsMsnStream * fs_msn_stream_new (FsMsnSession *session, FsMsnParticipant *participant, FsStreamDirection direction, - FsMsnConference *conference, - guint n_parameters, - GParameter *parameters, - GError **error) + FsMsnConference *conference) { FsMsnStream *self; @@ -814,19 +809,6 @@ fs_msn_stream_new (FsMsnSession *session, "conference", conference, NULL); - if (!self) - { - *error = g_error_new (FS_ERROR, FS_ERROR_CONSTRUCTION, - "Could not create object"); - return NULL; - } - else if (self->priv->construction_error) - { - g_propagate_error (error, self->priv->construction_error); - g_object_unref (self); - return NULL; - } - return self; } @@ -908,7 +890,7 @@ fs_msn_stream_set_transmitter (FsStream *stream, G_CALLBACK (_connection_failed), self); if (!fs_msn_connection_gather_local_candidates (self->priv->connection, - &self->priv->construction_error)) + error)) { g_object_unref (self->priv->connection); self->priv->connection = NULL; diff --git a/gst/fsmsnconference/fs-msn-stream.h b/gst/fsmsnconference/fs-msn-stream.h index 5818c674..4a05ff0a 100644 --- a/gst/fsmsnconference/fs-msn-stream.h +++ b/gst/fsmsnconference/fs-msn-stream.h @@ -76,10 +76,7 @@ GType fs_msn_stream_get_type (void); FsMsnStream *fs_msn_stream_new (FsMsnSession *session, FsMsnParticipant *participant, FsStreamDirection direction, - FsMsnConference *conference, - guint n_parameters, - GParameter *parameters, - GError **error); + FsMsnConference *conference); void fs_msn_stream_set_tos_locked (FsMsnStream *self, gint tos); diff --git a/gst/fsrawconference/fs-raw-session.c b/gst/fsrawconference/fs-raw-session.c index 7bc0fb1c..9509b32d 100644 --- a/gst/fsrawconference/fs-raw-session.c +++ b/gst/fsrawconference/fs-raw-session.c @@ -163,9 +163,6 @@ static void fs_raw_session_constructed (GObject *object); static FsStream *fs_raw_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint n_parameters, - GParameter *parameters, GError **error); static gchar **fs_raw_session_list_transmitters (FsSession *session); @@ -1148,15 +1145,11 @@ static FsStream * fs_raw_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint n_parameters, - GParameter *parameters, GError **error) { FsRawSession *self = FS_RAW_SESSION (session); FsStream *new_stream = NULL; FsRawConference *conference; - FsStreamTransmitter *stream_transmitter = NULL; if (!FS_IS_RAW_PARTICIPANT (participant)) { @@ -1174,33 +1167,23 @@ fs_raw_session_new_stream (FsSession *session, goto already_have_stream; GST_OBJECT_UNLOCK (conference); - if (transmitter) - { - stream_transmitter = _stream_get_stream_transmitter (NULL, - transmitter, participant, parameters, n_parameters, error, self); - if (!stream_transmitter) - goto error; - } - new_stream = FS_STREAM_CAST (fs_raw_stream_new (self, FS_RAW_PARTICIPANT (participant), - direction, conference, stream_transmitter, - _stream_get_stream_transmitter, self, error)); + direction, conference, + _stream_get_stream_transmitter, self)); - if (new_stream) - { - g_signal_connect_object (new_stream, "notify::remote-codecs", - G_CALLBACK (_stream_remote_codecs_changed), self, 0); + GST_OBJECT_LOCK (conference); + if (self->priv->stream) + goto already_have_stream; - GST_OBJECT_LOCK (conference); - if (self->priv->stream) - { - goto already_have_stream; - } - self->priv->stream = (FsRawStream *) new_stream; - GST_OBJECT_UNLOCK (conference); - } + self->priv->stream = (FsRawStream *) new_stream; + + GST_OBJECT_UNLOCK (conference); + + g_signal_connect_object (new_stream, "notify::remote-codecs", + G_CALLBACK (_stream_remote_codecs_changed), self, 0); + done: gst_object_unref (conference); @@ -1210,16 +1193,6 @@ already_have_stream: GST_OBJECT_UNLOCK (conference); g_set_error (error, FS_ERROR, FS_ERROR_ALREADY_EXISTS, "There already is a stream in this session"); - goto error; - -error: - fs_raw_session_remove_stream (self, NULL); - - if (stream_transmitter) - { - fs_stream_transmitter_stop (stream_transmitter); - g_object_unref (stream_transmitter); - } goto done; } diff --git a/gst/fsrawconference/fs-raw-stream.c b/gst/fsrawconference/fs-raw-stream.c index ed8e5ea1..c41b5114 100644 --- a/gst/fsrawconference/fs-raw-stream.c +++ b/gst/fsrawconference/fs-raw-stream.c @@ -90,8 +90,6 @@ struct _FsRawStreamPrivate GList *remote_codecs; - GError *construction_error; - gulong local_candidates_prepared_handler_id; gulong new_active_candidate_pair_handler_id; gulong new_local_candidate_handler_id; @@ -153,8 +151,6 @@ static void fs_raw_stream_set_property (GObject *object, const GValue *value, GParamSpec *pspec); -static void fs_raw_stream_constructed (GObject *object); - static void _local_candidates_prepared ( FsStreamTransmitter *stream_transmitter, gpointer user_data); @@ -202,7 +198,6 @@ fs_raw_stream_class_init (FsRawStreamClass *klass) gobject_class->set_property = fs_raw_stream_set_property; gobject_class->get_property = fs_raw_stream_get_property; - gobject_class->constructed = fs_raw_stream_constructed; gobject_class->dispose = fs_raw_stream_dispose; gobject_class->finalize = fs_raw_stream_finalize; @@ -503,64 +498,6 @@ fs_raw_stream_set_property (GObject *object, } } -static void -fs_raw_stream_constructed (GObject *object) -{ - FsRawStream *self = FS_RAW_STREAM_CAST (object); - - if (!self->priv->conference) { - self->priv->construction_error = g_error_new (FS_ERROR, - FS_ERROR_INVALID_ARGUMENTS, "A Stream needs a conference object"); - return; - } - - if (self->priv->stream_transmitter) - { - g_object_set (self->priv->stream_transmitter, "sending", - (self->priv->direction & FS_DIRECTION_SEND) ? TRUE : FALSE, NULL); - - self->priv->local_candidates_prepared_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "local-candidates-prepared", - G_CALLBACK (_local_candidates_prepared), - self, 0); - self->priv->new_active_candidate_pair_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "new-active-candidate-pair", - G_CALLBACK (_new_active_candidate_pair), - self, 0); - self->priv->new_local_candidate_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "new-local-candidate", - G_CALLBACK (_new_local_candidate), - self, 0); - self->priv->error_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "error", - G_CALLBACK (_transmitter_error), - self, 0); - self->priv->state_changed_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "state-changed", - G_CALLBACK (_state_changed), - self, 0); - - if (!fs_stream_transmitter_gather_local_candidates ( - self->priv->stream_transmitter, - &self->priv->construction_error)) - { - if (!self->priv->construction_error) - self->priv->construction_error = g_error_new (FS_ERROR, - FS_ERROR_INTERNAL, - "Unknown error while gathering local candidates"); - return; - } - } - - if (G_OBJECT_CLASS (fs_raw_stream_parent_class)->constructed) - G_OBJECT_CLASS (fs_raw_stream_parent_class)->constructed (object); -} - static void _local_candidates_prepared (FsStreamTransmitter *stream_transmitter, @@ -855,10 +792,8 @@ fs_raw_stream_new (FsRawSession *session, FsRawParticipant *participant, FsStreamDirection direction, FsRawConference *conference, - FsStreamTransmitter *stream_transmitter, stream_get_new_stream_transmitter_cb get_new_stream_transmitter_cb, - gpointer user_data, - GError **error) + gpointer user_data) { FsRawStream *self; @@ -870,22 +805,8 @@ fs_raw_stream_new (FsRawSession *session, "participant", participant, "direction", direction, "conference", conference, - "stream-transmitter", stream_transmitter, NULL); - if (!self) - { - *error = g_error_new (FS_ERROR, FS_ERROR_CONSTRUCTION, - "Could not create object"); - return NULL; - } - else if (self->priv->construction_error) - { - g_propagate_error (error, self->priv->construction_error); - g_object_unref (self); - return NULL; - } - self->priv->get_new_stream_transmitter_cb = get_new_stream_transmitter_cb; self->priv->user_data = user_data; @@ -964,8 +885,7 @@ fs_raw_stream_set_transmitter (FsStream *stream, if (!fs_stream_transmitter_gather_local_candidates ( self->priv->stream_transmitter, error)) { - if (!self->priv->construction_error) - GST_OBJECT_LOCK (conf); + GST_OBJECT_LOCK (conf); self->priv->stream_transmitter = NULL; GST_OBJECT_UNLOCK (conf); diff --git a/gst/fsrawconference/fs-raw-stream.h b/gst/fsrawconference/fs-raw-stream.h index c94ff8d3..4afa54db 100644 --- a/gst/fsrawconference/fs-raw-stream.h +++ b/gst/fsrawconference/fs-raw-stream.h @@ -84,10 +84,8 @@ FsRawStream *fs_raw_stream_new (FsRawSession *session, FsRawParticipant *participant, FsStreamDirection direction, FsRawConference *conference, - FsStreamTransmitter *stream_transmitter, stream_get_new_stream_transmitter_cb get_new_stream_transmitter_cb, - gpointer user_data, - GError **error); + gpointer user_data); G_END_DECLS diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c index 240c0fd2..44e58372 100644 --- a/gst/fsrtpconference/fs-rtp-session.c +++ b/gst/fsrtpconference/fs-rtp-session.c @@ -242,9 +242,6 @@ static void fs_rtp_session_constructed (GObject *object); static FsStream *fs_rtp_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint n_parameters, - GParameter *parameters, GError **error); static gboolean fs_rtp_session_start_telephony_event (FsSession *session, guint8 event, @@ -276,21 +273,13 @@ static gboolean _stream_new_remote_codecs (FsRtpStream *stream, static FsStreamTransmitter* _stream_get_new_stream_transmitter ( FsRtpStream *stream, - const gchar *transmitter_name, FsParticipant *participant, + const gchar *transmitter_name, GParameter *parameters, guint n_parameters, GError **error, gpointer user_data); -static FsStreamTransmitter *fs_rtp_session_get_new_stream_transmitter ( - FsRtpSession *self, - const gchar *transmitter_name, - FsParticipant *participant, - guint n_parameters, - GParameter *parameters, - GError **error); - static GList *fs_rtp_session_get_codecs_need_resend (FsSession *session, GList *old_codecs, GList *new_codecs); @@ -1725,7 +1714,6 @@ _remove_stream (gpointer user_data, * @participant: #FsParticipant of a participant for the new stream * @direction: #FsStreamDirection describing the direction of the new stream that will * be created for this participant - * @transmitter: Name of the type of transmitter to use for this session * @error: location of a #GError, or NULL if no error occured * * This function creates a stream for the given participant into the active session. @@ -1737,15 +1725,11 @@ static FsStream * fs_rtp_session_new_stream (FsSession *session, FsParticipant *participant, FsStreamDirection direction, - const gchar *transmitter, - guint n_parameters, - GParameter *parameters, GError **error) { FsRtpSession *self = FS_RTP_SESSION (session); FsRtpParticipant *rtpparticipant = NULL; FsStream *new_stream = NULL; - FsStreamTransmitter *st = NULL; if (!FS_IS_RTP_PARTICIPANT (participant)) { @@ -1759,26 +1743,13 @@ fs_rtp_session_new_stream (FsSession *session, rtpparticipant = FS_RTP_PARTICIPANT (participant); - if (transmitter) - { - st = fs_rtp_session_get_new_stream_transmitter (self, transmitter, - participant, n_parameters, parameters, error); - - if (!st) - { - fs_rtp_session_has_disposed_exit (self); - return NULL; - } - } - new_stream = FS_STREAM_CAST (fs_rtp_stream_new (self, rtpparticipant, - direction, st, _stream_new_remote_codecs, + direction, _stream_new_remote_codecs, _stream_known_source_packet_received, _stream_sending_changed_locked, _stream_ssrc_added_cb, _stream_get_new_stream_transmitter, - self, error)); - + self)); if (new_stream) { @@ -1793,10 +1764,12 @@ fs_rtp_session_new_stream (FsSession *session, self->priv->streams = g_list_append (self->priv->streams, new_stream); self->priv->streams_cookie++; FS_RTP_SESSION_UNLOCK (self); - - g_object_weak_ref (G_OBJECT (new_stream), _remove_stream, self); } + + g_object_weak_ref (G_OBJECT (new_stream), _remove_stream, self); + fs_rtp_session_has_disposed_exit (self); + return new_stream; } @@ -2322,46 +2295,10 @@ fs_rtp_session_get_transmitter (FsRtpSession *self, } -/** - * fs_rtp_session_get_new_stream_transmitter: - * @self: a #FsRtpSession - * @transmitter_name: The name of the transmitter to create a stream for - * @participant: The #FsRtpParticipant for this stream - * @n_parameters: the number of parameters - * @parameters: a table of n_parameters #GParameter structs - * - * This function will create a new #FsStreamTransmitter, possibly creating - * and inserting into the pipeline its parent #FsTransmitter - * - * Returns: a newly allocated #FsStreamTransmitter - */ - -static FsStreamTransmitter * -fs_rtp_session_get_new_stream_transmitter (FsRtpSession *self, - const gchar *transmitter_name, FsParticipant *participant, guint n_parameters, - GParameter *parameters, GError **error) -{ - FsTransmitter *transmitter; - FsStreamTransmitter *st = NULL; - - transmitter = fs_rtp_session_get_transmitter (self, transmitter_name, error); - - if (!transmitter) - return NULL; - - st = fs_transmitter_new_stream_transmitter (transmitter, participant, - n_parameters, parameters, error); - - g_object_unref (transmitter); - - return st; -} - - static FsStreamTransmitter * _stream_get_new_stream_transmitter (FsRtpStream *stream, - const gchar *transmitter_name, FsParticipant *participant, + const gchar *transmitter_name, GParameter *parameters, guint n_parameters, GError **error, diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c index 21fbf609..c688e52d 100644 --- a/gst/fsrtpconference/fs-rtp-stream.c +++ b/gst/fsrtpconference/fs-rtp-stream.c @@ -63,7 +63,6 @@ enum PROP_DIRECTION, PROP_PARTICIPANT, PROP_SESSION, - PROP_STREAM_TRANSMITTER, PROP_RTP_HEADER_EXTENSIONS }; @@ -74,8 +73,6 @@ struct _FsRtpStreamPrivate FsStreamDirection direction; - GError *construction_error; - stream_new_remote_codecs_cb new_remote_codecs_cb; stream_known_source_packet_receive_cb known_source_packet_received_cb; stream_sending_changed_locked_cb sending_changed_locked_cb; @@ -110,8 +107,6 @@ static void fs_rtp_stream_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void fs_rtp_stream_constructed (GObject *object); - static gboolean fs_rtp_stream_add_remote_candidates (FsStream *stream, GList *candidates, @@ -174,7 +169,6 @@ fs_rtp_stream_class_init (FsRtpStreamClass *klass) gobject_class->set_property = fs_rtp_stream_set_property; gobject_class->get_property = fs_rtp_stream_get_property; - gobject_class->constructed = fs_rtp_stream_constructed; gobject_class->dispose = fs_rtp_stream_dispose; gobject_class->finalize = fs_rtp_stream_finalize; @@ -204,20 +198,6 @@ fs_rtp_stream_class_init (FsRtpStreamClass *klass) g_object_class_override_property (gobject_class, PROP_SESSION, "session"); - /** - * FsRtpStream:stream-transmitter: - * - * The #FsStreamTransmitter for this stream. - * - */ - g_object_class_install_property (gobject_class, - PROP_STREAM_TRANSMITTER, - g_param_spec_object ("stream-transmitter", - "The transmitter use by the stream", - "An FsStreamTransmitter used by this stream", - FS_TYPE_STREAM_TRANSMITTER, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (gobject_class, PROP_RTP_HEADER_EXTENSIONS, g_param_spec_boxed ("rtp-header-extensions", @@ -226,7 +206,6 @@ fs_rtp_stream_class_init (FsRtpStreamClass *klass) " would like to use", FS_TYPE_RTP_HEADER_EXTENSION_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - } static void @@ -466,10 +445,6 @@ fs_rtp_stream_set_property (GObject *object, case PROP_PARTICIPANT: self->participant = FS_RTP_PARTICIPANT (g_value_dup_object (value)); break; - case PROP_STREAM_TRANSMITTER: - self->priv->stream_transmitter = - FS_STREAM_TRANSMITTER (g_value_get_object (value)); - break; case PROP_DIRECTION: { FsStreamTransmitter *st = NULL; @@ -540,65 +515,6 @@ fs_rtp_stream_set_property (GObject *object, } -static void -fs_rtp_stream_constructed (GObject *object) -{ - FsRtpStream *self = FS_RTP_STREAM_CAST (object); - - if (!self->priv->stream_transmitter) - goto done; - - g_object_set (self->priv->stream_transmitter, "sending", - self->priv->direction & FS_DIRECTION_SEND, NULL); - - self->priv->local_candidates_prepared_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "local-candidates-prepared", - G_CALLBACK (_local_candidates_prepared), - self, 0); - self->priv->new_active_candidate_pair_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "new-active-candidate-pair", - G_CALLBACK (_new_active_candidate_pair), - self, 0); - self->priv->new_local_candidate_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "new-local-candidate", - G_CALLBACK (_new_local_candidate), - self, 0); - self->priv->error_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "error", - G_CALLBACK (_transmitter_error), - self, 0); - self->priv->known_source_packet_received_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "known-source-packet-received", - G_CALLBACK (_known_source_packet_received), - self, 0); - self->priv->state_changed_handler_id = - g_signal_connect_object (self->priv->stream_transmitter, - "state-changed", - G_CALLBACK (_state_changed), - self, 0); - - if (!fs_stream_transmitter_gather_local_candidates ( - self->priv->stream_transmitter, - &self->priv->construction_error)) - { - if (!self->priv->construction_error) - self->priv->construction_error = g_error_new (FS_ERROR, - FS_ERROR_INTERNAL, - "Unknown error while gathering local candidates"); - return; - } - -done: - - if (G_OBJECT_CLASS (fs_rtp_stream_parent_class)->constructed) - G_OBJECT_CLASS (fs_rtp_stream_parent_class)->constructed(object); -} - /** * fs_rtp_stream_add_remote_candidate: @@ -743,8 +659,6 @@ fs_rtp_stream_set_remote_codecs (FsStream *stream, * @session: The #FsRtpSession this stream is a child of * @participant: The #FsRtpParticipant this stream is for * @direction: the initial #FsDirection for this stream - * @stream_transmitter: the #FsStreamTransmitter for this stream, one - * reference to it will be eaten * @new_remote_codecs_cb: Callback called when the remote codecs change * (ie when fs_rtp_stream_set_remote_codecs() is called). One must hold * the session lock across calls. @@ -762,14 +676,12 @@ FsRtpStream * fs_rtp_stream_new (FsRtpSession *session, FsRtpParticipant *participant, FsStreamDirection direction, - FsStreamTransmitter *stream_transmitter, stream_new_remote_codecs_cb new_remote_codecs_cb, stream_known_source_packet_receive_cb known_source_packet_received_cb, stream_sending_changed_locked_cb sending_changed_locked_cb, stream_ssrc_added_cb ssrc_added_cb, stream_get_new_stream_transmitter_cb get_new_stream_transmitter_cb, - gpointer user_data_for_cb, - GError **error) + gpointer user_data_for_cb) { FsRtpStream *self; @@ -782,7 +694,6 @@ fs_rtp_stream_new (FsRtpSession *session, "session", session, "participant", participant, "direction", direction, - "stream-transmitter", stream_transmitter, NULL); self->priv->new_remote_codecs_cb = new_remote_codecs_cb; @@ -793,12 +704,6 @@ fs_rtp_stream_new (FsRtpSession *session, self->priv->user_data_for_cb = user_data_for_cb; - if (self->priv->construction_error) { - g_propagate_error (error, self->priv->construction_error); - g_object_unref (self); - return NULL; - } - return self; } @@ -1184,8 +1089,8 @@ fs_rtp_stream_set_transmitter (FsStream *stream, } FS_RTP_SESSION_UNLOCK (session); - st = self->priv->get_new_stream_transmitter_cb (self, transmitter, - FS_PARTICIPANT (self->participant), + st = self->priv->get_new_stream_transmitter_cb (self, + FS_PARTICIPANT (self->participant), transmitter, stream_transmitter_parameters, stream_transmitter_n_parameters, error, self->priv->user_data_for_cb); @@ -1233,6 +1138,10 @@ fs_rtp_stream_set_transmitter (FsStream *stream, FS_RTP_SESSION_LOCK (session); self->priv->stream_transmitter = st; + if (self->priv->direction & FS_DIRECTION_SEND) + self->priv->sending_changed_locked_cb (self, + self->priv->direction & FS_DIRECTION_SEND, + self->priv->user_data_for_cb); FS_RTP_SESSION_UNLOCK (session); if (!fs_stream_transmitter_gather_local_candidates (st, error)) diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h index 4fc467d0..4e3c119c 100644 --- a/gst/fsrtpconference/fs-rtp-stream.h +++ b/gst/fsrtpconference/fs-rtp-stream.h @@ -98,22 +98,20 @@ typedef void (*stream_sending_changed_locked_cb) (FsRtpStream *stream, typedef void (*stream_ssrc_added_cb) (FsRtpStream *stream, guint32 ssrc, gpointer user_data); typedef FsStreamTransmitter* (*stream_get_new_stream_transmitter_cb) ( - FsRtpStream *stream, const gchar *transmitter_name, - FsParticipant *participant, GParameter *parameters, guint n_parameters, + FsRtpStream *stream, FsParticipant *participant, + const gchar *transmitter_name, GParameter *parameters, guint n_parameters, GError **error, gpointer user_data); FsRtpStream *fs_rtp_stream_new (FsRtpSession *session, FsRtpParticipant *participant, FsStreamDirection direction, - FsStreamTransmitter *stream_transmitter, stream_new_remote_codecs_cb new_remote_codecs_cb, stream_known_source_packet_receive_cb known_source_packet_received_cb, stream_sending_changed_locked_cb sending_changed_locked_cb, stream_ssrc_added_cb ssrc_added_cb, stream_get_new_stream_transmitter_cb get_new_stream_transmitter_cb, - gpointer user_data_for_cb, - GError **error); + gpointer user_data_for_cb); gboolean fs_rtp_stream_add_substream_unlock (FsRtpStream *stream, FsRtpSubStream *substream, diff --git a/python/pyfarsight.defs b/python/pyfarsight.defs index 825b62d7..48de7668 100644 --- a/python/pyfarsight.defs +++ b/python/pyfarsight.defs @@ -431,9 +431,6 @@ (parameters '("FsParticipant*" "participant") '("FsStreamDirection" "direction") - '("const-gchar*" "transmitter") - '("guint" "stream_transmitter_n_parameters") - '("GParameter*" "stream_transmitter_parameters") '("GError**" "error") ) ) @@ -648,6 +645,19 @@ (return-type "GstIterator*") ) +(define-method set_transmitter + (of-object "FsStream") + (unblock-threads t) + (c-name "fs_stream_set_transmitter") + (return-type "gboolean") + (parameters + '("const-gchar*" "transmitter") + '("GParameter*" "stream_transmitter_parameters") + '("guint" "stream_transmitter_n_parameters") + '("GError**" "error") + ) +) + ;; -*- scheme -*- ; object definitions ... diff --git a/python/pyfarsight.override b/python/pyfarsight.override index b75db9ec..4b63b61a 100644 --- a/python/pyfarsight.override +++ b/python/pyfarsight.override @@ -172,121 +172,6 @@ pyg_register_gtype_custom (FS_TYPE_CANDIDATE_LIST, _fs_candidate_list_from_value, _fs_candidate_list_to_value); %% -override fs_session_new_stream kwargs -static PyObject * -_wrap_fs_session_new_stream(PyGObject *self, PyObject *args, PyObject *kwargs) -{ - static char *kwlist[] = {"participant", "direction", "transmitter", - "transmitter_parameters", NULL}; - - PyObject *participant = NULL; - PyObject *py_ret; - gint direction; - const gchar *transmitter_name = NULL; - PyObject *st_params = NULL; - Py_ssize_t pos = 0, i = 0; - PyObject *key, *value; - GObjectClass *st_class = NULL; - GError *error = NULL; - FsStream *stream = NULL; - guint n_parameters = 0; - GParameter *parameters = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!i|zO!:FsSession.new_stream", - kwlist, - &PyFsParticipant_Type, &participant, - &direction, - &transmitter_name, - &PyDict_Type, &st_params)) - return NULL; - - if (transmitter_name && st_params) - { - GType st_type = 0; - - Py_BEGIN_ALLOW_THREADS - st_type = fs_session_get_stream_transmitter_type ( - FS_SESSION (pygobject_get (self)), transmitter_name); - Py_END_ALLOW_THREADS - - if (!st_type) - goto error; - - st_class = g_type_class_ref (st_type); - - n_parameters = PyDict_Size (st_params); - parameters = g_new0 (GParameter, n_parameters); - - while (PyDict_Next(st_params, &pos, &key, &value)) - { - GParamSpec *spec; - - if (!PyString_Check (key)) - { - PyErr_SetString (PyExc_TypeError, - "Expected Stream Parameter key to be a string"); - goto error; - } - - spec = g_object_class_find_property (st_class, PyString_AsString (key)); - - if (!spec) - { - PyErr_Format (PyExc_TypeError, "Received unknown key %s", - PyString_AsString (key)); - goto error; - } - - g_value_init (¶meters[i].value, G_PARAM_SPEC_VALUE_TYPE(spec)); - - parameters[i].name = PyString_AsString (key); - - if (pyg_value_from_pyobject (¶meters[i].value , value) < 0) - { - PyErr_Format (PyExc_TypeError, "Expected parameter %s to be a %s", - PyString_AsString (key), - g_type_name (G_PARAM_SPEC_VALUE_TYPE(spec))); - goto error; - } - - i++; - } - } - - Py_BEGIN_ALLOW_THREADS - stream = fs_session_new_stream (FS_SESSION (pygobject_get (self)), - FS_PARTICIPANT (pygobject_get (participant)), - direction, - transmitter_name, n_parameters, parameters, - &error); - Py_END_ALLOW_THREADS - - if (!stream) - goto error; - - if (parameters) - { - g_type_class_unref (st_class); - g_free (parameters); - } - - py_ret = pygobject_new (G_OBJECT (stream)); - g_object_unref (stream); - - return py_ret; - - error: - if (error) - pyg_error_check (&error); - - if (st_class) - g_type_class_unref (st_class); - if (parameters) - g_free (parameters); - - return NULL; -} -%% override-slot FsCodec.tp_setattr static int _wrap_fs_codec_tp_setattr(PyObject *self, char *attr, PyObject *value) diff --git a/tests/check/msn/conference.c b/tests/check/msn/conference.c index 84fd7b27..211ca9a2 100644 --- a/tests/check/msn/conference.c +++ b/tests/check/msn/conference.c @@ -275,8 +275,7 @@ setup_conference (FsStreamDirection dir, struct SimpleMsnConference *target) g_value_set_uint (¶m.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, &error); ts_fail_unless (dat->stream != NULL); ts_fail_unless (error == NULL); @@ -381,7 +380,7 @@ GST_START_TEST (test_msnconference_error) ts_fail_unless ( fs_session_new_stream (dat->session, dat->part, FS_DIRECTION_SEND, - NULL, 0, NULL, &error) == NULL); + &error) == NULL); ts_fail_unless (error->domain == FS_ERROR && error->code == FS_ERROR_ALREADY_EXISTS); g_clear_error (&error); diff --git a/tests/check/raw/conference.c b/tests/check/raw/conference.c index a781bbb3..db563a97 100644 --- a/tests/check/raw/conference.c +++ b/tests/check/raw/conference.c @@ -184,7 +184,7 @@ simple_conference_add_stream ( fail_if (st->participant == NULL, "Could not make participant, but no GError!"); st->stream = fs_session_new_stream (dat->session, st->participant, - FS_DIRECTION_BOTH, NULL, 0, NULL, &error); + FS_DIRECTION_BOTH, &error); if (error) fail ("Error while creating new stream (%d): %s", error->code, error->message); @@ -1167,7 +1167,7 @@ GST_START_TEST (test_rawconference_errors) stream = fs_session_new_stream (dat->session, participant, FS_DIRECTION_NONE, - NULL, 0, NULL, &error); + &error); ts_fail_unless (stream != NULL); fail_unless (fs_stream_set_transmitter (stream, "invalid-transmitter-name", @@ -1308,8 +1308,7 @@ GST_START_TEST (test_rawconference_dispose) part = fs_conference_new_participant (conf, &error); fail_if (part == NULL || error != NULL); - stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, NULL, - 0, NULL, &error); + stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, &error); fail_if (stream == NULL || error != NULL); g_object_run_dispose (G_OBJECT (stream)); @@ -1328,8 +1327,7 @@ GST_START_TEST (test_rawconference_dispose) g_object_unref (stream); - stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, NULL, - 0, NULL, &error); + stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, &error); fail_if (stream == NULL || error != NULL); g_object_run_dispose (G_OBJECT (stream)); diff --git a/tests/check/rtp/codecs.c b/tests/check/rtp/codecs.c index 414739b0..adf3f3bb 100644 --- a/tests/check/rtp/codecs.c +++ b/tests/check/rtp/codecs.c @@ -486,8 +486,7 @@ GST_START_TEST (test_rtpcodecs_reserved_pt) p = fs_conference_new_participant (FS_CONFERENCE (dat->conference), NULL); fail_if (p == NULL, "Could not add participant"); - s = fs_session_new_stream (dat->session, p, - FS_DIRECTION_BOTH, NULL, 0, NULL, NULL); + s = fs_session_new_stream (dat->session, p, FS_DIRECTION_BOTH, NULL); fail_if (s == NULL, "Could not add stream"); g_object_unref (p); @@ -725,7 +724,7 @@ _bus_message_element (GstBus *bus, GstMessage *message, fail ("Could not add second participant to conference %s", error->message); stream2 = fs_session_new_stream (cd->dat->session, p2, FS_DIRECTION_BOTH, - NULL, 0, NULL, NULL); + NULL); fail_if (stream2 == NULL, "Could not second create new stream"); @@ -824,7 +823,7 @@ run_test_rtpcodecs_config_data (gboolean preset_remotes) fail_if (cd.participant == NULL, "Could not add participant to conference"); cd.stream = fs_session_new_stream (cd.dat->session, cd.participant, - FS_DIRECTION_BOTH, NULL, 0, NULL, NULL); + FS_DIRECTION_BOTH, NULL); fail_if (cd.stream == NULL, "Could not create new stream"); @@ -1171,7 +1170,7 @@ GST_START_TEST (test_rtpcodecs_ptime) fail_if (participant == NULL, "Could not add participant to conference"); stream = fs_session_new_stream (dat->session, participant, - FS_DIRECTION_BOTH, NULL, 0, NULL, NULL); + FS_DIRECTION_BOTH, NULL); fail_if (stream == NULL, "Could not add stream to session"); codecs = g_list_append (NULL, fs_codec_copy (prefcodec)); @@ -1328,7 +1327,7 @@ GST_START_TEST (test_rtpcodecs_telephone_event_nego) setup_codec_tests (&dat, &participant, FS_MEDIA_TYPE_AUDIO); stream = fs_session_new_stream (dat->session, participant, - FS_DIRECTION_BOTH, NULL, 0, NULL, NULL); + FS_DIRECTION_BOTH, NULL); fail_if (stream == NULL, "Could not add stream to session"); g_object_get (dat->session, "codecs-without-config", &codecs, NULL); @@ -1437,7 +1436,7 @@ test_one_codec_internal (const gchar *addr, FsStream *stream; stream = fs_session_new_stream (session, participant, - FS_DIRECTION_BOTH, NULL, 0, NULL, NULL); + FS_DIRECTION_BOTH, NULL); fail_if (stream == NULL, "Could not add stream to session"); codecs = g_list_append (NULL, prefcodec); @@ -2273,7 +2272,7 @@ GST_START_TEST (test_rtpcodecs_nego_hdrext) stream = fs_session_new_stream (dat->session, participant, - FS_DIRECTION_BOTH, "rawudp", 0, NULL, NULL); + FS_DIRECTION_BOTH, NULL); fail_if (stream == NULL, "Could not add stream to session"); hdrexts_prefs = g_list_prepend (NULL, fs_rtp_header_extension_new (1, diff --git a/tests/check/rtp/conference.c b/tests/check/rtp/conference.c index d814d1f0..ebafde79 100644 --- a/tests/check/rtp/conference.c +++ b/tests/check/rtp/conference.c @@ -935,7 +935,7 @@ GST_START_TEST (test_rtpconference_errors) ts_fail_if (participant == NULL, "Could not create participant"); stream = fs_session_new_stream (dat->session, participant, FS_DIRECTION_NONE, - NULL, 0, NULL, &error); + &error); ts_fail_unless (stream != NULL); fail_unless (fs_stream_set_transmitter (stream, "invalid-transmitter-name", @@ -1242,8 +1242,7 @@ GST_START_TEST (test_rtpconference_dispose) part = fs_conference_new_participant (conf, &error); fail_if (part == NULL || error != NULL); - stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, NULL, - 0, NULL, &error); + stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, &error); fail_if (stream == NULL || error != NULL); g_object_run_dispose (G_OBJECT (stream)); @@ -1262,8 +1261,7 @@ GST_START_TEST (test_rtpconference_dispose) g_object_unref (stream); - stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, NULL, - 0, NULL, &error); + stream = fs_session_new_stream (session, part, FS_DIRECTION_BOTH, &error); fail_if (stream == NULL || error != NULL); g_object_run_dispose (G_OBJECT (stream)); diff --git a/tests/check/rtp/generic.c b/tests/check/rtp/generic.c index 46525e3b..71a16ce2 100644 --- a/tests/check/rtp/generic.c +++ b/tests/check/rtp/generic.c @@ -128,7 +128,7 @@ simple_conference_add_stream ( fail_if (st->participant == NULL, "Could not make participant, but no GError!"); st->stream = fs_session_new_stream (dat->session, st->participant, - FS_DIRECTION_BOTH, NULL, 0, NULL, &error); + FS_DIRECTION_BOTH, &error); if (error) fail ("Error while creating new stream (%d): %s", error->code, error->message); diff --git a/tests/check/rtp/recvcodecs.c b/tests/check/rtp/recvcodecs.c index c5b33e0f..b66d5fe3 100644 --- a/tests/check/rtp/recvcodecs.c +++ b/tests/check/rtp/recvcodecs.c @@ -222,8 +222,8 @@ GST_START_TEST (test_rtprecv_inband_config_data) ts_fail_if (participant == NULL, "Could not make participant, but no GError!"); - stream = fs_session_new_stream (session, participant, - FS_DIRECTION_RECV, NULL, 0, NULL, &error); + stream = fs_session_new_stream (session, participant, FS_DIRECTION_RECV, + &error); if (error) ts_fail ("Error while creating new stream (%d): %s", error->code, error->message); diff --git a/tests/check/rtp/sendcodecs.c b/tests/check/rtp/sendcodecs.c index f8122709..7ebe0a5e 100644 --- a/tests/check/rtp/sendcodecs.c +++ b/tests/check/rtp/sendcodecs.c @@ -293,7 +293,7 @@ one_way (GstElement *recv_pipeline, gint port) "Could not make participant, but no GError!"); stream = fs_session_new_stream (dat->session, participant, - FS_DIRECTION_SEND, NULL, 0, NULL, &error); + FS_DIRECTION_SEND, &error); if (error) ts_fail ("Error while creating new stream (%d): %s", error->code, error->message); |