return TRUE;
}
+static RTPSource *
+find_source (RTPSession * sess, guint32 ssrc)
+{
+ return g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
+ GINT_TO_POINTER (ssrc));
+}
+
+static void
+add_source (RTPSession * sess, RTPSource * src)
+{
+ g_hash_table_insert (sess->ssrcs[sess->mask_idx],
+ GINT_TO_POINTER (src->ssrc), src);
+ /* we have one more source now */
+ sess->total_sources++;
+}
/* must be called with the session lock, the returned source needs to be
* unreffed after usage. */
{
RTPSource *source;
- source =
- g_hash_table_lookup (sess->ssrcs[sess->mask_idx], GINT_TO_POINTER (ssrc));
+ source = find_source (sess, ssrc);
if (source == NULL) {
/* make new Source in probation and insert */
source = rtp_source_new (ssrc);
+ GST_DEBUG ("creating new source %08x %p", ssrc, source);
+
/* for RTP packets we need to set the source in probation. Receiving RTCP
* packets of an SSRC, on the other hand, is a strong indication that we
* are dealing with a valid source. */
/* configure a callback on the source */
rtp_source_set_callbacks (source, &callbacks, sess);
- g_hash_table_insert (sess->ssrcs[sess->mask_idx], GINT_TO_POINTER (ssrc),
- source);
-
- /* we have one more source now */
- sess->total_sources++;
+ add_source (sess, source);
*created = TRUE;
} else {
*created = FALSE;
g_return_val_if_fail (src != NULL, FALSE);
RTP_SESSION_LOCK (sess);
- find =
- g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
- GINT_TO_POINTER (src->ssrc));
+ find = find_source (sess, src->ssrc);
if (find == NULL) {
- g_hash_table_insert (sess->ssrcs[sess->mask_idx],
- GINT_TO_POINTER (src->ssrc), src);
- /* we have one more source now */
- sess->total_sources++;
+ add_source (sess, src);
result = TRUE;
}
RTP_SESSION_UNLOCK (sess);
g_return_val_if_fail (RTP_IS_SESSION (sess), NULL);
RTP_SESSION_LOCK (sess);
- result =
- g_hash_table_lookup (sess->ssrcs[sess->mask_idx], GINT_TO_POINTER (ssrc));
+ result = find_source (sess, ssrc);
if (result)
g_object_ref (result);
RTP_SESSION_UNLOCK (sess);
ssrc = g_random_int ();
/* see if it exists in the session, we're done if it doesn't */
- if (g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
- GINT_TO_POINTER (ssrc)) == NULL)
+ if (find_source (sess, ssrc) == NULL)
break;
}
return ssrc;
rtp_source_set_callbacks (source, &callbacks, sess);
/* we need an additional ref for the source in the hashtable */
g_object_ref (source);
- g_hash_table_insert (sess->ssrcs[sess->mask_idx], GINT_TO_POINTER (ssrc),
- source);
- /* we have one more source now */
- sess->total_sources++;
+ add_source (sess, source);
RTP_SESSION_UNLOCK (sess);
return source;
if (!sess->callbacks.request_key_unit)
return;
- src = g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
- GINT_TO_POINTER (sender_ssrc));
+ src = find_source (sess, sender_ssrc);
if (!src)
return;
if (fci_length < 8)
return;
- src = g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
- GINT_TO_POINTER (sender_ssrc));
+ src = find_source (sess, sender_ssrc);
/* Hack because Google fails to set the sender_ssrc correctly */
if (!src && sender_ssrc == 1) {
}
if (sess->rtcp_feedback_retention_window) {
- RTPSource *src = g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
- GINT_TO_POINTER (media_ssrc));
+ RTPSource *src = find_source (sess, media_ssrc);
if (src)
rtp_source_retain_rtcp_packet (src, packet, arrival->running_time);
rtp_session_request_key_unit (RTPSession * sess, guint32 ssrc, GstClockTime now,
gboolean fir, gint count)
{
- RTPSource *src = g_hash_table_lookup (sess->ssrcs[sess->mask_idx],
- GUINT_TO_POINTER (ssrc));
+ RTPSource *src = find_source (sess, ssrc);
if (!src)
return FALSE;