/* if there is no source using the suggested ssrc, most probably because
* this ssrc has just collided, suggest upstream to use it */
- suggested_ssrc = rtp_session_suggest_ssrc (session);
+ suggested_ssrc = rtp_session_suggest_ssrc (session, NULL);
internal_src = rtp_session_get_source_by_ssrc (session, suggested_ssrc);
if (!internal_src)
gst_structure_set (structure, "suggested-ssrc", G_TYPE_UINT,
GstCaps *result;
GstStructure *s1, *s2;
guint ssrc;
+ gboolean is_random;
priv = rtpsession->priv;
- ssrc = rtp_session_suggest_ssrc (priv->session);
+ ssrc = rtp_session_suggest_ssrc (priv->session, &is_random);
/* we can basically accept anything but we prefer to receive packets with our
* internal SSRC so that we don't have to patch it. Create a structure with
- * the SSRC and another one without. */
- s1 = gst_structure_new ("application/x-rtp", "ssrc", G_TYPE_UINT, ssrc, NULL);
- s2 = gst_structure_new_empty ("application/x-rtp");
-
- result = gst_caps_new_full (s1, s2, NULL);
+ * the SSRC and another one without.
+ * Only do this if the session actually decided on an ssrc already,
+ * otherwise we give upstream the opportunity to select an ssrc itself */
+ if (!is_random) {
+ s1 = gst_structure_new ("application/x-rtp", "ssrc", G_TYPE_UINT, ssrc,
+ NULL);
+ s2 = gst_structure_new_empty ("application/x-rtp");
+
+ result = gst_caps_new_full (s1, s2, NULL);
+ } else {
+ result = gst_caps_new_empty_simple ("application/x-rtp");
+ }
if (filter) {
GstCaps *caps = result;
/* this is the SSRC we suggest */
sess->suggested_ssrc = rtp_session_create_new_ssrc (sess);
+ sess->internal_ssrc_set = FALSE;
sess->first_rtcp = TRUE;
sess->next_rtcp_check_time = GST_CLOCK_TIME_NONE;
case PROP_INTERNAL_SSRC:
RTP_SESSION_LOCK (sess);
sess->suggested_ssrc = g_value_get_uint (value);
+ sess->internal_ssrc_set = TRUE;
RTP_SESSION_UNLOCK (sess);
if (sess->callbacks.reconfigure)
sess->callbacks.reconfigure (sess, sess->reconfigure_user_data);
switch (prop_id) {
case PROP_INTERNAL_SSRC:
- g_value_set_uint (value, rtp_session_suggest_ssrc (sess));
+ g_value_set_uint (value, rtp_session_suggest_ssrc (sess, NULL));
break;
case PROP_INTERNAL_SOURCE:
/* FIXME, return a random source */
/* mark the source BYE */
rtp_source_mark_bye (source, "SSRC Collision");
/* if we were suggesting this SSRC, change to something else */
- if (sess->suggested_ssrc == ssrc)
+ if (sess->suggested_ssrc == ssrc) {
sess->suggested_ssrc = rtp_session_create_new_ssrc (sess);
+ sess->internal_ssrc_set = TRUE;
+ }
on_ssrc_collision (sess, source);
sess->stats.active_sources++;
if (src->internal) {
sess->stats.internal_sources++;
- if (sess->suggested_ssrc != src->ssrc)
- sess->suggested_ssrc = src->ssrc;
}
/* update point-to-point status */
/**
* rtp_session_suggest_ssrc:
* @sess: a #RTPSession
+ * @is_random: if the suggested ssrc is random
*
* Suggest an unused SSRC in @sess.
*
* Returns: a free unused SSRC
*/
guint32
-rtp_session_suggest_ssrc (RTPSession * sess)
+rtp_session_suggest_ssrc (RTPSession * sess, gboolean * is_random)
{
guint32 result;
RTP_SESSION_LOCK (sess);
result = sess->suggested_ssrc;
+ if (is_random)
+ *is_random = !sess->internal_ssrc_set;
RTP_SESSION_UNLOCK (sess);
return result;
RTP_SESSION_LOCK (sess);
source = obtain_internal_source (sess, ssrc, &created, GST_CLOCK_TIME_NONE);
+ sess->suggested_ssrc = ssrc;
+ sess->internal_ssrc_set = TRUE;
if (source) {
rtp_source_update_caps (source, caps);
g_object_unref (source);
source = obtain_internal_source (sess, sess->suggested_ssrc, &created,
current_time);
+ sess->internal_ssrc_set = TRUE;
g_object_unref (source);
}