Streaming plugin: Cannot find (rtsp) rtp source stream in incoming rtcp function

In the janus_streaming_incoming_rtcp() function, searching the GHashTable *media_byid using packet->mindex returns NULL.

void janus_streaming_incoming_rtcp() {
  janus_streaming_rtp_source_stream *stream = g_hash_table_lookup(source->media_byid, GINT_TO_POINTER(packet->mindex));
  if(stream == NULL)
    return;
}

This happens because in the janus_streaming_create_rtsp_source() → janus_streaming_rtsp_connect_to_server() process,
the janus_streaming_rtp_source_stream is created without adding the index to the GHashTable media_byid.

However, in the janus_streaming_create_rtp_source() function, the index is explicitly added to the GHashTable media_byid.

static int janus_streaming_rtsp_connect_to_server() {
  ...
  if(stream->fd[0] != -1)
    g_hash_table_insert(source->media_byfd, GINT_TO_POINTER(stream->fd[0]), stream);
}

Why not insert index in media_byid?
When creating a streaming source with the RTSP type, the processing of incoming RTCP might not be necessary?

IIRC we only map RTP, not RTCP. Besides, RTSP mountpoints in the Streaming plugin don’t support more than one audio and one video stream, which means using -1 as a mindex is enough to get it working. Pure RTP mountpoints can have multiple audio and video streams, and so those need to be indexed accordingly to the m-line they’re associated with.

1 Like

Lorenzo, Thanks for an answer.
I am one of the people who loves janus.

(My english is not that good.)
I understood. What I wanted to say is …

Big if needed, if include the following REFERENCE code,
the janus_streaming_incoming_rtcp() function can find the stream using mindex and handle the RTCP.

The REFERENCE code is part of the code in the janus_streaming_create_rtp_source() function.

static int janus_streaming_rtsp_connect_to_server(janus_streaming_mountpoint *mp) {
	...

	// *REFERENCE* ->
	/* Map this stream by mindex */
	g_hash_table_insert(live_rtp_source->media_byid, GINT_TO_POINTER(stream->mindex), stream);
	// <- *REFERENCE*

	/* Map this stream by all its file descriptors */
	...
	if(stream->fd[0] != -1)
		g_hash_table_insert(source->media_byfd, GINT_TO_POINTER(stream->fd[0]), stream);
}