Can not get RTSP client starting with existing test streams

Topics: Bug Archive, Question
Feb 15, 2016 at 7:43 AM
Hello,

I searched a bunch of test streams for rtsp.

I used those here:
    //const string listenURL = "http://samples.mplayerhq.hu/V-codecs/h264/interlaced_crop.mp4";
    //const string listenURL = "http://archive.org/details/BUILDINGH263.3gp";
    const string listenURL = "http://archive.org/download/SampleMpeg4_201307/sample_mpeg4.mp4";
The first one at least always works using VLC Player for example. All 3 should work.

Then I try with my litte rtsp Client just to get some Streaming data:

private void RTPReceive(object param)
    {
        //Create a client
        m_RtpClient = new Media.Rtsp.RtspClient(listenURL);
        m_RtpClient.SocketReadTimeout = 3000;
        m_RtpClient.SocketWriteTimeout = 3000;

        ///Attach events at the packet level
        m_RtpClient.Client.RtcpPacketReceieved +=
          new Media.Rtp.RtpClient.RtcpPacketHandler(OnSourceRtcpPacketRecieved);
        m_RtpClient.Client.RtpPacketReceieved +=
          new Media.Rtp.RtpClient.RtpPacketHandler(OnSourceRtpPacketRecieved);

        //Performs the Options, Describe, Setup and Play Request
        m_RtpClient.StartPlaying();
Every time I start one of These, I get the exception "Unable to get Options".
When I delete the line in rtspclient,cs with its raiseexception I get some null reference exception at a later Point.

At least the first one shoulp Play or let me receive some data?
Why do I always get this exception? when I try with a wrong link I get an exception for new rtspclient already.

Can you please help me? Is there something I am missing or is it a bug or missing Feature in the rtspclient? I am still looking for a C# and Xamarin solution to get my RTP Client for Streaming Video from a camera working and your package Looks so promising...

Thanks a lot!

Eric
Coordinator
Feb 15, 2016 at 12:35 PM
Edited Feb 15, 2016 at 12:36 PM
Those sources are plain mp4 served over http, you don't need rtsp or rtp to consume them, you can use the Httpclient to download it or you can try the BaseMediaReader if you need to download and iterate the boxes or find information from the mp4.
Marked as answer by juliusfriedman on 2/15/2016 at 5:35 AM
Feb 15, 2016 at 2:31 PM
Okay. Sorry. I just want to get my RTP Client Show me some stuff. I am currently using my PC Client so I doo not run into that Port Problems again.
Now I attached my camera. I have a session description file. I start VLC Player by double clicking it. I see a Video stream.

I paste exactly the code from that file into my test Client in a new RTP Connection method:
        try
        {
                Media.Sdp.SessionDescription sessionDescription = new Media.Sdp.SessionDescription(@"v=0
                o=sip 123456 654321 IN IP4 172.16.255.255
                s=A conversation
                c=IN IP4 172.16.255.255/16
                t=0 0
                a=recvyonly
                a=type:broadcast
                m=video 5008 RTP/AVP 126
                a=rtpmap:126 H264/90000
                a=fmtp:126 packetization-mode=1;");

                RtpClient rtpClient = RtpClient.FromSessionDescription(sessionDescription);

                //rtpClient.RtpPacketReceieved += OnSourceRtpPacketRecieved;
                rtpClient.RtpFrameChanged += Client_RtpFrameChanged;
                //rtpClient.RtcpPacketReceieved += OnSourceRtcpPacketRecieved;

                rtpClient.Activate();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Leider nein: "+ ex.ToString());
        }
    }
It does not Show any Errors anymore. I am using my Method of SocketExtensions.cs where I have added try catch to FindOpenPort with return 30000 if it catches an exception.

I also added some loggings.

Transportcontext initialized: localRTP:172.16.104.6:30000 remoteRTP:172.16.255.255:5008 localRTCP:172.16.104.6:30001 remoteRTCP:172.16.255.255:5009

@SendRecieve - Begin
ReceiveData in progress
ReceiveData Error: TimedOut

Do you have any idea why it is not working? I get no exception, it Looks okay and activated, but I do not receive rtp packages.

The same with VLC Player always works perfect. I have taken down the Firewall, too, but it did not help.
The stream is not extremly fast but okay, it takes VLC one second to connect and I guess I have around 15 Frames there.

Thanks a lot!

Eric
Coordinator
Feb 15, 2016 at 4:52 PM
Edited Feb 15, 2016 at 4:53 PM
Post up a Wireshark capture from your SIP client which is working, I will be able to use that to both investigate this issue as well as add some more SIP functionality and address this issue better.

Please also attach a separate WireShark capture from VLC so I can compare that to whats going on also.

Finally please include a capture from this library.

Additionally it's probably because the data is coming on a different port than indicated in the SDP or your having another type of network issue, you may want to set the port to 0 and listen to all available traffic until you start to receive from a certain port, which the TransportClient will keep track of.

The other way would be to create the socket on the ports you need and pass it into the function so that the existing socket is used.

I will keep an eye out for the SIP capture and let you know what I find from there.
Marked as answer by juliusfriedman on 2/15/2016 at 9:52 AM
Feb 16, 2016 at 2:42 PM
Hello Julius,

today I did not have the always Streaming device anoymore that I can use to test rtp Client only without sip.

But I have run my Client which makes successfully the sip Connection and then opens the rtp Connection but cannot receive rtp packet using your rtp Client.

I have added 3 files for each case, one is a txt with the visual Studio Output, and two which are the same wireshark exports but with various formats only.
I have ran it 3 times, one time on my PC with Windows 7, one time with my android device (android 5.0 started from usb from visual Studio), and one time the same but with the punchhole variable in the rtp Client always turned on.

I uploaded a zip with the wireshark files and Output:
https://www.dropbox.com/s/08jjovmasimwbwl/Wireshark-SIPandRTP.zip?dl=0

I hope this helps. Help for my Project would be absolutely great and helpful, thanks.

For Android I made this changes in IPAdressExtensions because of not implemented exception (in android the commented part is active):
    //todo beh Xamarin Ersatz
    //private static System.Net.IPAddress emptyIpv6 = MapToIPv6(emptyIpv4);
    //private static System.Net.IPAddress intranetMask1v6 = MapToIPv6(intranetMask1v4);
    //private static System.Net.IPAddress intranetMask2v6 = MapToIPv6(intranetMask2v4);
    //private static System.Net.IPAddress intranetMask3v6 = MapToIPv6(intranetMask3v4);
    //private static System.Net.IPAddress intranetMask4v6 = MapToIPv6(intranetMask4v4);

    private static System.Net.IPAddress emptyIpv6 = emptyIpv4.MapToIPv6();
    private static System.Net.IPAddress intranetMask1v6 = intranetMask1v4.MapToIPv6();
    private static System.Net.IPAddress intranetMask2v6 = intranetMask2v4.MapToIPv6();
    private static System.Net.IPAddress intranetMask3v6 = intranetMask3v4.MapToIPv6();
    private static System.Net.IPAddress intranetMask4v6 = intranetMask4v4.MapToIPv6();

    public static System.Net.IPAddress MapToIPv6(this System.Net.IPAddress addr)
    {
        if (addr.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
            System.Console.WriteLine("Must pass an IPv4 address to MapToIPv6");

        string ipv4str = addr.ToString();

        return System.Net.IPAddress.Parse("::ffff:" + ipv4str);
    }
And in SocketExtensions I added a try catch around FindOpenPort and returned 0 in catch.

Thanks a lot! If you Need more informations, please let me know.
Coordinator
Feb 16, 2016 at 7:27 PM
Cool, thanks for sharing.

I would imagine that eventually the work around required for Android would not be required but it will be good for historical purposes.

I will take a look at what you posted and respond when I can, if I need more information you may hear from me sooner than expected.

One thing I will let you know is that it seems that your packets are coming from a multicast source '239.43.126.56', there is nothing in the SDP which indicates how you are supposed to know that, nor is there anything I can see in the SIP conversation.

Are you sure your not having some kind of networking routing issue or have multicast configured somewhere it shouldn't be?

I will take a look at implemented a SipClient within the next few weeks which will probably help with this.
Marked as answer by juliusfriedman on 2/16/2016 at 12:27 PM
Coordinator
Feb 16, 2016 at 10:17 PM
I also checked in 111890, it should be stable and includes some of those fixes for you already.

I have also started to add more SIP related stuff but that's not as ready yet.

Let me know if the changes I made work for you and thanks again for bringing this up.

I will let you know what I find in relation to the SIP stuff when I get further along.
Marked as answer by juliusfriedman on 2/16/2016 at 3:17 PM
Feb 17, 2016 at 7:50 AM
Edited Feb 17, 2016 at 10:16 AM
Hello Julius,

thanks a lot for the new update!

I had to make both changes I mentioned above. Now I have my Xamarin Client again working so far until the RTP starts.

With the new Version I get an exception already here:

RtpClient rtpClient = Media.Rtp.RtpClient.FromSessionDescription(sessionDescription);

Errorcode 10013
"Access denied"
{System.Net.Sockets.SocketException: Access denied
at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00030] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1092
at Media.Rtp.RtpClient+TransportContext.Initialize (System.Net.IPEndPoint localRtp, System.Net.IPEndPoint remoteRtp, System.Net.IPEndPoint localRtcp, System.Net.IPEndPoint remoteRtcp, Boolean punchHole) [0x001fc] in c:\Projekte\net7mma-111890\Rtp\RtpClient.cs:1538 }

I will try to examine this further, and also your hints. thanks.

PS:

It seems to happen at the RtcpSocket.Connect(RemoteRtcp = remoteRtcp);
I wrote the localRtcp to my console:
02-17 12:12:27.690 I/mono-stdout(11781): localRtcp is: 255.255.255.255:1

The Problem could be the port 1 in this case. I guess it is because I return port 0 in FindOpenPort if an exception occurs.
Feb 17, 2016 at 8:43 AM
Edited Feb 17, 2016 at 9:19 AM
Just an info. I thought it would be a good idea to turn this on:
                    //May help if behind a router
                    //Allow Nat Traversal
                    //RtcpSocket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
If I do this, again I get a not implemented exception.

{System.TypeLoadException: Could not load type 'System.Net.Sockets.IPProtectionLevel' from assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at Media.Rtp.RtpClient+TransportContext.Initialize (System.Net.IPAddress localIp, System.Net.IPAddress remoteIp, Int32 localRtpPort, Int32 localRtcpPort, Int32 remoteRtpPort, Int32 remoteRtcpPort, Boolean punchHole) [0x00000] in c:\Projekte\net7mma-111890\Rtp\RtpClient.cs:1448
at Media.Rtp.RtpClient.FromSessionDescription (Media.Sdp.SessionDescription sessionDescription, Media.Common.MemorySegment sharedMemory, Boolean incomingEvents, Boolean rtcpEnabled, System.Net.Sockets.Socket existingSocket, Nullable1 rtpPort, Nullable1 rtcpPort, Int32 remoteSsrc, Int32 minimumSequentialRtpPackets) [0x000e7] in c:\Projekte\net7mma-111890\Rtp\RtpClient.cs:281
at SKSSipClient.ViewModels.IncomingViewModel.InitSessionRTP (Independentsoft.Sip.Sdp.SessionDescription session) [0x00035] in C:\Projekte\SKS-Sip-Client-withSip.NetAndMMA\Kinkel-ClientUITest\Kinkel_ClientUITest\ViewModels\IncomingViewModel.cs:250 }
Feb 17, 2016 at 11:19 AM
When I use Port 30000 in the Catch Block of findOpenPort to return, with my Xamarin Client again I run into the "Unknown RTP Version 1" Error.

409 148.026852 192.168.1.118 192.168.1.114 RTP 60 Unknown RTP version 1
411 148.026853 192.168.1.114 192.168.1.118 ICMP 74 Destination unreachable (Port unreachable)

Thanks a lot for your help!
Coordinator
Feb 17, 2016 at 12:43 PM
Edited Feb 17, 2016 at 12:45 PM
It seems access is denied because of the address your attempting to bind on, 255.255.255.255 is being returned from GetUnicastIPAddress.

I will see about making a change there also to fix that as well as maybe a work around for when GetActiveUdpListeners / GetActiveTcpListeners is not implemented.

I will also see about not incrementing the port when the port is 0 which should resolve the rtcp issue with the port being set to 1, sorry about that.

The unknown version 1 is because of hole punching, it shouldn't effect the client, the exception is not propagated at this time and you probably only encountered it because you were debugging with all thrown exceptions?
Marked as answer by juliusfriedman on 2/17/2016 at 5:43 AM
Feb 17, 2016 at 2:12 PM
I added some own logging just to see the Problems, that's why I get all the error Messages. :-)

Thanks a lot Julius!
Coordinator
Feb 17, 2016 at 2:58 PM
Okay, I think I have addressed all of this in 111891.

I will continue by taking a look at the SIP conversation and seeing if I can figure out why the packets are coming on a different address than indicated in the Invite.

I will let you know what I find.

Please let me know if this fixes the issues you cited above though.

Thanks again for your interest and bringing this up!
Marked as answer by juliusfriedman on 2/17/2016 at 7:58 AM
Coordinator
Feb 17, 2016 at 3:12 PM
I also just made a special update for the logging of the version stuff so you don't have include those statements. You should find it in 111893.

Let me know if you have any issues with the updates and if your still having issues I should be looking into!
Marked as answer by juliusfriedman on 2/17/2016 at 8:12 AM
Feb 18, 2016 at 2:30 PM
Edited Feb 19, 2016 at 12:48 PM
Hello Julius,

thanks a lot for the new update! :-)

