mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
Move the connection code in one place
Add some comments
This commit is contained in:
parent
74210e67be
commit
b312f98627
2 changed files with 23 additions and 10 deletions
|
@ -215,6 +215,7 @@ handle_play_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *r
|
||||||
case GST_STATE_CHANGE_FAILURE:
|
case GST_STATE_CHANGE_FAILURE:
|
||||||
goto service_unavailable;
|
goto service_unavailable;
|
||||||
case GST_STATE_CHANGE_ASYNC:
|
case GST_STATE_CHANGE_ASYNC:
|
||||||
|
/* wait for paused state change to complete */
|
||||||
ret = gst_element_get_state (media->pipeline, NULL, NULL, -1);
|
ret = gst_element_get_state (media->pipeline, NULL, NULL, -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -724,29 +725,33 @@ static gboolean
|
||||||
client_accept (GstRTSPClient *client, GIOChannel *channel)
|
client_accept (GstRTSPClient *client, GIOChannel *channel)
|
||||||
{
|
{
|
||||||
/* a new client connected. */
|
/* a new client connected. */
|
||||||
int server_sock_fd;
|
int server_sock_fd, fd;
|
||||||
unsigned int address_len;
|
unsigned int address_len;
|
||||||
GstRTSPConnection *conn;
|
GstRTSPConnection *conn;
|
||||||
|
|
||||||
conn = client->connection;
|
|
||||||
|
|
||||||
server_sock_fd = g_io_channel_unix_get_fd (channel);
|
server_sock_fd = g_io_channel_unix_get_fd (channel);
|
||||||
|
|
||||||
address_len = sizeof (client->address);
|
address_len = sizeof (client->address);
|
||||||
memset (&client->address, 0, address_len);
|
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);
|
&address_len);
|
||||||
if (conn->fd.fd == -1)
|
if (fd == -1)
|
||||||
goto accept_failed;
|
goto accept_failed;
|
||||||
|
|
||||||
g_print ("added new client %p ip %s with fd %d\n", client,
|
/* now create the connection object */
|
||||||
inet_ntoa (client->address.sin_addr), conn->fd.fd);
|
gst_rtsp_connection_create (NULL, &conn);
|
||||||
|
conn->fd.fd = fd;
|
||||||
|
|
||||||
/* FIXME some hackery, we need to have a connection method to accept server
|
/* FIXME some hackery, we need to have a connection method to accept server
|
||||||
* connections */
|
* connections */
|
||||||
gst_poll_add_fd (conn->fdset, &conn->fd);
|
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;
|
return TRUE;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -814,8 +819,6 @@ gst_rtsp_client_get_session_pool (GstRTSPClient *client)
|
||||||
gboolean
|
gboolean
|
||||||
gst_rtsp_client_accept (GstRTSPClient *client, GIOChannel *channel)
|
gst_rtsp_client_accept (GstRTSPClient *client, GIOChannel *channel)
|
||||||
{
|
{
|
||||||
gst_rtsp_connection_create (NULL, &client->connection);
|
|
||||||
|
|
||||||
if (!client_accept (client, channel))
|
if (!client_accept (client, channel))
|
||||||
goto accept_failed;
|
goto accept_failed;
|
||||||
|
|
||||||
|
@ -828,7 +831,6 @@ gst_rtsp_client_accept (GstRTSPClient *client, GIOChannel *channel)
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
accept_failed:
|
accept_failed:
|
||||||
{
|
{
|
||||||
gst_rtsp_connection_close (client->connection);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,17 @@ G_BEGIN_DECLS
|
||||||
typedef struct _GstRTSPClient GstRTSPClient;
|
typedef struct _GstRTSPClient GstRTSPClient;
|
||||||
typedef struct _GstRTSPClientClass GstRTSPClientClass;
|
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 {
|
struct _GstRTSPClient {
|
||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue