|
|
@@ -425,6 +425,26 @@ JingleSessionPC.prototype.setLocalDescription = function (sdp, success,
|
|
425
|
425
|
}
|
|
426
|
426
|
};
|
|
427
|
427
|
|
|
|
428
|
+/**
|
|
|
429
|
+ * Although it states "replace transport" it does accept full Jingle offer
|
|
|
430
|
+ * which should contain new ICE transport details.
|
|
|
431
|
+ * @param jingleOfferElem an element Jingle IQ that contains new offer and
|
|
|
432
|
+ * transport info.
|
|
|
433
|
+ * @param success callback called when we succeed to accept new offer.
|
|
|
434
|
+ * @param failure function(error) called when we fail to accept new offer.
|
|
|
435
|
+ */
|
|
|
436
|
+JingleSessionPC.prototype.replaceTransport = function (jingleOfferElem,
|
|
|
437
|
+ success,
|
|
|
438
|
+ failure) {
|
|
|
439
|
+ // Set offer as RD
|
|
|
440
|
+ this.setOfferCycle(jingleOfferElem,
|
|
|
441
|
+ function () {
|
|
|
442
|
+ // Set local description OK, now localSDP up to date
|
|
|
443
|
+ this.sendTransportAccept(this.localSDP, success, failure);
|
|
|
444
|
+ }.bind(this),
|
|
|
445
|
+ failure);
|
|
|
446
|
+};
|
|
|
447
|
+
|
|
428
|
448
|
/**
|
|
429
|
449
|
* Sends Jingle 'session-accept' message.
|
|
430
|
450
|
* @param localSDP the 'SDP' object with local session description
|
|
|
@@ -464,6 +484,71 @@ JingleSessionPC.prototype.sendSessionAccept = function (localSDP,
|
|
464
|
484
|
IQ_TIMEOUT);
|
|
465
|
485
|
};
|
|
466
|
486
|
|
|
|
487
|
+/**
|
|
|
488
|
+ * Sends Jingle 'transport-accept' message which is a response to
|
|
|
489
|
+ * 'transport-replace'.
|
|
|
490
|
+ * @param localSDP the 'SDP' object with local session description
|
|
|
491
|
+ * @param success callback called when we receive 'RESULT' packet for
|
|
|
492
|
+ * 'transport-replace'
|
|
|
493
|
+ * @param failure function(error) called when we receive an error response or
|
|
|
494
|
+ * when the request has timed out.
|
|
|
495
|
+ */
|
|
|
496
|
+JingleSessionPC.prototype.sendTransportAccept = function(localSDP, success,
|
|
|
497
|
+ failure) {
|
|
|
498
|
+ var self = this;
|
|
|
499
|
+ var tAccept = $iq({to: this.peerjid, type: 'set'})
|
|
|
500
|
+ .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
|
|
|
501
|
+ action: 'transport-accept',
|
|
|
502
|
+ initiator: this.initiator,
|
|
|
503
|
+ sid: this.sid});
|
|
|
504
|
+
|
|
|
505
|
+ localSDP.media.forEach(function(medialines, idx){
|
|
|
506
|
+ var mline = SDPUtil.parse_mline(medialines.split('\r\n')[0]);
|
|
|
507
|
+ tAccept.c('content',
|
|
|
508
|
+ { creator: self.initiator == self.me ? 'initiator' : 'responder',
|
|
|
509
|
+ name: mline.media
|
|
|
510
|
+ }
|
|
|
511
|
+ );
|
|
|
512
|
+ localSDP.transportToJingle(idx, tAccept);
|
|
|
513
|
+ tAccept.up();
|
|
|
514
|
+ });
|
|
|
515
|
+
|
|
|
516
|
+ // Calling tree() to print something useful to the logger
|
|
|
517
|
+ tAccept = tAccept.tree();
|
|
|
518
|
+ console.info("Sending transport-accept: ", tAccept);
|
|
|
519
|
+
|
|
|
520
|
+ self.connection.sendIQ(tAccept,
|
|
|
521
|
+ success,
|
|
|
522
|
+ self.newJingleErrorHandler(tAccept, failure),
|
|
|
523
|
+ IQ_TIMEOUT);
|
|
|
524
|
+};
|
|
|
525
|
+
|
|
|
526
|
+/**
|
|
|
527
|
+ * Sends Jingle 'transport-reject' message which is a response to
|
|
|
528
|
+ * 'transport-replace'.
|
|
|
529
|
+ * @param success callback called when we receive 'RESULT' packet for
|
|
|
530
|
+ * 'transport-replace'
|
|
|
531
|
+ * @param failure function(error) called when we receive an error response or
|
|
|
532
|
+ * when the request has timed out.
|
|
|
533
|
+ */
|
|
|
534
|
+JingleSessionPC.prototype.sendTransportReject = function(success, failure) {
|
|
|
535
|
+ // Send 'transport-reject', so that the focus will
|
|
|
536
|
+ // know that we've failed
|
|
|
537
|
+ var tReject = $iq({to: this.peerjid, type: 'set'})
|
|
|
538
|
+ .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
|
|
|
539
|
+ action: 'transport-reject',
|
|
|
540
|
+ initiator: this.initiator,
|
|
|
541
|
+ sid: this.sid});
|
|
|
542
|
+
|
|
|
543
|
+ tReject = tReject.tree();
|
|
|
544
|
+ logger.info("Sending 'transport-reject", tReject);
|
|
|
545
|
+
|
|
|
546
|
+ this.connection.sendIQ(tReject,
|
|
|
547
|
+ success,
|
|
|
548
|
+ this.newJingleErrorHandler(tReject, failure),
|
|
|
549
|
+ IQ_TIMEOUT);
|
|
|
550
|
+};
|
|
|
551
|
+
|
|
467
|
552
|
JingleSessionPC.prototype.terminate = function (reason, text,
|
|
468
|
553
|
success, failure) {
|
|
469
|
554
|
var term = $iq({to: this.peerjid,
|