李勇

1.音视频模块增加streamId,和最新版的sdk兼容

@@ -86,6 +86,7 @@ class AudioApe extends Ape { @@ -86,6 +86,7 @@ class AudioApe extends Ape {
86 } 86 }
87 87
88 let channelInfo={}; 88 let channelInfo={};
  89 + channelInfo.owner=GlobalConfig.nodeId;
89 channelInfo.status=ApeConsts.CHANNEL_STATUS_OPENING; 90 channelInfo.status=ApeConsts.CHANNEL_STATUS_OPENING;
90 channelInfo.fromNodeId=GlobalConfig.nodeId; 91 channelInfo.fromNodeId=GlobalConfig.nodeId;
91 channelInfo.channelId=_param.channelId;//freeChannel 92 channelInfo.channelId=_param.channelId;//freeChannel
@@ -95,6 +96,10 @@ class AudioApe extends Ape { @@ -95,6 +96,10 @@ class AudioApe extends Ape {
95 channelInfo.toNodeId=0; 96 channelInfo.toNodeId=0;
96 channelInfo.userId=_param.userId; 97 channelInfo.userId=_param.userId;
97 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_AUDIO; 98 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_AUDIO;
  99 + channelInfo.streamId=GlobalConfig.siteId+"_"
  100 + + GlobalConfig.classId + "_"+_param.userId
  101 + +"_" + _param.channelId + "_" + _param.timestamp;
  102 +
98 this.sendTableUpdateHandler(channelInfo); 103 this.sendTableUpdateHandler(channelInfo);
99 return {"code": ApeConsts.RETURN_SUCCESS, "data":"推流成功!"} 104 return {"code": ApeConsts.RETURN_SUCCESS, "data":"推流成功!"}
100 } 105 }
@@ -121,6 +126,7 @@ class AudioApe extends Ape { @@ -121,6 +126,7 @@ class AudioApe extends Ape {
121 } 126 }
122 127
123 let channelInfo={}; 128 let channelInfo={};
  129 + channelInfo.owner=0;