Your Switch in FindOpenPort somehow does not seem to work for me. Android Nexus 7 with Android 5.0 installed, started by my RTPClient App from Visual Studio 15 with Xamarin 4.0

if IOS || WATCHOS || TVOS || ANDROID || ANDROID_11

..

I got an GetActiveUDPListeners not implemented Exception again, so I added try ...
        catch
        {
            return ProbeForOpenPort(type, start, even, localIp);
        }
with your new stuff, then I got past that Point.

Same goes for the MapToIPv6.

Except for that I did not Change any code in the RTPClient, just added my own logging again.

Again I start my RTP Client from the Session Description I got from my successful connected SIP Client with an incoming call:
            Media.Sdp.SessionDescription sessionDescription = new Media.Sdp.SessionDescription(session.ToString());
            sessionDescription.SessionName = session.Name;
            sessionDescription.SessionId = session.Owner.SessionID.ToString();

            rtpClient.IncomingRtcpPacketEventsEnabled = true;
            rtpClient.IncomingRtpPacketEventsEnabled = true;

            rtpClient.RtpPacketReceieved += OnSourceRtpPacketRecieved;
            rtpClient.RtpFrameChanged += OnSourceFrameChanged;
            rtpClient.RtcpPacketReceieved += OnSourceRtcpPacketRecieved;
            rtpClient.Activate();
No exception or something here anymore!
If I use it this way, it successfully connects both RTP and RPCT now it seems, but does never walk into ReceiveData.

Setup the RtcpSocket
RTPCSocket connected successfully
02-18 16:18:00.496 I/mono-stdout( 9760): Setup the RtcpSocket
localIp:255.255.255.255 remoteIp:192.168.1.114 localport:30004 rtpPort: rtcpPort: mediaPort:9078
02-18 16:18:00.497 I/mono-stdout( 9760): RTPCSocket connected successfully
transportcontext added
02-18 16:18:00.500 I/mono-stdout( 9760): localIp:255.255.255.255 remoteIp:192.168.1.114 localport:30004 rtpPort: rtcpPort: mediaPort:9078
02-18 16:18:00.504 I/mono-stdout( 9760): transportcontext added
Thread started: RtpClient-03d6a76e-46b3-4d49-92e7-a882cbb106ec #7

That Looks very good, but nothing more seems to happen. ReceiveData seems not to be reached.
After a while the RTPClient successfully sends a goodbye because of the timeout.

So I added a

rtpClient.SendReceiversReports();

after Activate.

After starting again, now I get

154 72.578401 192.168.1.114 192.168.1.118 ICMP 110 Destination unreachable (Port unreachable)
...User Datagram Protocol, Src Port: 30001 (30001), Dst Port: 7079 (7079)
155 72.578401 192.168.1.114 192.168.1.118 ICMP 110 Destination unreachable (Port unreachable)
...User Datagram Protocol, Src Port: 30003 (30003), Dst Port: 9079 (9079)

