[farsight2/master] Set state to connected when we begin to receive data without receiving "connected" first
Louis-Francis Ratté-Boulianne
louis-francis.ratte-boulianne at collabora.co.uk
Tue Jul 14 09:51:05 PDT 2009
---
gst/fsmsnconference/fs-msn-connection.c | 33 ++++++++++++++++++++++++++----
gst/fsmsnconference/fs-msn-connection.h | 4 ++-
gst/fsmsnconference/fs-msn-stream.c | 7 ++++-
3 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/gst/fsmsnconference/fs-msn-connection.c b/gst/fsmsnconference/fs-msn-connection.c
index f4ccb20..0e72b73 100644
--- a/gst/fsmsnconference/fs-msn-connection.c
+++ b/gst/fsmsnconference/fs-msn-connection.c
@@ -251,13 +251,14 @@ fs_msn_connection_finalize (GObject *object)
*/
FsMsnConnection *
-fs_msn_connection_new (guint session_id, guint initial_port)
+fs_msn_connection_new (guint session_id, gboolean producer, guint initial_port)
{
FsMsnConnection *self = g_object_new (FS_TYPE_MSN_CONNECTION, NULL);
if (self) {
self->session_id = session_id;
self->initial_port = initial_port;
+ self->producer = producer;
}
return self;
@@ -731,7 +732,7 @@ connection_cb (FsMsnConnection *self, FsMsnPollFD *pollfd)
}
else
{
- GST_WARNING ("Authentication failed");
+ GST_WARNING ("Authentication failed check=%s", check);
goto error;
}
}
@@ -753,16 +754,23 @@ connection_cb (FsMsnConnection *self, FsMsnPollFD *pollfd)
{
gchar str[14] = {0};
- if (recv(pollfd->pollfd.fd, str, 13, 0) != -1)
+ if (recv(pollfd->pollfd.fd, str, 13, MSG_PEEK) != -1)
{
GST_DEBUG ("Got %s, checking if it's connected", str);
if (strcmp (str, "connected\r\n\r\n") == 0)
{
GST_DEBUG ("connection successful");
+ recv(pollfd->pollfd.fd, str, 13, 0);
pollfd->status = FS_MSN_STATUS_CONNECTED2;
pollfd->want_write = TRUE;
gst_poll_fd_ctl_write (self->poll, &pollfd->pollfd, TRUE);
}
+ else if (!self->producer)
+ {
+ GST_DEBUG ("connection successful");
+ pollfd->status = FS_MSN_STATUS_SEND_RECEIVE;
+ success = TRUE;
+ }
else
{
GST_WARNING ("connected failed");
@@ -786,12 +794,19 @@ connection_cb (FsMsnConnection *self, FsMsnPollFD *pollfd)
{
gchar str[14] = {0};
- if (recv(pollfd->pollfd.fd, str, 13, 0) != -1)
+ if (recv(pollfd->pollfd.fd, str, 13, MSG_PEEK) != -1)
{
GST_DEBUG ("Got %s, checking if it's connected", str);
if (strcmp (str, "connected\r\n\r\n") == 0)
{
GST_DEBUG ("connection successful");
+ recv(pollfd->pollfd.fd, str, 13, 0);
+ pollfd->status = FS_MSN_STATUS_SEND_RECEIVE;
+ success = TRUE;
+ }
+ else if (!self->producer)
+ {
+ GST_DEBUG ("connection successful");
pollfd->status = FS_MSN_STATUS_SEND_RECEIVE;
success = TRUE;
}
@@ -859,7 +874,15 @@ connection_cb (FsMsnConnection *self, FsMsnPollFD *pollfd)
if (send(pollfd->pollfd.fd, "connected\r\n\r\n", 13, 0) != -1)
{
GST_DEBUG ("sent connected");
- pollfd->status = FS_MSN_STATUS_CONNECTED2;
+ if (self->producer)
+ {
+ pollfd->status = FS_MSN_STATUS_SEND_RECEIVE;
+ success = TRUE;
+ }
+ else
+ {
+ pollfd->status = FS_MSN_STATUS_CONNECTED2;
+ }
}
else
{
diff --git a/gst/fsmsnconference/fs-msn-connection.h b/gst/fsmsnconference/fs-msn-connection.h
index 9432ee0..48c41b7 100644
--- a/gst/fsmsnconference/fs-msn-connection.h
+++ b/gst/fsmsnconference/fs-msn-connection.h
@@ -71,6 +71,7 @@ struct _FsMsnConnection
gchar *remote_recipient_id; /* protected by lock */
guint session_id; /* protected by lock */
guint initial_port;
+ gboolean producer;
GThread *polling_thread; /* protected by lock */
GstClockTime poll_timeout; /* protected by lock */
@@ -81,7 +82,8 @@ struct _FsMsnConnection
GType fs_msn_connection_get_type (void);
-FsMsnConnection *fs_msn_connection_new (guint session_id, guint initial_port);
+FsMsnConnection *fs_msn_connection_new (guint session_id, gboolean producer,
+ guint initial_port);
gboolean fs_msn_connection_gather_local_candidates (FsMsnConnection *connection,
GError **error);
diff --git a/gst/fsmsnconference/fs-msn-stream.c b/gst/fsmsnconference/fs-msn-stream.c
index 4c9a41d..906b60b 100644
--- a/gst/fsmsnconference/fs-msn-stream.c
+++ b/gst/fsmsnconference/fs-msn-stream.c
@@ -449,11 +449,13 @@ static void
fs_msn_stream_constructed (GObject *object)
{
FsMsnStream *self = FS_MSN_STREAM_CAST (object);
+ gboolean producer = FALSE;
if (self->priv->direction == FS_DIRECTION_SEND)
{
GstElementFactory *fact = NULL;
+ producer = TRUE;
fact = gst_element_factory_find ("mimenc");
if (fact)
{
@@ -469,8 +471,9 @@ fs_msn_stream_constructed (GObject *object)
}
else if (self->priv->direction == FS_DIRECTION_RECV)
{
- GstElementFactory *fact = NULL;
+ GstElementFactory *fact = NULL;
+ producer = FALSE;
fact = gst_element_factory_find ("mimdec");
if (fact)
{
@@ -492,7 +495,7 @@ fs_msn_stream_constructed (GObject *object)
}
self->priv->connection = fs_msn_connection_new (self->priv->session_id,
- self->priv->initial_port);
+ producer, self->priv->initial_port);
g_signal_connect (self->priv->connection,
"new-local-candidate",
--
1.5.6.5
More information about the farsight-commits
mailing list