From: Wim Taymans Date: Tue, 20 Jan 2009 12:57:47 +0000 (+0100) Subject: Move the connection code in one place X-Git-Tag: 1.19.3~495^2~1624 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b312f98627e2f19ec9d13894ccc37e6423efd292;p=platform%2Fupstream%2Fgstreamer.git Move the connection code in one place Add some comments --- diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c index d13787a..5249b4d 100644 --- a/gst/rtsp-server/rtsp-client.c +++ b/gst/rtsp-server/rtsp-client.c @@ -215,6 +215,7 @@ handle_play_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *r case GST_STATE_CHANGE_FAILURE: goto service_unavailable; case GST_STATE_CHANGE_ASYNC: + /* wait for paused state change to complete */ ret = gst_element_get_state (media->pipeline, NULL, NULL, -1); break; } @@ -724,29 +725,33 @@ static gboolean client_accept (GstRTSPClient *client, GIOChannel *channel) { /* a new client connected. */ - int server_sock_fd; + int server_sock_fd, fd; unsigned int address_len; GstRTSPConnection *conn; - conn = client->connection; - server_sock_fd = g_io_channel_unix_get_fd (channel); address_len = sizeof (client->address); memset (&client->address, 0, address_len); - conn->fd.fd = accept (server_sock_fd, (struct sockaddr *) &client->address, + fd = accept (server_sock_fd, (struct sockaddr *) &client->address, &address_len); - if (conn->fd.fd == -1) + if (fd == -1) goto accept_failed; - g_print ("added new client %p ip %s with fd %d\n", client, - inet_ntoa (client->address.sin_addr), conn->fd.fd); + /* now create the connection object */ + gst_rtsp_connection_create (NULL, &conn); + conn->fd.fd = fd; /* FIXME some hackery, we need to have a connection method to accept server * connections */ gst_poll_add_fd (conn->fdset, &conn->fd); + g_print ("added new client %p ip %s with fd %d\n", client, + inet_ntoa (client->address.sin_addr), conn->fd.fd); + + client->connection = conn; + return TRUE; /* ERRORS */ @@ -814,8 +819,6 @@ gst_rtsp_client_get_session_pool (GstRTSPClient *client) gboolean gst_rtsp_client_accept (GstRTSPClient *client, GIOChannel *channel) { - gst_rtsp_connection_create (NULL, &client->connection); - if (!client_accept (client, channel)) goto accept_failed; @@ -828,7 +831,6 @@ gst_rtsp_client_accept (GstRTSPClient *client, GIOChannel *channel) /* ERRORS */ accept_failed: { - gst_rtsp_connection_close (client->connection); return FALSE; } } diff --git a/gst/rtsp-server/rtsp-client.h b/gst/rtsp-server/rtsp-client.h index bbe85b7..1f80480 100644 --- a/gst/rtsp-server/rtsp-client.h +++ b/gst/rtsp-server/rtsp-client.h @@ -54,6 +54,17 @@ G_BEGIN_DECLS typedef struct _GstRTSPClient GstRTSPClient; typedef struct _GstRTSPClientClass GstRTSPClientClass; +/** + * GstRTSPClient: + * + * @connection: the connection object handling the client request. + * @address: the address of the connection + * @media: handle to the media handled by the client. + * @pool: handle to the session pool used by the client. + * @thread: thread to handle the client connection + * + * The client structure. + */ struct _GstRTSPClient { GObject parent;