form Server, then the Client automatically sends

164 77.563195 192.168.1.118 192.168.1.114 RTCP 82 Receiver Report Source description

and then again the above error from Server and so on always repeats.

The old native Client we have for trying which is very instable but sometimes working,
interestingly seems to start the same way and also gets the two Errors on same ports one time,
but after that starts working.

Any idea where that could come from? Is there except punchhole a way to open / search again for the port abnd Change it?

https://www.dropbox.com/s/2fqecox2n7nbs1a/MMA897-SIP%26RTPClient.zip?dl=0

Thanks a lot,

Eric
Coordinator
Feb 18, 2016 at 2:34 PM
Can you send me the Wireshark capture of the client which is working but unstable?

I will take a look and see what if anything I could be doing differently while still being complaint to the rfc.
Marked as answer by juliusfriedman on 2/18/2016 at 7:34 AM
Coordinator
Feb 18, 2016 at 5:24 PM
I seem to have found a bug in the RtpClient which may help with packets not being received.

I have also applied the change for ProbForOpenPort in the ClientSession.

I am not sure exactly how your build process is working but apparently those defines are not being defined and when you build the code you are not getting the path you expect compiled.

That would also explain why MapToIPV6 is not present.

I just actually make another update, can you please run the Unit Tests and tell me what you get for 'TestPlatformExtensions' and 'TestOperatingSystemExtensions' as well as 'TestBinary' when this exception occurs.

