summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-06-17 18:20:43 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-06-17 18:20:43 +0000
commitaabfd87d938fc364236342a7d8a818a78bbd71a0 (patch)
treef5e63686761b82523d12273c3ef10b4d1ba5a04c
parent1cce622d6edc1dc1df3c30b7590afc3fa3920774 (diff)
read caps in connect
Original commit message from CVS: read caps in connect
-rw-r--r--ChangeLog8
-rw-r--r--gst/tcp/gsttcpclientsrc.c62
-rw-r--r--gst/tcp/gsttcpclientsrc.h1
-rw-r--r--sys/v4l/gstv4lsrc.c1
4 files changed, 49 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 22cf1edb0..4d4a2a50f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2004-06-17 Thomas Vander Stichele <thomas at apestaart dot org>
+ * gst/tcp/gsttcpclientsrc.c: (gst_tcpclientsrc_init),
+ (gst_tcpclientsrc_getcaps), (gst_tcpclientsrc_get),
+ (gst_tcpclientsrc_init_receive):
+ * gst/tcp/gsttcpclientsrc.h:
+ read caps when connecting to server for GDP so we set them correctly
+
+2004-06-17 Thomas Vander Stichele <thomas at apestaart dot org>
+
* gst/videorate/gstvideorate.c: (gst_videorate_chain):
notify drops and duplicates
* gst/videoscale/videoscale.c: (videoscale_get_structure):
diff --git a/gst/tcp/gsttcpclientsrc.c b/gst/tcp/gsttcpclientsrc.c
index 2b833adba..d81cd02ee 100644
--- a/gst/tcp/gsttcpclientsrc.c
+++ b/gst/tcp/gsttcpclientsrc.c
@@ -70,6 +70,8 @@ static void gst_tcpclientsrc_base_init (gpointer g_class);
static void gst_tcpclientsrc_class_init (GstTCPClientSrc * klass);
static void gst_tcpclientsrc_init (GstTCPClientSrc * tcpclientsrc);
+static GstCaps *gst_tcpclientsrc_getcaps (GstPad * pad);
+
static GstData *gst_tcpclientsrc_get (GstPad * pad);
static GstElementStateReturn gst_tcpclientsrc_change_state (GstElement *
element);
@@ -169,6 +171,7 @@ gst_tcpclientsrc_init (GstTCPClientSrc * this)
this->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (this), this->srcpad);
gst_pad_set_get_function (this->srcpad, gst_tcpclientsrc_get);
+ gst_pad_set_getcaps_function (this->srcpad, gst_tcpclientsrc_getcaps);
this->port = TCP_DEFAULT_PORT;
this->host = g_strdup (TCP_DEFAULT_HOST);
@@ -176,10 +179,27 @@ gst_tcpclientsrc_init (GstTCPClientSrc * this)
this->sock_fd = -1;
this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
this->curoffset = 0;
+ this->caps = NULL;
GST_FLAG_UNSET (this, GST_TCPCLIENTSRC_OPEN);
}
+static GstCaps *
+gst_tcpclientsrc_getcaps (GstPad * pad)
+{
+ GstTCPClientSrc *src;
+
+ src = GST_TCPCLIENTSRC (GST_OBJECT_PARENT (pad));
+
+ if (!GST_FLAG_IS_SET (src, GST_TCPCLIENTSRC_OPEN))
+ return gst_caps_new_any ();
+
+ if (src->caps)
+ return src->caps;
+
+ return gst_caps_new_any ();
+}
+
static GstData *
gst_tcpclientsrc_get (GstPad * pad)
{
@@ -189,7 +209,6 @@ gst_tcpclientsrc_get (GstPad * pad)
GstData *data = NULL;
GstBuffer *buf = NULL;
- GstCaps *caps;
g_return_val_if_fail (pad != NULL, NULL);
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
@@ -235,27 +254,6 @@ gst_tcpclientsrc_get (GstPad * pad)
buf = gst_buffer_new_and_alloc (readsize);
break;
case GST_TCP_PROTOCOL_TYPE_GDP:
- /* if we haven't received caps yet, we should get them first */
- if (!src->caps_received) {
- gchar *string;
-
- if (!(caps = gst_tcp_gdp_read_caps (GST_ELEMENT (src), src->sock_fd))) {
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
- ("Could not read caps through GDP"));
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
- src->caps_received = TRUE;
- string = gst_caps_to_string (caps);
- GST_DEBUG_OBJECT (src, "Received caps through GDP: %s", string);
- g_free (string);
-
- if (!gst_pad_try_set_caps (pad, caps)) {
- g_warning ("Could not set caps");
- return GST_DATA (gst_event_new (GST_EVENT_EOS));
- }
- }
-
- /* now receive the buffer header */
if (!(data = gst_tcp_gdp_read_header (GST_ELEMENT (src), src->sock_fd))) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Could not read data header through GDP"));
@@ -443,6 +441,26 @@ gst_tcpclientsrc_init_receive (GstTCPClientSrc * this)
this->buffer_after_discont = NULL;
GST_FLAG_SET (this, GST_TCPCLIENTSRC_OPEN);
+ /* get the caps if we're using GDP */
+ if (this->protocol == GST_TCP_PROTOCOL_TYPE_GDP) {
+ /* if we haven't received caps yet, we should get them first */
+ if (!this->caps_received) {
+ gchar *string;
+ GstCaps *caps;
+
+ GST_DEBUG_OBJECT (this, "getting caps through GDP");
+ if (!(caps = gst_tcp_gdp_read_caps (GST_ELEMENT (this), this->sock_fd))) {
+ GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL),
+ ("Could not read caps through GDP"));
+ return FALSE;
+ }
+ this->caps_received = TRUE;
+ this->caps = caps;
+ string = gst_caps_to_string (caps);
+ GST_DEBUG_OBJECT (this, "Received caps through GDP: %s", string);
+ g_free (string);
+ }
+ }
return TRUE;
}
diff --git a/gst/tcp/gsttcpclientsrc.h b/gst/tcp/gsttcpclientsrc.h
index 414082b03..466f2b0f5 100644
--- a/gst/tcp/gsttcpclientsrc.h
+++ b/gst/tcp/gsttcpclientsrc.h
@@ -72,6 +72,7 @@ struct _GstTCPClientSrc {
GstTCPProtocolType protocol; /* protocol used for reading data */
gboolean caps_received; /* if we have received caps yet */
+ GstCaps *caps;
GstClock *clock;
gboolean send_discont; /* TRUE when we need to send a discont */
diff --git a/sys/v4l/gstv4lsrc.c b/sys/v4l/gstv4lsrc.c
index 91db3584d..357026a0b 100644
--- a/sys/v4l/gstv4lsrc.c
+++ b/sys/v4l/gstv4lsrc.c
@@ -583,7 +583,6 @@ gst_v4lsrc_palette_to_caps (int palette)
return caps;
}
-
static GstPadLinkReturn
gst_v4lsrc_src_link (GstPad * pad, const GstCaps * vscapslist)
{