কম্পিউটার টিউটোরিয়াল

HTML5-এ createSignalingChannel() উদাহরণ

WebRTC ব্রাউজারগুলোর মাঝপথে পিয়ার-টু-পিয়ার কমিউনিকেশন অপেক্ষা করে। এই মেকানিজমে সিগন্যালিং, নেটওয়ার্ক ইনফো, সেশন কন্ট্রোল এবং মিডিয়া ইনফো প্রয়োজন। ওয়েব ডেভেলপার ব্রাউজারগুলোর মাঝপথে যোগাযোগের জন্য SIP বা XMPP বা যেকোনো টু-ওয়ে কমিউনিকেশন বেছে নিতে পারেন। createSignalingChannel() এর একটি উদাহরণ:

var signalingChannel = createSignalingChannel();
var pc;
var configuration = ...; // run start(true) to initiate a call
function start(isCaller) {
  pc = new RTCPeerConnection(configuration);
  // send any ice candidates to the other peer
  pc.onicecandidate = function(evt) {
    signalingChannel.send(JSON.stringify({ "candidate": evt.candidate }));
  };
  // once remote stream arrives, show it in the remote video element
  pc.onaddstream = function(evt) {
    remoteView.src = URL.createObjectURL(evt.stream);
  };
  // get the local stream, show it in the local video element and send it
  navigator.getUserMedia({ "audio": true, "video": true }, function(stream) {
    selfView.src = URL.createObjectURL(stream);
    pc.addStream(stream);
    if (isCaller)
      pc.createOffer(gotDescription);
    else
      pc.createAnswer(pc.remoteDescription, gotDescription);
    function gotDescription(desc) {
      pc.setLocalDescription(desc);
      signalingChannel.send(JSON.stringify({ "sdp": desc }));
    }
  });
}
signalingChannel.onmessage = function(evt) {
  if (!pc)
    start(false);
  var signal = JSON.parse(evt.data);
  if (signal.sdp)
    pc.setRemoteDescription(new RTCSessionDescription(signal.sdp));
  else
    pc.addIceCandidate(new RTCIceCandidate(signal.candidate));
};
  1. HTML5 IndexedDB উদাহরণ

  2. HTML5 Canvas Transformation

  3. জাভাস্ক্রিপ্ট Numbers উদাহরণ

  4. PHP-তে HTML-এ XML কীভাবে প্রদর্শন করবেন?