Thanks!
Marked as answer by juliusfriedman on 2/18/2016 at 10:24 AM
Feb 19, 2016 at 10:07 AM
Edited Feb 19, 2016 at 10:08 AM
Hello Julius,

I do not have any Special Conditional Compilation symbols set, so I guess when Compiling on my PC, These #if ANDROID etc is false.
When deploying later on the Nexus 7 with Android 5 device, this won't work I guess.

In my Version of your code I just made them always true now for testing purposes. I will later upload a new package with Screens of my build Settings, and wireshark Protokolls, thanks :-)

Eric
Coordinator
Feb 19, 2016 at 11:30 AM
The latest changes simply handle the NotImplementedException and should work even without the defines in place.

I also don't think you need the Early Rtcp, I had it disabled because I didn't test it , if for some reason you need it I suppose that enabling it can't hurt but probably should be looked into for being enabled by an option on the TransportContext or by checking the session description for the ability for it to be supported.

I can take a look at that also but it seems that you have everything working now, if not let me know where your still having trouble.
Marked as answer by juliusfriedman on 2/19/2016 at 4:30 AM
Feb 19, 2016 at 12:40 PM
Edited Feb 19, 2016 at 12:50 PM
Hello Julius,

I uploaded a new package with some screens of build properties of my android solution in visual studio 15 with xamarin 4.0.

https://www.dropbox.com/s/2fqecox2n7nbs1a/MMA897-SIP%26RTPClient.zip?dl=0

I added Wireshark scripts marked with "Old" for the two old implementations. Both receive RTP Packets. The Android does not show video, for the IOS both video and audio work.
Both are buggy and unstable. both were made native (no xamarin) using "PJSIP" from pjsib.org and not by me. I am looking hard to find a xamarin solution.

