Skip to content

How to make initializing Media with fd work on Android?

I am using LibVLCSharp (version 3.0.0) in a Xamarin app. I have a rtsp link from which I can receive the stream from external camera and display it using libVLC. Everything works fine when the media is created with rtsp link as var media = new Media(_libVLC, rtspLink, FromType.FromLocation).

But in my Android project I need to bind connection between my external camera and my app to a specific camera wi-fi. This is needed to be able to simultaneously get stream from the camera and send it to the server.

Rtsp link has the following structure: rtsp://ip:port/live. So what I am trying to do is to create a Java socket with ip and port from the link (I need Java socket to be able to bind it to wi-fi network with Android api Network.BindSocket), connect to it. Then I am obtaining socket's file descriptor with ParcelFileDescriptor.FromSocket(_socket).Fd and I am creating VLC Media inside of Android project with the obtained int value using the constructor Media.Media(LibVLC libVLC, int fd).

The input can not be parsed by VLC as far as I can see from the logs:

[VLC] [0000007843910290/4875] libvlc stream: read error: Software caused connection abort

[VLC] [00000078164c6ad0/4874] libvlc demux: cannot peek

[VLC] [00000078220eea90/4874] libvlc input: Your input can't be opened

[VLC] [00000078220eea90/4874] libvlc input: VLC is unable to open the MRL 'fd://68'. Check the log for details.

Questions:

  • where can I see this log with details?
  • do I need to specify something else for the lib, I haven't found such an option (like the actual path /live for instance)?
  • do I need to send rtsp commands to my socket myself to make it work?
  • or maybe initialization should be performed in some other way?
  • additionally maybe it is somehow possible to obtain information (like fd) about input or output connection the library creates?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information