Video doorphone using RTSP camera

These examples / test setups show how to use tSIP as an endpoint combining SIP/RTP audio and RTSP video from camera.
SIP + RTSP doorphone

Background: I've created this examples responding to request describing setup with doorphone, FRITZ!Box and RTSP network camera. I don't think that FRITZ!Box supports video, I'm also not 100% sure if it is even necesary for this particular setup, maybe it would work better with plain peer-to-peer calls (there are some video doorphones that are working both as SIP video endpoint and RTSP server, in this case tSIP "video" build would also work). It still seems like a valid and non-unique use case.

I had prepared an example for similar scenario in the past: video doorphone, but it was based on different assumptions. tSIP was used just to start/stop separate RTSP video player, audio path was handled by separate "regular" SIP desk phone and BLF/dialog-info subscriptions were used to trigger RTSP playback. As FRITZ!Box is not supporting BLF, it would not work with it. As mpv video plugin for tSIP was created later, similar setup can also be now created in a more elegant way.

Yak shaving - testing RTSP

Initially I did not have RTSP network camera at home. At the time of writing this (end of July 2024), it was also not possible to find any working publicly available RTSP stream / test service. Really, I've tried few dozen links and all were dead at the moment. Perhaps some unsecured private cameras could be reached, but even if, they might dead as well the very next day. I needed a way to test it locallly.

VLC

This well-known video player has also built-in RTSP server functionality. Media/Stream menu allows to use video file or local USB camera as a source.
VLC RTSP steaming
VLC RTSP steaming
Don't miss the "Add" button.
VLC RTSP steaming
VLC RTSP steaming
It looks like everything works here with transcoding disabled.
VLC RTSP steaming

Issues found:

Adding option to select RTSP transport required updating tSIP_mpv.dll. Make sure to use version newer that 2.0, e.g. the one included in archives below.

Despite the reliability issue, VLC seems to be useful tool for testing.

live555

From what I understand live555 might be the key part of RTSP support in VLC.
While tSIP works pretty well, almost perfectly under Wine (thanks to Wine improvements, recently with lubuntu 24 / Wine 9.0 even network interfaces and audio devices are listed correctly), it is Windows native. It doesn't seem like live555 Windows binaries are readily available, so I'm adding them here, along with a test WebM/VP8 file that can be used a video source: live555_mediaserver_vs2022_bin_x64_release_static.7z. Source: https://github.com/tomek-o/live555_vs2022.

To use live555 mediaServer just start executable placing supported video file next to it and connect with rtsp://ip_address/file_name (including file extension). The list of supported file formats is limited comparing to VLC.

tSIP + tSIP_mpv.dll: video in the main window

Video is rendered on one of the buttons from "console" area.
tSIP RTSP in the main window
mpv_doorphone.7z
Download also libmpv-2.dll from the link below and put it next to tSIP.exe!

tSIP + tSIP_mpv.dll: video in the tray notifier

Tray notifier started as a tiny notification window, displaying caller name and Answer/Hangup buttons, but since tSIP 0.3.4 it can be resized and customized, working as a button container. This allows to separate doorphone handling from regular calls and activities and it would also work well is answering doorphone is a side job.
tSIP RTSP in the tray window
mpv_doorphone_tray.7z
Download also libmpv-2.dll from the link below and put it next to tSIP.exe!

Configuration

Both examples, using the main window and the tray notifier window are using similar "on call state" Lua script. This script starts or stops RTSP video playback depending on call state. What is important for a doorphone, video is displayed before call is answered (answering the call is not necesary to see the video). For displaying video, selected button (placed either in the main window or in the tray notifier window) is used as a canvas. Actual video handling is done by tSIP_mpv.dll (placed in /phone folder and activated in tSIP configuration) and libmpv-2.dll (placed next to tSIP.exe).

Lua script contains configuration section at the beginning. It includes:

Some additional mpv properties reducing video delay:

PluginSendMessageText("tSIP_mpv.dll", PLAYER_NAME .. " SET_PROPERTY_STRING cache no")
PluginSendMessageText("tSIP_mpv.dll", PLAYER_NAME .. " SET_PROPERTY_STRING demuxer-readahead-secs 0")
PluginSendMessageText("tSIP_mpv.dll", PLAYER_NAME .. " SET_PROPERTY_STRING cache-pause no")
PluginSendMessageText("tSIP_mpv.dll", PLAYER_NAME .. " SET_PROPERTY_STRING untimed yes")

Example with 4 buttons switching RTSP cameras

tSIP RTSP with 4 buttons
mpv_doorphone_4btns.7z

Latency test

mpv RTSP latency test

Glass-to-glass latency with two "real" cameras tested, modern Hanhwa dome camera and older Vivotek IP8133 was pretty consistent, close to 260 ms.

Recording video

Add

PluginSendMessageText("tSIP_mpv.dll", M.PLAYER_NAME .. " SET_PROPERTY_STRING stream-record record_test.ts")

after PLAY command (order seems to matter, same as selected output format).

Few ideas

Other notes

Related

Back to howto list