mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 10:42:22 +00:00
adding none caps nego option
Original commit message from CVS: adding none caps nego option
This commit is contained in:
parent
e05e44f6d5
commit
1312e75f80
6 changed files with 168 additions and 82 deletions
|
@ -28,7 +28,6 @@ extern "C" {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CONTROL_ZERO,
|
CONTROL_ZERO,
|
||||||
CONTROL_NONE,
|
CONTROL_NONE,
|
||||||
CONTROL_TCP,
|
|
||||||
CONTROL_TCP
|
CONTROL_TCP
|
||||||
} Gst_TCP_Control;
|
} Gst_TCP_Control;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ extern "C" {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CONTROL_ZERO,
|
CONTROL_ZERO,
|
||||||
CONTROL_NONE,
|
CONTROL_NONE,
|
||||||
CONTROL_TCP,
|
|
||||||
CONTROL_TCP
|
CONTROL_TCP
|
||||||
} Gst_TCP_Control;
|
} Gst_TCP_Control;
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,25 @@ enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_HOST,
|
ARG_HOST,
|
||||||
ARG_PORT,
|
ARG_PORT,
|
||||||
|
ARG_CONTROL
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GST_TYPE_TCPSINK_CONTROL (gst_tcpsink_control_get_type())
|
||||||
|
static GType
|
||||||
|
gst_tcpsink_control_get_type(void) {
|
||||||
|
static GType tcpsink_control_type = 0;
|
||||||
|
static GEnumValue tcpsink_control[] = {
|
||||||
|
{CONTROL_NONE, "1", "none"},
|
||||||
|
{CONTROL_TCP, "2", "tcp"},
|
||||||
|
{CONTROL_ZERO, NULL, NULL}
|
||||||
|
};
|
||||||
|
if (!tcpsink_control_type) {
|
||||||
|
tcpsink_control_type = g_enum_register_static("GstTCPSinkControl", tcpsink_control);
|
||||||
|
}
|
||||||
|
return tcpsink_control_type;
|
||||||
|
}
|
||||||
|
|
||||||
static void gst_tcpsink_class_init (GstTCPSink *klass);
|
static void gst_tcpsink_class_init (GstTCPSink *klass);
|
||||||
static void gst_tcpsink_init (GstTCPSink *tcpsink);
|
static void gst_tcpsink_init (GstTCPSink *tcpsink);
|
||||||
|
|
||||||
|
@ -106,6 +122,9 @@ gst_tcpsink_class_init (GstTCPSink *klass)
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
|
||||||
g_param_spec_int ("port", "port", "The port to send the packets to",
|
g_param_spec_int ("port", "port", "The port to send the packets to",
|
||||||
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
|
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_CONTROL,
|
||||||
|
g_param_spec_enum ("control", "control", "The type of control",
|
||||||
|
GST_TYPE_TCPSINK_CONTROL, CONTROL_TCP, G_PARAM_READWRITE));
|
||||||
|
|
||||||
gobject_class->set_property = gst_tcpsink_set_property;
|
gobject_class->set_property = gst_tcpsink_set_property;
|
||||||
gobject_class->get_property = gst_tcpsink_get_property;
|
gobject_class->get_property = gst_tcpsink_get_property;
|
||||||
|
@ -129,56 +148,67 @@ gst_tcpsink_sinkconnect (GstPad *pad, GstCaps *caps)
|
||||||
|
|
||||||
tcpsink = GST_TCPSINK (gst_pad_get_parent (pad));
|
tcpsink = GST_TCPSINK (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
memset (&serv_addr, 0, sizeof(serv_addr));
|
switch (tcpsink->control) {
|
||||||
|
case CONTROL_TCP:
|
||||||
|
memset (&serv_addr, 0, sizeof(serv_addr));
|
||||||
|
|
||||||
/* if its an IP address */
|
/* if its an IP address */
|
||||||
if (inet_aton (tcpsink->host, &addr)) {
|
if (inet_aton (tcpsink->host, &addr)) {
|
||||||
memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
|
memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we dont need to lookup for localhost */
|
/* we dont need to lookup for localhost */
|
||||||
else if (strcmp (tcpsink->host, TCP_DEFAULT_HOST) == 0) {
|
else if (strcmp (tcpsink->host, TCP_DEFAULT_HOST) == 0) {
|
||||||
if (inet_aton ("127.0.0.1", &addr)) {
|
if (inet_aton ("127.0.0.1", &addr)) {
|
||||||
memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
|
memmove (&(serv_addr.sin_addr), &addr, sizeof (struct in_addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if its a hostname */
|
/* if its a hostname */
|
||||||
else if ((he = gethostbyname (tcpsink->host))) {
|
else if ((he = gethostbyname (tcpsink->host))) {
|
||||||
memmove (&(serv_addr.sin_addr), he->h_addr, he->h_length);
|
memmove (&(serv_addr.sin_addr), he->h_addr, he->h_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
perror("hostname lookup error?");
|
perror("hostname lookup error?");
|
||||||
return GST_PAD_LINK_REFUSED;
|
return GST_PAD_LINK_REFUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
serv_addr.sin_family = AF_INET;
|
serv_addr.sin_family = AF_INET;
|
||||||
serv_addr.sin_port = htons(tcpsink->port+1);
|
serv_addr.sin_port = htons(tcpsink->port+1);
|
||||||
|
|
||||||
doc = xmlNewDoc ("1.0");
|
doc = xmlNewDoc ("1.0");
|
||||||
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "NewCaps", NULL);
|
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "NewCaps", NULL);
|
||||||
|
|
||||||
gst_caps_save_thyself (caps, doc->xmlRootNode);
|
gst_caps_save_thyself (caps, doc->xmlRootNode);
|
||||||
|
|
||||||
if ((fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
|
if ((fd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
|
||||||
perror("socket");
|
perror("socket");
|
||||||
return GST_PAD_LINK_REFUSED;
|
return GST_PAD_LINK_REFUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof (serv_addr)) != 0) {
|
if (connect(fd, (struct sockaddr *)&serv_addr, sizeof (serv_addr)) != 0)
|
||||||
g_printerr ("tcpsink: connect to %s port %d failed: %s\n",
|
{
|
||||||
|
g_printerr ("tcpsink: connect to %s port %d failed: %s\n",
|
||||||
tcpsink->host, tcpsink->port+1, g_strerror(errno));
|
tcpsink->host, tcpsink->port+1, g_strerror(errno));
|
||||||
return GST_PAD_LINK_REFUSED;
|
return GST_PAD_LINK_REFUSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fdopen (dup (fd), "wb");
|
||||||
|
|
||||||
|
xmlDocDump(f, doc);
|
||||||
|
fclose (f);
|
||||||
|
close (fd);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case CONTROL_NONE:
|
||||||
|
return GST_PAD_LINK_OK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return GST_PAD_LINK_REFUSED;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fdopen (dup (fd), "wb");
|
|
||||||
|
|
||||||
xmlDocDump(f, doc);
|
|
||||||
fclose (f);
|
|
||||||
close (fd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +233,7 @@ gst_tcpsink_init (GstTCPSink *tcpsink)
|
||||||
|
|
||||||
tcpsink->host = g_strdup (TCP_DEFAULT_HOST);
|
tcpsink->host = g_strdup (TCP_DEFAULT_HOST);
|
||||||
tcpsink->port = TCP_DEFAULT_PORT;
|
tcpsink->port = TCP_DEFAULT_PORT;
|
||||||
|
tcpsink->control = CONTROL_TCP;
|
||||||
|
|
||||||
tcpsink->clock = NULL;
|
tcpsink->clock = NULL;
|
||||||
}
|
}
|
||||||
|
@ -254,6 +285,9 @@ gst_tcpsink_set_property (GObject *object, guint prop_id, const GValue *value, G
|
||||||
case ARG_PORT:
|
case ARG_PORT:
|
||||||
tcpsink->port = g_value_get_int (value);
|
tcpsink->port = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_CONTROL:
|
||||||
|
tcpsink->control = g_value_get_enum (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -275,6 +309,9 @@ gst_tcpsink_get_property (GObject *object, guint prop_id, GValue *value, GParamS
|
||||||
case ARG_PORT:
|
case ARG_PORT:
|
||||||
g_value_set_int (value, tcpsink->port);
|
g_value_set_int (value, tcpsink->port);
|
||||||
break;
|
break;
|
||||||
|
case ARG_CONTROL:
|
||||||
|
g_value_set_enum (value, tcpsink->control);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -325,8 +362,6 @@ gst_tcpsink_init_send (GstTCPSink *sink)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("tcpsink: connected to %s port %d\n", sink->host, sink->port);
|
|
||||||
|
|
||||||
GST_FLAG_SET (sink, GST_TCPSINK_OPEN);
|
GST_FLAG_SET (sink, GST_TCPSINK_OPEN);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -42,6 +42,7 @@ extern "C" {
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include "gsttcp.h"
|
||||||
|
|
||||||
#define GST_TYPE_TCPSINK \
|
#define GST_TYPE_TCPSINK \
|
||||||
(gst_tcpsink_get_type())
|
(gst_tcpsink_get_type())
|
||||||
|
@ -71,6 +72,7 @@ struct _GstTCPSink {
|
||||||
|
|
||||||
int sock;
|
int sock;
|
||||||
struct sockaddr_in theiraddr;
|
struct sockaddr_in theiraddr;
|
||||||
|
Gst_TCP_Control control;
|
||||||
|
|
||||||
gint port;
|
gint port;
|
||||||
gchar *host;
|
gchar *host;
|
||||||
|
|
|
@ -42,9 +42,25 @@ enum {
|
||||||
enum {
|
enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_PORT,
|
ARG_PORT,
|
||||||
|
ARG_CONTROL
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GST_TYPE_TCPSRC_CONTROL (gst_tcpsrc_control_get_type())
|
||||||
|
static GType
|
||||||
|
gst_tcpsrc_control_get_type(void) {
|
||||||
|
static GType tcpsrc_control_type = 0;
|
||||||
|
static GEnumValue tcpsrc_control[] = {
|
||||||
|
{CONTROL_NONE, "1", "none"},
|
||||||
|
{CONTROL_TCP, "2", "tcp"},
|
||||||
|
{CONTROL_ZERO, NULL, NULL}
|
||||||
|
};
|
||||||
|
if (!tcpsrc_control_type) {
|
||||||
|
tcpsrc_control_type = g_enum_register_static("GstTCPSrcControl", tcpsrc_control);
|
||||||
|
}
|
||||||
|
return tcpsrc_control_type;
|
||||||
|
}
|
||||||
|
|
||||||
static void gst_tcpsrc_class_init (GstTCPSrc *klass);
|
static void gst_tcpsrc_class_init (GstTCPSrc *klass);
|
||||||
static void gst_tcpsrc_init (GstTCPSrc *tcpsrc);
|
static void gst_tcpsrc_init (GstTCPSrc *tcpsrc);
|
||||||
|
|
||||||
|
@ -99,6 +115,9 @@ gst_tcpsrc_class_init (GstTCPSrc *klass)
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
|
||||||
g_param_spec_int ("port", "port", "The port to receive the packets from",
|
g_param_spec_int ("port", "port", "The port to receive the packets from",
|
||||||
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
|
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class, ARG_CONTROL,
|
||||||
|
g_param_spec_enum ("control", "control", "The type of control",
|
||||||
|
GST_TYPE_TCPSRC_CONTROL, CONTROL_TCP, G_PARAM_READWRITE));
|
||||||
|
|
||||||
gobject_class->set_property = gst_tcpsrc_set_property;
|
gobject_class->set_property = gst_tcpsrc_set_property;
|
||||||
gobject_class->get_property = gst_tcpsrc_get_property;
|
gobject_class->get_property = gst_tcpsrc_get_property;
|
||||||
|
@ -126,6 +145,7 @@ gst_tcpsrc_init (GstTCPSrc *tcpsrc)
|
||||||
gst_pad_set_get_function (tcpsrc->srcpad, gst_tcpsrc_get);
|
gst_pad_set_get_function (tcpsrc->srcpad, gst_tcpsrc_get);
|
||||||
|
|
||||||
tcpsrc->port = TCP_DEFAULT_PORT;
|
tcpsrc->port = TCP_DEFAULT_PORT;
|
||||||
|
tcpsrc->control = CONTROL_TCP;
|
||||||
tcpsrc->clock = NULL;
|
tcpsrc->clock = NULL;
|
||||||
tcpsrc->sock = -1;
|
tcpsrc->sock = -1;
|
||||||
tcpsrc->control_sock = -1;
|
tcpsrc->control_sock = -1;
|
||||||
|
@ -154,42 +174,56 @@ gst_tcpsrc_get (GstPad *pad)
|
||||||
|
|
||||||
FD_ZERO (&read_fds);
|
FD_ZERO (&read_fds);
|
||||||
FD_SET (tcpsrc->sock, &read_fds);
|
FD_SET (tcpsrc->sock, &read_fds);
|
||||||
FD_SET (tcpsrc->control_sock, &read_fds);
|
|
||||||
|
if (tcpsrc->control_sock >= 0) {
|
||||||
|
FD_SET (tcpsrc->control_sock, &read_fds);
|
||||||
|
}
|
||||||
|
|
||||||
max_sock = MAX(tcpsrc->sock, tcpsrc->control_sock);
|
max_sock = MAX(tcpsrc->sock, tcpsrc->control_sock);
|
||||||
|
|
||||||
if (select (max_sock+1, &read_fds, NULL, NULL, NULL) > 0) {
|
if (select (max_sock+1, &read_fds, NULL, NULL, NULL) > 0) {
|
||||||
if ((tcpsrc->control_sock != -1) &&
|
if ((tcpsrc->control_sock != -1) && FD_ISSET (tcpsrc->control_sock, &read_fds))
|
||||||
FD_ISSET (tcpsrc->control_sock, &read_fds)) {
|
{
|
||||||
#ifndef GST_DISABLE_LOADSAVE
|
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
buf = g_malloc (1024*10);
|
switch (tcpsrc->control) {
|
||||||
|
case CONTROL_TCP:
|
||||||
|
|
||||||
len = sizeof (struct sockaddr);
|
#ifndef GST_DISABLE_LOADSAVE
|
||||||
client_sock = accept (tcpsrc->control_sock, &client_addr, &len);
|
buf = g_malloc (1024*10);
|
||||||
|
|
||||||
if (client_sock <= 0) {
|
len = sizeof (struct sockaddr);
|
||||||
perror ("control_sock accept");
|
client_sock = accept (tcpsrc->control_sock, &client_addr, &len);
|
||||||
}
|
|
||||||
|
|
||||||
else if ((ret = read (client_sock, buf, 1024*10)) <= 0) {
|
if (client_sock <= 0) {
|
||||||
perror ("control_sock read");
|
perror ("control_sock accept");
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else if ((ret = read (client_sock, buf, 1024*10)) <= 0) {
|
||||||
buf[ret] = '\0';
|
perror ("control_sock read");
|
||||||
doc = xmlParseMemory(buf, ret);
|
}
|
||||||
caps = gst_caps_load_thyself(doc->xmlRootNode);
|
|
||||||
|
|
||||||
/* foward the connect, we don't signal back the result here... */
|
else {
|
||||||
gst_pad_proxy_link (tcpsrc->srcpad, caps);
|
buf[ret] = '\0';
|
||||||
}
|
doc = xmlParseMemory(buf, ret);
|
||||||
|
caps = gst_caps_load_thyself(doc->xmlRootNode);
|
||||||
|
|
||||||
g_free (buf);
|
/* foward the connect, we don't signal back the result here... */
|
||||||
|
gst_pad_proxy_link (tcpsrc->srcpad, caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (buf);
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
case CONTROL_NONE:
|
||||||
|
default:
|
||||||
|
g_free (buf);
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
outbuf = NULL;
|
outbuf = NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -220,9 +254,7 @@ gst_tcpsrc_get (GstPad *pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GST_FLAG_IS_SET (tcpsrc, GST_TCPSRC_CONNECTED)) {
|
if (!GST_FLAG_IS_SET (tcpsrc, GST_TCPSRC_CONNECTED)) {
|
||||||
g_print ("accepting stream..\n");
|
|
||||||
tcpsrc->client_sock = accept (tcpsrc->sock, &client_addr, &len);
|
tcpsrc->client_sock = accept (tcpsrc->sock, &client_addr, &len);
|
||||||
g_print ("accepted stream.\n");
|
|
||||||
|
|
||||||
if (tcpsrc->client_sock <= 0) {
|
if (tcpsrc->client_sock <= 0) {
|
||||||
perror ("accept");
|
perror ("accept");
|
||||||
|
@ -272,6 +304,9 @@ gst_tcpsrc_set_property (GObject *object, guint prop_id, const GValue *value, GP
|
||||||
case ARG_PORT:
|
case ARG_PORT:
|
||||||
tcpsrc->port = g_value_get_int (value);
|
tcpsrc->port = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
case ARG_CONTROL:
|
||||||
|
tcpsrc->control = g_value_get_enum (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -290,6 +325,9 @@ gst_tcpsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
|
||||||
case ARG_PORT:
|
case ARG_PORT:
|
||||||
g_value_set_int (value, tcpsrc->port);
|
g_value_set_int (value, tcpsrc->port);
|
||||||
break;
|
break;
|
||||||
|
case ARG_CONTROL:
|
||||||
|
g_value_set_enum (value, tcpsrc->control);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -310,35 +348,46 @@ gst_tcpsrc_init_receive (GstTCPSrc *src)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((src->control_sock = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
|
|
||||||
perror("control_socket");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bind (src->sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1) {
|
if (bind (src->sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1) {
|
||||||
perror("stream_sock bind");
|
perror("stream_sock bind");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
src->myaddr.sin_port = htons (src->port+1); /* short, network byte order */
|
|
||||||
|
|
||||||
if (bind (src->control_sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1) {
|
|
||||||
perror("control bind");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen (src->sock, 5) == -1) {
|
if (listen (src->sock, 5) == -1) {
|
||||||
perror("stream_sock listen");
|
perror("stream_sock listen");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listen (src->control_sock, 5) == -1) {
|
|
||||||
perror("control listen");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
fcntl (src->sock, F_SETFL, O_NONBLOCK);
|
fcntl (src->sock, F_SETFL, O_NONBLOCK);
|
||||||
fcntl (src->control_sock, F_SETFL, O_NONBLOCK);
|
|
||||||
|
switch (src->control) {
|
||||||
|
case CONTROL_TCP:
|
||||||
|
if ((src->control_sock = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
|
perror("control_socket");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
src->myaddr.sin_port = htons (src->port+1);
|
||||||
|
if (bind (src->control_sock, (struct sockaddr *) &src->myaddr, sizeof (src->myaddr)) == -1)
|
||||||
|
{
|
||||||
|
perror("control bind");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen (src->control_sock, 5) == -1) {
|
||||||
|
perror("control listen");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fcntl (src->control_sock, F_SETFL, O_NONBLOCK);
|
||||||
|
case CONTROL_NONE:
|
||||||
|
GST_FLAG_SET (src, GST_TCPSRC_OPEN);
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
GST_FLAG_SET (src, GST_TCPSRC_OPEN);
|
GST_FLAG_SET (src, GST_TCPSRC_OPEN);
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include "gsttcp.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ struct _GstTCPSrc {
|
||||||
int sock;
|
int sock;
|
||||||
int client_sock;
|
int client_sock;
|
||||||
int control_sock;
|
int control_sock;
|
||||||
|
Gst_TCP_Control control;
|
||||||
|
|
||||||
struct sockaddr_in myaddr;
|
struct sockaddr_in myaddr;
|
||||||
GstClock *clock;
|
GstClock *clock;
|
||||||
|
|
Loading…
Reference in a new issue