I added some Console log here in RTPClient.cs:
    internal protected virtual int ReceiveData(Socket socket, ref EndPoint remote, out SocketError error, bool expectRtp = true, bool expectRtcp = true, MemorySegment buffer = null)
    {
        //Nothing bad happened yet.
        error = SocketError.SocketError;

        Console.WriteLine("ReceiveData started");

        if (buffer == null) buffer = m_Buffer;

        //Ensure the socket can poll
        if (IsDisposed || m_StopRequested || socket == null || remote == null || BaseDisposable.IsNullOrDisposed(buffer)) return 0;
        Console.WriteLine("ReceiveData polling");
        bool tcp = socket.ProtocolType == ProtocolType.Tcp;
        Console.WriteLine("ReceiveData tcp = " + tcp.ToString());
        //Cache the offset at the time of the call
        int received = 0;

        try
        {
            //Determine how much data is 'Available'
            //int available = socket.ReceiveFrom(m_Buffer.Array, offset, m_Buffer.Count, SocketFlags.Peek, ref remote);

            error = SocketError.Success;

            ////If the receive was a success
            //if (available > 0)
            //{                                       
            received = socket.ReceiveFrom(buffer.Array, buffer.Offset, buffer.Count, SocketFlags.None, ref remote);
            Console.WriteLine("ReceiveData received = " + received.ToString());
            //Under TCP use Framing to obtain the length of the packet as well as the context.
            if (tcp) return ProcessFrameData(buffer.Array, buffer.Offset, received, socket);
If I do not use anything after RTPClient.FromSessiondescription then RTPClient.Activate then no more errors but nothing more happens and a Goodbye send from Client later (for both PC and android).

So I used SendReceiversReport after the Activate, from the Old Wireshark Logins it looks to me the old clients are doing it this way.

Then I got errors.

In both cases PC or Android it looks okay so far now, both say RTP and RTCP are connected.

The PC reaches in RTPClient ReceiveData, but then quits with a socket exception. The android never seems to reach this point.

I add both Visual Studio Outputs for you, maybe that helps?

For my Client App I added these, and for every one ot those I write a console log. Packets are being sent for both PC and android, but never received.
            rtpClient.RtpPacketSent += OnSourceRtpPacketSent;
            rtpClient.RtcpPacketSent += OnSourceRtcpPacketSent;
            rtpClient.RtpPacketReceieved += OnSourceRtpPacketRecieved;
            rtpClient.RtpFrameChanged += OnSourceFrameChanged;
            rtpClient.RtcpPacketReceieved += OnSourceRtcpPacketRecieved;

And the "localIP:..." Log which for Android has the 255.... again is from here:
    public class TransportContext : Common.BaseDisposable, Common.ISocketReference
    {
        #region Statics

        public static TransportContext FromMediaDescription(Sdp.SessionDescription sessionDescription, byte dataChannel, byte controlChannel, Sdp.MediaDescription mediaDescription, bool rtcpEnabled = true, int remoteSsrc = 0, int minimumSequentialpackets = 2, IPAddress localIp = null, IPAddress remoteIp = null, int? rtpPort = null, int? rtcpPort = null, bool connect = false, Socket existingSocket = null)
        {
...
                //Check for udp if no existing socket was given
                if (false == hasSocket && string.Compare(mediaDescription.MediaProtocol, Media.Rtp.RtpClient.RtpAvpProfileIdentifier, true) == 0)
                {
                    int localPort = Media.Common.Extensions.Socket.SocketExtensions.ProbeForOpenPort(ProtocolType.Udp);
                    tc.Initialize(localIp, remoteIp, localPort == 0 ? localPort : localPort++, localPort == 0 ? localPort : localPort++, rtpPort ?? mediaDescription.MediaPort, rtcpPort ?? (mediaDescription.MediaPort != 0 ? mediaDescription.MediaPort + 1 : mediaDescription.MediaPort));
                    Console.WriteLine("localIp:" + localIp.ToString() + " remoteIp:" + remoteIp.ToString() + " localport:" + localPort + " rtpPort:" + rtpPort.ToString() + " rtcpPort:" + rtcpPort.ToString() + " mediaPort:" + mediaDescription.MediaPort.ToString());
                }
                else if (hasSocket)//If had a socket use it
                {
                    tc.Initialize(existingSocket);
                    Console.WriteLine("existing socket:" + existingSocket.ToString());
                }
                else
                {
                    tc.Initialize(localIp, remoteIp, rtpPort ?? mediaDescription.MediaPort);
                    Console.WriteLine("localIp:" + localIp.ToString() + " remoteIp:" + remoteIp.ToString() + " rtpPort:" + rtpPort.ToString() + " mediaPort:" + mediaDescription.MediaPort.ToString());
                }
Here my collection with stuff (same link as on top)
https://www.dropbox.com/s/2fqecox2n7nbs1a/MMA897-SIP%26RTPClient.zip?dl=0

It would be great if we could get this working, for me mostly the xamarin is important. But it would be great if your library would work stable on both pc and xamarin platforms.
Thanks again for your patience and work, and have a nice weekend :-)

Eric
Coordinator
Feb 19, 2016 at 12:54 PM
Thanks for the info, I will check out the files shortly and let you know if I can find anything.

Ideally it should work everywhere .Net can and I'll do what I can to ensure that, also if there's something which needs to be enabled even in an optional way I will try to help just to compass more compatibility.

Right now I would disable the early Rtcp until we can determine first why the packets aren't being received.

It could still be something else wrong with the IPAddress the library is returning, I will check it out and let you know.
Marked as answer by juliusfriedman on 2/19/2016 at 5:54 AM
Coordinator
Feb 19, 2016 at 1:58 PM
Edited Feb 19, 2016 at 1:59 PM
Looking at the logs I am confused about a few things.

It seems in the Wireshark log for the Android client with MMA897 that you are having some SIP issues, it says the OPTIONS response is not received and eventually sends a BYE and more OPTIONS and then more BYE requests.

The other confusing thing it seems is that in the logs there is a line

'02-19 14:16:50.690 I/mono-stdout( 7283): Transportcontext initialized: localRTP:255.255.255.255:30000 remoteRTP:192.168.1.114:7078 localRTCP:255.255.255.255:30001 remoteRTCP:192.168.1.114:7079'

Where does this come from?

Because right after that I see

'localIp:255.255.255.255 remoteIp:192.168.1.114 localport:30004 rtpPort: rtcpPort: mediaPort:9078
02-19 14:16:51.145 I/mono-stdout( 7283): localIp:255.255.255.255 remoteIp:192.168.1.114 localport:30004 rtpPort: rtcpPort: mediaPort:9078'

I think it may be a problem with the way I am using '==' with the IPAddress, not really sure why the Broadcast address is being seen there anyway but this should fix that.

I have uploaded the changes in 111898 and that should resolve that.

Please try again and lets see what the result is this time, sorry for the hassle.
Marked as answer by juliusfriedman on 2/19/2016 at 6:58 AM
Feb 22, 2016 at 6:43 AM
Hello Julius,

the developer of the Gateway said the Options are meant to be something like a "heartbeat Signal".
The Options are sent from time to time to every Client online.

I am Aware this is not conform / Standard, but there is nothing I can do about that. But I guess this is no Problem.

The first log is from here (RTPClient.cs)
        public void Initialize(IPEndPoint localRtp, IPEndPoint remoteRtp, IPEndPoint localRtcp, IPEndPoint remoteRtcp, bool punchHole = true)
        {
            if (IsDisposed || IsActive) return;

            Console.WriteLine("Transportcontext initialized: localRTP:" + localRtp.ToString() + " remoteRTP:" + remoteRtp.ToString() + " localRTCP:" + localRtcp.ToString() + " remoteRTCP:" + remoteRtcp.ToString());

The 2nd one is from RTPClient.FromMediaDescription:
            //Handle connect
            if (connect)
            {
                bool hasSocket = existingSocket != null;

                //Check for udp if no existing socket was given
                if (false == hasSocket && string.Compare(mediaDescription.MediaProtocol, Media.Rtp.RtpClient.RtpAvpProfileIdentifier, true) == 0)
                {
                    int localPort = Media.Common.Extensions.Socket.SocketExtensions.ProbeForOpenPort(ProtocolType.Udp);
                    tc.Initialize(localIp, remoteIp, localPort == 0 ? localPort : localPort++, localPort == 0 ? localPort : localPort++, rtpPort ?? mediaDescription.MediaPort, rtcpPort ?? (mediaDescription.MediaPort != 0 ? mediaDescription.MediaPort + 1 : mediaDescription.MediaPort));
                    Console.WriteLine("localIp:" + localIp.ToString() + " remoteIp:" + remoteIp.ToString() + " localport:" + localPort + " rtpPort:" + rtpPort.ToString() + " rtcpPort:" + rtcpPort.ToString() + " mediaPort:" + mediaDescription.MediaPort.ToString());
                }
                else if (hasSocket)//If had a socket use it
                {
                    tc.Initialize(existingSocket);
                    Console.WriteLine("existing socket:" + existingSocket.ToString());
                }
                else
                {
                    tc.Initialize(localIp, remoteIp, rtpPort ?? mediaDescription.MediaPort);
                    Console.WriteLine("localIp:" + localIp.ToString() + " remoteIp:" + remoteIp.ToString() + " rtpPort:" + rtpPort.ToString() + " mediaPort:" + mediaDescription.MediaPort.ToString());
                }

I will try with the latest Version now. Thanks a lot for your help and Support! :-)

Eric
Feb 22, 2016 at 2:33 PM
I am running in the same Problems with the latest Version again. But I do not Need to Change anything on the code anymore to get it working so far without Problems I can see in the Output.

I saw the ICMP Error Messages also always appear my old Clients, which are working most time. So this does not seem to be the Problem.

I just can't get the Client to send me some RTP Packages ...

I now changed added the missing Trying before the ringing but it is still the same.
I tried to force the SIP to only use RTP but then the Register did not work anymore. Can I turn off UDP and set the RTPClient to prefer TCP always for testing purposes?

Thanks a lot for your help!

Eric
Feb 23, 2016 at 1:27 PM
Now the not-implement Errors are gone and port Problems at least seem to be resolved one Problem remains for me.

I have build up my SIP Connection:
Client - Server
Register->
<-Unauthorized
Register->
<-OK
Pressing doorbell on terminal do add an incoming call
<-Invite
Trying->
Ringing->
OK->
<-Ack

And now I got my session description.

I start your RTPClient:
    public void InitSessionRTP(Independentsoft.Sip.Sdp.SessionDescription session)
    {
        try
        {
            Media.Sdp.SessionDescription sessionDescription = new Media.Sdp.SessionDescription(session.ToString());
            sessionDescription.SessionName = session.Name;
            sessionDescription.SessionId = session.Owner.SessionID.ToString();

            ClientLogger.Instance.Log("RTPClient Created from SessionDescription: "+sessionDescription);
            //RtpClient rtpClient = Media.Rtp.RtpClient.FromSessionDescription(sessionDescription, rtcpEnabled:false);
            RtpClient rtpClient = Media.Rtp.RtpClient.FromSessionDescription(sessionDescription);

            rtpClient.RtpPacketSent += OnSourceRtpPacketSent;
            rtpClient.RtcpPacketSent += OnSourceRtcpPacketSent;
            rtpClient.RtpPacketReceieved += OnSourceRtpPacketRecieved;
            rtpClient.RtpFrameChanged += OnSourceFrameChanged;
            rtpClient.RtcpPacketReceieved += OnSourceRtcpPacketRecieved;

            //foreach (var context in rtpClient.GetTransportContexts())
            //    context.Initialize(context.RtpSocket, context.RtcpSocket);

            rtpClient.Activate();
            //Am I supposed to use this?
            //rtpClient.SendReports();
            //rtpClient.SendSendersReports();
            rtpClient.SendReceiversReports();
        }
        catch (Exception ex)
        {
            ClientLogger.Instance.Log("Problem occured during connection RTP: " + ex.ToString());
        }
    }
Everything Looks fine so far. Except for the ICMP Errors Messages which also appear in the old working native Client.

The OnSourceRtcpPacketSent catches sending data.
But I do not receive any RTP Data or any data at all.

Any idea what am I missing here? Do I Need to open ports manually or whatever? Or is there something I must tell the RTPClient to start sending? Or can I tell him to send me some Test package somehow?

Thanks a lot Julius!
Coordinator
Feb 23, 2016 at 6:44 PM
Can you please do two final capture's, one with the new code and then please do another one with the SIP client which is working so I can see whats different about the two, in all honestly I think this is some type of networking issue but it's possible that there is something else wrong which is what the final captures will confirm.

Sorry for any trouble and hopefully this last set will narrow it down.
Marked as answer by juliusfriedman on 2/23/2016 at 11:45 AM
Feb 24, 2016 at 6:55 AM
Edited Feb 24, 2016 at 6:57 AM
Hello Julius,

you are right, the exisitng "not implemented" etc exception are all gone, this could be a Network issue now.
It would be really great if you could help me find it.
I am really grateful you wrote your package and help me out, and I still hope I can use it instead having to write a PJSIP wrapper :-)

I made a new capture and added the complete wireshark and visual Studio Output.
I also added my RTPClient.cs File to Show you were I added some logs (just search for console).
Maybe it helps you understand my VS Output and maybe you consider some of those helpful to add for the next Version using your log.

https://www.dropbox.com/s/s2uf7ppw06bhfnt/Wireshark-AndroidClientWithMMA899.zip?dl=0

Right now I cannot make a new capture with the old Clients (do not have Access to both at this Moment but will have later again). These were made with native code using PJSIP but both not stable, I was told to make a new App for both Android and IOS and later PC using Xamarin. The old ones are not stable and are not updated anymore.

But you can use the files I sent you before: Wireshark-OldIOS8Client.pcapng and Wireshark-OldAndroidClient.pcapng. Nothing was changed at the old Clients, and nothing will Change there in future if I get the Xamarin solution with your Client working :-)

Thanks a lot! If you Need further info or something please let me know!

Eric
Coordinator
Feb 29, 2016 at 8:15 PM
It looks like the SIP Client is not responding on the ports in which it indicates from the invite, I am pretty sure that the problem is that you are using an old session description and not a current one which is the reason for the port mis match.

The funny thing is that I can't see the SIP Client send any data at all other than the response to the SIP messages in the capture you sent.

This indicates to me that you are not forwarding the traffic from your SIP Client to your application correctly.

When you can see Rtp packets coming in Wireshark after the SIP ACK and you still can't get the RtpClient to raise the event, then you have a problem with something in this library again, until that time you have an issue with routing and or the SIP Client which I can't really help with.

Let me know once you get Rtp flowing again how I can help if your still having issues.
Marked as answer by juliusfriedman on 2/29/2016 at 1:15 PM