Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming Plugin: RTSP does not support "threads" configuration like RTP #2359

Closed
jreich888 opened this issue Sep 14, 2020 · 9 comments
Closed

Comments

@jreich888
Copy link

Since RTSP ultimately uses RTP for stream reception, the RTSP sources should support configuration for "threads" to add helper threads as is supported for RTP. When I try this for RTP I can see the created helper threads using ps -T, but no such additional threads exist for the RTSP streams.

When I look at the code (streaming plugin v0.0.8, Janus v0.10.5) I can see that the thread creation occurs only in the janus_streaming_create_rtp_source() function, and not in the _create_rtsp_source() method.
https://github.com/meetecho/janus-gateway/blob/v0.10.5/plugins/janus_streaming.c#L6060
Additionally, the threads parameter is not even parsed for the RTSP type case.

To reproduce, add a streaming source with a configuration as below. See that the sources is created and that when reviewing threads using ps -T that a main processor thread mp 1 exists but no helper threads for that source.

thread_test: {
        type = "rtsp"
        id = 1
        description = "Thread Test RTSP"
        audio = false
        video = true
        url = "rtsp://192.168.1.123/0"
        rtsp_user = "username"
        rtsp_pwd = "password"
        threads = 2
}
@atoppi
Copy link
Member

atoppi commented Sep 15, 2020

HI @jreich888 ,
I've been going through your post on the group.

  • Do you have any evidence that using helper threads on RTSP mountpoints will avoid the issue you described on huge KF ?
  • Did you get to find the cause of the drop ?
  • Have you tried increasing the kernel UDP buffers ?

@atoppi
Copy link
Member

atoppi commented Sep 15, 2020

Another question: do you have a packet capture filtered on the RTSP negotiated ports ? (e.g. input capture (not with Admin API) on the ports that Janus is using to get media from the RasperryPi).

@jreich888
Copy link
Author

jreich888 commented Sep 15, 2020 via email

@lminiero
Copy link
Member

@jreich888 see the commit above, that you can find in PR #2361. I haven't tested yet, so please do that when you have some time and provide some feedback (on the PR, not here) on whether it works as expected.

@atoppi
Copy link
Member

atoppi commented Sep 16, 2020

@jreich888 thanks for the response.
If the packets are present in the pcap at the mountpoint input then:

  • I suspect there's some point where Janus is simply dropping them
  • Changing kernel buffers should be useless at this moment (the OS got them)

Configuring the helper threads is definitely worth trying but I'm interested in tracking down the root issue that lead to the drop.
Very likely the same issue might be present in RTP mountpoints too.
Helpers threads should be used as an enhancement and not a fix.

@atoppi
Copy link
Member

atoppi commented Sep 16, 2020

@jreich888 on second thought, setting a higher value to UDP recv buffer size is still worth trying.

To set ~1MB of buffer:
sysctl -w net.core.rmem_default=1064960
sysctl -w net.core.rmem_max=1064960

Janus is just using the system defaults, it does not set a specifc skt option in that regard.

@atoppi
Copy link
Member

atoppi commented Sep 16, 2020

To check if UDP datagrams are being discarded the following command works on my machine (Ubuntu 20.04)

atoppi@atoppi:~$ sudo netstat -suna
IcmpMsg:
    InType3: 41
    OutType3: 830
Udp:
    227106 packets received
    1205 packets to unknown port received
    0 packet receive errors
    194589 packets sent
    0 receive buffer errors
    0 send buffer errors
    IgnoredMulti: 1970
UdpLite:
IpExt:
    InMcastPkts: 648
    OutMcastPkts: 637
    InBcastPkts: 1970
    OutBcastPkts: 5
    InOctets: 504174491
    OutOctets: 151779263
    InMcastOctets: 94376
    OutMcastOctets: 93495
    InBcastOctets: 450618
    OutBcastOctets: 377
    InNoECTPkts: 507411

packet receive errors and receive buffer errors are the parameters to monitor in this case

@jreich888
Copy link
Author

jreich888 commented Sep 16, 2020 via email

@atoppi
Copy link
Member

atoppi commented Sep 16, 2020

The UDP receive buffers are per socket, right?

Yes, that setting is per socket.

In my case, I'm suspecting that the OS was getting the packets (confirmed by
packet capture), but the dropped as the rx buffer was full (with the
Raspbian default buffer size of 80kB).

I agree with your analysis and you could confirm it with netstat -suna.

I'm running 1MB buffer size now

Did it solve the issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants