mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
source: also use the source for bye_reason
Store the BYE reason in our internal source object. Rename the methods on the source object a little because now the BYE can be received in RTCP or set when the session wants to send BYE.
This commit is contained in:
parent
ddd071e54c
commit
1d02496d15
4 changed files with 51 additions and 45 deletions
|
@ -546,8 +546,6 @@ rtp_session_finalize (GObject * object)
|
|||
for (i = 0; i < 32; i++)
|
||||
g_hash_table_destroy (sess->ssrcs[i]);
|
||||
|
||||
g_free (sess->bye_reason);
|
||||
|
||||
g_object_unref (sess->source);
|
||||
|
||||
G_OBJECT_CLASS (rtp_session_parent_class)->finalize (object);
|
||||
|
@ -1658,7 +1656,7 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
|
|||
|
||||
RTP_SESSION_LOCK (sess);
|
||||
/* ignore more RTP packets when we left the session */
|
||||
if (sess->source->received_bye)
|
||||
if (sess->source->marked_bye)
|
||||
goto ignore;
|
||||
|
||||
/* update arrival stats */
|
||||
|
@ -1823,7 +1821,7 @@ rtp_session_process_sr (RTPSession * sess, GstRTCPPacket * packet,
|
|||
return;
|
||||
|
||||
/* don't try to do lip-sync for sources that sent a BYE */
|
||||
if (rtp_source_received_bye (source))
|
||||
if (RTP_SOURCE_IS_MARKED_BYE (source))
|
||||
*do_sync = FALSE;
|
||||
else
|
||||
*do_sync = TRUE;
|
||||
|
@ -2005,8 +2003,8 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
|||
prevactive = RTP_SOURCE_IS_ACTIVE (source);
|
||||
prevsender = RTP_SOURCE_IS_SENDER (source);
|
||||
|
||||
/* let the source handle the rest */
|
||||
rtp_source_process_bye (source, reason);
|
||||
/* mark the source BYE */
|
||||
rtp_source_mark_bye (source, reason);
|
||||
|
||||
pmembers = sess->stats.active_sources;
|
||||
|
||||
|
@ -2022,7 +2020,7 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
|
|||
}
|
||||
members = sess->stats.active_sources;
|
||||
|
||||
if (!sess->source->received_bye && members < pmembers) {
|
||||
if (!sess->source->marked_bye && members < pmembers) {
|
||||
/* some members went away since the previous timeout estimate.
|
||||
* Perform reverse reconsideration but only when we are not scheduling a
|
||||
* BYE ourselves. */
|
||||
|
@ -2288,7 +2286,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
|||
type = gst_rtcp_packet_get_type (&packet);
|
||||
|
||||
/* when we are leaving the session, we should ignore all non-BYE messages */
|
||||
if (sess->source->received_bye && type != GST_RTCP_TYPE_BYE) {
|
||||
if (sess->source->marked_bye && type != GST_RTCP_TYPE_BYE) {
|
||||
GST_DEBUG ("ignoring non-BYE RTCP packet because we are leaving");
|
||||
goto next;
|
||||
}
|
||||
|
@ -2328,7 +2326,7 @@ rtp_session_process_rtcp (RTPSession * sess, GstBuffer * buffer,
|
|||
|
||||
/* if we are scheduling a BYE, we only want to count bye packets, else we
|
||||
* count everything */
|
||||
if (sess->source->received_bye) {
|
||||
if (sess->source->marked_bye) {
|
||||
if (is_bye) {
|
||||
sess->stats.bye_members++;
|
||||
UPDATE_AVG (sess->stats.avg_rtcp_packet_size, arrival.bytes);
|
||||
|
@ -2476,7 +2474,7 @@ calculate_rtcp_interval (RTPSession * sess, gboolean deterministic,
|
|||
sess->recalc_bandwidth = FALSE;
|
||||
}
|
||||
|
||||
if (sess->source->received_bye) {
|
||||
if (sess->source->marked_bye) {
|
||||
result = rtp_stats_calculate_bye_interval (&sess->stats);
|
||||
} else {
|
||||
result = rtp_stats_calculate_rtcp_interval (&sess->stats,
|
||||
|
@ -2510,14 +2508,11 @@ rtp_session_schedule_bye_locked (RTPSession * sess, const gchar * reason,
|
|||
source = sess->source;
|
||||
|
||||
/* ignore more BYEs */
|
||||
if (source->received_bye)
|
||||
if (source->marked_bye)
|
||||
goto done;
|
||||
|
||||
/* we have BYE now */
|
||||
source->received_bye = TRUE;
|
||||
/* at least one member wants to send a BYE */
|
||||
g_free (sess->bye_reason);
|
||||
sess->bye_reason = g_strdup (reason);
|
||||
rtp_source_mark_bye (source, reason);
|
||||
INIT_AVG (sess->stats.avg_rtcp_packet_size, 100);
|
||||
sess->stats.bye_members = 1;
|
||||
sess->first_rtcp = TRUE;
|
||||
|
@ -2608,7 +2603,7 @@ rtp_session_next_timeout (RTPSession * sess, GstClockTime current_time)
|
|||
result = current_time;
|
||||
}
|
||||
|
||||
if (sess->source->received_bye) {
|
||||
if (sess->source->marked_bye) {
|
||||
if (sess->sent_bye) {
|
||||
GST_DEBUG ("we sent BYE already");
|
||||
interval = GST_CLOCK_TIME_NONE;
|
||||
|
@ -2786,7 +2781,7 @@ session_cleanup (const gchar * key, RTPSource * source, ReportData * data)
|
|||
|
||||
/* check for our own source, we don't want to delete our own source. */
|
||||
if (!(source == sess->source)) {
|
||||
if (source->received_bye) {
|
||||
if (source->marked_bye) {
|
||||
/* if we received a BYE from the source, remove the source after some
|
||||
* time. */
|
||||
if (data->current_time > source->bye_time &&
|
||||
|
@ -2917,6 +2912,7 @@ session_bye (RTPSession * sess, ReportData * data)
|
|||
{
|
||||
GstRTCPPacket *packet = &data->packet;
|
||||
GstRTCPBuffer *rtcp = &data->rtcpbuf;
|
||||
RTPSource *source = sess->source;
|
||||
|
||||
/* open packet */
|
||||
session_start_rtcp (sess, data);
|
||||
|
@ -2926,9 +2922,9 @@ session_bye (RTPSession * sess, ReportData * data)
|
|||
|
||||
/* add a BYE packet */
|
||||
gst_rtcp_buffer_add_packet (rtcp, GST_RTCP_TYPE_BYE, packet);
|
||||
gst_rtcp_packet_bye_add_ssrc (packet, sess->source->ssrc);
|
||||
if (sess->bye_reason)
|
||||
gst_rtcp_packet_bye_set_reason (packet, sess->bye_reason);
|
||||
gst_rtcp_packet_bye_add_ssrc (packet, source->ssrc);
|
||||
if (source->bye_reason)
|
||||
gst_rtcp_packet_bye_set_reason (packet, source->bye_reason);
|
||||
|
||||
/* we have a BYE packet now */
|
||||
data->is_bye = TRUE;
|
||||
|
@ -3094,7 +3090,7 @@ rtp_session_on_timeout (RTPSession * sess, GstClockTime current_time,
|
|||
|
||||
/* see if we need to generate SR or RR packets */
|
||||
if (is_rtcp_time (sess, current_time, &data)) {
|
||||
if (own->received_bye) {
|
||||
if (own->marked_bye) {
|
||||
/* generate BYE instead */
|
||||
GST_DEBUG ("generating BYE message");
|
||||
session_bye (sess, &data);
|
||||
|
@ -3137,8 +3133,6 @@ rtp_session_on_timeout (RTPSession * sess, GstClockTime current_time,
|
|||
g_hash_table_insert (sess->ssrcs[sess->mask_idx],
|
||||
GINT_TO_POINTER (own->ssrc), own);
|
||||
|
||||
g_free (sess->bye_reason);
|
||||
sess->bye_reason = NULL;
|
||||
sess->sent_bye = FALSE;
|
||||
sess->change_ssrc = FALSE;
|
||||
notify = TRUE;
|
||||
|
|
|
@ -213,7 +213,6 @@ struct _RTPSession {
|
|||
|
||||
GstClockTime next_early_rtcp_time;
|
||||
|
||||
gchar *bye_reason;
|
||||
gboolean sent_bye;
|
||||
|
||||
RTPSessionCallbacks callbacks;
|
||||
|
|
|
@ -219,7 +219,10 @@ rtp_source_class_init (RTPSourceClass * klass)
|
|||
void
|
||||
rtp_source_reset (RTPSource * src)
|
||||
{
|
||||
src->received_bye = FALSE;
|
||||
src->marked_bye = FALSE;
|
||||
if (src->bye_reason)
|
||||
g_free (src->bye_reason);
|
||||
src->bye_reason = NULL;
|
||||
|
||||
src->stats.cycles = -1;
|
||||
src->stats.jitter = 0;
|
||||
|
@ -321,7 +324,7 @@ rtp_source_create_stats (RTPSource * src)
|
|||
"ssrc", G_TYPE_UINT, (guint) src->ssrc,
|
||||
"internal", G_TYPE_BOOLEAN, internal,
|
||||
"validated", G_TYPE_BOOLEAN, src->validated,
|
||||
"received-bye", G_TYPE_BOOLEAN, src->received_bye,
|
||||
"received-bye", G_TYPE_BOOLEAN, src->marked_bye,
|
||||
"is-csrc", G_TYPE_BOOLEAN, src->is_csrc,
|
||||
"is-sender", G_TYPE_BOOLEAN, is_sender,
|
||||
"seqnum-base", G_TYPE_INT, src->seqnum_base,
|
||||
|
@ -670,21 +673,21 @@ rtp_source_is_sender (RTPSource * src)
|
|||
}
|
||||
|
||||
/**
|
||||
* rtp_source_received_bye:
|
||||
* rtp_source_is_marked_bye:
|
||||
* @src: an #RTPSource
|
||||
*
|
||||
* Check if @src has receoved a BYE packet.
|
||||
* Check if @src is marked as leaving the session with a BYE packet.
|
||||
*
|
||||
* Returns: %TRUE if @src has received a BYE packet.
|
||||
* Returns: %TRUE if @src has been marked BYE.
|
||||
*/
|
||||
gboolean
|
||||
rtp_source_received_bye (RTPSource * src)
|
||||
rtp_source_is_marked_bye (RTPSource * src)
|
||||
{
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (RTP_IS_SOURCE (src), FALSE);
|
||||
|
||||
result = src->received_bye;
|
||||
result = RTP_SOURCE_IS_MARKED_BYE (src);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -694,11 +697,11 @@ rtp_source_received_bye (RTPSource * src)
|
|||
* rtp_source_get_bye_reason:
|
||||
* @src: an #RTPSource
|
||||
*
|
||||
* Get the BYE reason for @src. Check if the source receoved a BYE message first
|
||||
* with rtp_source_received_bye().
|
||||
* Get the BYE reason for @src. Check if the source is marked as leaving the
|
||||
* session with a BYE message first with rtp_source_is_marked_bye().
|
||||
*
|
||||
* Returns: The BYE reason or NULL when no reason was given or the source did
|
||||
* not receive a BYE message yet. g_fee() after usage.
|
||||
* Returns: The BYE reason or NULL when no reason was given or the source was
|
||||
* not marked BYE yet. g_free() after usage.
|
||||
*/
|
||||
gchar *
|
||||
rtp_source_get_bye_reason (RTPSource * src)
|
||||
|
@ -1118,25 +1121,27 @@ probation_seqnum:
|
|||
}
|
||||
|
||||
/**
|
||||
* rtp_source_process_bye:
|
||||
* rtp_source_mark_bye:
|
||||
* @src: an #RTPSource
|
||||
* @reason: the reason for leaving
|
||||
*
|
||||
* Notify @src that a BYE packet has been received. This will make the source
|
||||
* inactive.
|
||||
* Mark @src in the BYE state. This can happen when the source wants to
|
||||
* leave the sesssion or when a BYE packets has been received.
|
||||
*
|
||||
* This will make the source inactive.
|
||||
*/
|
||||
void
|
||||
rtp_source_process_bye (RTPSource * src, const gchar * reason)
|
||||
rtp_source_mark_bye (RTPSource * src, const gchar * reason)
|
||||
{
|
||||
g_return_if_fail (RTP_IS_SOURCE (src));
|
||||
|
||||
GST_DEBUG ("marking SSRC %08x as BYE, reason: %s", src->ssrc,
|
||||
GST_STR_NULL (reason));
|
||||
|
||||
/* copy the reason and mark as received_bye */
|
||||
/* copy the reason and mark as bye */
|
||||
g_free (src->bye_reason);
|
||||
src->bye_reason = g_strdup (reason);
|
||||
src->received_bye = TRUE;
|
||||
src->marked_bye = TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -51,7 +51,7 @@ typedef struct _RTPSourceClass RTPSourceClass;
|
|||
* Check if @src is active. A source is active when it has been validated
|
||||
* and has not yet received a BYE packet.
|
||||
*/
|
||||
#define RTP_SOURCE_IS_ACTIVE(src) (src->validated && !src->received_bye)
|
||||
#define RTP_SOURCE_IS_ACTIVE(src) (src->validated && !src->marked_bye)
|
||||
|
||||
/**
|
||||
* RTP_SOURCE_IS_SENDER:
|
||||
|
@ -60,6 +60,14 @@ typedef struct _RTPSourceClass RTPSourceClass;
|
|||
* Check if @src is a sender.
|
||||
*/
|
||||
#define RTP_SOURCE_IS_SENDER(src) (src->is_sender)
|
||||
/**
|
||||
* RTP_SOURCE_IS_MARKED_BYE:
|
||||
* @src: an #RTPSource
|
||||
*
|
||||
* Check if @src is a marked as BYE.
|
||||
*/
|
||||
#define RTP_SOURCE_IS_MARKED_BYE(src) (src->marked_bye)
|
||||
|
||||
|
||||
/**
|
||||
* RTPSourcePushRTP:
|
||||
|
@ -137,7 +145,7 @@ struct _RTPSource {
|
|||
|
||||
GstStructure *sdes;
|
||||
|
||||
gboolean received_bye;
|
||||
gboolean marked_bye;
|
||||
gchar *bye_reason;
|
||||
|
||||
GSocketAddress *rtp_from;
|
||||
|
@ -199,7 +207,8 @@ gboolean rtp_source_is_active (RTPSource *src);
|
|||
gboolean rtp_source_is_validated (RTPSource *src);
|
||||
gboolean rtp_source_is_sender (RTPSource *src);
|
||||
|
||||
gboolean rtp_source_received_bye (RTPSource *src);
|
||||
void rtp_source_mark_bye (RTPSource *src, const gchar *reason);
|
||||
gboolean rtp_source_is_marked_bye (RTPSource *src);
|
||||
gchar * rtp_source_get_bye_reason (RTPSource *src);
|
||||
|
||||
void rtp_source_update_caps (RTPSource *src, GstCaps *caps);
|
||||
|
@ -219,7 +228,6 @@ GstFlowReturn rtp_source_process_rtp (RTPSource *src, GstBuffer *buffe
|
|||
GstFlowReturn rtp_source_send_rtp (RTPSource *src, gpointer data, gboolean is_list,
|
||||
GstClockTime running_time);
|
||||
/* RTCP messages */
|
||||
void rtp_source_process_bye (RTPSource *src, const gchar *reason);
|
||||
void rtp_source_process_sr (RTPSource *src, GstClockTime time, guint64 ntptime,
|
||||
guint32 rtptime, guint32 packet_count, guint32 octet_count);
|
||||
void rtp_source_process_rb (RTPSource *src, guint64 ntpnstime, guint8 fractionlost,
|
||||
|
|
Loading…
Reference in a new issue