0

I currently have code that returns a valid URI for streaming from an IP Camera. I take that uri and pass it into an object for streaming. Can I configure the objects so they stream over TCP? The VLC application has a setting where I can stream this same URI over TCP so I know the camera has the functionality. When I use the VLC application it just forces RTP over port 554 for a TCP video stream. Currently with this code, it sets up RTSP over 554 and begins streaming RTP over UDP from a different port. What am I missing?

Establish Objects 
            _libVLC = new LibVLC();
            _mp = new MediaPlayer(_libVLC);
            videoView.MediaPlayer = _mp;

////GET local uri//// 

            bool check = Uri.IsWellFormedUriString(local_uri.Uri.ToString(), UriKind.RelativeOrAbsolute);   
            if (check)
            {
                                          
                    _mp.Play(new LibVLCSharp.Shared.Media(_libVLC, local_uri.Uri));
                    check = false;

The uri string comes back formatted as Rtsp://MY-IP

I've tried what a few others have recommended by reformatting it to... rtsp-tcp://MY-IP and it doesn't seem to work (or i'm doing it wrong).

//////////////////////////////// Edit: ////////////////////

            LibVLCSharp.Shared.Media media = new Media(_libVLC, local_uri.Uri);
            media.AddOption(":rtsp-tcp"); //<---- Is this passing the option correctly. 
            _mp.Play(media);
NewCode
  • 39
  • 4

2 Answers2

1

Pass "--rtsp-tcp" as a LibVLC option, or :rtsp-tcp as a media option.

See https://wiki.videolan.org/VLC_command-line_help/

cube45
  • 3,429
  • 2
  • 24
  • 35
  • Thank you! I've attached what I tried on the original post. It doesn't work. Am I doing this correctly? Or at least have the right idea. Watching the wire-shark captures closely when using the VLC application it looks like out of the 4 payloads sent (Options, describe, setup, play) the setup payload is the one that tells it to play TCP. I abandoned attempting something like what you have because I assumed this only affected the "Options" payload. Maybe I was to quick to jump to conclusions. – NewCode Feb 05 '21 at 15:08
0

When you first initialize your VLC object _libVLC = new LibVLC(), you can overload the constructor with a string.

Here is the RTSP-TCP option on the VLC Command-Line Help: RTSP-TCP option

You can then initialize your VLC object like so:

_libVLC = new LibVLC("--rtsp-tcp")

As @cube45 pointed out, you can use the VLC Command-Line help doc to help you find the options that suits you. A simple Ctrl + f followed by your search should help you determine whether or not what you are looking for exists in this library.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83