| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
| 4 <script type="text/javascript" src="webrtc_test_audio.js"></script> | 4 <script type="text/javascript" src="webrtc_test_audio.js"></script> |
| 5 <script type="text/javascript"> | 5 <script type="text/javascript"> |
| 6 $ = function(id) { | 6 $ = function(id) { |
| 7 return document.getElementById(id); | 7 return document.getElementById(id); |
| 8 }; | 8 }; |
| 9 | 9 |
| 10 window.onerror = function(errorMsg, url, lineNumber, column, errorObj) { | 10 window.onerror = function(errorMsg, url, lineNumber, column, errorObj) { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 // channel is closed. The test passes when the state transition completes. | 546 // channel is closed. The test passes when the state transition completes. |
| 547 function setupDataChannel(params) { | 547 function setupDataChannel(params) { |
| 548 var sendDataString = "send some text on a data channel." | 548 var sendDataString = "send some text on a data channel." |
| 549 firstDataChannel = gFirstConnection.createDataChannel( | 549 firstDataChannel = gFirstConnection.createDataChannel( |
| 550 "sendDataChannel", params); | 550 "sendDataChannel", params); |
| 551 assertEquals('connecting', firstDataChannel.readyState); | 551 assertEquals('connecting', firstDataChannel.readyState); |
| 552 | 552 |
| 553 // When |firstDataChannel| transition to open state, send a text string. | 553 // When |firstDataChannel| transition to open state, send a text string. |
| 554 firstDataChannel.onopen = function() { | 554 firstDataChannel.onopen = function() { |
| 555 assertEquals('open', firstDataChannel.readyState); | 555 assertEquals('open', firstDataChannel.readyState); |
| 556 if (firstDataChannel.reliable) { | 556 firstDataChannel.send(sendDataString); |
| 557 firstDataChannel.send(sendDataString); | |
| 558 } else { | |
| 559 sendDataRepeatedlyUntilClosed(firstDataChannel); | |
| 560 } | |
| 561 } | 557 } |
| 562 | 558 |
| 563 // When |firstDataChannel| receive a message, close the channel and | 559 // When |firstDataChannel| receive a message, close the channel and |
| 564 // initiate a new offer/answer exchange to complete the closure. | 560 // initiate a new offer/answer exchange to complete the closure. |
| 565 firstDataChannel.onmessage = function(event) { | 561 firstDataChannel.onmessage = function(event) { |
| 566 assertEquals(event.data, sendDataString); | 562 assertEquals(event.data, sendDataString); |
| 567 firstDataChannel.close(); | 563 firstDataChannel.close(); |
| 568 negotiate(); | 564 negotiate(); |
| 569 } | 565 } |
| 570 | 566 |
| 571 // When |firstDataChannel| transition to closed state, the test pass. | 567 // When |firstDataChannel| transition to closed state, the test pass. |
| 572 addExpectedEvent(); | 568 addExpectedEvent(); |
| 573 firstDataChannel.onclose = function() { | 569 firstDataChannel.onclose = function() { |
| 574 assertEquals('closed', firstDataChannel.readyState); | 570 assertEquals('closed', firstDataChannel.readyState); |
| 575 eventOccured(); | 571 eventOccured(); |
| 576 } | 572 } |
| 577 | 573 |
| 578 // Event handler for when |gSecondConnection| receive a new dataChannel. | 574 // Event handler for when |gSecondConnection| receive a new dataChannel. |
| 579 gSecondConnection.ondatachannel = function (event) { | 575 gSecondConnection.ondatachannel = function (event) { |
| 580 var secondDataChannel = event.channel; | 576 var secondDataChannel = event.channel; |
| 581 | 577 |
| 582 // When |secondDataChannel| receive a message, send a message back. | 578 // When |secondDataChannel| receive a message, send a message back. |
| 583 secondDataChannel.onmessage = function(event) { | 579 secondDataChannel.onmessage = function(event) { |
| 584 assertEquals(event.data, sendDataString); | 580 assertEquals(event.data, sendDataString); |
| 585 console.log("gSecondConnection received data"); | 581 console.log("gSecondConnection received data"); |
| 586 if (secondDataChannel.reliable) { | 582 assertEquals('open', secondDataChannel.readyState); |
| 587 // If we're reliable we will just send one message over the channel, | 583 secondDataChannel.send(sendDataString); |
| 588 // and therefore channel one's message handler cannot have shut us | |
| 589 // down already. | |
| 590 assertEquals('open', secondDataChannel.readyState); | |
| 591 secondDataChannel.send(sendDataString); | |
| 592 } else { | |
| 593 // If unreliable, this could be one in a series of messages and it | |
| 594 // is possible we already replied (which will close our channel). | |
| 595 sendDataRepeatedlyUntilClosed(secondDataChannel); | |
| 596 } | |
| 597 } | 584 } |
| 598 } | 585 } |
| 599 | |
| 600 // Sends |sendDataString| on |dataChannel| every 200ms as long as | |
| 601 // |dataChannel| is open. | |
| 602 function sendDataRepeatedlyUntilClosed(dataChannel) { | |
| 603 var sendTimer = setInterval(function() { | |
| 604 if (dataChannel.readyState == 'open') | |
| 605 dataChannel.send(sendDataString); | |
| 606 else | |
| 607 clearInterval(sendTimer); | |
| 608 }, 200); | |
| 609 } | |
| 610 } | 586 } |
| 611 | 587 |
| 612 // SCTP data channel setup is slightly different then RTP based | 588 // SCTP data channel setup is slightly different then RTP based |
| 613 // channels. Due to a bug in libjingle, we can't send data immediately | 589 // channels. Due to a bug in libjingle, we can't send data immediately |
| 614 // after channel becomes open. So for that reason in SCTP, | 590 // after channel becomes open. So for that reason in SCTP, |
| 615 // we are sending data from second channel, when ondatachannel event is | 591 // we are sending data from second channel, when ondatachannel event is |
| 616 // received. So data flow happens 2 -> 1 -> 2. | 592 // received. So data flow happens 2 -> 1 -> 2. |
| 617 function setupSctpDataChannel(params) { | 593 function setupSctpDataChannel(params) { |
| 618 var sendDataString = "send some text on a data channel." | 594 var sendDataString = "send some text on a data channel." |
| 619 firstDataChannel = gFirstConnection.createDataChannel( | 595 firstDataChannel = gFirstConnection.createDataChannel( |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 912 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
| 937 style="display:none"></canvas></td> | 913 style="display:none"></canvas></td> |
| 938 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 914 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
| 939 style="display:none"></canvas></td> | 915 style="display:none"></canvas></td> |
| 940 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 916 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
| 941 style="display:none"></canvas></td> | 917 style="display:none"></canvas></td> |
| 942 </tr> | 918 </tr> |
| 943 </table> | 919 </table> |
| 944 </body> | 920 </body> |
| 945 </html> | 921 </html> |
| OLD | NEW |