rtsp/udp: port to 0.11

This commit is contained in:
Wim Taymans 2011-04-05 17:06:41 +02:00
parent e6102a38c3
commit f67c95d826
5 changed files with 41 additions and 20 deletions

View file

@ -464,6 +464,7 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
GstRTPDecSession *session;
guint32 ssrc;
guint8 pt;
GstRTPBuffer rtp;
rtpdec = GST_RTP_DEC (GST_PAD_PARENT (pad));
@ -472,8 +473,11 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer)
if (!gst_rtp_buffer_validate (buffer))
goto bad_packet;
ssrc = gst_rtp_buffer_get_ssrc (buffer);
pt = gst_rtp_buffer_get_payload_type (buffer);
gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp);
ssrc = gst_rtp_buffer_get_ssrc (&rtp);
pt = gst_rtp_buffer_get_payload_type (&rtp);
gst_rtp_buffer_unmap (&rtp);
GST_DEBUG_OBJECT (rtpdec, "SSRC %08x, PT %d", ssrc, pt);

View file

@ -1026,6 +1026,9 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx)
* configure the transport of the stream and is used to identity the stream in
* the RTP-Info header field returned from PLAY. */
control_url = gst_sdp_media_get_attribute_val (media, "control");
if (control_url == NULL) {
control_url = gst_sdp_message_get_attribute_val_n (sdp, "control", 0);
}
GST_DEBUG_OBJECT (src, "stream %d, (%p)", stream->id, stream);
GST_DEBUG_OBJECT (src, " pt: %d", stream->pt);
@ -1047,6 +1050,9 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx)
const gchar *base;
gboolean has_slash;
if (g_strcmp0 (control_url, "*") == 0)
control_url = "";
if (src->control)
base = src->control;
else if (src->content_base)
@ -2104,6 +2110,7 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
GstFlowReturn res = GST_FLOW_OK;
guint8 *data;
guint size;
gsize bsize;
GstRTSPResult ret;
GstRTSPMessage message = { 0 };
GstRTSPConnection *conn;
@ -2111,8 +2118,8 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
src = stream->parent;
data = GST_BUFFER_DATA (buffer);
size = GST_BUFFER_SIZE (buffer);
data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
size = bsize;
gst_rtsp_message_init_data (&message, stream->channel[1]);
@ -2133,6 +2140,7 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
gst_rtsp_message_steal_body (&message, &data, &size);
gst_rtsp_message_unset (&message);
gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return res;
@ -3603,9 +3611,8 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src)
size -= 1;
buf = gst_buffer_new ();
GST_BUFFER_DATA (buf) = data;
GST_BUFFER_MALLOCDATA (buf) = data;
GST_BUFFER_SIZE (buf) = size;
gst_buffer_take_memory (buf,
gst_memory_new_wrapped (0, data, g_free, size, 0, size));
/* don't need message anymore */
gst_rtsp_message_unset (&message);

View file

@ -209,7 +209,8 @@ static GstFlowReturn
gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
{
GstDynUDPSink *sink;
gint ret, size;
gint ret;
gsize size;
guint8 *data;
GstMetaNetAddress *meta;
struct sockaddr_in theiraddr;
@ -227,8 +228,7 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
sink = GST_DYNUDPSINK (bsink);
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
GST_DEBUG ("about to send %d bytes", size);
@ -247,6 +247,8 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
#endif
(struct sockaddr *) &theiraddr, sizeof (theiraddr));
gst_buffer_unmap (buffer, data, size);
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN) {
goto send_error;

View file

@ -120,10 +120,12 @@ static void gst_multiudpsink_finalize (GObject * object);
static GstFlowReturn gst_multiudpsink_render (GstBaseSink * sink,
GstBuffer * buffer);
#if 0
#ifndef G_OS_WIN32 /* sendmsg() is not available on Windows */
static GstFlowReturn gst_multiudpsink_render_list (GstBaseSink * bsink,
GstBufferList * list);
#endif
#endif
static GstStateChangeReturn gst_multiudpsink_change_state (GstElement *
element, GstStateChange transition);
@ -359,8 +361,10 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
gstelement_class->change_state = gst_multiudpsink_change_state;
gstbasesink_class->render = gst_multiudpsink_render;
#if 0
#ifndef G_OS_WIN32
gstbasesink_class->render_list = gst_multiudpsink_render_list;
#endif
#endif
klass->add = gst_multiudpsink_add;
klass->remove = gst_multiudpsink_remove;
@ -488,15 +492,15 @@ static GstFlowReturn
gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
{
GstMultiUDPSink *sink;
gint ret, size, num = 0, no_clients = 0;
gint ret, num = 0, no_clients = 0;
gsize size;
guint8 *data;
GList *clients;
gint len;
sink = GST_MULTIUDPSINK (bsink);
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
if (size > UDP_MAX_SIZE) {
GST_WARNING ("Attempting to send a UDP packet larger than maximum "
@ -554,12 +558,15 @@ gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
}
g_mutex_unlock (sink->client_lock);
gst_buffer_unmap (buffer, data, size);
GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
no_clients);
return GST_FLOW_OK;
}
#if 0
#ifndef G_OS_WIN32
static GstFlowReturn
gst_multiudpsink_render_list (GstBaseSink * bsink, GstBufferList * list)
@ -569,7 +576,6 @@ gst_multiudpsink_render_list (GstBaseSink * bsink, GstBufferList * list)
gint ret, size = 0, num = 0, no_clients = 0;
struct iovec *iov;
struct msghdr msg = { 0 };
GstBufferListIterator *it;
guint gsize;
GstBuffer *buf;
@ -659,6 +665,7 @@ invalid_list:
return GST_FLOW_ERROR;
}
#endif
#endif
static void
gst_multiudpsink_set_clients_string (GstMultiUDPSink * sink,

View file

@ -421,6 +421,7 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
socklen_t slen;
guint8 *pktdata;
gint pktsize;
gsize offset;
#ifdef G_OS_UNIX
gint readsize;
#elif defined G_OS_WIN32
@ -499,6 +500,7 @@ no_select:
pktdata = g_malloc (readsize);
pktsize = readsize;
offset = 0;
while (TRUE) {
slen = sizeof (sa);
@ -528,19 +530,18 @@ no_select:
break;
}
outbuf = gst_buffer_new ();
GST_BUFFER_MALLOCDATA (outbuf) = pktdata;
/* patch pktdata and len when stripping off the headers */
if (G_UNLIKELY (udpsrc->skip_first_bytes != 0)) {
if (G_UNLIKELY (readsize <= udpsrc->skip_first_bytes))
goto skip_error;
pktdata += udpsrc->skip_first_bytes;
offset += udpsrc->skip_first_bytes;
ret -= udpsrc->skip_first_bytes;
}
GST_BUFFER_DATA (outbuf) = pktdata;
GST_BUFFER_SIZE (outbuf) = ret;
outbuf = gst_buffer_new ();
gst_buffer_take_memory (outbuf,
gst_memory_new_wrapped (0, pktdata, g_free, pktsize, offset, ret));
/* use buffer metadata so receivers can also track the address */
meta = gst_buffer_add_meta_net_address (outbuf);