胡斌

get_rtmp_port,format default url with the rtmp port got

正在显示 1 个修改的文件 包含 41 行增加11 行删除
@@ -144,6 +144,7 @@ a:active { @@ -144,6 +144,7 @@ a:active {
144 var websocket; 144 var websocket;
145 var initload = true; 145 var initload = true;
146 var player; 146 var player;
  147 + var rtmp_port = 1935;
147 148
148 149
149 function testWebSocket() 150 function testWebSocket()
@@ -168,6 +169,12 @@ a:active { @@ -168,6 +169,12 @@ a:active {
168 wsState = "idle"; 169 wsState = "idle";
169 } 170 }
170 171
  172 + function playRTMPStream(url){
  173 + document.getElementById('inputURL').value = url;
  174 + queryParameters['source'] = url;
  175 + initialize();
  176 + }
  177 +
171 function onMessage(evt) 178 function onMessage(evt)
172 { 179 {
173 if(typeof(evt.data)=="string"){ 180 if(typeof(evt.data)=="string"){
@@ -183,8 +190,17 @@ a:active { @@ -183,8 +190,17 @@ a:active {
183 var result = dv.getUint16(0, true); 190 var result = dv.getUint16(0, true);
184 var byte_order = dv.getUint8(2, true); 191 var byte_order = dv.getUint8(2, true);
185 var data_len = dv.getUint32(4, true); 192 var data_len = dv.getUint32(4, true);
186 -  
187 - if(result == 83){//get camera sucess 193 +
  194 + if(0 == result){//mov_start success
  195 + playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ms");
  196 + }
  197 + else if(11 == result){//ss_start success
  198 + playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ss");
  199 + }
  200 + else if(55 == result){//ds_start success
  201 + playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/ds");
  202 + }
  203 + else if(result == 83){//get camera sucess
188 if(data_len > 4){ 204 if(data_len > 4){
189 var cam_num = dv.getUint32(8, true); 205 var cam_num = dv.getUint32(8, true);
190 var offset = 12; 206 var offset = 12;
@@ -228,18 +244,25 @@ a:active { @@ -228,18 +244,25 @@ a:active {
228 } 244 }
229 } 245 }
230 else if(85 == result){//cam_share success 246 else if(85 == result){//cam_share success
231 - document.getElementById('inputURL').value = "rtmp://127.0.0.1/live/cs";  
232 - queryParameters['source'] = "rtmp://127.0.0.1/live/cs";  
233 - initialise(); 247 + playRTMPStream("rtmp://127.0.0.1:" + rtmp_port + "/live/cs");
234 } 248 }
235 else if(95 == result){//get_videoparam success 249 else if(95 == result){//get_videoparam success
236 var data = new Uint8Array(evt.target.result, 8, evt.target.result.byteLength - 8 -1); 250 var data = new Uint8Array(evt.target.result, 8, evt.target.result.byteLength - 8 -1);
237 //var data_sting = new TextDecoder("utf-8").decode(data); 251 //var data_sting = new TextDecoder("utf-8").decode(data);
238 var data_sting = utf8to16(data); 252 var data_sting = utf8to16(data);
239 - var td = document.getElementById('videoparam');  
240 - td.value = data_sting; 253 + var input = document.getElementById('videoparam');
  254 + input.value = data_sting;
241 writeToScreen('<span style="color: blue;">get_videoparam result: ' + data_sting + ' </span>'); 255 writeToScreen('<span style="color: blue;">get_videoparam result: ' + data_sting + ' </span>');
242 } 256 }
  257 + else if(105 == result){//get_rtmp_port_success
  258 + var data = new Uint8Array(evt.target.result, 8, evt.target.result.byteLength - 8 -1);
  259 + //var data_sting = new TextDecoder("utf-8").decode(data);
  260 + var data_sting = utf8to16(data);
  261 + var input = document.getElementById('rtmp_port');
  262 + input.value = data_sting;
  263 + rtmp_port = data_sting;
  264 + writeToScreen('<span style="color: blue;">get_rtmp_port result: ' + data_sting + ' </span>');
  265 + }
243 else{ 266 else{
244 var data = new Uint8Array(evt.target.result, 8, evt.target.result.byteLength - 8); 267 var data = new Uint8Array(evt.target.result, 8, evt.target.result.byteLength - 8);
245 //var data_sting = new TextDecoder("utf-8").decode(data); 268 //var data_sting = new TextDecoder("utf-8").decode(data);
@@ -439,7 +462,9 @@ a:active { @@ -439,7 +462,9 @@ a:active {
439 cmd.data = utf16to8(param.value); 462 cmd.data = utf16to8(param.value);
440 cmd.data_len = cmd.data.length; 463 cmd.data_len = cmd.data.length;
441 } 464 }
442 - 465 + else if(obj.id == "get_rtmp_port"){
  466 + cmd.type = 52;
  467 + }
443 468
444 doSendWSCmd(cmd); 469 doSendWSCmd(cmd);
445 } 470 }
@@ -483,7 +508,7 @@ a:active { @@ -483,7 +508,7 @@ a:active {
483 player = document.getElementById(id); 508 player = document.getElementById(id);
484 } 509 }
485 510
486 - function initialise() 511 + function initialize()
487 { 512 {
488 function getUrlParam( name ) 513 function getUrlParam( name )
489 { 514 {
@@ -576,7 +601,7 @@ a:active { @@ -576,7 +601,7 @@ a:active {
576 function playStream() 601 function playStream()
577 { 602 {
578 queryParameters['source'] = document.getElementById('inputURL').value; 603 queryParameters['source'] = document.getElementById('inputURL').value;
579 - initialise(); 604 + initialize();
580 } 605 }
581 606
582 function checkbox(type) 607 function checkbox(type)
@@ -625,7 +650,7 @@ a:active { @@ -625,7 +650,7 @@ a:active {
625 output.innerHTML = ""; 650 output.innerHTML = "";
626 } 651 }
627 652
628 - initialise(); 653 + initialize();
629 654
630 </script> 655 </script>
631 656
@@ -682,6 +707,11 @@ a:active { @@ -682,6 +707,11 @@ a:active {
682 <tr> 707 <tr>
683 <td width="800" height="300" background="images/upperright_03.gif"> 708 <td width="800" height="300" background="images/upperright_03.gif">
684 <table width="510" border="0" cellspacing="0" cellpadding="0"> 709 <table width="510" border="0" cellspacing="0" cellpadding="0">
  710 + <tr>
  711 + <td width="35" colspan="2"><img src="images/spacer.gif" width="20" height="10" /></td>
  712 + <td colspan="3"><button type="button" id="get_rtmp_port" onclick="onTestClick(this)">get_rtmp_port</button></td>
  713 + <td colspan="3"><input id="rtmp_port" width="400"/></td>
  714 + </tr>
685 <tr> 715 <tr>
686 <td width="35" colspan="2"><img src="images/spacer.gif" width="20" height="10" /></td> 716 <td width="35" colspan="2"><img src="images/spacer.gif" width="20" height="10" /></td>
687 <td colspan="3"><button type="button" id="ss_start" onclick="onTestClick(this)">ss_start</button></td> 717 <td colspan="3"><button type="button" id="ss_start" onclick="onTestClick(this)">ss_start</button></td>