124 channelInfo.status=ApeConsts.CHANNEL_STATUS_RELEASED; 130 channelInfo.status=ApeConsts.CHANNEL_STATUS_RELEASED;
125 channelInfo.fromNodeId=0; 131 channelInfo.fromNodeId=0;
126 channelInfo.channelId=openingChannel; 132 channelInfo.channelId=openingChannel;
@@ -128,6 +134,7 @@ class AudioApe extends Ape { @@ -128,6 +134,7 @@ class AudioApe extends Ape {
128 channelInfo.classId=GlobalConfig.classId; 134 channelInfo.classId=GlobalConfig.classId;
129 channelInfo.toNodeId=0; 135 channelInfo.toNodeId=0;
130 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_DEFAULT; 136 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_DEFAULT;
  137 + channelInfo.streamId="";
131 this.sendTableUpdateHandler(channelInfo); 138 this.sendTableUpdateHandler(channelInfo);
132 } 139 }
133 140
@@ -194,7 +201,8 @@ class AudioApe extends Ape { @@ -194,7 +201,8 @@ class AudioApe extends Ape {
194 201
195 let tableItemPdu = new pdu['RCRegistryTableItemPdu']; 202 let tableItemPdu = new pdu['RCRegistryTableItemPdu'];
196 tableItemPdu.itemIdx = _channelInfo.channelId; 203 tableItemPdu.itemIdx = _channelInfo.channelId;
197 - tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 204 + //tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定
  205 + tableItemPdu.owner = _channelInfo.owner;//0收到flash的是这个值,MCU做了了用户掉线处理,30秒之后会清理owner为0
198 tableItemPdu.itemData = updateModelPdu.toArrayBuffer(); 206 tableItemPdu.itemData = updateModelPdu.toArrayBuffer();
199 207
200 //insert 208 //insert
@@ -245,7 +253,13 @@ class AudioApe extends Ape { @@ -245,7 +253,13 @@ class AudioApe extends Ape {
245 tableUpdateHandler(owner, itemIdx, itemData) { 253 tableUpdateHandler(owner, itemIdx, itemData) {
246 // debugger; 254 // debugger;
247 let updateChannelInfo = this.unPackPdu(owner, itemIdx, itemData); 255 let updateChannelInfo = this.unPackPdu(owner, itemIdx, itemData);
248 - 256 + //****很重要********
  257 + //如果owner的值为0,代表的是这个歌频道已经被释放了(mcu服务端对于占用channel的掉线用户,就是把owner设置为0)
  258 + if(owner==0){
  259 + loger.log("释放占用的频道,channel",itemIdx);
  260 + updateChannelInfo.status=ApeConsts.CHANNEL_STATUS_RELEASED;
  261 + updateChannelInfo.streamId="";
  262 + }
249 this.mediaModule.mediaChannels[itemIdx] = updateChannelInfo; 263 this.mediaModule.mediaChannels[itemIdx] = updateChannelInfo;
250 264
251 this._emit(MessageTypes.AUDIO_UPDATE, updateChannelInfo); 265 this._emit(MessageTypes.AUDIO_UPDATE, updateChannelInfo);
@@ -271,6 +285,7 @@ class AudioApe extends Ape { @@ -271,6 +285,7 @@ class AudioApe extends Ape {
271 packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp(); 285 packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp();
272 packPduModel.fromNodeId = GlobalConfig.nodeId; 286 packPduModel.fromNodeId = GlobalConfig.nodeId;
273 packPduModel.toNodeId = 0; 287 packPduModel.toNodeId = 0;
  288 + packPduModel.streamId=_param.streamId;
274 console.log("packPdu",packPduModel); 289 console.log("packPdu",packPduModel);
275 return packPduModel; 290 return packPduModel;
276 } 291 }
@@ -89,6 +89,7 @@ class VideoApe extends Ape { @@ -89,6 +89,7 @@ class VideoApe extends Ape {
89 } 89 }
90 90
91 let channelInfo={}; 91 let channelInfo={};
  92 + channelInfo.owner=GlobalConfig.nodeId;
92 channelInfo.status=ApeConsts.CHANNEL_STATUS_OPENING; 93 channelInfo.status=ApeConsts.CHANNEL_STATUS_OPENING;
93 channelInfo.fromNodeId=GlobalConfig.nodeId; 94 channelInfo.fromNodeId=GlobalConfig.nodeId;
94 channelInfo.channelId=_param.channelId;//freeChannel 95 channelInfo.channelId=_param.channelId;//freeChannel
@@ -98,6 +99,10 @@ class VideoApe extends Ape { @@ -98,6 +99,10 @@ class VideoApe extends Ape {
98 channelInfo.toNodeId=0; 99 channelInfo.toNodeId=0;
99 channelInfo.userId=_param.userId; 100 channelInfo.userId=_param.userId;
100 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_VIDEO; 101 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_VIDEO;
  102 + channelInfo.streamId=GlobalConfig.siteId+"_"
  103 + + GlobalConfig.classId + "_"+_param.userId
  104 + +"_" + _param.channelId + "_" + _param.timestamp;
  105 +
101 this.sendTableUpdateHandler(channelInfo); 106 this.sendTableUpdateHandler(channelInfo);
102 return {"code": ApeConsts.RETURN_SUCCESS, "data":"推流成功!"} 107 return {"code": ApeConsts.RETURN_SUCCESS, "data":"推流成功!"}
103 } 108 }
@@ -125,6 +130,7 @@ class VideoApe extends Ape { @@ -125,6 +130,7 @@ class VideoApe extends Ape {
125 } 130 }
126 131
127 let channelInfo={}; 132 let channelInfo={};
  133 + channelInfo.owner=0;
128 channelInfo.status=ApeConsts.CHANNEL_STATUS_RELEASED; 134 channelInfo.status=ApeConsts.CHANNEL_STATUS_RELEASED;
129 channelInfo.fromNodeId=0; 135 channelInfo.fromNodeId=0;
130 channelInfo.channelId=openingChannel; 136 channelInfo.channelId=openingChannel;
@@ -132,6 +138,7 @@ class VideoApe extends Ape { @@ -132,6 +138,7 @@ class VideoApe extends Ape {
132 channelInfo.classId=GlobalConfig.classId; 138 channelInfo.classId=GlobalConfig.classId;
133 channelInfo.toNodeId=0; 139 channelInfo.toNodeId=0;
134 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_DEFAULT; 140 channelInfo.mediaType=ApeConsts.MEDIA_TYPE_DEFAULT;
  141 + channelInfo.streamId="";
135 this.sendTableUpdateHandler(channelInfo); 142 this.sendTableUpdateHandler(channelInfo);
136 } 143 }
137 144
@@ -215,7 +222,8 @@ class VideoApe extends Ape { @@ -215,7 +222,8 @@ class VideoApe extends Ape {
215 222
216 let tableItemPdu = new pdu['RCRegistryTableItemPdu']; 223 let tableItemPdu = new pdu['RCRegistryTableItemPdu'];
217 tableItemPdu.itemIdx = _channelInfo.channelId;//tableItemPdu.itemIdx=ApeConsts.VIDEO_OBJ_TABLE_ID+2; 224 tableItemPdu.itemIdx = _channelInfo.channelId;//tableItemPdu.itemIdx=ApeConsts.VIDEO_OBJ_TABLE_ID+2;
218 - tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 225 + //tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定
  226 + tableItemPdu.owner = _channelInfo.owner;//0收到flash的是这个值,MCU做了了用户掉线处理,30秒之后会清理owner为0
219 tableItemPdu.itemData = updateModelPdu.toArrayBuffer(); 227 tableItemPdu.itemData = updateModelPdu.toArrayBuffer();
220 228
221 //insert 229 //insert
@@ -265,8 +273,17 @@ class VideoApe extends Ape { @@ -265,8 +273,17 @@ class VideoApe extends Ape {
265 } 273 }
266 274
267 tableUpdateHandler(owner, itemIdx, itemData) { 275 tableUpdateHandler(owner, itemIdx, itemData) {
  276 +
268 // debugger; 277 // debugger;
269 let videoChannelInfo = this.unPackPdu(owner, itemIdx, itemData); 278 let videoChannelInfo = this.unPackPdu(owner, itemIdx, itemData);
  279 + //****很重要********
  280 + //如果owner的值为0,代表的是这个歌频道已经被释放了(mcu服务端对于占用channel的掉线用户,就是把owner设置为0)
  281 + if(owner==0){
  282 + loger.log("释放占用的频道,channel",itemIdx);
  283 + videoChannelInfo.status=ApeConsts.CHANNEL_STATUS_RELEASED;
  284 + videoChannelInfo.streamId="";
  285 + }
  286 +
270 this.mediaModule.mediaChannels[itemIdx] = videoChannelInfo; 287 this.mediaModule.mediaChannels[itemIdx] = videoChannelInfo;
271 this._emit(MessageTypes.VIDEO_UPDATE, videoChannelInfo); 288 this._emit(MessageTypes.VIDEO_UPDATE, videoChannelInfo);
272 } 289 }
@@ -291,6 +308,7 @@ class VideoApe extends Ape { @@ -291,6 +308,7 @@ class VideoApe extends Ape {
291 packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp(); 308 packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp();
292 packPduModel.fromNodeId = GlobalConfig.nodeId; 309 packPduModel.fromNodeId = GlobalConfig.nodeId;
293 packPduModel.toNodeId = 0; 310 packPduModel.toNodeId = 0;
  311 + packPduModel.streamId=_param.streamId||"";
294 console.log("packPdu",packPduModel); 312 console.log("packPdu",packPduModel);
295 return packPduModel; 313 return packPduModel;
296 } 314 }
@@ -776,6 +776,7 @@ message RCAudioChannelInfoPdu { @@ -776,6 +776,7 @@ message RCAudioChannelInfoPdu {
776 optional uint32 class_id = 7;//课堂号 776 optional uint32 class_id = 7;//课堂号
777 optional string site_id = 8;//站点号 777 optional string site_id = 8;//站点号
778 optional string user_id = 9;//用户的userId 778 optional string user_id = 9;//用户的userId
  779 + optional string stream_id = 10;//流名称
779 } 780 }
780 781
781 message RCVideoChannelInfoPdu { 782 message RCVideoChannelInfoPdu {
@@ -788,6 +789,7 @@ message RCVideoChannelInfoPdu { @@ -788,6 +789,7 @@ message RCVideoChannelInfoPdu {
788 optional uint32 class_id = 7;//课堂号 789 optional uint32 class_id = 7;//课堂号
789 optional string site_id = 8;//站点号 790 optional string site_id = 8;//站点号
790 optional string user_id = 9;//用户的userId 791 optional string user_id = 9;//用户的userId
  792 + optional string stream_id = 10;//流名称
791 } 793 }
792 794
793 message RCVideoChannelInfoRecordPdu { 795 message RCVideoChannelInfoRecordPdu {