Skip to content

Commit 9dca86f

Browse files
committed
Plumb through clear-ssrc signal to rtp session, remove the corresponding rtp source
1 parent 35c3589 commit 9dca86f

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

subprojects/gst-plugins-good/gst/rtpmanager/gstrtpbin.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,10 @@ gst_rtp_bin_clear_ssrc (GstRtpBin * bin, guint session_id, guint32 ssrc)
12461246
g_signal_emit_by_name (demux, "clear-ssrc", ssrc, NULL);
12471247
gst_object_unref (demux);
12481248
}
1249+
1250+
if (session) {
1251+
g_signal_emit_by_name (session->session, "clear-ssrc", ssrc, NULL);
1252+
}
12491253
}
12501254

12511255
static GstElement *

subprojects/gst-plugins-good/gst/rtpmanager/gstrtpsession.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ enum
199199
SIGNAL_REQUEST_PT_MAP,
200200
SIGNAL_CLEAR_PT_MAP,
201201
SIGNAL_SEND_BYE,
202+
SIGNAL_CLEAR_SSRC,
202203

203204
SIGNAL_ON_NEW_SSRC,
204205
SIGNAL_ON_SSRC_COLLISION,
@@ -379,6 +380,7 @@ static gboolean gst_rtp_session_setcaps_send_rtp (GstPad * pad,
379380

380381
static void gst_rtp_session_clear_pt_map (GstRtpSession * rtpsession);
381382
static void gst_rtp_session_send_bye (GstRtpSession * rtpsession);
383+
static void gst_rtp_session_clear_ssrc (GstRtpSession * rtpsession, guint ssrc);
382384

383385
static GstStructure *gst_rtp_session_create_stats (GstRtpSession * rtpsession);
384386

@@ -570,6 +572,19 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
570572
G_STRUCT_OFFSET (GstRtpSessionClass, send_bye),
571573
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0, G_TYPE_NONE);
572574

575+
/**
576+
* GstRtpSession::clear-ssrc:
577+
* @sess: the object which received the signal
578+
* @ssrc: the ssrc
579+
*
580+
* Reset the rtpsource associated with the given ssrc.
581+
*/
582+
gst_rtp_session_signals[SIGNAL_CLEAR_SSRC] =
583+
g_signal_new ("clear-ssrc", G_TYPE_FROM_CLASS (klass),
584+
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
585+
G_STRUCT_OFFSET (GstRtpSessionClass, clear_ssrc),
586+
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_UINT);
587+
573588
/**
574589
* GstRtpSession::on-new-ssrc:
575590
* @sess: the object which received the signal
@@ -895,6 +910,7 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
895910

896911
klass->clear_pt_map = GST_DEBUG_FUNCPTR (gst_rtp_session_clear_pt_map);
897912
klass->send_bye = GST_DEBUG_FUNCPTR (gst_rtp_session_send_bye);
913+
klass->clear_ssrc = GST_DEBUG_FUNCPTR (gst_rtp_session_clear_ssrc);
898914

899915
/* sink pads */
900916
gst_element_class_add_static_pad_template (gstelement_class,
@@ -1487,6 +1503,12 @@ gst_rtp_session_send_bye (GstRtpSession * rtpsession)
14871503
rtp_session_schedule_bye (rtpsession->priv->session, current_time);
14881504
}
14891505

1506+
static void
1507+
gst_rtp_session_clear_ssrc (GstRtpSession * rtpsession, guint ssrc)
1508+
{
1509+
rtp_session_clear_ssrc (rtpsession->priv->session, ssrc);
1510+
}
1511+
14901512
/* called when the session manager has an RTP packet ready to be pushed */
14911513
static GstFlowReturn
14921514
gst_rtp_session_process_rtp (RTPSession * sess, RTPSource * src,

subprojects/gst-plugins-good/gst/rtpmanager/gstrtpsession.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct _GstRtpSessionClass {
6565
GstCaps* (*request_pt_map) (GstRtpSession *sess, guint pt);
6666
void (*clear_pt_map) (GstRtpSession *sess);
6767
void (*send_bye) (GstRtpSession *sess);
68+
void (*clear_ssrc) (GstRtpSession *sess, guint32 ssrc);
6869

6970
void (*on_new_ssrc) (GstRtpSession *sess, guint32 ssrc);
7071
void (*on_ssrc_collision) (GstRtpSession *sess, guint32 ssrc);

subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,6 +3958,45 @@ rtp_session_mark_all_bye (RTPSession * sess, const gchar * reason)
39583958
RTP_SESSION_UNLOCK (sess);
39593959
}
39603960

3961+
/**
3962+
* rtp_session_clear_ssrc:
3963+
* @sess: an #RTPSession
3964+
* @ssrc: the ssrc
3965+
*
3966+
* Remove the rtp source corresponding to the given ssrc
3967+
*/
3968+
void
3969+
rtp_session_clear_ssrc (RTPSession * sess, guint ssrc)
3970+
{
3971+
g_return_if_fail (RTP_IS_SESSION (sess));
3972+
RTPSource *source;
3973+
3974+
RTP_SESSION_LOCK (sess);
3975+
source = find_source (sess, ssrc);
3976+
if (source) {
3977+
GST_DEBUG ("Set closing ssrc %u", ssrc);
3978+
source->closing = TRUE;
3979+
gboolean is_sender = RTP_SOURCE_IS_SENDER (source);
3980+
gboolean is_active = RTP_SOURCE_IS_ACTIVE (source);
3981+
3982+
sess->total_sources--;
3983+
if (is_sender) {
3984+
sess->stats.sender_sources--;
3985+
if (source->internal)
3986+
sess->stats.internal_sender_sources--;
3987+
}
3988+
if (is_active)
3989+
sess->stats.active_sources--;
3990+
3991+
if (source->internal)
3992+
sess->stats.internal_sources--;
3993+
3994+
/* Now remove the marked sources */
3995+
g_hash_table_remove (sess->ssrcs[sess->mask_idx], GINT_TO_POINTER(ssrc));
3996+
}
3997+
RTP_SESSION_UNLOCK (sess);
3998+
}
3999+
39614000
/* Stop the current @sess and schedule a BYE message for the other members.
39624001
* One must have the session lock to call this function
39634002
*/

subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,5 +464,7 @@ gboolean rtp_session_request_nack (RTPSession * sess,
464464

465465
void rtp_session_update_recv_caps_structure (RTPSession * sess, const GstStructure * s);
466466

467+
void rtp_session_clear_ssrc (RTPSession *sess, guint ssrc);
468+
467469

468470
#endif /* __RTP_SESSION_H__ */

0 commit comments

Comments
 (0)