|
@@ -27,7 +27,7 @@ class NodeSipSession {
|
27
|
27
|
this.expires = this.request.headers.expires;
|
28
|
28
|
}
|
29
|
29
|
|
30
|
|
- //主机通讯地址&端口
|
|
30
|
+ //远程监控设备的主机通讯地址&端口
|
31
|
31
|
this.host = remote.info.address;
|
32
|
32
|
|
33
|
33
|
this.port = remote.info.port;
|
|
@@ -75,6 +75,25 @@ class NodeSipSession {
|
75
|
75
|
context.sessions.set(this.id, this);
|
76
|
76
|
}
|
77
|
77
|
|
|
78
|
+ //ntv add 更新远程设备信息
|
|
79
|
+ updateRemote(remote){
|
|
80
|
+ this.request = remote.request;
|
|
81
|
+ this.protocol = remote.info.protocol;
|
|
82
|
+ //注册请求
|
|
83
|
+ if (this.request && this.request.headers) {
|
|
84
|
+
|
|
85
|
+ if (this.request.headers.via[0])
|
|
86
|
+ this.via = this.request.headers.via[0];
|
|
87
|
+
|
|
88
|
+ //过期时间
|
|
89
|
+ if (this.request.headers.expires)
|
|
90
|
+ this.expires = this.request.headers.expires;
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ //主机通讯地址&端口
|
|
94
|
+ this.host = remote.info.address;
|
|
95
|
+ this.port = remote.info.port;
|
|
96
|
+ }
|
78
|
97
|
//启动
|
79
|
98
|
async run(authModule,auto_play) {
|
80
|
99
|
|
|
@@ -760,7 +779,7 @@ class NodeSipSession {
|
760
|
779
|
|
761
|
780
|
for (var key in this.dialogs) {
|
762
|
781
|
let session = this.dialogs[key];
|
763
|
|
- if (session.bye && session.port === rport && session.host === rhost && session.channelId === channelId && session.play === 'realplay') {
|
|
782
|
+ if (session.bye && session.port == rport && session.host == rhost && session.channelId == channelId && session.play == 'realplay') {
|
764
|
783
|
isFinded = true;
|
765
|
784
|
findssrc = session.ssrc;
|
766
|
785
|
break;
|
|
@@ -778,10 +797,10 @@ class NodeSipSession {
|
778
|
797
|
|
779
|
798
|
//ssrc is here -- by ntv wangjian
|
780
|
799
|
//let ssrc = "0" + channelId.substring(16, 20) + channelId.substring(3, 8);
|
781
|
|
- let ssed = channelId.substring(13);
|
782
|
|
- let ised = '' + (parseInt(ssed)*13+10000);
|
783
|
|
- let ssrc = "1" + ssed + ised.substring(ised.length-2);
|
784
|
|
-
|
|
800
|
+ let sub1 = 10000 + parseInt(this.id.substring(15));
|
|
801
|
+ let sub2 = channelId.substring(15);
|
|
802
|
+ let ssrc = '' + sub1 + sub2;
|
|
803
|
+
|
785
|
804
|
let host = rhost || "127.0.0.1";
|
786
|
805
|
|
787
|
806
|
let port = rport || 9200;
|
|
@@ -857,6 +876,9 @@ class NodeSipSession {
|
857
|
876
|
|
858
|
877
|
context.nodeEvent.emit('sdpReceived', sdp);
|
859
|
878
|
|
|
879
|
+ //add ntv
|
|
880
|
+ context.ssrcs.set(ssrc,{id:that.id,chid:channelId,play:'realplay'});
|
|
881
|
+
|
860
|
882
|
//Step 7 SIP服务器收到媒体流发送者返回200 OK响应后,向 媒体流发送者 发送 ACK请求,请求中不携带消息体,完成与媒体流发送者的invite会话建立过程
|
861
|
883
|
that.uas.send({
|
862
|
884
|
method: 'ACK',
|
|
@@ -888,6 +910,9 @@ class NodeSipSession {
|
888
|
910
|
}
|
889
|
911
|
|
890
|
912
|
that.dialogs[key] = { channelId: channelId, ssrc: ssrc, host: host, port: port, bye: byeRequest, play: 'realplay' };
|
|
913
|
+
|
|
914
|
+ //console.log("BYE INFO:");
|
|
915
|
+ //console.log(that.dialogs[key]);
|
891
|
916
|
}
|
892
|
917
|
|
893
|
918
|
result.data = { ssrc: ssrc };
|
|
@@ -924,13 +949,17 @@ class NodeSipSession {
|
924
|
949
|
//搜索满足条件的会话
|
925
|
950
|
let session = this.dialogs[key];
|
926
|
951
|
//ntv 注释掉多余条件,因为数据类型不同导致找不到
|
927
|
|
- if (session.bye /*&& session.port === rport && session.host === rhost */ && session.channelId === channelId && session.play === 'realplay') {
|
|
952
|
+ if (session.bye && session.port == rport && session.host == rhost && session.channelId == channelId && session.play == 'realplay') {
|
928
|
953
|
//ntv 挪到回调中,TODO 这个指令发不成功!
|
929
|
954
|
//context.nodeEvent.emit('stopPlayed', session.ssrc);
|
|
955
|
+
|
|
956
|
+ //add by ntv 强制更新uri地址,因为终端地址会变。
|
|
957
|
+ session.bye.uri = 'sip:' + this.id + '@' + this.host + ':' + this.port;
|
|
958
|
+
|
930
|
959
|
this.uas.send(session.bye, (response) => {
|
931
|
960
|
Logger.log(`[${this.id}] StopRealPlay status=${response.status}`);
|
932
|
961
|
|
933
|
|
- if(response.status==200){
|
|
962
|
+ //if(response.status==200){ //ntv 注释20210127
|
934
|
963
|
/**
|
935
|
964
|
ntv remove rtp连接断开时再emit这条消息,放到了stream/session中执行
|
936
|
965
|
*/
|
|
@@ -944,7 +973,7 @@ class NodeSipSession {
|
944
|
973
|
}
|
945
|
974
|
|
946
|
975
|
});
|
947
|
|
- }
|
|
976
|
+ //}
|
948
|
977
|
});
|
949
|
978
|
|
950
|
979
|
//ntv
|