1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
|
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.jabber;
import java.util.*;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smackx.packet.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.ContentPacketExtension.*;
import net.java.sip.communicator.service.neomedia.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.media.*;
import net.java.sip.communicator.util.*;
/**
* Implements a Jabber <tt>CallPeer</tt>.
*
* @author Emil Ivov
* @author Lyubomir Marinov
*/
public class CallPeerJabberImpl
extends MediaAwareCallPeer<CallJabberImpl,
CallPeerMediaHandlerJabberImpl,
ProtocolProviderServiceJabberImpl>
{
/**
* The <tt>Logger</tt> used by the <tt>CallPeerJabberImpl</tt> class and its
* instances for logging output.
*/
private static final Logger logger
= Logger.getLogger(CallPeerJabberImpl.class);
/**
* The jabber address of this peer
*/
private String peerJID = null;
/**
* The {@link JingleIQ} that created the session that this call represents.
*/
private JingleIQ sessionInitIQ;
/**
* Any discovery information that we have for this peer.
*/
private DiscoverInfo discoverInfo;
/**
* Indicates whether this peer was the one that initiated the session.
*/
private boolean isInitiator = false;
/**
* Creates a new call peer with address <tt>peerAddress</tt>.
*
* @param peerAddress the Jabber address of the new call peer.
* @param owningCall the call that contains this call peer.
*/
public CallPeerJabberImpl(String peerAddress,
CallJabberImpl owningCall)
{
super(owningCall);
this.peerJID = peerAddress;
setMediaHandler( new CallPeerMediaHandlerJabberImpl(this) );
}
/**
* Returns a String locator for that peer.
*
* @return the peer's address or phone number.
*/
public String getAddress()
{
return peerJID;
}
/**
* Specifies the address, phone number, or other protocol specific
* identifier that represents this call peer. This method is to be
* used by service users and MUST NOT be called by the implementation.
*
* @param address The address of this call peer.
*/
public void setAddress(String address)
{
String oldAddress = getAddress();
if(peerJID.equals(address))
return;
this.peerJID = address;
//Fire the Event
fireCallPeerChangeEvent(
CallPeerChangeEvent.CALL_PEER_ADDRESS_CHANGE,
oldAddress,
address);
}
/**
* Returns a human readable name representing this peer.
*
* @return a String containing a name for that peer.
*/
public String getDisplayName()
{
if (getCall() != null)
{
Contact contact = getContact();
if (contact != null)
return contact.getDisplayName();
}
return peerJID;
}
/**
* Returns the contact corresponding to this peer or null if no
* particular contact has been associated.
* <p>
* @return the <tt>Contact</tt> corresponding to this peer or null
* if no particular contact has been associated.
*/
public Contact getContact()
{
ProtocolProviderService pps = getCall().getProtocolProvider();
OperationSetPresence opSetPresence
= pps.getOperationSet(OperationSetPresence.class);
return opSetPresence.findContactByID(getAddress());
}
/**
* Processes the session initiation {@link JingleIQ} that we were created
* with, passing its content to the media handler and then sends either a
* "session-info/ringing" or a "session-terminate" response.
*
* @param sessionInitIQ The {@link JingleIQ} that created the session that
* we are handling here.
*/
protected synchronized void processSessionInitiate(JingleIQ sessionInitIQ)
{
this.sessionInitIQ = sessionInitIQ;
this.isInitiator = true;
// This is the SDP offer that came from the initial session-initiate.
// Contrary to SIP, we are guaranteed to have content because XEP-0166
// says: "A session consists of at least one content type at a time."
List<ContentPacketExtension> offer = sessionInitIQ.getContentList();
try
{
getMediaHandler().processOffer(offer);
}
catch(Exception ex)
{
logger.info("Failed to process an incoming session initiate", ex);
//send an error response;
String reasonText = "Error: " + ex.getMessage();
JingleIQ errResp
= JinglePacketFactory.createSessionTerminate(
sessionInitIQ.getTo(),
sessionInitIQ.getFrom(),
sessionInitIQ.getSID(),
Reason.INCOMPATIBLE_PARAMETERS,
reasonText);
setState(CallPeerState.FAILED, reasonText);
getProtocolProvider().getConnection().sendPacket(errResp);
return;
}
//send a ringing response
if (logger.isTraceEnabled())
logger.trace("will send ringing response: ");
getProtocolProvider().getConnection().sendPacket(
JinglePacketFactory.createRinging(sessionInitIQ));
}
/**
* Processes the session initiation {@link JingleIQ} that we were created
* with, passing its content to the media handler and then sends either a
* "session-info/ringing" or a "session-terminate" response.
*
* @throws OperationFailedException exception
*/
protected synchronized void initiateSession()
throws OperationFailedException
{
isInitiator = false;
//Create the media description that we'd like to send to the other side.
List<ContentPacketExtension> offer
= getMediaHandler().createContentList();
//send a ringing response
if (logger.isTraceEnabled())
logger.trace("will send ringing response: ");
ProtocolProviderServiceJabberImpl protocolProvider
= getProtocolProvider();
this.sessionInitIQ
= JinglePacketFactory.createSessionInitiate(
protocolProvider.getOurJID(),
this.peerJID,
JingleIQ.generateSID(),
offer);
protocolProvider.getConnection().sendPacket(sessionInitIQ);
}
/**
* Indicates a user request to answer an incoming call from this
* <tt>CallPeer</tt>.
*
* Sends an OK response to <tt>callPeer</tt>. Make sure that the call
* peer contains an SDP description when you call this method.
*
* @throws OperationFailedException if we fail to create or send the
* response.
*/
public synchronized void answer()
throws OperationFailedException
{
Iterable<ContentPacketExtension> answer;
try
{
answer = getMediaHandler().generateSessionAccept();
}
catch(Exception exc)
{
logger.info("Failed to answer an incoming call", exc);
//send an error response
String reasonText = "Error: " + exc.getMessage();
JingleIQ errResp
= JinglePacketFactory.createSessionTerminate(
sessionInitIQ.getTo(),
sessionInitIQ.getFrom(),
sessionInitIQ.getSID(),
Reason.FAILED_APPLICATION,
reasonText);
setState(CallPeerState.FAILED, reasonText);
getProtocolProvider().getConnection().sendPacket(errResp);
return;
}
JingleIQ response
= JinglePacketFactory.createSessionAccept(
sessionInitIQ.getTo(),
sessionInitIQ.getFrom(),
getJingleSID(),
answer);
//send the packet first and start the stream later in case the media
//relay needs to see it before letting hole punching techniques through.
getProtocolProvider().getConnection().sendPacket(response);
getMediaHandler().start();
//tell everyone we are connecting so that the audio notifications would
//stop
setState(CallPeerState.CONNECTED);
}
/**
* Ends the call with for this <tt>CallPeer</tt>. Depending on the state
* of the peer the method would send a CANCEL, BYE, or BUSY_HERE message
* and set the new state to DISCONNECTED.
*/
public void hangup()
{
// do nothing if the call is already ended
if (CallPeerState.DISCONNECTED.equals(getState())
|| CallPeerState.FAILED.equals(getState()))
{
if (logger.isDebugEnabled())
logger.debug("Ignoring a request to hangup a call peer "
+ "that is already DISCONNECTED");
return;
}
CallPeerState prevPeerState = getState();
setState(CallPeerState.DISCONNECTED);
JingleIQ responseIQ = null;
if (prevPeerState.equals(CallPeerState.CONNECTED)
|| CallPeerState.isOnHold(prevPeerState))
{
responseIQ = JinglePacketFactory.createBye(
getProtocolProvider().getOurJID(), peerJID, getJingleSID());
}
else if (CallPeerState.CONNECTING.equals(prevPeerState)
|| CallPeerState.CONNECTING_WITH_EARLY_MEDIA.equals(prevPeerState)
|| CallPeerState.ALERTING_REMOTE_SIDE.equals(prevPeerState))
{
responseIQ = JinglePacketFactory.createCancel(
getProtocolProvider().getOurJID(), peerJID, getJingleSID());
}
else if (prevPeerState.equals(CallPeerState.INCOMING_CALL))
{
responseIQ = JinglePacketFactory.createBusy(
getProtocolProvider().getOurJID(), peerJID, getJingleSID());
}
else if (prevPeerState.equals(CallPeerState.BUSY)
|| prevPeerState.equals(CallPeerState.FAILED))
{
// For FAILED and BUSY we only need to update CALL_STATUS
// as everything else has been done already.
}
else
{
logger.info("Could not determine call peer state!");
}
if (responseIQ != null)
getProtocolProvider().getConnection().sendPacket(responseIQ);
}
/**
* Returns the session ID of the Jingle session associated with this call.
*
* @return the session ID of the Jingle session associated with this call.
*/
public String getJingleSID()
{
return sessionInitIQ.getSID();
}
/**
* Puts this peer into a {@link CallPeerState#DISCONNECTED}, indicating a
* reason to the user, if there is one.
*
* @param jingleIQ the {@link JingleIQ} that's terminating our session.
*/
public void processSessionTerminate(JingleIQ jingleIQ)
{
String reasonStr = "Call ended by remote side.";
ReasonPacketExtension reasonExt = jingleIQ.getReason();
if(reasonStr != null)
{
Reason reason = reasonExt.getReason();
if(reason != null)
reasonStr += " Reason: " + reason.toString() + ".";
String text = reasonExt.getText();
if(text != null)
reasonStr += " " + text;
}
setState(CallPeerState.DISCONNECTED, reasonStr);
}
/**
* Processes the session initiation {@link JingleIQ} that we were created
* with, passing its content to the media handler and then sends either a
* "session-info/ringing" or a "session-terminate" response.
*
* @param sessionInitIQ The {@link JingleIQ} that created the session that
* we are handling here.
*/
public void processSessionAccept(JingleIQ sessionInitIQ)
{
this.sessionInitIQ = sessionInitIQ;
CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler();
List<ContentPacketExtension> answer = sessionInitIQ.getContentList();
try
{
mediaHandler.processAnswer(answer);
}
catch(Exception exc)
{
if (logger.isInfoEnabled())
logger.info("Failed to process a session-accept", exc);
//send an error response;
JingleIQ errResp = JinglePacketFactory.createSessionTerminate(
sessionInitIQ.getTo(), sessionInitIQ.getFrom(),
sessionInitIQ.getSID(), Reason.INCOMPATIBLE_PARAMETERS,
exc.getClass().getName() + ": " + exc.getMessage());
setState(CallPeerState.FAILED, "Error: " + exc.getMessage());
getProtocolProvider().getConnection().sendPacket(errResp);
return;
}
//tell everyone we are connecting so that the audio notifications would
//stop
setState(CallPeerState.CONNECTED);
mediaHandler.start();
}
/**
* Puts the <tt>CallPeer</tt> represented by this instance on or off hold.
*
* @param onHold <tt>true</tt> to have the <tt>CallPeer</tt> put on hold;
* <tt>false</tt>, otherwise
*
* @throws OperationFailedException if we fail to construct or send the
* INVITE request putting the remote side on/off hold.
*/
public void putOnHold(boolean onHold)
throws OperationFailedException
{
CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler();
mediaHandler.setLocallyOnHold(onHold);
SessionInfoType type;
if(onHold)
type = SessionInfoType.hold;
else
{
type = SessionInfoType.unhold;
getMediaHandler().reinitAllContents();
}
//we are now on hold and need to realize this before potentially
//spoling it all with an exception while sending the packet :).
reevalLocalHoldStatus();
JingleIQ onHoldIQ = JinglePacketFactory.createSessionInfo(
getProtocolProvider().getOurJID(),
peerJID,
getJingleSID(),
type);
getProtocolProvider().getConnection().sendPacket(onHoldIQ);
}
/**
* Sets the service discovery information that we have for this peer.
*
* @param discoverInfo the discovery information that we have obtained for
* this peer.
*/
public void setDiscoverInfo(DiscoverInfo discoverInfo)
{
this.discoverInfo = discoverInfo;
}
/**
* Returns the service discovery information that we have for this peer.
*
* @return the service discovery information that we have for this peer.
*/
public DiscoverInfo getDiscoverInfo()
{
return discoverInfo;
}
/**
* Determines whether this peer was the one that initiated the session. Note
* that if this peer is the initiator of the session then this means we are
* the responder!
*
* @return <tt>true</tt> if this peer is the one that initiated the session
* and <tt>false</tt> otherwise (i.e. if _we_ initiated the session).
*/
public boolean isInitiator()
{
return isInitiator;
}
/**
* Handles the specified session <tt>info</tt> packet according to its
* content.
*
* @param info the {@link SessionInfoPacketExtension} that we just received.
*/
public void processSessionInfo(SessionInfoPacketExtension info)
{
if( info.getType() == SessionInfoType.ringing)
setState(CallPeerState.ALERTING_REMOTE_SIDE);
if (info.getType() == SessionInfoType.hold)
{
getMediaHandler().setRemotelyOnHold(true);
reevalRemoteHoldStatus();
}
else if (info.getType() == SessionInfoType.unhold
|| info.getType() == SessionInfoType.active)
{
getMediaHandler().setRemotelyOnHold(false);
reevalRemoteHoldStatus();
}
}
/**
* Send a <tt>content-add</tt> to add video setup.
*/
private void sendAddVideoContent()
{
List<ContentPacketExtension> contents = null;
try
{
contents = getMediaHandler().createContentList(MediaType.VIDEO);
}
catch(Exception exc)
{
logger.warn("Failed to gather content for video type", exc);
return;
}
ProtocolProviderServiceJabberImpl protocolProvider
= getProtocolProvider();
JingleIQ contentIQ
= JinglePacketFactory.createContentAdd(
protocolProvider.getOurJID(),
this.peerJID,
getJingleSID(),
contents);
protocolProvider.getConnection().sendPacket(contentIQ);
}
/**
* Send a <tt>content-remove</tt> to remove video setup.
*/
private void sendRemoveVideoContent()
{
CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler();
ContentPacketExtension content = new ContentPacketExtension();
ContentPacketExtension remoteContent
= mediaHandler.getRemoteContent(MediaType.VIDEO.toString());
content.setName(remoteContent.getName());
content.setCreator(remoteContent.getCreator());
content.setSenders(remoteContent.getSenders());
ProtocolProviderServiceJabberImpl protocolProvider
= getProtocolProvider();
JingleIQ contentIQ
= JinglePacketFactory.createContentRemove(
protocolProvider.getOurJID(),
this.peerJID,
getJingleSID(),
Arrays.asList(content));
protocolProvider.getConnection().sendPacket(contentIQ);
mediaHandler.removeContent(remoteContent.getName());
}
/**
* Send a <tt>content</tt> message to reflect change in video setup (start
* or stop). Message can be content-modify if video content exists,
* content-add if we start video but video is not enabled on the peer or
* content-remove if we stop video and video is not enabled on the peer.
*
* @param allowed if the local video is allowed or not
*/
public void sendModifyVideoContent(boolean allowed)
{
ContentPacketExtension ext = new ContentPacketExtension();
ContentPacketExtension remoteContent = getMediaHandler().
getRemoteContent(MediaType.VIDEO.toString());
if(remoteContent == null)
{
if(allowed)
sendAddVideoContent();
return;
}
else if(!allowed &&
((!isInitiator &&
remoteContent.getSenders() == SendersEnum.initiator) ||
(isInitiator &&
remoteContent.getSenders() == SendersEnum.responder)))
{
sendRemoveVideoContent();
return;
}
SendersEnum senders = remoteContent.getSenders();
/* adjust the senders attribute depending on current value and if we
* allowed or not local video streaming
*/
if(allowed)
{
if(senders != SendersEnum.none)
{
senders = SendersEnum.both;
}
else if(senders == SendersEnum.none && !isInitiator)
{
senders = SendersEnum.initiator;
}
else if(senders == SendersEnum.none && isInitiator)
{
senders = SendersEnum.responder;
}
}
else
{
if(senders == SendersEnum.both)
{
senders = !isInitiator ? SendersEnum.responder :
SendersEnum.initiator;
}
else
{
senders = SendersEnum.none;
}
}
ext.setSenders(senders);
ext.setCreator(remoteContent.getCreator());
ext.setName(remoteContent.getName());
JingleIQ contentIQ = JinglePacketFactory
.createContentModify(getProtocolProvider().getOurJID(),
this.peerJID, getJingleSID(), ext);
getProtocolProvider().getConnection().sendPacket(contentIQ);
try
{
getMediaHandler().reinitContent(remoteContent.getName(), senders);
}
catch(Exception e)
{
logger.warn("Exception occurred when media reinitialization", e);
}
}
/**
* Processes the content-add {@link JingleIQ}.
*
* @param content The {@link JingleIQ} that contains content that remote
* peer wants to be added
*/
public void processContentAdd(JingleIQ content)
{
CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler();
List<ContentPacketExtension> contents = content.getContentList();
Iterable<ContentPacketExtension> answerContents;
JingleIQ contentIQ;
try
{
mediaHandler.processOffer(contents);
answerContents = mediaHandler.generateSessionAccept();
contentIQ = null;
}
catch(Exception e)
{
logger.warn("Exception occurred", e);
answerContents = null;
contentIQ
= JinglePacketFactory.createContentReject(
getProtocolProvider().getOurJID(),
this.peerJID,
getJingleSID(),
answerContents);
}
if(contentIQ == null)
{
/* send content-accept */
contentIQ
= JinglePacketFactory.createContentAccept(
getProtocolProvider().getOurJID(),
this.peerJID,
getJingleSID(),
answerContents);
}
getProtocolProvider().getConnection().sendPacket(contentIQ);
mediaHandler.start();
}
/**
* Processes the content-accept {@link JingleIQ}.
*
* @param content The {@link JingleIQ} that contains content that remote
* peer has accepted
*/
public void processContentAccept(JingleIQ content)
{
List<ContentPacketExtension> contents = content.getContentList();
try
{
getMediaHandler().processAnswer(contents);
}
catch(Exception exc)
{
logger.warn("Failed to process a content-accept", exc);
//send an error response;
JingleIQ errResp = JinglePacketFactory.createSessionTerminate(
sessionInitIQ.getTo(), sessionInitIQ.getFrom(),
sessionInitIQ.getSID(), Reason.INCOMPATIBLE_PARAMETERS,
"Error: " + exc.getMessage());
setState(CallPeerState.FAILED, "Error: " + exc.getMessage());
getProtocolProvider().getConnection().sendPacket(errResp);
return;
}
getMediaHandler().start();
}
/**
* Processes the content-modify {@link JingleIQ}.
*
* @param content The {@link JingleIQ} that contains content that remote
* peer wants to be modified
*/
public void processContentModify(JingleIQ content)
{
ContentPacketExtension ext = content.getContentList().get(0);
SendersEnum senders = ext.getSenders();
try
{
getMediaHandler().reinitContent(ext.getName(), senders);
}
catch(Exception exc)
{
logger.info("Failed to process an incoming content-modify", exc);
//send an error response;
JingleIQ errResp = JinglePacketFactory.createSessionTerminate(
sessionInitIQ.getTo(), sessionInitIQ.getFrom(),
sessionInitIQ.getSID(), Reason.INCOMPATIBLE_PARAMETERS,
"Error: " + exc.getMessage());
setState(CallPeerState.FAILED, "Error: " + exc.getMessage());
getProtocolProvider().getConnection().sendPacket(errResp);
return;
}
}
/**
* Processes the content-remove {@link JingleIQ}.
*
* @param content The {@link JingleIQ} that contains content that remote
* peer wants to be removed
*/
public void processContentRemove(JingleIQ content)
{
List<ContentPacketExtension> contents = content.getContentList();
if (!contents.isEmpty())
{
CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler();
for(ContentPacketExtension c : contents)
mediaHandler.removeContent(c.getName());
/*
* TODO XEP-0166: Jingle says: If the content-remove results in zero
* content definitions for the session, the entity that receives the
* content-remove SHOULD send a session-terminate action to the
* other party (since a session with no content definitions is
* void).
*/
}
}
/**
* Processes the content-reject {@link JingleIQ}.
*
* @param content The {@link JingleIQ}
*/
public void processContentReject(JingleIQ content)
{
if(content.getContentList().isEmpty())
{
//send an error response;
JingleIQ errResp = JinglePacketFactory.createSessionTerminate(
sessionInitIQ.getTo(), sessionInitIQ.getFrom(),
sessionInitIQ.getSID(), Reason.INCOMPATIBLE_PARAMETERS,
"Error: content rejected");
setState(CallPeerState.FAILED, "Error: content rejected");
getProtocolProvider().getConnection().sendPacket(errResp);
return;
}
}
/**
* Processes the <tt>transport-info</tt> {@link JingleIQ}.
*
* @param jingleIQ the <tt>transport-info</tt> {@link JingleIQ} to process
*/
public void processTransportInfo(JingleIQ jingleIQ)
{
/*
* The transport-info action is used to exchange transport candidates so
* it only concerns the mediaHandler.
*/
try
{
getMediaHandler().processTransportInfo(jingleIQ.getContentList());
}
catch (OperationFailedException ofe)
{
logger.error("Failed to process an incoming transport-info", ofe);
}
}
/**
* Sends local candidate addresses from the local peer to the remote peer
* using the <tt>transport-info</tt> {@link JingleIQ}.
*
* @param contents the local candidate addresses to be sent from the local
* peer to the remote peer using the <tt>transport-info</tt>
* {@link JingleIQ}
*/
void sendTransportInfo(Iterable<ContentPacketExtension> contents)
{
JingleIQ transportInfo = new JingleIQ();
for (ContentPacketExtension content : contents)
transportInfo.addContent(content);
ProtocolProviderServiceJabberImpl protocolProvider
= getProtocolProvider();
transportInfo.setAction(JingleAction.TRANSPORT_INFO);
transportInfo.setFrom(protocolProvider.getOurJID());
transportInfo.setSID(getJingleSID());
transportInfo.setTo(getAddress());
transportInfo.setType(IQ.Type.SET);
protocolProvider.getConnection().sendPacket(transportInfo);
}
}
|