diff --git a/ChangeLog b/ChangeLog index 22cf1edb04..4d4a2a50fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-06-17 Thomas Vander Stichele + + * 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 * gst/videorate/gstvideorate.c: (gst_videorate_chain): diff --git a/gst/tcp/gsttcpclientsrc.c b/gst/tcp/gsttcpclientsrc.c index 2b833adbad..d81cd02eef 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 414082b03e..466f2b0f5d 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 91db3584d5..357026a0bc 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) {