正在显示
8 个修改的文件
包含
337 行增加
和
50 行删除
| @@ -116,6 +116,8 @@ export default class MessageEntrance extends Emiter { | @@ -116,6 +116,8 @@ export default class MessageEntrance extends Emiter { | ||
| 116 | this.getPublishVideoPath = this._getPublishVideoPath; | 116 | this.getPublishVideoPath = this._getPublishVideoPath; |
| 117 | this.publishVideo = this._publishVideo; | 117 | this.publishVideo = this._publishVideo; |
| 118 | this.stopPublishVideo = this._stopPublishVideo; | 118 | this.stopPublishVideo = this._stopPublishVideo; |
| 119 | + this.sendVideoCommandMsg=this.sendVideoCommandMsg; | ||
| 120 | + | ||
| 119 | 121 | ||
| 120 | //whiteBoradApe | 122 | //whiteBoradApe |
| 121 | this.sendInsertAnnotaion = this._sendInsertAnnotaion; | 123 | this.sendInsertAnnotaion = this._sendInsertAnnotaion; |
| @@ -620,6 +622,12 @@ export default class MessageEntrance extends Emiter { | @@ -620,6 +622,12 @@ export default class MessageEntrance extends Emiter { | ||
| 620 | } | 622 | } |
| 621 | 623 | ||
| 622 | //VidoeApe | 624 | //VidoeApe |
| 625 | + sendVideoCommandMsg(_param){ | ||
| 626 | + if(_video_ape){ | ||
| 627 | + _video_ape.sendVideoCommandMsg(_param); | ||
| 628 | + } | ||
| 629 | + } | ||
| 630 | + | ||
| 623 | _getPlayVideoPath(_param){ | 631 | _getPlayVideoPath(_param){ |
| 624 | if(_video_ape){ | 632 | if(_video_ape){ |
| 625 | return _video_ape.getPlayVideoPath(_param); | 633 | return _video_ape.getPlayVideoPath(_param); |
| @@ -102,8 +102,8 @@ class EverSocket extends Emiter { | @@ -102,8 +102,8 @@ class EverSocket extends Emiter { | ||
| 102 | loger.log('WebSocket建立成功', this.wsURL); | 102 | loger.log('WebSocket建立成功', this.wsURL); |
| 103 | 103 | ||
| 104 | //启动心跳,检查socket链接状态 | 104 | //启动心跳,检查socket链接状态 |
| 105 | - //this.pingTimer = window.setInterval(this._sendPingHandler.bind(this), EverSocket.PING_INTERVAL); | ||
| 106 | - //this.pongTimer = window.setInterval(this._checkPongHandler.bind(this), EverSocket.PONG_INTERVAL); | 105 | + this.pingTimer = window.setInterval(this._sendPingHandler.bind(this), EverSocket.PING_INTERVAL); |
| 106 | + this.pongTimer = window.setInterval(this._checkPongHandler.bind(this), EverSocket.PONG_INTERVAL); | ||
| 107 | 107 | ||
| 108 | this._setConnected(); | 108 | this._setConnected(); |
| 109 | } | 109 | } |
| @@ -253,9 +253,9 @@ GlobalConfig.port="80"; | @@ -253,9 +253,9 @@ GlobalConfig.port="80"; | ||
| 253 | GlobalConfig.MCUServerIP="114.215.195.70"; | 253 | GlobalConfig.MCUServerIP="114.215.195.70"; |
| 254 | GlobalConfig.docServer="";//当前的文档地址加载的服务器地址 | 254 | GlobalConfig.docServer="";//当前的文档地址加载的服务器地址 |
| 255 | GlobalConfig.MCUServerPort=9003; | 255 | GlobalConfig.MCUServerPort=9003; |
| 256 | -GlobalConfig.maxVideoChannels=1; | ||
| 257 | -GlobalConfig.maxAudioChannels=1; | ||
| 258 | -GlobalConfig.maxMediaChannels=2; | 256 | +GlobalConfig.maxVideoChannels=0; |
| 257 | +GlobalConfig.maxAudioChannels=0; | ||
| 258 | +GlobalConfig.maxMediaChannels=0; | ||
| 259 | GlobalConfig.isDebug=false; | 259 | GlobalConfig.isDebug=false; |
| 260 | GlobalConfig.deBugData={}; | 260 | GlobalConfig.deBugData={}; |
| 261 | 261 |
| @@ -3,6 +3,8 @@ import Loger from 'Loger'; | @@ -3,6 +3,8 @@ import Loger from 'Loger'; | ||
| 3 | import MessageTypes from 'MessageTypes'; | 3 | import MessageTypes from 'MessageTypes'; |
| 4 | import GlobalConfig from 'GlobalConfig'; | 4 | import GlobalConfig from 'GlobalConfig'; |
| 5 | import MD5 from "md5"; | 5 | import MD5 from "md5"; |
| 6 | +import ApeConsts from 'apes/ApeConsts'; | ||
| 7 | + | ||
| 6 | // 日志对象 | 8 | // 日志对象 |
| 7 | const loger = Loger.getLoger('Sass'); | 9 | const loger = Loger.getLoger('Sass'); |
| 8 | 10 | ||
| @@ -105,7 +107,7 @@ class Sass extends Emiter { | @@ -105,7 +107,7 @@ class Sass extends Emiter { | ||
| 105 | */ | 107 | */ |
| 106 | //判断是否是老师 | 108 | //判断是否是老师 |
| 107 | let isTeacher=0; | 109 | let isTeacher=0; |
| 108 | - if(confInfo.userRole=="host"){ | 110 | + if(confInfo.userRole==ApeConsts.host){ |
| 109 | isTeacher=1 | 111 | isTeacher=1 |
| 110 | } | 112 | } |
| 111 | 113 |
| @@ -6,6 +6,7 @@ export default function ApeConsts(id) { | @@ -6,6 +6,7 @@ export default function ApeConsts(id) { | ||
| 6 | } | 6 | } |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | + | ||
| 9 | //课堂状态 | 10 | //课堂状态 |
| 10 | ApeConsts.CLASS_STATUS_WAIT= 0;//课堂还未开始 | 11 | ApeConsts.CLASS_STATUS_WAIT= 0;//课堂还未开始 |
| 11 | ApeConsts.CLASS_STATUS_STARTED= 1;//直播中 | 12 | ApeConsts.CLASS_STATUS_STARTED= 1;//直播中 |
| @@ -27,6 +28,19 @@ ApeConsts.CLASS_ACTION_CLOSE_ALL=1;//所有人关闭会议 | @@ -27,6 +28,19 @@ ApeConsts.CLASS_ACTION_CLOSE_ALL=1;//所有人关闭会议 | ||
| 27 | ApeConsts.CLASS_TYPE_INTERACT= 1; // 互动课堂,通过MS转发音视频,不能进行H5观看 | 28 | ApeConsts.CLASS_TYPE_INTERACT= 1; // 互动课堂,通过MS转发音视频,不能进行H5观看 |
| 28 | ApeConsts.CLASS_TYPE_LIVE= 2; // 直播课堂,通过CDN转发音视频,不能进行音视频互动 | 29 | ApeConsts.CLASS_TYPE_LIVE= 2; // 直播课堂,通过CDN转发音视频,不能进行音视频互动 |
| 29 | 30 | ||
| 31 | + | ||
| 32 | +/* | ||
| 33 | +flash | ||
| 34 | +public static const NR_GUEST:uint = 0; // 客人 | ||
| 35 | +public static const NR_NORMAL:uint = 1; // 普通与会者 | ||
| 36 | +public static const NR_ADMIN:uint = 2; // 管理员 | ||
| 37 | +public static const NR_MASTER:uint = 4; // 主持人 | ||
| 38 | +public static const NR_SLAVE:uint = 8; // 主讲人 | ||
| 39 | +public static const NR_ASSISTANT:uint = 16; // 助教 | ||
| 40 | +public static const NR_INVISIBLE:uint = 32; // 隐身用户 | ||
| 41 | +*/ | ||
| 42 | + | ||
| 43 | + | ||
| 30 | //角色身份 | 44 | //角色身份 |
| 31 | ApeConsts.NR_GUEST = 0; // 客人 | 45 | ApeConsts.NR_GUEST = 0; // 客人 |
| 32 | ApeConsts.NR_NORMAL = 1;// 普通与会者 | 46 | ApeConsts.NR_NORMAL = 1;// 普通与会者 |
| @@ -36,7 +50,6 @@ ApeConsts.NR_SLAVE = 8; // 主讲人 | @@ -36,7 +50,6 @@ ApeConsts.NR_SLAVE = 8; // 主讲人 | ||
| 36 | ApeConsts.NR_ASSISTANT = 16; // 助教 | 50 | ApeConsts.NR_ASSISTANT = 16; // 助教 |
| 37 | ApeConsts.NR_INVISIBLE = 32; // 隐身用户 | 51 | ApeConsts.NR_INVISIBLE = 32; // 隐身用户 |
| 38 | 52 | ||
| 39 | - | ||
| 40 | //用户的身份,5种类型: | 53 | //用户的身份,5种类型: |
| 41 | ApeConsts.host="host";//(主持人/老师) | 54 | ApeConsts.host="host";//(主持人/老师) |
| 42 | ApeConsts.presenter="presenter";//(主讲人) | 55 | ApeConsts.presenter="presenter";//(主讲人) |
| @@ -45,6 +58,37 @@ ApeConsts.normal="normal";//(普通角色/学生) | @@ -45,6 +58,37 @@ ApeConsts.normal="normal";//(普通角色/学生) | ||
| 45 | ApeConsts.record="record";//(暂时没用. | 58 | ApeConsts.record="record";//(暂时没用. |
| 46 | 59 | ||
| 47 | 60 | ||
| 61 | +/*msType type*/ | ||
| 62 | +ApeConsts.MS_TYPE_DEFAULT= 0;//默认MS,(废弃) | ||
| 63 | +ApeConsts.MS_TYPE_FMS= 1;//第三方FMS,目前一直用这个 | ||
| 64 | + | ||
| 65 | + | ||
| 66 | +//用户状态 | ||
| 67 | +ApeConsts.USER_HAND_UP = 0x0020; // 举手 | ||
| 68 | +ApeConsts.USER_MIC_OPEN = 0x0040; // 麦克风开启 | ||
| 69 | +ApeConsts.USER_CAMERA_OPEN = 0x0080; // 视频开启 | ||
| 70 | + | ||
| 71 | + | ||
| 72 | +//VIDEO MIC | ||
| 73 | +ApeConsts.OPEN_CAMERA= "open.camera"; | ||
| 74 | +ApeConsts.CLOSE_CAMERA= "close.camera"; | ||
| 75 | +ApeConsts.OPEN_MIC= "open.mic"; | ||
| 76 | +ApeConsts.CLOSE_MIC= "close.mic"; | ||
| 77 | + | ||
| 78 | + | ||
| 79 | +// VIDEO AUDIO CHANNEL使用状态 | ||
| 80 | +ApeConsts.CHANNEL_STATUS_RELEASED = 0;///< 无人占用状态 | ||
| 81 | +ApeConsts.CHANNEL_STATUS_OPENING = 1;///< 已经占用成功 | ||
| 82 | + | ||
| 83 | + | ||
| 84 | +//FLASH中使用下面4个 | ||
| 85 | +ApeConsts.CGS_RELEASED = 0;///< 无人占用状态 | ||
| 86 | +ApeConsts.CGS_PENDING = 1;///< 占用成功,等待打开 | ||
| 87 | +ApeConsts.CGS_OPENNED = 2;///< 打开成功 | ||
| 88 | +ApeConsts.CGS_GRABBING = 3; ///< 准备占用中, 属于本地状态机需要用的状态,在多点数据库中不存在。 | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + | ||
| 48 | ApeConsts.INVALIDATE_CHANNEL_ID = -1; | 92 | ApeConsts.INVALIDATE_CHANNEL_ID = -1; |
| 49 | ApeConsts.INVALIDATE_NODE_ID = -1; | 93 | ApeConsts.INVALIDATE_NODE_ID = -1; |
| 50 | 94 | ||
| @@ -55,12 +99,6 @@ ApeConsts.DOC_ACTION_SWITCH_PAGE=2;//文档翻页 | @@ -55,12 +99,6 @@ ApeConsts.DOC_ACTION_SWITCH_PAGE=2;//文档翻页 | ||
| 55 | ApeConsts.DOC_ACTION_COMMAND=3;//文档操作:滚动、缩放 | 99 | ApeConsts.DOC_ACTION_COMMAND=3;//文档操作:滚动、缩放 |
| 56 | 100 | ||
| 57 | 101 | ||
| 58 | -// RCChannelGrabStatus | ||
| 59 | -ApeConsts.CGS_RELEASED = 0;///< 无人占用状态 | ||
| 60 | -ApeConsts.CGS_PENDING = 1;///< 占用成功,等待打开 | ||
| 61 | -ApeConsts.CGS_OPENNED = 2;///< 打开成功 | ||
| 62 | -ApeConsts.CGS_GRABBING = 3; ///< 准备占用中, 属于本地状态机需要用的状态,在多点数据库中不存在。 | ||
| 63 | - | ||
| 64 | // defs for common session id | 102 | // defs for common session id |
| 65 | ApeConsts.CONFERENCE_SESSION_ID = 11; | 103 | ApeConsts.CONFERENCE_SESSION_ID = 11; |
| 66 | ApeConsts.CHAT_SESSION_ID = 12; | 104 | ApeConsts.CHAT_SESSION_ID = 12; |
| @@ -163,7 +163,7 @@ class DocApe extends Ape { | @@ -163,7 +163,7 @@ class DocApe extends Ape { | ||
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | if(fullPath&&fullPath.indexOf("http://")<0){ | 165 | if(fullPath&&fullPath.indexOf("http://")<0){ |
| 166 | - fullPath="http;//"+fullPath; | 166 | + fullPath="http://"+fullPath; |
| 167 | } | 167 | } |
| 168 | loger.warn('getDocFullPath ->',fullPath); | 168 | loger.warn('getDocFullPath ->',fullPath); |
| 169 | return [fullPath]; | 169 | return [fullPath]; |
| @@ -18,6 +18,8 @@ import ApeConsts from './ApeConsts'; | @@ -18,6 +18,8 @@ import ApeConsts from './ApeConsts'; | ||
| 18 | import pdu from 'pdus'; | 18 | import pdu from 'pdus'; |
| 19 | import Loger from 'Loger'; | 19 | import Loger from 'Loger'; |
| 20 | import MessageTypes from 'MessageTypes'; | 20 | import MessageTypes from 'MessageTypes'; |
| 21 | +import GlobalConfig from 'GlobalConfig'; | ||
| 22 | +import EngineUtils from 'EngineUtils'; | ||
| 21 | 23 | ||
| 22 | let loger = Loger.getLoger('VideoChat'); | 24 | let loger = Loger.getLoger('VideoChat'); |
| 23 | 25 | ||
| @@ -41,9 +43,8 @@ class VideoChat extends Ape { | @@ -41,9 +43,8 @@ class VideoChat extends Ape { | ||
| 41 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | 43 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); |
| 42 | this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.VIDEO_OBJ_TABLE_ID, ApeConsts.VIDEO_OBJ_TABLE_NAME, ApeConsts.VIDEO_OBJ_TABLE_TAG, 0, new ArrayBuffer); | 44 | this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.VIDEO_OBJ_TABLE_ID, ApeConsts.VIDEO_OBJ_TABLE_NAME, ApeConsts.VIDEO_OBJ_TABLE_TAG, 0, new ArrayBuffer); |
| 43 | 45 | ||
| 44 | - | ||
| 45 | - // ape listeners | ||
| 46 | - this.on(pdu.RCPDU_VIDEO_SEND_DATA_REQUEST, this.videoIncomingHandler.bind(this)); | 46 | + // videoApe 监听视频控制消息,用户之间的消息传递 |
| 47 | + this.on(pdu.RCPDU_VIDEO_SEND_DATA_REQUEST, this.videoCommandHandler.bind(this)); | ||
| 47 | } | 48 | } |
| 48 | /////////////发送数据操作////////////////////////////////////////////////////// | 49 | /////////////发送数据操作////////////////////////////////////////////////////// |
| 49 | //获取播流地址 | 50 | //获取播流地址 |
| @@ -54,24 +55,207 @@ class VideoChat extends Ape { | @@ -54,24 +55,207 @@ class VideoChat extends Ape { | ||
| 54 | //获取推流地址 | 55 | //获取推流地址 |
| 55 | getPublishVideoPath(_param){ | 56 | getPublishVideoPath(_param){ |
| 56 | loger.log('getPublishVideoPath'); | 57 | loger.log('getPublishVideoPath'); |
| 58 | + //判断当前开启的视频数量是否已经是最大值,如果已经是最大值,不能再开启 | ||
| 59 | + | ||
| 57 | return {"code":0,"data":"推流地址XXXXXXXXXXXXXXXXXXXXXXX"}; | 60 | return {"code":0,"data":"推流地址XXXXXXXXXXXXXXXXXXXXXXX"}; |
| 58 | } | 61 | } |
| 59 | 62 | ||
| 60 | //推流 | 63 | //推流 |
| 61 | publishVideo(_param){ | 64 | publishVideo(_param){ |
| 62 | - loger.log('publishVideo'); | 65 | + loger.log('publishVideo -> maxVideoChannels',GlobalConfig.maxVideoChannels); |
| 66 | + this.sendTableUpdateHandler(); | ||
| 67 | + /* protected function startPushMessageFlash():void | ||
| 68 | + { | ||
| 69 | + if((!Config.enableCDNServer && !Config.isH5Moudle) || | ||
| 70 | + Config.customer == Config.customerTaobao || | ||
| 71 | + Config.msType == Config.MS_TYPE_FMS | ||
| 72 | + ) | ||
| 73 | + return; | ||
| 74 | + | ||
| 75 | + var obj:Object = new Object; | ||
| 76 | + obj.confID = Config.confID; | ||
| 77 | + obj.streamType = RCNetStream.PRT_CAM_SOUND_FLASH; | ||
| 78 | + obj.uriPush = "rtmp://" + Config.liveServerAddr + ":" + Config.liveServerPort + "/3m/" + streamName; | ||
| 79 | + _streamPublished.send("startPush", obj); | ||
| 80 | + log.info("startPushMessageFlash,startPush streamType:" + obj.streamType); | ||
| 81 | + }*/ | ||
| 82 | + | ||
| 83 | +/* var rtmpUrl:String = ""; | ||
| 84 | + if(Config.msType == Config.MS_TYPE_DEFAULT) | ||
| 85 | + { | ||
| 86 | + rtmpUrl = "rtmp://" + mediaServerAddr + ":" + mediaServerPort; | ||
| 87 | + } | ||
| 88 | + else if(Config.msType == Config.MS_TYPE_FMS)//fms下链接地址 pzm+ 2016.4.12 | ||
| 89 | + { | ||
| 90 | + if(Config.clientType == Config.CT_RECORDPLAYER) | ||
| 91 | + { | ||
| 92 | + rtmpUrl = "rtmp://" + mediaServerAddr + ":" + mediaServerPort + "/vod"; | ||
| 93 | + } | ||
| 94 | + else | ||
| 95 | + { | ||
| 96 | + rtmpUrl = "rtmp://" + mediaServerAddr + ":" + mediaServerPort + "/live/" + Config.confID; | ||
| 97 | + } | ||
| 98 | + }*/ | ||
| 63 | } | 99 | } |
| 64 | //停止推流 | 100 | //停止推流 |
| 65 | stopPublishVideo(_param){ | 101 | stopPublishVideo(_param){ |
| 66 | - loger.log('stopPublishVideo.'); | 102 | + loger.log('stopPublishVideo -> maxVideoChannels',GlobalConfig.maxVideoChannels); |
| 103 | + this.sendTableUpdateHandler(); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + // | ||
| 107 | + //aaaa(){ | ||
| 108 | + // if (event.cmd == ApplicationFacade.OPEN_MIC) | ||
| 109 | + // { | ||
| 110 | + // if (audioDeviceOpenedUsers() >= Config.maxAudioChannels) | ||
| 111 | + // { | ||
| 112 | + // item.closeAudioDevice(); | ||
| 113 | + // Alert.show(resourceManager.getString('meeting', 'CannotOpenDeviceAnyMore'), | ||
| 114 | + // resourceManager.getString('meeting', 'AlertWarning'), Alert.OK, item); | ||
| 115 | + // event.stopImmediatePropagation(); | ||
| 116 | + // } | ||
| 117 | + // else | ||
| 118 | + // { | ||
| 119 | + // super.updateCamMicStatus(event.camOpened, event.micOpened, event.node_id); | ||
| 120 | + // } | ||
| 121 | + // } | ||
| 122 | + // else if (event.cmd == ApplicationFacade.OPEN_CAMERA) | ||
| 123 | + // { | ||
| 124 | + // if (videoDeviceOpenedUsers() >= Config.maxVideoChannels) | ||
| 125 | + // { | ||
| 126 | + // item.closeVideoDevice(); | ||
| 127 | + // Alert.show(resourceManager.getString('meeting', 'CannotOpenDeviceAnyMore'), | ||
| 128 | + // resourceManager.getString('meeting', 'AlertWarning'), Alert.OK, item); | ||
| 129 | + // event.stopImmediatePropagation(); | ||
| 130 | + // } | ||
| 131 | + // else | ||
| 132 | + // { | ||
| 133 | + // super.updateCamMicStatus(event.camOpened, event.micOpened, event.node_id); | ||
| 134 | + // } | ||
| 135 | + // } | ||
| 136 | + //} | ||
| 137 | + | ||
| 138 | + curAudioDeviceOpenedUsers() | ||
| 139 | + { | ||
| 140 | + //var openedUsers:int = 0; | ||
| 141 | + //var index:int = 0; | ||
| 142 | + // | ||
| 143 | + //for(index = 0; index < _userArray.length; index++) | ||
| 144 | + //{ | ||
| 145 | + // var tmpNode:RCNodeInfoRecordPdu = RCNodeInfoRecordPdu(_userArray.getItemAt(index)); | ||
| 146 | + // if(tmpNode.status & RCNodeStatus_E.NR_MIC_OPEN) | ||
| 147 | + // { | ||
| 148 | + // openedUsers++; | ||
| 149 | + // } | ||
| 150 | + //} | ||
| 151 | + // | ||
| 152 | + //return openedUsers; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + curVideoDeviceOpenedUsers() | ||
| 156 | + { | ||
| 157 | + //var openedUsers:int = 0; | ||
| 158 | + //var index:int = 0; | ||
| 159 | + // | ||
| 160 | + //for(index = 0; index < _userArray.length; index++) | ||
| 161 | + //{ | ||
| 162 | + // var tmpNode:RCNodeInfoRecordPdu = RCNodeInfoRecordPdu(_userArray.getItemAt(index)); | ||
| 163 | + // if(tmpNode.status & RCNodeStatus_E.NR_CAMERA_OPEN) | ||
| 164 | + // { | ||
| 165 | + // openedUsers++; | ||
| 166 | + // } | ||
| 167 | + //} | ||
| 168 | + //return openedUsers; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + sendVideoCommandMsg(_messageInfo) { | ||
| 172 | + if(this._classInfo===null||EngineUtils.isEmptyObject(this._classInfo)){ | ||
| 173 | + loger.log('不能发送Video消息.McuClient还未初始化数据!'); | ||
| 174 | + if(GlobalConfig.getCurrentStatus().code==0||GlobalConfig.getCurrentStatus().code==1){ | ||
| 175 | + this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_SEND_FAILED_NO_JOIN); | ||
| 176 | + return; | ||
| 177 | + } | ||
| 178 | + return ; | ||
| 67 | } | 179 | } |
| 180 | + // to, message | ||
| 181 | + loger.log('发送Video消息.', _messageInfo); | ||
| 182 | + | ||
| 183 | + | ||
| 184 | + /* message RCVideoSendDataRequestPdu { | ||
| 185 | + optional uint32 initiator = 1; | ||
| 186 | + optional bool key_frame = 2; | ||
| 187 | + optional uint32 sequence_id = 3; | ||
| 188 | + optional uint32 slice_id = 4; | ||
| 189 | + optional bytes user_data = 5; | ||
| 190 | + } | ||
| 191 | + */ | ||
| 192 | + | ||
| 193 | + let videoSendPdu = new pdu['RCVideoSendDataRequestPdu']; | ||
| 194 | + videoSendPdu.type = pdu.RCPDU_VIDEO_SEND_DATA_REQUEST; | ||
| 195 | + videoSendPdu.initiator = GlobalConfig.nodeId;//发起人 | ||
| 196 | + videoSendPdu.peer = parseInt(_messageInfo.to);//发送给谁,公聊的时候是0,私聊的时候是指定的用户id | ||
| 197 | + videoSendPdu.userData = this._rCArrayBufferUtil.strToUint8Array("h5" + _messageInfo.message);//开头两个字会乱码 | ||
| 198 | + videoSendPdu.isPublic = true; | ||
| 199 | + videoSendPdu.sliceId=_messageInfo.sliceId||0; | ||
| 200 | + | ||
| 201 | + if (!videoSendPdu.isPublic && 0!=videoSendPdu.peer) { | ||
| 202 | + //发送给制定的人 | ||
| 203 | + loger.log('发送私聊Video消息.'); | ||
| 204 | + this.send(videoSendPdu); | ||
| 205 | + } else { | ||
| 206 | + //发送给所有人 | ||
| 207 | + loger.log('发送公聊Video消息.'); | ||
| 208 | + this.sendChatUniform(videoSendPdu); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + sendTableUpdateHandler(){ | ||
| 213 | + loger.log("video===sendTableUpdateHandler "); | ||
| 214 | + /* //验证坐标点集合数组是否合法 | ||
| 215 | + if(_docDataModel==null||_itemIdx==null){ | ||
| 216 | + this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 217 | + return null; | ||
| 218 | + }*/ | ||
| 219 | + loger.log("video===sendTableUpdateHandler "); | ||
| 220 | + | ||
| 221 | + let updateModelPdu=this.packPdu({},ApeConsts.VIDEO_OBJ_TABLE_ID+2); | ||
| 222 | + | ||
| 223 | + | ||
| 68 | 224 | ||
| 225 | + let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | ||
| 226 | + tableItemPdu.itemIdx=ApeConsts.VIDEO_OBJ_TABLE_ID+2;//直接用时间戳作为id | ||
| 227 | + tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | ||
| 228 | + tableItemPdu.itemData =updateModelPdu.toArrayBuffer(); | ||
| 69 | 229 | ||
| 230 | + //insert | ||
| 231 | + let tableInsertItemPdu = new pdu['RCRegistryTableUpdateItemPdu']; | ||
| 232 | + //optional RCPduType_E type = 1 [default = RCPDU_REG_TABLE_UPDATE_PDU]; | ||
| 233 | + //repeated RCRegistryTableItemPdu items = 2; | ||
| 234 | + tableInsertItemPdu.type = pdu.RCPDU_REG_TABLE_UPDATE_PDU;// | ||
| 235 | + tableInsertItemPdu.items.push(tableItemPdu); | ||
| 236 | + | ||
| 237 | + let updateObjPdu = new pdu['RCRegistryUpdateObjPdu']; | ||
| 238 | + updateObjPdu.objId = ApeConsts.VIDEO_OBJ_TABLE_ID;// | ||
| 239 | + updateObjPdu.subType = tableInsertItemPdu.type; | ||
| 240 | + updateObjPdu.userData = tableInsertItemPdu.toArrayBuffer(); | ||
| 241 | + | ||
| 242 | + //同步 | ||
| 243 | + let adapterItemPdu = new pdu['RCAdapterItemPdu']; | ||
| 244 | + adapterItemPdu.type = pdu.RCPDU_REG_UPDATE_OBJ; | ||
| 245 | + adapterItemPdu.itemData = updateObjPdu.toArrayBuffer(); | ||
| 246 | + | ||
| 247 | + let adapterPdu = new pdu['RCAdapterPdu']; | ||
| 248 | + adapterPdu.type = pdu.RCPDU_REG_ADAPTER; | ||
| 249 | + adapterPdu.item.push(adapterItemPdu); | ||
| 250 | + | ||
| 251 | + loger.log("发送更新文档.itemIdx="+tableItemPdu.itemIdx); | ||
| 252 | + this.sendUniform(adapterPdu,true); | ||
| 253 | + } | ||
| 70 | /////收到消息处理///////////////////////////////////////////////////////////////////////////////// | 254 | /////收到消息处理///////////////////////////////////////////////////////////////////////////////// |
| 71 | 255 | ||
| 72 | // 视频消息处理 | 256 | // 视频消息处理 |
| 73 | - videoIncomingHandler(videoBuffer) { | ||
| 74 | - let videoReceivePdu = pdu['VideoSendDataRequestPdu'].decode(videoBuffer); | 257 | + videoCommandHandler(videoBuffer) { |
| 258 | + let videoReceivePdu = pdu['RCVideoSendDataRequestPdu'].decode(videoBuffer); | ||
| 75 | 259 | ||
| 76 | let video_data = { }; | 260 | let video_data = { }; |
| 77 | video_data._initiator = videoReceivePdu.initiator; | 261 | video_data._initiator = videoReceivePdu.initiator; |
| @@ -80,27 +264,22 @@ class VideoChat extends Ape { | @@ -80,27 +264,22 @@ class VideoChat extends Ape { | ||
| 80 | video_data._slice_id = videoReceivePdu.sliceId; | 264 | video_data._slice_id = videoReceivePdu.sliceId; |
| 81 | video_data._data = videoReceivePdu.userData; | 265 | video_data._data = videoReceivePdu.userData; |
| 82 | 266 | ||
| 83 | - | ||
| 84 | // this._notify(RCApeEvent.E_VIDEO_DATA, videoReceivePdu.sessionId, videoReceivePdu.channelId, video_data); | 267 | // this._notify(RCApeEvent.E_VIDEO_DATA, videoReceivePdu.sessionId, videoReceivePdu.channelId, video_data); |
| 85 | - loger.log('视频消息处理 videoIncomingHandler.', video_data); | ||
| 86 | - this._emit(MessageTypes.VIDEO_RECEIVE, video_data); | ||
| 87 | - | 268 | + loger.log('视频消息处理 videoCommandHandler.', video_data); |
| 269 | + //this._emit(MessageTypes.VIDEO_RECEIVE, video_data); | ||
| 88 | } | 270 | } |
| 89 | 271 | ||
| 90 | tableUpdateHandler(owner, itemIdx, itemData) { | 272 | tableUpdateHandler(owner, itemIdx, itemData) { |
| 91 | // debugger; | 273 | // debugger; |
| 92 | - let videoChannelInfo = pdu['RCVideoChannelInfoRecordPdu'].decode(itemData); | ||
| 93 | - videoChannelInfo.owner = owner; | ||
| 94 | - videoChannelInfo.channelId = itemIdx; | ||
| 95 | - videoChannelInfo.status = owner === 0 ? ApeConsts.CGS_RELEASED : videoChannelInfo.status; | ||
| 96 | - | ||
| 97 | - loger.log('视频消息处理 tableUpdateHandler.',videoChannelInfo); | ||
| 98 | - | 274 | + let videoChannelInfo =this.unPackPdu(owner, itemIdx, itemData); |
| 275 | + //videoChannelInfo.owner = owner; | ||
| 276 | + //videoChannelInfo.channelId = itemIdx; | ||
| 277 | + //videoChannelInfo.status = owner === 0 ? ApeConsts.CHANNEL_STATUS_RELEASED : videoChannelInfo.status; | ||
| 278 | + //loger.log('视频消息处理 tableUpdateHandler.',videoChannelInfo); | ||
| 99 | this.videoChannels[itemIdx] = videoChannelInfo; | 279 | this.videoChannels[itemIdx] = videoChannelInfo; |
| 100 | - switch (videoChannelInfo.status) { | ||
| 101 | - case ApeConsts.CGS_RELEASED: | ||
| 102 | - case ApeConsts.CGS_PENDING: | ||
| 103 | - case ApeConsts.CGS_GRABBING: | 280 | + |
| 281 | +/* switch (videoChannelInfo.status) { | ||
| 282 | + case ApeConsts.CHANNEL_STATUS_RELEASED: | ||
| 104 | // 只能关闭自己的流 | 283 | // 只能关闭自己的流 |
| 105 | if (this.activeChannelId === videoChannelInfo.channelId) { | 284 | if (this.activeChannelId === videoChannelInfo.channelId) { |
| 106 | this.activeChannelId = 0; | 285 | this.activeChannelId = 0; |
| @@ -108,18 +287,22 @@ class VideoChat extends Ape { | @@ -108,18 +287,22 @@ class VideoChat extends Ape { | ||
| 108 | this.emitVideoChange(); | 287 | this.emitVideoChange(); |
| 109 | } | 288 | } |
| 110 | break; | 289 | break; |
| 111 | - case ApeConsts.CGS_OPENNED: | ||
| 112 | - this.activeChannelId = videoChannelInfo.channelId; | ||
| 113 | - // AMS | ||
| 114 | - if (this._classInfo.msType === '1') { | ||
| 115 | - this.activeURL = `http://dazhi.3mang.com/live/${this._classInfo.classId}/${this._classInfo.classId}_${videoChannelInfo.channelId}_flash_cam_mic_aac/playlist.m3u8`; | ||
| 116 | - }else { | ||
| 117 | - this.activeURL = `http://hls.3mang.com/live/${this._classInfo.classId}_${videoChannelInfo.channelId}_flash_cam_mic_aac/playlist.m3u8`; | ||
| 118 | - } | 290 | + case ApeConsts.CHANNEL_STATUS_OPENING: |
| 291 | + //_playUrl = "rtmfp://" + Config.mediaServerAddr + ":" + Config.mediaServerPort + "/message/" + _streamName; | ||
| 292 | + //_cdnUrl = "rtmp://" + Config.mediaCDNServerAddr + ":" + Config.mediaCDNServerPort + "/message/" + _streamName; | ||
| 293 | + //this.activeChannelId = videoChannelInfo.channelId; | ||
| 294 | + //// AMS/FMS | ||
| 295 | + //if (this._classInfo.msType ==ApeConsts.MS_TYPE_FMS) { | ||
| 296 | + // this.activeURL = `http://dazhi.3mang.com/live/${this._classInfo.classId}/${this._classInfo.classId}_${videoChannelInfo.channelId}_flash_cam_mic_aac/playlist.m3u8`; | ||
| 297 | + //}else { | ||
| 298 | + // this.activeURL = `http://hls.3mang.com/live/${this._classInfo.classId}_${videoChannelInfo.channelId}_flash_cam_mic_aac/playlist.m3u8`; | ||
| 299 | + //} | ||
| 119 | // 任何人都可以打开流 | 300 | // 任何人都可以打开流 |
| 120 | this.emitVideoChange(); | 301 | this.emitVideoChange(); |
| 121 | break; | 302 | break; |
| 122 | - } | 303 | + default: |
| 304 | + break; | ||
| 305 | + }*/ | ||
| 123 | } | 306 | } |
| 124 | 307 | ||
| 125 | emitVideoChange() { | 308 | emitVideoChange() { |
| @@ -129,6 +312,53 @@ class VideoChat extends Ape { | @@ -129,6 +312,53 @@ class VideoChat extends Ape { | ||
| 129 | }); | 312 | }); |
| 130 | }; | 313 | }; |
| 131 | 314 | ||
| 315 | + | ||
| 316 | + ///////数据的封包和解包///////////////////////////////////////// | ||
| 317 | + packPdu(_param,_itemIdx){ | ||
| 318 | + loger.log("VIDEO===packPdu "); | ||
| 319 | + //验证坐标点集合数组是否合法 | ||
| 320 | + if(_param==null||_itemIdx==null){ | ||
| 321 | + this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 322 | + return null; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + /* message RCVideoChannelInfoPdu { | ||
| 326 | + optional uint32 status = 1;//开启的状态 | ||
| 327 | + optional uint32 channel_id = 2;//唯一的频道id | ||
| 328 | + optional uint32 timestamp = 3;//更新的时间戳 | ||
| 329 | + optional uint32 from_node_id = 4;//发起者的id | ||
| 330 | + optional uint32 to_node_id = 5;//接收者的id,(如果是0,所有人都接收) | ||
| 331 | + }*/ | ||
| 332 | + | ||
| 333 | + //判断type类型,根据type设置不同的参数 | ||
| 334 | + let packPduModel =new pdu['RCVideoChannelInfoPdu']; | ||
| 335 | + packPduModel.status=ApeConsts.CHANNEL_STATUS_OPENING; | ||
| 336 | + packPduModel.channelId=_itemIdx; | ||
| 337 | + packPduModel.timestamp=EngineUtils.creatTimestamp(); | ||
| 338 | + packPduModel.fromNodeId =GlobalConfig.nodeId; | ||
| 339 | + packPduModel.toNodeId = 0; | ||
| 340 | + console.log(packPduModel); | ||
| 341 | + return packPduModel; | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + unPackPdu(owner, itemIdx,itemData){ | ||
| 345 | + loger.log("VIDEO==unPackPdu "); | ||
| 346 | + if(owner==null||itemIdx==null||itemData==null){ | ||
| 347 | + this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 348 | + return null; | ||
| 349 | + } | ||
| 350 | + try{ | ||
| 351 | + | ||
| 352 | + let videoChannelInfo = pdu['RCVideoChannelInfoPdu'].decode(itemData); | ||
| 353 | + loger.log(videoChannelInfo); | ||
| 354 | + return videoChannelInfo; | ||
| 355 | + }catch (err){ | ||
| 356 | + loger.log("VIDEO收到数据 unPackPdu Pdu解析错误,itemIdx="+itemIdx+" err:"+err.message); | ||
| 357 | + } | ||
| 358 | + return null; | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + | ||
| 132 | } | 362 | } |
| 133 | 363 | ||
| 134 | export default VideoChat; | 364 | export default VideoChat; |
| @@ -735,11 +735,12 @@ message RCAudioSendDataRequestPdu { | @@ -735,11 +735,12 @@ message RCAudioSendDataRequestPdu { | ||
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | message RCVideoSendDataRequestPdu { | 737 | message RCVideoSendDataRequestPdu { |
| 738 | - optional uint32 initiator = 1; | ||
| 739 | - required bool key_frame = 2; | ||
| 740 | - required uint32 sequence_id = 3; | ||
| 741 | - required uint32 slice_id = 4; | ||
| 742 | - required bytes user_data = 5; | 738 | + required uint32 initiator = 1; |
| 739 | + optional bool key_frame = 2; | ||
| 740 | + optional uint32 sequence_id = 3; | ||
| 741 | + optional uint32 slice_id = 4; | ||
| 742 | + optional bytes user_data = 5; | ||
| 743 | + optional uint32 action = 6; | ||
| 743 | } | 744 | } |
| 744 | 745 | ||
| 745 | message RCAudioChannelInfoRecordPdu { | 746 | message RCAudioChannelInfoRecordPdu { |
| @@ -750,6 +751,14 @@ message RCAudioChannelInfoRecordPdu { | @@ -750,6 +751,14 @@ message RCAudioChannelInfoRecordPdu { | ||
| 750 | required uint32 codec = 5; | 751 | required uint32 codec = 5; |
| 751 | } | 752 | } |
| 752 | 753 | ||
| 754 | +message RCVideoChannelInfoPdu { | ||
| 755 | + optional uint32 status = 1;//开启的状态 | ||
| 756 | + optional uint32 channel_id = 2;//唯一的频道id | ||
| 757 | + optional uint32 timestamp = 3;//更新的时间戳 | ||
| 758 | + optional uint32 from_node_id = 4;//发起者的id | ||
| 759 | + optional uint32 to_node_id = 5;//接收者的id,(如果是0,所有人都接收) | ||
| 760 | +} | ||
| 761 | + | ||
| 753 | message RCVideoChannelInfoRecordPdu { | 762 | message RCVideoChannelInfoRecordPdu { |
| 754 | optional uint32 status = 1; | 763 | optional uint32 status = 1; |
| 755 | optional uint32 device_id = 2; | 764 | optional uint32 device_id = 2; |
-
请 注册 或 登录 后发表评论