[jitsi-dev] Almost have session


#1

Hello,

I have my RTC app for ios app working to the point of:
  
    connecting to openfire
    authenticate
    join myroom (existing jitmeet conference)
    receiving jingile session initiate. (respond appropriately)
    parsing sdp from that
    
    creating RTCPeerconnection but before i can answer or offer, i set the sdp and get this:

Error(webrtcsession.cc:268): SetRemoteDescription failed: Called with type in wrong state, type: answer state: STATE_INIT

I am working under the assumption that i do not need to do any ice negotiation. i just do the following

  when i get and respond to the session initiate i do this:

  self.peerConnectionFactory = [[RTCPeerConnectionFactory alloc] init];
    self.pcObserver = [[PCObserver alloc] initWithDelegate:self];
    self.peerConnection =
      [self.peerConnectionFactory peerConnectionWithICEServers:nil //not nil in non-jitsi
                                                 constraints:_constraints
                                                    delegate:self.pcObserver];

    APPRTCAppDelegate* appDel = (APPRTCAppDelegate*)[UIApplication sharedApplication].delegate;
        
    NSString *sdpString = appDel.streamTVC.sdpString;
    
    RTCSessionDescription *sdp = [[RTCSessionDescription alloc]
                                  initWithType:@"answer" sdp:[APPRTCJitsiDelegate preferISAC:sdpString]]; //remove preferisaac
    [self.peerConnection setRemoteDescriptionWithDelegate:self sessionDescription:sdp];

  from this i get called back with error setting sdp
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didSetSessionDescriptionWithError:(NSError *)error {

with error containing SetRemoteDescription failed: Called with type in wrong state, type: answer state: STATE_INIT

since this is initiated by jingle session-initiate, i should not createOffer, just an createAnswer with the spp i parse from the jingleinitiate, right?

i seem to be just about to have a connection working but i am stuck here.

Peter Mycue
pmycue@us.ibm.com
pmycue@gmail.com
704-626-9772


#2

[...]

RTCSessionDescription*sdp = [[RTCSessionDescriptionalloc]
initWithType:@"answer" sdp:[APPRTCJitsiDelegate preferISAC:sdpString]];

since you get a session-initiate from the remote, the type should be 'offer' here.

//remove preferisaac

[self.peerConnectionsetRemoteDescriptionWithDelegate:selfsessionDescription:sdp];

from this i get called back with error setting sdp
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didSetSessionDescriptionWithError:(NSError *)error {

with error containing *SetRemoteDescription failed: Called with type in
wrong state, type: answer state: STATE_INIT*
*

since this is initiated by jingle session-initiate, i should not
createOffer, just an createAnswer with the spp i parse from the
jingleinitiate, right?

No, you need to call createAnswer from the setRemoteDescription success callback. You get an SDP from that which (after doing a setLocalDescription) you transfrom into jingle and send back as session-accept.


#3

Thanks Philipp!

I changed the answer to offer with this as my SDP string and now i get

Warning(webrtcsession.cc:141): Session description must have SDES or DTLS-SRTP.
Error(webrtcsession.cc:268): SetRemoteDescription failed: Called with a SDP without crypto enabled.

It seems that the code i used as a model for translating to sdp has this missing, so i guess i am going to have to figure that out.
  // Things that remain to be done:
  // * Generate the "crypto" line from the < ><crypto> element.
  // * Generate the "ssrc" lines from the <streams> element.

Is there somewhere i can find an example of this part? also, i see no crypto element in my initiate iq (included below). i don't suppose that can be disabled?

what do the jingle encryption and ssrc tags look like and how do i convert them to sdp?

(lldb) po sdpString
v=0
o=- 9135848008193788882 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
m=audio RTP/SAVPF 111 103 104 0 8 106 105 13 126
c=IN IP4 0.0.0.0
a=ice-ufrag:dm24t
a=ice-pwd:2073s75ri9jakl0ja6bkk88av7
a=candidate:1 1 udp 2130706431 2002:902:37b8:0:0:0:902:37b8 5254 typ host
a=candidate:2 1 udp 2130706431 9.2.55.184 5254 typ host
a=candidate:3 1 udp 2113937151 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5254 typ host
a=candidate:1 2 udp 2130706430 2002:902:37b8:0:0:0:902:37b8 5255 typ host
a=candidate:2 2 udp 2130706430 9.2.55.184 5255 typ host
a=candidate:3 2 udp 2113937150 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5255 typ host
m=video RTP/SAVPF 100 116 117
c=IN IP4 0.0.0.0
a=ice-ufrag:5c1iq
a=ice-pwd:89r6lc6r5adijsvqvsl1r7dp3
a=candidate:1 1 udp 2130706431 2002:902:37b8:0:0:0:902:37b8 5258 typ host
a=candidate:2 1 udp 2130706431 9.2.55.184 5258 typ host
a=candidate:3 1 udp 2113937151 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5258 typ host
a=candidate:1 2 udp 2130706430 2002:902:37b8:0:0:0:902:37b8 5259 typ host
a=candidate:2 2 udp 2130706430 9.2.55.184 5259 typ host
a=candidate:3 2 udp 2113937150 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5259 typ host

My jingle iq

2014-11-05 16:57:56.761 AppRTCDemo[2859:886135] RECV:

<iq to="peterios@ibm903-r87y4km/46fb0547" type="set" id="88:sendIQ" from="myroom@conference.ibm903-r87y4km/b1b3783f">
  <jingle xmlns="urn:xmpp:jingle:1" action="session-initiate" initiator="b1b3783f@ibm903-r87y4km/b1b3783f" sid="ovvr4ca58p30">
    <content creator="initiator" name="audio" senders="both">
      <description xmlns="urn:xmpp:jingle:apps:rtp:1" media="audio" ssrc="1914249563">
        <payload-type id="111" name="opus" clockrate="48000" channels="2"><parameter name="minptime" value="10"/></payload-type>
        <payload-type id="103" name="ISAC" clockrate="16000" channels="1"/>
        <payload-type id="104" name="ISAC" clockrate="32000" channels="1"/>
        <payload-type id="0" name="PCMU" clockrate="8000" channels="1"/>
        <payload-type id="8" name="PCMA" clockrate="8000" channels="1"/>
        <payload-type id="106" name="CN" clockrate="32000" channels="1"/>
        <payload-type id="105" name="CN" clockrate="16000" channels="1"/>
        <payload-type id="13" name="CN" clockrate="8000" channels="1"/>
        <payload-type id="126" name="telephone-event" clockrate="8000" channels="1"/>
          <source xmlns="urn:xmpp:jingle:apps:rtp:ssma:0" ssrc="1914249563">
            <parameter name="cname" value="hsFRiT0eh9dtHtV7"/>
            <parameter name="msid" value="r3OWwiMMDcfwnwjvZngUTQVM25aiT3ABfkXJ b662a0bd-08d4-4daa-95a5-cd16017e7a82"/>
            <parameter name="mslabel" value="r3OWwiMMDcfwnwjvZngUTQVM25aiT3ABfkXJ"/>
            <parameter name="label" value="b662a0bd-08d4-4daa-95a5-cd16017e7a82"/>
          </source>
          <source xmlns="urn:xmpp:jingle:apps:rtp:ssma:0" ssrc="3735928559">
            <parameter name="cname" value="mixed"/>
            <parameter name="label" value="mixedlabelv0"/>
            <parameter name="msid" value="mixedmslabel mixedlabelv0"/>
            <parameter name="mslabel" value="mixedmslabel"/>
          </source>
        <ssrc xmlns="http://estos.de/ns/ssrc" cname="mixed" msid="mixedmslabel mixedlabelv0" mslabel="mixedmslabel" label="mixedlabelv0" ssrc="3735928559"/>
        <rtp-hdrext xmlns="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0" uri="urn:ietf:params:rtp-hdrext:ssrc-audio-level" id="1"/>
      </description>
      <transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" ufrag="dm24t" pwd="2073s75ri9jakl0ja6bkk88av7">
          <fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" hash="sha-1" setup="actpass">72:2A:BA:AB:C8:86:09:D8:6C:78:EF:51:5A:57:DD:7B:45:78:9C:84</fingerprint>
          <candidate foundation="1" component="1" protocol="udp" priority="2130706431" ip="2002:902:37b8:0:0:0:902:37b8" port="5254" type="host" generation="0" network="1" id="g16i0qarn4"/>
          <candidate foundation="2" component="1" protocol="udp" priority="2130706431" ip="9.2.55.184" port="5254" type="host" generation="0" network="1" id="y1mvdhb0oo"/>
          <candidate foundation="3" component="1" protocol="udp" priority="2113937151" ip="fe80:0:0:0:e0e1:bee7:27dd:a0a1" port="5254" type="host" generation="0" network="1" id="sfxksymq8s"/>
          <candidate foundation="1" component="2" protocol="udp" priority="2130706430" ip="2002:902:37b8:0:0:0:902:37b8" port="5255" type="host" generation="0" network="1" id="7du56htaz0"/>
          <candidate foundation="2" component="2" protocol="udp" priority="2130706430" ip="9.2.55.184" port="5255" type="host" generation="0" network="1" id="65024yio1n"/>
          <candidate foundation="3" component="2" protocol="udp" priority="2113937150" ip="fe80:0:0:0:e0e1:bee7:27dd:a0a1" port="5255" type="host" generation="0" network="1" id="ww84ou7hw0"/>
      </transport>
    </content>
    <content creator="initiator" name="video" senders="both">
      <description xmlns="urn:xmpp:jingle:apps:rtp:1" media="video" ssrc="557740937">
        <payload-type id="100" name="VP8" clockrate="90000" channels="1">
          <rtcp-fb xmlns="urn:xmpp:jingle:apps:rtp:rtcp-fb:0" type="ccm" subtype="fir"/>
          <rtcp-fb xmlns="urn:xmpp:jingle:apps:rtp:rtcp-fb:0" type="nack"/>
          <rtcp-fb xmlns="urn:xmpp:jingle:apps:rtp:rtcp-fb:0" type="goog-remb"/>
        </payload-type>
        <payload-type id="116" name="red" clockrate="90000" channels="1"/>
        <payload-type id="117" name="ulpfec" clockrate="90000" channels="1"/>
          <source xmlns="urn:xmpp:jingle:apps:rtp:ssma:0" ssrc="557740937">
            <parameter name="cname" value="I2itIXIcwyR88kMU"/>
            <parameter name="msid" value="c0DDmTU2O3e87pHV5jLKIyXy7uAFY8bD8QNk 199a0539-6074-463a-9285-23d56947e9f2"/>
            <parameter name="mslabel" value="c0DDmTU2O3e87pHV5jLKIyXy7uAFY8bD8QNk"/>
            <parameter name="label" value="199a0539-6074-463a-9285-23d56947e9f2"/>
          </source>
          <source xmlns="urn:xmpp:jingle:apps:rtp:ssma:0" ssrc="3735928559">
            <parameter name="cname" value="mixed"/>
            <parameter name="label" value="mixedlabelv0"/>
            <parameter name="msid" value="mixedmslabel mixedlabelv0"/>
            <parameter name="mslabel" value="mixedmslabel"/>
          </source>
        <ssrc xmlns="http://estos.de/ns/ssrc" cname="mixed" msid="mixedmslabel mixedlabelv0" mslabel="mixedmslabel" label="mixedlabelv0" ssrc="3735928559"/>
          <rtp-hdrext xmlns="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0" uri="urn:ietf:params:rtp-hdrext:toffset" id="2"/>
          <rtp-hdrext xmlns="urn:xmpp:jingle:apps:rtp:rtp-hdrext:0" uri="http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time" id="3"/>
      </description>
      <transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" ufrag="5c1iq" pwd="89r6lc6r5adijsvqvsl1r7dp3">
        <fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" hash="sha-1" setup="actpass">87:62:14:74:FF:A7:2C:B1:7C:73:A9:A9:C2:EA:AA:A3:46:7E:A9:35</fingerprint>
        <candidate foundation="1" component="1" protocol="udp" priority="2130706431" ip="2002:902:37b8:0:0:0:902:37b8" port="5258" type="host" generation="0" network="1" id="utrot0nr0b"/>
        <candidate foundation="2" component="1" protocol="udp" priority="2130706431" ip="9.2.55.184" port="5258" type="host" generation="0" network="1" id="ai2s1nc089"/>
        <candidate foundation="3" component="1" protocol="udp" priority="2113937151" ip="fe80:0:0:0:e0e1:bee7:27dd:a0a1" port="5258" type="host" generation="0" network="1" id="sjyierw3hb"/>
        <candidate foundation="1" component="2" protocol="udp" priority="2130706430" ip="2002:902:37b8:0:0:0:902:37b8" port="5259" type="host" generation="0" network="1" id="mgpx8on03c"/>
        <candidate foundation="2" component="2" protocol="udp" priority="2130706430" ip="9.2.55.184" port="5259" type="host" generation="0" network="1" id="q0heqb1pq5"/>
        <candidate foundation="3" component="2" protocol="udp" priority="2113937150" ip="fe80:0:0:0:e0e1:bee7:27dd:a0a1" port="5259" type="host" generation="0" network="1" id="5mmnn2ryvb"/>
      </transport>
    </content>
  </jingle>
</iq>

Peter Mycue
pmycue@us.ibm.com
pmycue@gmail.com
704-626-9772

···

On Nov 5, 2014, at 4:41 PM, Philipp Hancke <fippo@goodadvice.pages.de> wrote:

[...]

RTCSessionDescription*sdp = [[RTCSessionDescriptionalloc]
initWithType:@"answer" sdp:[APPRTCJitsiDelegate preferISAC:sdpString]];

since you get a session-initiate from the remote, the type should be 'offer' here.

//remove preferisaac

[self.peerConnectionsetRemoteDescriptionWithDelegate:selfsessionDescription:sdp];

from this i get called back with error setting sdp
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didSetSessionDescriptionWithError:(NSError *)error {

with error containing *SetRemoteDescription failed: Called with type in
wrong state, type: answer state: STATE_INIT*
*
*

since this is initiated by jingle session-initiate, i should not
createOffer, just an createAnswer with the spp i parse from the
jingleinitiate, right?

No, you need to call createAnswer from the setRemoteDescription success callback. You get an SDP from that which (after doing a setLocalDescription) you transfrom into jingle and send back as session-accept.

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev


#4

Thanks Philipp!

I changed the answer to offer with this as my SDP string and now i get

*Warning(webrtcsession.cc <http://webrtcsession.cc>:141): Session
description must have SDES or DTLS-SRTP.*
*Error(webrtcsession.cc <http://webrtcsession.cc>:268):
SetRemoteDescription failed: Called with a SDP without crypto enabled.*
*
It seems that the code i used as a model for translating to sdp has this
missing, so i guess i am going to have to figure that out.
// Things that remain to be done:
// * Generate the "crypto" line from the <><crypto> element.
// * Generate the "ssrc" lines from the <streams> element.

Is there somewhere i can find an example of this part? also, i see no
crypto element in my initiate iq (included below). i don't suppose that
can be disabled?

what do the jingle encryption and ssrc tags look like and how do i
convert them to sdp?

encryption/fingerprint: see below, the crypto stuff won't help you.
The ssrc tags and their mappings are relatively "new", described in
http://xmpp.org/extensions/xep-0339.html

*(lldb) **po sdpString*
v=0
o=- 9135848008193788882 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
m=audio RTP/SAVPF 111 103 104 0 8 106 105 13 126
c=IN IP4 0.0.0.0
a=ice-ufrag:dm24t
a=ice-pwd:2073s75ri9jakl0ja6bkk88av7
a=candidate:1 1 udp 2130706431 2002:902:37b8:0:0:0:902:37b8 5254 typ host
a=candidate:2 1 udp 2130706431 9.2.55.184 5254 typ host
a=candidate:3 1 udp 2113937151 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5254 typ host
a=candidate:1 2 udp 2130706430 2002:902:37b8:0:0:0:902:37b8 5255 typ host
a=candidate:2 2 udp 2130706430 9.2.55.184 5255 typ host
a=candidate:3 2 udp 2113937150 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5255 typ host

You'll need to map they <payload/> elements to a=rtpmap, too.

m=video RTP/SAVPF 100 116 117
c=IN IP4 0.0.0.0
a=ice-ufrag:5c1iq
a=ice-pwd:89r6lc6r5adijsvqvsl1r7dp3
a=candidate:1 1 udp 2130706431 2002:902:37b8:0:0:0:902:37b8 5258 typ host
a=candidate:2 1 udp 2130706431 9.2.55.184 5258 typ host
a=candidate:3 1 udp 2113937151 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5258 typ host
a=candidate:1 2 udp 2130706430 2002:902:37b8:0:0:0:902:37b8 5259 typ host
a=candidate:2 2 udp 2130706430 9.2.55.184 5259 typ host
a=candidate:3 2 udp 2113937150 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5259 typ host

You should have an a=fingerprint line here for each m-line. http://xmpp.org/extensions/xep-0320.html has the full spec.

Potentially you need to enable DTLS in the native lib, not sure if that is done by default... it will complain with a different error when it gets an offer with a fingerprint but dtls isn't enabled.

My jingle iq

[...]

*<fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" hash="sha-1"
setup="actpass">72:2A:BA:AB:C8:86:09:D8:6C:78:EF:51:5A:57:DD:7B:45:78:9C:84</fingerprint>*

the fingerprint (and the a=setup line) from here.

hope that helps a little further

···

Am 05.11.2014 um 14:32 schrieb Peter Mycue:


#5

Phillip, although I cannot help you directly (I don't do ios). I can share
my experience with webrtc and jitsi. I was unsuccessful with my app until I
allowed ICE to do its thing; I was manually creating ports on my public IP
and generating host candidates, but none of that worked until I integrated
the ice negotiation. In my case I created an app wherein a server generated
stream is sent to a browser client and I only used libjitsi.

Good luck,
Paul

···

On Wed, Nov 5, 2014 at 5:54 PM, Philipp Hancke <fippo@goodadvice.pages.de> wrote:

Am 05.11.2014 um 14:32 schrieb Peter Mycue:

Thanks Philipp!

I changed the answer to offer with this as my SDP string and now i get

*Warning(webrtcsession.cc <http://webrtcsession.cc>:141): Session
description must have SDES or DTLS-SRTP.*
*Error(webrtcsession.cc <http://webrtcsession.cc>:268):
SetRemoteDescription failed: Called with a SDP without crypto enabled.*
*
*
It seems that the code i used as a model for translating to sdp has this
missing, so i guess i am going to have to figure that out.
// Things that remain to be done:
// * Generate the "crypto" line from the <><crypto> element.
// * Generate the "ssrc" lines from the <streams> element.

Is there somewhere i can find an example of this part? also, i see no
crypto element in my initiate iq (included below). i don't suppose that
can be disabled?

what do the jingle encryption and ssrc tags look like and how do i
convert them to sdp?

encryption/fingerprint: see below, the crypto stuff won't help you.
The ssrc tags and their mappings are relatively "new", described in
http://xmpp.org/extensions/xep-0339.html

*(lldb) **po sdpString*
v=0
o=- 9135848008193788882 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
m=audio RTP/SAVPF 111 103 104 0 8 106 105 13 126
c=IN IP4 0.0.0.0
a=ice-ufrag:dm24t
a=ice-pwd:2073s75ri9jakl0ja6bkk88av7
a=candidate:1 1 udp 2130706431 2002:902:37b8:0:0:0:902:37b8 5254 typ host
a=candidate:2 1 udp 2130706431 9.2.55.184 5254 typ host
a=candidate:3 1 udp 2113937151 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5254 typ
host
a=candidate:1 2 udp 2130706430 2002:902:37b8:0:0:0:902:37b8 5255 typ host
a=candidate:2 2 udp 2130706430 9.2.55.184 5255 typ host
a=candidate:3 2 udp 2113937150 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5255 typ
host

You'll need to map they <payload/> elements to a=rtpmap, too.

m=video RTP/SAVPF 100 116 117

c=IN IP4 0.0.0.0
a=ice-ufrag:5c1iq
a=ice-pwd:89r6lc6r5adijsvqvsl1r7dp3
a=candidate:1 1 udp 2130706431 2002:902:37b8:0:0:0:902:37b8 5258 typ host
a=candidate:2 1 udp 2130706431 9.2.55.184 5258 typ host
a=candidate:3 1 udp 2113937151 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5258 typ
host
a=candidate:1 2 udp 2130706430 2002:902:37b8:0:0:0:902:37b8 5259 typ host
a=candidate:2 2 udp 2130706430 9.2.55.184 5259 typ host
a=candidate:3 2 udp 2113937150 fe80:0:0:0:e0e1:bee7:27dd:a0a1 5259 typ
host

You should have an a=fingerprint line here for each m-line.
http://xmpp.org/extensions/xep-0320.html has the full spec.

Potentially you need to enable DTLS in the native lib, not sure if that is
done by default... it will complain with a different error when it gets an
offer with a fingerprint but dtls isn't enabled.

My jingle iq

[...]

*<fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" hash="sha-1"
setup="actpass">72:2A:BA:AB:C8:86:09:D8:6C:78:EF:51:5A:57:
DD:7B:45:78:9C:84</fingerprint>*

the fingerprint (and the a=setup line) from here.

hope that helps a little further

_______________________________________________
dev mailing list
dev@jitsi.org
Unsubscribe instructions and other list options:
http://lists.jitsi.org/mailman/listinfo/dev

--
http://gregoire.org/
https://github.com/Red5 <http://code.google.com/p/red5/>