Unable to decode SAP/SDP data using UdpClient when streaming video remotely RRS feed

  • Question

  • I'm not able to decode UDP packets containing SAP/SDP data associated with streaming video to a multicast IP address ( from VLC Media Player 1.1.9 -- that is, sending the video and announcements between 2 machines on the same subnet. I'm using the UdpClient from System.Net.Sockets to receive the data, and when I attempt to decode the byte array with Encoding.UTF8.GetString, it just returns a garbled string.  Perhaps it's encrypted?

    When I setup VLC to run on the same machine as my development environment (VS2012) and stream the video to the same multicast IP address, I have no problem decoding the SDP document associated with the SAP announcement, which is great, but I need to make this work in a networked configuration.

    Here's the code for creating the UdpClient:

    private string _ipAddress; // << assigned elsewhere

    private string _port; // << assigned 4001 elsewhere

    private UdpClient _udpClient = null;

    public void Connect()


        // open session for SAP announcements based on IP address and port number provided.

        _udpClient = new UdpClient(Convert.ToInt32(_port));


        _udpClient.MulticastLoopback = false;

        _listenerThread = new Thread(Listen);



    private void Listen()


            IPEndPoint ipEndpoint = null;

            ipEndpoint = new IPEndPoint(System.Net.IPAddress.Any, 0);

            // we continue listening indefinitely until this thread is joined when the listener is disconnected or disposed

            while (true)


                       // this line returns a garbled string:

                byte[] data = _udpClient.Receive(ref ipEndpoint); 

                if (data != null)


                    string message = Encoding.UTF8.GetString(data);






    Any recommendations on what I need to do differently to decode those UDP packets with my SAP/SDP announcements from VLC?

    Thanks -


    Friday, June 7, 2013 10:48 PM