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);
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 */
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;
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;
}
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. */
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;
}
/* 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);
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,
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;
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;
/* 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 &&
{
GstRTCPPacket *packet = &data->packet;
GstRTCPBuffer *rtcp = &data->rtcpbuf;
+ RTPSource *source = sess->source;
/* open packet */
session_start_rtcp (sess, 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;
/* 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);
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;
GstClockTime next_early_rtcp_time;
- gchar *bye_reason;
gboolean sent_bye;
RTPSessionCallbacks callbacks;
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;
"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,
}
/**
- * 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;
}
* 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)
}
/**
- * 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
* 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:
* 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:
GstStructure *sdes;
- gboolean received_bye;
+ gboolean marked_bye;
gchar *bye_reason;
GSocketAddress *rtp_from;
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);
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,