Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expects m line #6

Open
sualko opened this issue Nov 5, 2015 · 16 comments
Open

Expects m line #6

sualko opened this issue Nov 5, 2015 · 16 comments

Comments

@sualko
Copy link

sualko commented Nov 5, 2015

Hey guys,

I have trouble to get this working with my strophe.jinglejs library, receiving Chromium 45.0.2454.101 prints me:

Uncaught (in promise) Failed to parse SessionDescription. m= 1 RTP/SAVPF 
Expects m line.

Your example works, but I think it is outdated, so maybe something changed.

I use this snippet to send a file via my lib:

  getFile: function() {
      // the otalk logo
      var otalkLogo = 'data:image/png;base64,.....';
      var data = otalkLogo.match(/data:([^;]*);(base64)?,([0-9A-Za-z+/]+)/);
      var raw = atob(data[3]);
      var arr = new Uint8Array(raw.length);
      for (var i = 0; i < raw.length; i++) {
         arr[i] = raw.charCodeAt(i);
      }
      var file = new Blob([arr], {
         type: data[1]
      });
      file.name = 'somename';
      file.lastModifiedDate = new Date();
      return file;
   },
   sendFile: function(jid, file) {
      var self = jsxc.webrtc;

      // manager is JSM
      var sess = self.conn.jingle.manager.createFileTransferSession(jid);

      sess.on('change:sessionState', function() {
         jsxc.debug('Session state', sess.state);
      });
      sess.on('change:connectionState', function() {
         jsxc.debug('Connection state', sess.connectionState);
      });

      sess.start(file);
   }

The incoming jingle on receiver side:

<body xmlns:stream="http://etherx.jabber.org/streams" xmlns="http://jabber.org/protocol/httpbind" sid="0595d003-70b4-40e8-9369-7dd4dca4fbd9">
  <iq xmlns="jabber:client" type="set" to="georg@localhost/c9c4730f-591d-4d83-8b6a-f392602631c9" from="klaus@localhost/4f349287-864f-44f3-bea4-bda635f01e8e" id="">
    <jingle xmlns="urn:xmpp:jingle:1" sid="f440e73c-11ef-4bfe-8d90-d3a34ffe57f3" action="session-initiate">
      <content creator="initiator" name="data">
        <description xmlns="urn:xmpp:jingle:apps:file-transfer:3">
          <offer>
            <file>
              <date>2015-11-05T12:45:03.472Z</date>
              <name>somename</name><size>1682</size>
              <hash xmlns="urn:xmpp:hashes:1" algo="sha-1"/>
            </file>
          </offer>
        </description>
        <transport xmlns="urn:xmpp:jingle:transports:ice-udp:1" ufrag="tg8d1Df56Gx7CcJj" pwd="WFj9rg2TDCms9qICz+JFIUZ5">
          <fingerprint xmlns="urn:xmpp:jingle:apps:dtls:0" hash="sha-256" setup="actpass">E4:26:89:C3:AF:36:29:DA:3D:F6:4D:D9:C8:F7:13:16:7D:5B:D9:98:E3:F7:B7:E8:17:47:D9:D2:62:72:33:A7</fingerprint>
          <sctpmap xmlns="urn:xmpp:jingle:transports:dtls-sctp:1" number="5000" streams="1024" protocol="webrtc-datachannel"/>
        </transport>
      </content>
    </jingle>
  </iq>
</body>

I guess the sctpmap line is not correct used, but the JXT parser should work fine, because stanza._extensions.jingle._extensions._jingleContent._iceUdp.sctp looks good.

@legastero @fippo Do you have any idea, where the JXT object to sdp translation happens? I tried to get it, but without success.

@sualko
Copy link
Author

sualko commented Nov 5, 2015

chrome://webrtc-internals gives me the following (receiver):

{ servers: [turn:jsxc.org], iceTransportType: all, bundlePolicy: balanced, rtcpMuxPolicy: negotiate }, optional: {DtlsSrtpKeyAgreement:true, RtpDataChannels:false}

RtpDataChannels:false looks wrong.

sender:

{ servers: [], iceTransportType: all, bundlePolicy: balanced, rtcpMuxPolicy: negotiate },

@fippo
Copy link
Member

fippo commented Nov 5, 2015

RtpDataChannels: false should be ok, even though it's the default. The m-line should start with m=application...

Can you check what the descType is in
https://github.com/otalk/sdp-jingle-json/blob/master/lib/tosdp.js#L43 ?

@sualko
Copy link
Author

sualko commented Nov 10, 2015

Sorry for the delay, the descType is filetransfer.

@sualko
Copy link
Author

sualko commented Nov 13, 2015

@fippo If I change the line to

