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; GstRTPDecSession *session;
guint32 ssrc; guint32 ssrc;
guint8 pt; guint8 pt;
GstRTPBuffer rtp;
rtpdec = GST_RTP_DEC (GST_PAD_PARENT (pad)); 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)) if (!gst_rtp_buffer_validate (buffer))
goto bad_packet; 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); 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 * configure the transport of the stream and is used to identity the stream in
* the RTP-Info header field returned from PLAY. */ * the RTP-Info header field returned from PLAY. */
control_url = gst_sdp_media_get_attribute_val (media, "control"); 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, "stream %d, (%p)", stream->id, stream);
GST_DEBUG_OBJECT (src, " pt: %d", stream->pt); 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; const gchar *base;
gboolean has_slash; gboolean has_slash;
if (g_strcmp0 (control_url, "*") == 0)
control_url = "";
if (src->control) if (src->control)
base = src->control; base = src->control;
else if (src->content_base) else if (src->content_base)
@ -2104,6 +2110,7 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
GstFlowReturn res = GST_FLOW_OK; GstFlowReturn res = GST_FLOW_OK;
guint8 *data; guint8 *data;
guint size; guint size;
gsize bsize;
GstRTSPResult ret; GstRTSPResult ret;
GstRTSPMessage message = { 0 }; GstRTSPMessage message = { 0 };
GstRTSPConnection *conn; GstRTSPConnection *conn;
@ -2111,8 +2118,8 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstBuffer * buffer)
stream = (GstRTSPStream *) gst_pad_get_element_private (pad); stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
src = stream->parent; src = stream->parent;
data = GST_BUFFER_DATA (buffer); data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
size = GST_BUFFER_SIZE (buffer); size = bsize;
gst_rtsp_message_init_data (&message, stream->channel[1]); 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_steal_body (&message, &data, &size);
gst_rtsp_message_unset (&message); gst_rtsp_message_unset (&message);
gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return res; return res;
@ -3603,9 +3611,8 @@ gst_rtspsrc_loop_interleaved (GstRTSPSrc * src)
size -= 1; size -= 1;
buf = gst_buffer_new (); buf = gst_buffer_new ();
GST_BUFFER_DATA (buf) = data; gst_buffer_take_memory (buf,
GST_BUFFER_MALLOCDATA (buf) = data; gst_memory_new_wrapped (0, data, g_free, size, 0, size));
GST_BUFFER_SIZE (buf) = size;
/* don't need message anymore */ /* don't need message anymore */
gst_rtsp_message_unset (&message); gst_rtsp_message_unset (&message);

View file

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

View file

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

View file

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