forked from DoubangoTelecom/sipml5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIPml.js
2067 lines (1875 loc) · 97.4 KB
/
SIPml.js
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
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2012-2016 Doubango Telecom <http://www.doubango.org>
* License: BSD
* This file is part of Open Source sipML5 solution <http://www.sipml5.org>
*/
/**
@fileoverview This is SIPML5 "library" contains a lot of classes and functions.
@name sipML5 API
@author Doubango Telecom <http://www.doubango.org>
@version 2.1.3
*/
/**
@namespace
@description Root namesapce.
*/
SIPml = {};
/** @private */SIPml.b_initialized = false;
/** @private */SIPml.b_initializing = false;
/** @private */SIPml.s_navigator_friendly_name = 'unknown';
/** @private */SIPml.b_navigator_outdated = false;
/** @private */SIPml.s_navigator_version = 'unknown';
/** @private */SIPml.s_system_friendly_name = 'unknown';
/** @private */SIPml.b_webrtc4all_plugin_outdated = false;
/** @private */SIPml.b_webrtc4all_supported = false;
/** @private */SIPml.s_webrtc4all_version = 'unknown';
/** @private */SIPml.b_have_media_stream = false;
/** @private */SIPml.b_webrtc_supported = false;
/**
Sets the debug level.
@since version 1.3.203
@param {String} level The level. Supported values: <i>info</i>, <i>warn</i>, <i>error</i> and <i>fatal</i>.
*/
SIPml.setDebugLevel = function (level) {
tsk_utils_log_set_level(level === 'fatal' ? 1 : (level === 'error' ? 2 : (level === 'warn' ? 3 : 4)));
}
/**
Starts debugging the native (C/C++) code. Requires webrt4all plugin.
On Windows, the output file should be at <b>C:\Users\<YOUR LOGIN>\AppData\Local\Temp\Low\webrtc4all.log</b>.
Starting the native debug isn't recommended and must be done to track issues only.
@since version 2.0.0
*/
SIPml.startNativeDebug = function () {
WebRtc4all_GetPlugin().startDebug();
}
/**
Stops debugging the native (C/C++) code. Requires webrt4all plugin.
@since version 2.0.0
*/
SIPml.stopNativeDebug = function () {
WebRtc4all_GetPlugin().stopDebug();
}
/**
Gets the current WebRTC type being used.
@since version 1.4.217
@returns {String} the WebRTC type. Possible values: <i>native</i>, <i>w4a</i>, <i>erisson</i> or <i>unknown</i>.
*/
SIPml.getWebRtcType = function () {
switch (WebRtc4all_GetType()) {
case WebRtcType_e.W4A: case WebRtcType_e.IE: case WebRtcType_e.NPAPI: return "w4a";
case WebRtcType_e.ERICSSON: return "erisson";
case WebRtcType_e.NATIVE: return "native";
default: return "unknown";
}
}
/**
Sets the default webrtc type. Must be called before <a href="#.init">initializing</a> the engine.
@since version 2.0.0
@param {String} type The type. Supported values: <i>native</i>, <i>w4a</i> and <i>erisson</i>.
@returns {Boolean} <i>true</i> if succeed; otherwise <i>false</i>
*/
SIPml.setWebRtcType = function (type) {
if (SIPml.isInitialized()) {
throw new Error("ERR_ALREADY_INITIALIZED: Engine already initialized.");
}
return WebRtc4all_SetType(type);
}
/**
Gets the list of running apps. Requires webrt4all plugin.
@since version 2.0.0
@returns {String} the the list of running apps. Format: <i>(base64($$WindowID$$=str(...)$$Description$$=str(...)$$IconData$$=base64(...)$$IconType$$=str(...)))*</i>
@throws {ERR_NOT_READY | ERR_NOT_SUPPORTED} <font color="red">ERR_NOT_READY</font> | <font color="red">ERR_NOT_SUPPORTED</font>
*/
SIPml.getRunningApps = function () {
if (SIPml.getWebRtcType() != 'w4a') {
throw new Error("ERR_NOT_SUPPORTED: requires webrtc4all plugin");
}
return WebRtc4all_GetPlugin().runningApps();
}
/**
Sets the video fps. Requires webrt4all plugin.
@since version 2.0.0
@param {Integer} fps fps value.
@returns {Integer} 0 if successful; otherwise nonzero
@throws {ERR_NOT_READY | ERR_NOT_SUPPORTED} <font color="red">ERR_NOT_READY</font> | <font color="red">ERR_NOT_SUPPORTED</font>
*/
SIPml.setFps = function (fps) {
if (SIPml.getWebRtcType() != 'w4a') {
throw new Error("ERR_NOT_SUPPORTED: Setting maximum video size requires webrtc4all plugin");
}
WebRtc4all_GetPlugin().fps = fps;
return 0;
}
/**
Sets the maximum video size. Requires webrt4all plugin.
@since version 2.0.0
@param {String} maxVideoSize maxVideoSize value. Supported values: "sqcif", "qcif" "qvga" "cif" "hvga", "vga", "4cif", "svga", "480p", "720p", "16cif", "1080p", "2160p".
@returns {Integer} 0 if successful; otherwise nonzero
@throws {ERR_NOT_READY | ERR_NOT_SUPPORTED} <font color="red">ERR_NOT_READY</font> | <font color="red">ERR_NOT_SUPPORTED</font>
*/
SIPml.setMaxVideoSize = function (maxVideoSize) {
if (SIPml.getWebRtcType() != 'w4a') {
throw new Error("ERR_NOT_SUPPORTED: Setting FPS requires webrtc4all plugin");
}
WebRtc4all_GetPlugin().maxVideoSize = maxVideoSize;
return 0;
}
/**
Sets the maximum bandwidth (upload). Requires webrt4all plugin.
@since version 2.0.0
@param {Integer} maxBandwidthUp maxBandwidthUp value (kbps).
@returns {Integer} 0 if successful; otherwise nonzero
@throws {ERR_NOT_READY | ERR_NOT_SUPPORTED} <font color="red">ERR_NOT_READY</font> | <font color="red">ERR_NOT_SUPPORTED</font>
*/
SIPml.setMaxBandwidthUp = function (maxBandwidthUp) {
if (SIPml.getWebRtcType() != 'w4a') {
throw new Error("ERR_NOT_SUPPORTED: Setting maximum bandwidth requires webrtc4all plugin");
}
WebRtc4all_GetPlugin().maxBandwidthUp = maxBandwidthUp;
return 0;
}
/**
Sets the maximum bandwidth (down). Requires webrt4all plugin.
@since version 2.0.0
@param {Integer} maxBandwidthUp maxBandwidthUp value (kbps).
@returns {Integer} 0 if successful; otherwise nonzero
@throws {ERR_NOT_READY | ERR_NOT_SUPPORTED} <font color="red">ERR_NOT_READY</font> | <font color="red">ERR_NOT_SUPPORTED</font>
*/
SIPml.setMaxBandwidthDown = function (maxBandwidthDown) {
if (SIPml.getWebRtcType() != 'w4a') {
throw new Error("ERR_NOT_SUPPORTED: Setting maximum bandwidth requires webrtc4all plugin");
}
WebRtc4all_GetPlugin().maxBandwidthDown = maxBandwidthDown;
return 0;
}
/**
Defines whether to enable "zero-artifacts" features. Requires webrt4all plugin. <br />
More information about this option on Doubango's TelePresence wiki page: <a href="https://code.google.com/p/telepresence/wiki/Technical_Video_quality#Zero-artifacts">https://code.google.com/p/telepresence/wiki/Technical_Video_quality#Zero-artifacts</a>
@since version 2.0.0
@param {Boolean} zeroArtifacts New optional value.
@returns {Integer} 0 if successful; otherwise nonzero
@throws {ERR_NOT_READY | ERR_NOT_SUPPORTED} <font color="red">ERR_NOT_READY</font> | <font color="red">ERR_NOT_SUPPORTED</font>
*/
SIPml.setZeroArtifacts = function (zeroArtifacts) {
if (SIPml.getWebRtcType() != 'w4a') {
throw new Error("ERR_NOT_SUPPORTED: Setting maximum bandwidth requires webrtc4all plugin");
}
WebRtc4all_GetPlugin().zeroArtifacts = zeroArtifacts;
return 0;
}
/**
Gets the version name of the installed <a href="http://code.google.com/p/webrtc4all/">webrtc4all plugin</a>.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} Version name (e.g. '1.12.756')
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getWebRtc4AllVersion = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_webrtc4all_version;
};
/**
Gets the web browser version (e.g. <i>'1.5.beta'</i>).
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} The the web browser version.
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getNavigatorVersion = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_navigator_version;
};
/**
Gets the web browser friendly name (e.g. <i>'chrome'</i>, <i>'firefox'</i>, <i>'safari'</i>, <i>'opera'</i>, <i>'ie'</i> or <i>'netscape'</i>).
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} The web browser friendly name.
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getNavigatorFriendlyName = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_navigator_friendly_name;
};
/**
Gets the Operating System friendly name (e.g. <i>'windows'</i>, <i>'mac'</i>, <i>'lunix'</i>, <i>'solaris'</i>, <i>'sunos'</i> or <i>'powerpc'</i>).
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} The Operating System friendly name.
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getSystemFriendlyName = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_system_friendly_name;
};
/**
Checks whether the web browser supports WebRTC but is outdated.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if outdated; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isNavigatorOutdated = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_navigator_outdated;
}
/**
Checks whether the <a href="http://code.google.com/p/webrtc4all/">webrtc4all plugin</a> is outdated or not.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if outdated; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isWebRtc4AllPluginOutdated = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_webrtc4all_plugin_outdated;
}
/**
Checks whether the <a href="http://code.google.com/p/webrtc4all/">webrtc4all plugin</a> is installed or not.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isWebRtc4AllSupported = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_webrtc4all_supported;
}
/**
Checks whether Screen share is supported on this browser.
You must <a href="#.init">initialize</a> the engine before calling this function.
@since version 1.3.203
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isScreenShareSupported = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return (SIPml.getWebRtcType() === "w4a") || (navigator.userAgent.match('Chrome') && parseInt(navigator.userAgent.match(/Chrome\/(.*) /)[1]) >= 26);
}
/**
Checks whether WebRTC is supported or not.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isWebRtcSupported = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_webrtc_supported;
}
/**
Checks whether WebSocket is supported or not.
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
*/
SIPml.isWebSocketSupported = function () {
return tsk_utils_have_websocket();
}
/**
Checks whether <a href="https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia">getUserMedia</a> is supported or not. The engined must be initialized before calling this function.
@static
@returns {Boolean} <i>true</i> if <a href="https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia">getUserMedia</a> is supported; otherwise <i>false</i>
*/
SIPml.haveMediaStream = function () {
if (!SIPml.isInitialized()) {
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_have_media_stream;
}
/**
Checks whether the engine is ready to make/receive calls or not. <br />
The engine is ready when:
<ul>
<li>engine is <a href="#.init">initialized</a></li>
<li>webrtc is supported</li>
<li>we got a valid media stream (from <a href="https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia">getUserMedia</a>)</li>
</ul>
@static
@returns {Boolean} <i>true</i> if the engine is ready; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isReady = function () {
return (SIPml.isInitialized() && SIPml.isWebRtcSupported() && SIPml.haveMediaStream());
}
/**
Checks whether the engine is initialized or not. To initialize the stack you must call <a href="#.init">init()</a> function.
@static
@returns {Boolean} <i>true</i> if the engine is initialized; otherwise <i>false</i>
*/
SIPml.isInitialized = function () { return SIPml.b_initialized; }
/**
Initialize the engine. <b>You must call this function before any other.</b>.
@param {CallbackFunction} [readyCallback] Optional callback function to call when the stack finish initializing and become ready.
@param {CallbackFunction} [errorCallback] Optional callback function to call when initialization fails.
@example
SIPml.init(function(e){ console.info('engine is ready'); }, function(e){ console.info('Error: ' + e.message); });
@static
*/
SIPml.init = function (successCallback, errorCallback) {
if (!SIPml.b_initialized && !SIPml.b_initializing) {
SIPml.b_initializing = true;
tsk_utils_init_webrtc();
tsk_utils_log_info('User-Agent=' + (navigator.userAgent || "unknown"));
SIPml.b_have_media_stream = tsk_utils_have_stream();
SIPml.b_webrtc_supported = tsk_utils_have_webrtc();
SIPml.b_webrtc4all_supported = tsk_utils_have_webrtc4all();
SIPml.s_webrtc4all_version = tsk_utils_webrtc4all_get_version();
SIPml.s_navigator_friendly_name = tsk_utils_get_navigator_friendly_name();
SIPml.s_system_friendly_name = tsk_utils_get_system_friendly_name();
// prints whether WebSocket is supported
tsk_utils_log_info("WebSocket supported = " + (SIPml.isWebSocketSupported() ? "yes" : "no"));
// check webrtc4all version
if (tsk_utils_have_webrtc4all()) {
tsk_utils_log_info("WebRTC type = " + WebRtc4all_GetType() + " version = " + tsk_utils_webrtc4all_get_version());
if (SIPml.s_webrtc4all_version != '1.35.981') {
SIPml.b_webrtc4all_plugin_outdated = true;
}
}
// prints navigator friendly name
tsk_utils_log_info("Navigator friendly name = " + SIPml.s_navigator_friendly_name);
// gets navigator version
if (SIPml.s_navigator_friendly_name == 'ie') {
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(navigator.userAgent) != null) {
SIPml.s_navigator_version = RegExp.$1;
}
}
// prints OS friendly name
tsk_utils_log_info("OS friendly name = " + SIPml.s_system_friendly_name);
// prints support for WebRTC (native or plugin)
tsk_utils_log_info("Have WebRTC = " + (tsk_utils_have_webrtc() ? "yes" : "false"));
// prints support for getUserMedia
tsk_utils_log_info("Have GUM = " + (tsk_utils_have_stream() ? "yes" : "false"));
// checks for WebRTC support
if (!tsk_utils_have_webrtc()) {
// is it chrome?
if (SIPml.s_navigator_friendly_name == "chrome") {
SIPml.b_navigator_outdated = true;
return;
}
// for now the plugins (WebRTC4all only works on Windows)
if (SIPml.s_system_friendly_name == 'win' || SIPml.s_system_friendly_name == 'windows') {
// Internet explorer
if (SIPml.s_navigator_friendly_name == 'ie') {
// Check for IE version
var rv = -1;
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
rv = parseFloat(RegExp.$1);
}
if (rv < 9.0) {
SIPml.b_navigator_outdated = true;
return;
}
// break page loading ('window.location' won't stop JS execution)
if (!tsk_utils_have_webrtc4all()) {
return;
}
}
}
}
if (SIPml.b_webrtc_supported && SIPml.b_have_media_stream) {
SIPml.b_initialized = true;
SIPml.b_initializing = false;
tsk_utils_log_info("Engine initialized");
if (successCallback) {
successCallback({});
}
}
else {
if (errorCallback) {
var s_description = !SIPml.b_webrtc_supported ? "WebRTC not supported" : (!SIPml.b_have_media_stream ? "getUserMedia not supported" : "Internal error");
errorCallback({ description: s_description });
}
}
}
}
// ================================== SIPml.EventTarget ==========================================
/**
@constructor
Defines an event target. You sould never create an event target object.
*/
SIPml.EventTarget = function () {
this.ao_listeners = [];
}
/**
Adds an event listener to the target object. <br /><br />
<table border="1">
<tr>
<td><b>Target classes<b></td>
<td><b>Supported event types<b></td>
<td><b>Raised event object<b></td>
<td><b>Remarques<b></td>
</tr>
<tr>
<td><a href="SIPml.Stack.html" name="SIPml.EventTarget.Stack">SIPml.Stack</a></td>
<td>
<b>*</b><br/> starting<br/> started<br/> stopping<br/> stopped<br/> failed_to_start<br/> failed_to_stop<br/> i_new_call<br /> i_new_message<br />
m_permission_requested<br/> m_permission_accepted<br/> m_permission_refused
</td>
<td><a href="SIPml.Stack.Event.html">SIPml.Stack.Event</a></td>
<td>'*' is used to listen for all events</td>
</tr>
<tr>
<td>
<a href="SIPml.Session.html" name="SIPml.EventTarget.Session">SIPml.Session</a>
<ul>
<li><a href="SIPml.Session.Call.html">SIPml.Session.Call</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Message</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Registration</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Subscribe</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Publish</a></li>
<ul>
</td>
<td><b>*</b><br/> connecting<br /> connected<br /> terminating<br /> terminated<br />
i_ao_request<br />
media_added<br/> media_removed<br/>
i_request<br/> o_request<br/> cancelled_request<br/> sent_request<br/>
transport_error<br/> global_error<br/> message_error<br/> webrtc_error
</td>
<td><a href="SIPml.Session.Event.html">SIPml.Session.Event</a></td>
<td>'*' is used to listen for all events<br /></td>
</tr>
<tr>
<td><a href="SIPml.Session.Call.html" name="SIPml.EventTarget.Session.Call">SIPml.Session.Call</a></td>
<td>
m_early_media<br/> m_local_hold_ok<br/> m_local_hold_nok<br/> m_local_resume_ok<br/> m_local_resume_nok<br/> m_remote_hold<br/> m_remote_resume<br/>
m_stream_video_local_added<br /> m_stream_video_local_removed<br/> m_stream_video_remote_added<br/> m_stream_video_remote_removed <br />
m_stream_audio_local_added<br /> m_stream_audio_local_removed<br/> m_stream_audio_remote_added<br/> m_stream_audio_remote_removed <br />
i_ect_new_call<br/> o_ect_trying<br/> o_ect_accepted<br/> o_ect_completed<br/> i_ect_completed<br/> o_ect_failed<br/> i_ect_failed<br/> o_ect_notify<br/> i_ect_notify<br/> i_ect_requested <br />
m_bfcp_info<br />
i_info
</td>
<td><a href="SIPml.Session.Event.html">SIPml.Session.Event</a></td>
<td>borrows all events supported by <a href="SIPml.Session.html">SIPml.Session</a></td>
</tr>
<tr>
<td><a href="SIPml.Session.Subscribe.html" name="SIPml.EventTarget.Session.Subscribe">SIPml.Session.Subscribe</a></td>
<td>
i_notify
</td>
<td><a href="SIPml.Session.Event.html">SIPml.Session.Event</a></td>
<td>borrows all events supported by <a href="SIPml.Session.html">SIPml.Session</a></td>
</tr>
</table>
@param {String|Array} type The event type/identifier. Must not be null or empty. Use <b>'*'</b> to listen for all events.
@param {function} listener The object that receives a notification when an event of the specified type occurs. This must be an object implementing the <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener">EventListener</a> interface, or simply a JavaScript function.
@example
// listen for a single event
this.addEventListener('started', function(e){
console.info("'started' event fired");
});
// or listen for two or more events
this.addEventListener(['started', 'stopped'], function(e){
console.info("'"+e.type+"' event fired");
});
// or listen for all events
this.addEventListener('*', function(e){
console.info("'"+e.type+"' event fired");
});
@see <a href="#removeEventListener">removeEventListener</a>
@throws {ERR_INVALID_PARAMETER_VALUE|ERR_INVALID_PARAMETER_TYPE} <font color="red">ERR_INVALID_PARAMETER_VALUE</font> | <font color="red">ERR_INVALID_PARAMETER_TYPE</font>
*/
SIPml.EventTarget.prototype.addEventListener = function (o_type, o_listener) {
if (!o_listener) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: 'listener' must not be null");
}
if (!o_type) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: 'type' must not be null");
}
if (!(o_type instanceof String || typeof o_type == "string" || o_type instanceof Array)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: 'type' must be a string or array");
}
if (o_type instanceof Array) {
var This = this;
o_type.forEach(function (s_type) {
if (!tsk_string_is_null_or_empty(s_type) && tsk_string_is_string(s_type)) {
This.ao_listeners[s_type] = o_listener;
}
});
}
else {
this.ao_listeners[o_type] = o_listener;
}
}
/**
Removes an event listener from the target object.
@param {String} type The event type/identifier to stop listening for.
@see <a href="#addEventListener">addEventListener</a>
@exemple
this.removeEventListener('started');
*/
SIPml.EventTarget.prototype.removeEventListener = function (s_type) {
if (tsk_string_is_string(s_type) && !tsk_string_is_null_or_empty(s_type)) {
this.ao_listeners[s_type] = undefined;
}
}
/**
@ignore
@private
@param {Object} event
*/
SIPml.EventTarget.prototype.dispatchEvent = function (o_event) {
var o_listener = (this.ao_listeners[o_event.s_type] || this.ao_listeners['*']);
if (o_listener) {
o_listener.call(this, o_event.o_value);
}
}
// ================================== SIPml.Event ==========================================
/**
SIP event object. You should never create an instance of this class by yourself.
@constructor
@param {String} type The event type or identifier. Please check <a href="SIPml.EventTarget.html#SIPml.EventTarget.Session">this link</a> for more information about all supported session event types.
@param {tsip_event} [event] Private wrapped session object.
@property {String} type The event <a href="SIPml.EventTarget.html#SIPml.EventTarget.Session">type or identifier</a> (e.g. <i>'connected'</i>).
@property {String} description User-friendly description in english (e.g. <i>'Session is now connected'</i>).
*/
SIPml.Event = function (s_type, o_event) {
this.type = s_type;
this.description = o_event ? o_event.s_phrase : s_type;
this.o_event = o_event;
}
/**
Gets the SIP response code.
@returns {Integer} The SIP response code (e.g. 404).
*/
SIPml.Event.prototype.getSipResponseCode = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message && o_message.is_response()) {
return o_message.get_response_code();
}
return -1;
}
/**
Gets the SIP content associated to this event. This function could be called to get the content of the incoming SIP message ('i_new_message' event).
@returns {Object} SIP content.
@see <a href="#getContentType">getContentType</a>, <a href="#getContentString">getContentString</a>
*/
SIPml.Event.prototype.getContent = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message) {
return o_message.get_content();
}
return null;
}
/**
Gets the SIP content associated to this event. This function could be called to get the content of the incoming SIP message ('i_new_message' event).
@returns {String} SIP content.
@see <a href="#getContentType">getContentType</a>, <a href="#getContent">getContent</a>
*/
SIPml.Event.prototype.getContentString = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message) {
return o_message.get_content_as_string();
}
return null;
}
/**
Gets the SIP content-type associated to this event. This function could be called to get the content-type of the incoming SIP message ('i_new_message' event).
@returns {Object} SIP content-type.
@see <a href="#getContent">getContent</a>
*/
SIPml.Event.prototype.getContentType = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message) {
return o_message.get_content_type();
}
return null;
}
// ================================== SIPml.Stack ==========================================
/**
Anonymous SIP Stack configuration object.
@namespace SIPml.Stack.Configuration
@name SIPml.Stack.Configuration
@property {String} realm The domain name. Required for stack <a href="SIPml.Stack.html#constructor">constructor</a> but optional when used with <a href="SIPml.Stack.html#setConfiguration">setConfiguration</a>. <br />
Example: <i>example.org</i>
@property {String} impi The authentication name. Required for stack <a href="SIPml.Stack.html#constructor">constructor</a> but optional when used with <a href="SIPml.Stack.html#setConfiguration">setConfiguration</a>.<br />
Example: <i>+33600000000</i> or <i>bob</i>.
@property {string} impu The full SIP uri address. Required for stack <a href="SIPml.Stack.html#constructor">constructor</a> but optional when used with <a href="SIPml.Stack.html#setConfiguration">setConfiguration</a>.<br />
Example: <i>sip:+33600000000@example.com</i> or <i>tel:+33600000000</i> or <i>sip:bob@example.com</i>
@property {String} [password] The password to use for SIP authentication.<br />
Example: <i>mysecret</i>
@property {String} [display_name] The display name to use in SIP requests. This is the String displayed by the called party for incoming calls. <br />
Example: <i>I Am Legend</i>
@property {String} [websocket_proxy_url] The websocket proxy url to connect to (SIP server or gateway address). If unset the stack will use sipml5.org as host and a random port. You should not set this value unless you know what you're doing.<br />
Example: <i>ws://sipml5.org:5060</i>
@property {String} [outbound_proxy_url] The outbound Proxy URL is used to set the destination IP address and Port to use for all outgoing requests regardless the <i>domain name</i> (a.k.a <i>realm</i>). <br />
This is a good option for developers using a SIP domain name without valid DNS A/NAPTR/SRV records. You should not set this value unless you know what you're doing. <br />
Example: <i>udp://192.168.0.12:5060</i>
@property {Array} [ice_servers] The list of the STUN/TURN servers to use. The format must be as explained at <a target=_blank href="http://www.w3.org/TR/webrtc/#rtciceserver-type">http://www.w3.org/TR/webrtc/#rtciceserver-type</a>. <br />
To disable TURN/STUN to speedup ICE candidates gathering you can use an empty array. e.g. <i>[]</i>. <br />
Example: <i>[{ url: 'stun:stun.l.google.com:19302'}, { url:'turn:user@numb.viagenie.ca', credential:'myPassword'}]</i>
@property {Object} [bandwidth] Defines the maximum audio and video bandwidth to use. This will change the outhoing SDP to include a "b:AS=" attribute. Use <i>0</i> to let the browser negotiates the right value using RTCP-REMB and congestion control. Same property could be used at session level to override this value.<br />
<i>Available since version 1.3.203</i>. <br />
Example: <i>{ audio:64, video:512 }</i>
@property {Object} [video_size] Defines the maximum and minimum video size to be used. All values are optional. The browser will try to find the best video size between <i>max</i> and <i>min</i> based on the camera capabilities. Same property could be used at session level to override this value.<br />
<i>Available since version 1.3.203</i>. <br />
Example: <i>{ minWidth:640, minHeight:480, maxWidth:1920, maxHeight:1080 }</i>
@property {Boolean} [enable_rtcweb_breaker] Whether to enable the <a href="http://webrtc2sip.org/#aRTCWebBreaker" target=_blank>RTCWeb Breaker</a> module to allow calling SIP-legacy networks. <br />
Example: <i>true</i>
@property {Boolean} [enable_click2call] Whether to enable the <a href="http://click2dial.org" target=_blank>Click2Call / Click2Dial</a> service.
<i>Available since version 1.2.181</i>. <br />
Example: <i>true</i>
@property {Boolean} [enable_early_ims] Whether to enable 3GGP Early IMS as per <a href="http://www.arib.or.jp/english/html/overview/doc/STD-T63v9_60/5_Appendix/Rel6/33/33978-660.pdf" target=_blank>TR 33.978</a>. Should be 'true' unless you're using a real IMS network. <br />
<i>Available since version 1.3.203</i>. <br />
Example: <i>true</i>
@property {Boolean} [enable_media_stream_cache] Whether to reuse the same media stream for all calls. If your website is <b>not using https</b> then, the browser will request access to the camera (or microphone) every time you try to make a call. Caching the media stream will avoid getting these notifications for each call. <br />
<i>Available since version 1.3.203</i>. <br />
Example: <i>true</i>
@property {Object} [events_listener] Object to subscribe to some events.
Example:
<ul>
<li><i>{ events: '*', listener: function(e){} }</i> </li>
<li><i>{ events: 'started', listener: function(e){} }</i></li>
<li><i>{ events: ['started', 'stopped'], listener: function(e){} }</i></li>
</ul>
You can also use <a href="#addEventListener">addEventListener</a> to add listeners to the stack.
@property {Array} [sip_headers] Stack-level SIP headers to add to all outgoing requests. Each header is an object with a <i>name</i> and <i>value</i> fields. <br />
Example: <i>sip_headers: [{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'}, {name: 'Organization', value: 'Doubango Telecom'}]</i>
@example
var configuration = {
realm: 'example.org',
impi: 'bob',
impu: 'sip:bob@example.org',
password: 'mysecret', // optional
display_name: 'I Am Legend', // optional
websocket_proxy_url: 'ws://192.168.0.10:5060', // optional
outbound_proxy_url: 'udp://192.168.0.12:5060', // optional
ice_servers: [{ url: 'stun:stun.l.google.com:19302'}, { url:'turn:user@numb.viagenie.ca', credential:'myPassword'}], // optional
enable_rtcweb_breaker: true, // optional
enable_click2call: false, // optional
enable_early_ims: true, // optional
events_listener: { events: '*', listener: listenerFunc }, // optional
sip_headers: [ //optional
{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'},
{name: 'Organization', value: 'Doubango Telecom'}
]
};
*/
/**
This is the root object used by any other object to make/receive calls, messages or manage presence.
You have to create an instance of this class before anything else.
@extends SIPml.EventTarget
@constructor
@class
@param {SIPml.Stack.Configuration} configuration Configuration object. Could be updated later using <a href="#setConfiguration">setConfiguration</a>.
@throws {ERR_INVALID_PARAMETER_VALUE|ERR_INVALID_PARAMETER_TYPE} <font color="red">ERR_INVALID_PARAMETER_VALUE</font> | <font color="red">ERR_INVALID_PARAMETER_TYPE</font>
@example
var listenerFunc = function(e){
console.info('stack event = ' + e.type);
// Please check <a href="SIPml.EventTarget.html#SIPml.EventTarget.Stack">this link</a> for more information on all supported events.
}
var o_stack = new SIPml.Stack({
realm: 'example.org',
impi: 'bob',
impu: 'sip:bob@example.org',
password: 'mysecret', // optional
display_name: 'I Am Legend', // optional
websocket_proxy_url: 'ws://192.168.0.10:5060', // optional
outbound_proxy_url: 'udp://192.168.0.12:5060', // optional
ice_servers: [{ url: 'stun:stun.l.google.com:19302'}, { url:'turn:user@numb.viagenie.ca', credential:'myPassword'}], // optional
bandwidth: { audio:64, video:512 }, // optional
video_size: { minWidth:640, minHeight:480, maxWidth:1920, maxHeight:1080 }, // optional
enable_rtcweb_breaker: true, // optional
enable_click2call: false, // optional
events_listener: { events: '*', listener: listenerFunc }, //optional
sip_headers: [ //optional
{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'},
{name: 'Organization', value: 'Doubango Telecom'}
]
}
);
@see <a href="#setConfiguration">setConfiguration</a>
*/
SIPml.Stack = function (o_conf) {
SIPml.init();
SIPml.EventTarget.call(this);
/*
members:
- o_stack {tsip_stack}
*/
if (!o_conf) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: null configuration value");
}
if (tsk_string_is_null_or_empty(o_conf.realm)) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.realm + "' is not valid as realm value");
}
if (tsk_string_is_null_or_empty(o_conf.impi)) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.impi + "' is not valid as impi value");
}
if (tsk_string_is_null_or_empty(o_conf.impu)) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.impu + "' is not valid as impu value");
}
// check IMPU validity
var o_impu = tsip_uri.prototype.Parse(o_conf.impu);
if (!o_impu || !o_impu.s_user_name || !o_impu.s_host) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.impu + "' is not valid as SIP Uri");
}
var i_port;
var s_proxy;
if (!SIPml.isWebSocketSupported()) {
// port and host will be updated using the result from DNS SRV(NAPTR(realm))
i_port = 5060;
s_proxy = o_conf.realm;
}
else {
// there are at least 5 servers running on the cloud.
// we will connect to one of them and let the balancer to choose the right one (less connected sockets)
// each port can accept up to 65K connections which means that the cloud can manage 325K active connections
// the number of port will be increased or decreased based on the current trafic
// webrtc2sip 2.2+ (Doubango):
// WS: 10060, 11060, 12060, 13060, 14060
// WSS: 10062, 11062, 12062, 13062, 14062
//
i_port = ((o_conf.enable_rtcweb_breaker || (window.location && window.location.protocol == "https:")) ? 10062 : 10060) + (((new Date().getTime()) % 5) * 1000);
s_proxy = "ns313841.ovh.net";
}
// create the stack
this.o_stack = new tsip_stack(o_conf.realm, o_conf.impi, o_conf.impu, s_proxy, i_port);
this.o_stack.oStack = this;
// set configurations
this.setConfiguration(o_conf);
// listen for stack events
this.o_stack.on_event_stack = function (e) {
var s_type;
switch (e.i_code) {
case tsip_event_code_e.STACK_STARTING: s_type = 'starting'; break;
case tsip_event_code_e.STACK_STARTED: s_type = 'started'; break;
case tsip_event_code_e.STACK_STOPPING: s_type = 'stopping'; break;
case tsip_event_code_e.STACK_STOPPED: s_type = 'stopped'; break;
case tsip_event_code_e.STACK_FAILED_TO_START: s_type = 'failed_to_start'; break;
case tsip_event_code_e.STACK_FAILED_TO_STOP: s_type = 'failed_to_stop'; break;
}
if (s_type) {
e.o_stack.oStack.dispatchEvent({ s_type: s_type, o_value: new SIPml.Stack.Event(s_type, e) });
}
}
// listen for dialog events
this.o_stack.on_event_dialog = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if (!oSession) {
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id);
return;
}
switch (e.i_code) {
case tsip_event_code_e.DIALOG_TRANSPORT_ERROR: s_type = 'transport_error'; break;
case tsip_event_code_e.DIALOG_GLOBAL_ERROR: s_type = 'global_error'; break;
case tsip_event_code_e.DIALOG_MESSAGE_ERROR: s_type = 'message_error'; break;
case tsip_event_code_e.DIALOG_WEBRTC_ERROR: s_type = 'webrtc_error'; break;
case tsip_event_code_e.DIALOG_REQUEST_INCOMING: s_type = 'i_request'; break;
case tsip_event_code_e.DIALOG_REQUEST_OUTGOING: s_type = 'o_request'; break;
case tsip_event_code_e.DIALOG_REQUEST_CANCELLED: s_type = 'cancelled_request'; break;
case tsip_event_code_e.DIALOG_REQUEST_SENT: s_type = 'sent_request'; break;
case tsip_event_code_e.DIALOG_MEDIA_ADDED: s_type = 'media_added'; break;
case tsip_event_code_e.DIALOG_MEDIA_REMOVED: s_type = 'media_removed'; break;
case tsip_event_code_e.DIALOG_CONNECTING: s_type = 'connecting'; break;
case tsip_event_code_e.DIALOG_CONNECTED: s_type = 'connected'; break;
case tsip_event_code_e.DIALOG_BFCP_INFO: s_type = 'bfcp_info'; break;
case tsip_event_code_e.DIALOG_TERMINATING: s_type = 'terminating'; break;
case tsip_event_code_e.DIALOG_TERMINATED:
{
s_type = 'terminated';
e.o_session.o_stack.oStack.ao_sessions[i_session_id] = undefined;
break;
}
default: break;
}
if (s_type) {
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
}
// listen for MESSAGE events
this.o_stack.on_event_message = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
switch (e.e_message_type) {
case tsip_event_message_type_e.I_MESSAGE: s_type = 'i_new_message'; break;
case tsip_event_message_type_e.AO_MESSAGE: s_type = 'i_ao_request'; break;
}
if (s_type) {
// 'i_new_call' is stack-level event
if (s_type == 'i_new_message') {
var oNewEvent = new SIPml.Stack.Event(s_type, e);
oNewEvent.newSession = new SIPml.Session.Message(e.o_session);
e.o_session.o_stack.oStack.ao_sessions[i_session_id] = oNewEvent.newSession; // save session
e.o_session.o_stack.oStack.dispatchEvent({ s_type: s_type, o_value: oNewEvent });
}
else {
if (oSession) {
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
else {
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
}
}
}
};
// listen for PUBLISH events
this.o_stack.on_event_publish = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if (!oSession) {
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
return;
}
switch (e.e_publish_type) {
case tsip_event_publish_type_e.I_PUBLISH: break;
case tsip_event_publish_type_e.I_UNPUBLISH: break;
case tsip_event_publish_type_e.AO_PUBLISH:
case tsip_event_publish_type_e.AO_UNPUBLISH:
{
s_type = 'i_ao_request';
break;
}
}
if (s_type) {
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
}
// listen for SUBSCRIBE events
this.o_stack.on_event_subscribe = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if (!oSession) {
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
return;
}
switch (e.e_subscribe_type) {
case tsip_event_subscribe_type_e.I_SUBSCRIBE: break;
case tsip_event_subscribe_type_e.I_UNSUBSRIBE: break;
case tsip_event_subscribe_type_e.AO_SUBSCRIBE:
case tsip_event_subscribe_type_e.AO_UNSUBSCRIBE:
case tsip_event_subscribe_type_e.AO_NOTIFY:
{
s_type = 'i_ao_request';
break;
}
case tsip_event_subscribe_type_e.I_NOTIFY:
{
s_type = 'i_notify';
break;
}
}
if (s_type) {
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
}
// listen for INVITE events
this.o_stack.on_event_invite = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if (!oSession) {
switch (e.e_invite_type) {
case tsip_event_invite_type_e.I_NEW_CALL:
case tsip_event_invite_type_e.M_STREAM_LOCAL_REQUESTED:
case tsip_event_invite_type_e.M_STREAM_LOCAL_ACCEPTED:
case tsip_event_invite_type_e.M_STREAM_LOCAL_REFUSED:
case tsip_event_invite_type_e.M_BFCP_INFO:
break;
case tsip_event_invite_type_e.M_STREAM_LOCAL_ADDED:
case tsip_event_invite_type_e.M_STREAM_REMOTE_ADDED:
case tsip_event_invite_type_e.M_STREAM_LOCAL_REMOVED:
case tsip_event_invite_type_e.M_STREAM_REMOTE_REMOVED:
case tsip_event_invite_type_e.I_AO_REQUEST:
tsk_utils_log_info('Not notifying to session with id = ' + i_session_id + ' for event = ' + e.e_invite_type);
return;
default:
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
return;
}
}