if (desc.descType == 'datachannel' || desc.descType == 'filetransfer') {

I get no error anymore, but the receivedFile is not fired. I will try to investigate this in more detail.

@sualko
Copy link
Author

sualko commented Nov 13, 2015

:D Sorry, I forgot to accept an incoming filetransfer.

Now the sender gets an error

Uncaught TypeError: Cannot read property 'payloads' of undefined

in

exports.toMediaSDP = function (content, opts) {
    var sdp = [];

    var role = opts.role || 'initiator';
    var direction = opts.direction || 'outgoing'; //is incoming. Is this right on sender side?

    var desc = content.description;
    var transport = content.transport;
    var payloads = desc.payloads || [];   //tosdp.js#L43

@sualko
Copy link
Author

sualko commented Nov 13, 2015

After I replaced all occurrences (5) of 'datachannel' with 'datachannel' everything works smooth. Should I create some pr for that, or should it work the other way round?

@fippo
Copy link
Member

fippo commented Nov 13, 2015

hrm... https://github.com/otalk/jingle-filetransfer-session/blob/master/index.js#L200-L202 and https://github.com/otalk/jingle-filetransfer-session/blob/master/index.js#L221-L223 should replace the 'filetransfer' with the low-level 'datachannel' before things are passed down to sdp-jingle-json.
What does the json description that gets passed down look like?

@sualko
Copy link
Author

sualko commented Nov 13, 2015

Do you mean how changes looks like?

@fippo
Copy link
Member

fippo commented Nov 17, 2015

err.. yeah

@sualko
Copy link
Author

sualko commented Nov 18, 2015

If I add this in line https://github.com/otalk/jingle-filetransfer-session/blob/master/index.js#L203

console.log('onSessionInitiate', ' = ' + changes.contents[0].description.descType);

it prints

onSessionInitiate = filetransfer

This is a snapshot before descType is (or in this case not) overwritten:
screenshot from 2015-11-18 11-02-48
and after:
screenshot from 2015-11-18 11-03-54

@sualko
Copy link
Author

sualko commented Nov 18, 2015

I found a description setter, so I guess it is no good idea to test against descType. Any idea how to solve this? How can I help?

This was referenced Nov 18, 2015
@fippo
Copy link
Member

fippo commented Nov 18, 2015

what confuses me is that https://github.com/otalk/jingle.js/blob/master/test/filetransfer.js still passes and shows the correct value (aka: works for me).
Does console.log(JSON.stringify(changes, null, ' ')) show the same wrong thing?

@sualko
Copy link
Author

sualko commented Nov 19, 2015

Yes:

{
 "action": "session-initiate",
 "sid": "d4c96cc9-26e0-4ca9-8ed7-0fc17e9a0040",
 "contents": [
  {
   "creator": "initiator",
   "disposition": "session",
   "name": "data",
   "senders": "both",
   "description": {
    "descType": "filetransfer",
    "offer": {
     "hash": {
      "algo": "sha-1"
     },
     "name": "image001.png",
     "size": 7217,
     "date": "2015-11-03T10:11:23.000Z",
     "hashes": [
      {
       "algo": "sha-1"
      }
     ]
    },
    "request": {}
   },
   "transport": {
    "transType": "iceUdp",
    "pwd": "F0JY3g+c9...",
    "ufrag": "xt08cgdsmrEVpi5q",
    "fingerprints": [
     {
      "hash": "sha-256",
      "setup": "actpass",
      "value": "E4:26:89:C3:AF:36:29:DA:3D:F6:4D:D9:C8:F7:13:16:7D:5B:D9:98:E3:F7:B7:E8:17:47:D9:D2:62:72:33:A7"
     }
    ],
    "sctp": [
     {
      "number": "5000",
      "protocol": "webrtc-datachannel",
      "streams": "1024"
     }
    ]
   }
  }
 ]
}

I still have the feeling, that something is messed up (but this comes maybe from the fact, that it is very complicated with all this libs). E.g. in the jingle-filetransfer-session lib the descType seems to be inconsistent.

https://github.com/otalk/jingle-filetransfer-session/blob/master/index.js#L51
https://github.com/otalk/jingle-filetransfer-session/blob/master/index.js#L85

Also the jingle.js lib looks for filetransfer:

https://github.com/otalk/jingle.js/blob/master/index.js#L26

Also the stanza definitions uses filetransfer as value:

https://github.com/otalk/jxt-xmpp/blob/master/src/file.js#L50

@fippo
Copy link
Member

fippo commented Nov 19, 2015

This is somewhat somewhat complicated by design.
At the jingle layer it is supposed to be a 'filetransfer' descType. WebRTC/SCTP is just the transport here.

sdp-jingle-json does not know (or care) about filetransfers which is why the application (in this case jingle-filetransfer-session) needs to rewrite the descType and pluck the information it is interested in (offer, name, hash, etc).

@legastero since the test is only dealing with json objects, any chance that stanza objects behave differently when trying to modify them?

@fippo
Copy link
Member

fippo commented Nov 21, 2015

chatting with @legastero it seems that what I do here works with json objects but not stanza.io objects (in the current version?)
More next week, you might want to try converting to json until then

@sualko
Copy link
Author

sualko commented Nov 27, 2015

you might want to try converting to json until then

Thought your lib would require jxt objects, but this also seems to work:

var req = jxt.parse(iq.outerHTML);

this.manager.process(req.toJSON());

Crazy stuff. Now the error is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants