mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
source: small cleanups
This commit is contained in:
parent
566b0dce40
commit
c795b72988
2 changed files with 10 additions and 20 deletions
|
@ -1176,34 +1176,24 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
|
||||||
guint32 rtptime;
|
guint32 rtptime;
|
||||||
guint64 ext_rtptime;
|
guint64 ext_rtptime;
|
||||||
guint64 rt_diff, rtp_diff;
|
guint64 rt_diff, rtp_diff;
|
||||||
GstBufferList *list = NULL;
|
|
||||||
GstBuffer *buffer = NULL;
|
|
||||||
guint packets;
|
guint packets;
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
|
|
||||||
g_return_val_if_fail (RTP_IS_SOURCE (src), GST_FLOW_ERROR);
|
g_return_val_if_fail (RTP_IS_SOURCE (src), GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (is_list || GST_IS_BUFFER (data), GST_FLOW_ERROR);
|
g_return_val_if_fail (is_list || GST_IS_BUFFER (data), GST_FLOW_ERROR);
|
||||||
|
|
||||||
if (is_list) {
|
|
||||||
list = GST_BUFFER_LIST_CAST (data);
|
|
||||||
|
|
||||||
/* We can grab the caps from the first group, since all
|
|
||||||
* groups of a buffer list have same caps. */
|
|
||||||
buffer = gst_buffer_list_get (list, 0);
|
|
||||||
if (!buffer)
|
|
||||||
goto no_buffer;
|
|
||||||
} else {
|
|
||||||
buffer = GST_BUFFER_CAST (data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we are a sender now */
|
/* we are a sender now */
|
||||||
src->is_sender = TRUE;
|
src->is_sender = TRUE;
|
||||||
|
|
||||||
if (is_list) {
|
if (is_list) {
|
||||||
|
GstBufferList *list = GST_BUFFER_LIST_CAST (data);
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
/* Each group makes up a network packet. */
|
/* Each group makes up a network packet. */
|
||||||
packets = gst_buffer_list_length (list);
|
packets = gst_buffer_list_length (list);
|
||||||
|
if (packets == 0)
|
||||||
|
goto no_buffer;
|
||||||
|
|
||||||
for (i = 0, len = 0; i < packets; i++) {
|
for (i = 0, len = 0; i < packets; i++) {
|
||||||
if (!gst_rtp_buffer_map (gst_buffer_list_get (list, i), GST_MAP_READ,
|
if (!gst_rtp_buffer_map (gst_buffer_list_get (list, i), GST_MAP_READ,
|
||||||
&rtp))
|
&rtp))
|
||||||
|
@ -1215,6 +1205,7 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
|
||||||
/* subsequent info taken from first list member */
|
/* subsequent info taken from first list member */
|
||||||
gst_rtp_buffer_map (gst_buffer_list_get (list, 0), GST_MAP_READ, &rtp);
|
gst_rtp_buffer_map (gst_buffer_list_get (list, 0), GST_MAP_READ, &rtp);
|
||||||
} else {
|
} else {
|
||||||
|
GstBuffer *buffer = GST_BUFFER_CAST (data);
|
||||||
packets = 1;
|
packets = 1;
|
||||||
if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp))
|
if (!gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp))
|
||||||
goto invalid_packet;
|
goto invalid_packet;
|
||||||
|
@ -1230,6 +1221,8 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
|
||||||
do_bitrate_estimation (src, running_time, &src->bytes_sent);
|
do_bitrate_estimation (src, running_time, &src->bytes_sent);
|
||||||
|
|
||||||
rtptime = gst_rtp_buffer_get_timestamp (&rtp);
|
rtptime = gst_rtp_buffer_get_timestamp (&rtp);
|
||||||
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
|
||||||
ext_rtptime = src->last_rtptime;
|
ext_rtptime = src->last_rtptime;
|
||||||
ext_rtptime = gst_rtp_buffer_ext_timestamp (&ext_rtptime, rtptime);
|
ext_rtptime = gst_rtp_buffer_ext_timestamp (&ext_rtptime, rtptime);
|
||||||
|
|
||||||
|
@ -1253,11 +1246,8 @@ rtp_source_send_rtp (RTPSource * src, gpointer data, gboolean is_list,
|
||||||
src->last_rtptime = ext_rtptime;
|
src->last_rtptime = ext_rtptime;
|
||||||
|
|
||||||
/* push packet */
|
/* push packet */
|
||||||
if (!src->callbacks.push_rtp) {
|
if (!src->callbacks.push_rtp)
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
|
||||||
goto no_callback;
|
goto no_callback;
|
||||||
}
|
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
|
||||||
|
|
||||||
GST_LOG ("pushing RTP %s %" G_GUINT64_FORMAT, is_list ? "list" : "packet",
|
GST_LOG ("pushing RTP %s %" G_GUINT64_FORMAT, is_list ? "list" : "packet",
|
||||||
src->stats.packets_sent);
|
src->stats.packets_sent);
|
||||||
|
|
|
@ -72,7 +72,7 @@ typedef struct _RTPSourceClass RTPSourceClass;
|
||||||
/**
|
/**
|
||||||
* RTPSourcePushRTP:
|
* RTPSourcePushRTP:
|
||||||
* @src: an #RTPSource
|
* @src: an #RTPSource
|
||||||
* @buffer: the RTP buffer ready for processing
|
* @data: the RTP buffer or buffer list ready for processing
|
||||||
* @user_data: user data specified when registering
|
* @user_data: user data specified when registering
|
||||||
*
|
*
|
||||||
* This callback will be called when @src has @buffer ready for further
|
* This callback will be called when @src has @buffer ready for further
|
||||||
|
@ -80,7 +80,7 @@ typedef struct _RTPSourceClass RTPSourceClass;
|
||||||
*
|
*
|
||||||
* Returns: a #GstFlowReturn.
|
* Returns: a #GstFlowReturn.
|
||||||
*/
|
*/
|
||||||
typedef GstFlowReturn (*RTPSourcePushRTP) (RTPSource *src, GstBuffer *buffer,
|
typedef GstFlowReturn (*RTPSourcePushRTP) (RTPSource *src, gpointer data,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue