Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" href="my-styles.css">
- <script language="javascript" src="js/sip-0.11.6.min.js"></script>
- <script>
- var session; // aglobal variable for the user session
- var remoteVideo = document.getElementById('remoteVideo');
- var localVideo = document.getElementById('localVideo');
- //registration
- var userAgent = new SIP.UA({
- uri: 'test@10.10.30.10',
- transportOptions: {
- wsServers: ['ws://10.10.30.10:8090'],
- traceSip: true,
- iceCheckingTimeout: 35000,
- register: true,
- stunServers: [],
- turnServers: []
- },
- authorizationUser: 'test',
- password: 'xtend'
- });
- function createUserSession(userName,userAgent)
- {
- //send invitation
- session = userAgent.invite(userName, {
- media: {
- constraints: {
- audio: true,
- video: false
- }
- }
- });
- return session;
- }
- //create the user session
- function callUser()
- {
- session=createUserSession(document.getElementById('txtUserName').value,userAgent);
- }
- //accept invitation
- userAgent.on('invite', function(session) {
- alert('incoming call');
- session.accept();
- });
- //add media event
- session.on('trackAdded', function() {
- // We need to check the peer connection to determine which track was added
- var pc = session.sessionDescriptionHandler.peerConnection;
- // Gets remote tracks
- var remoteStream = new MediaStream();
- pc.getReceivers().forEach(function(receiver) {
- remoteStream.addTrack(receiver.track);
- });
- remoteVideo.srcObject = remoteStream;
- remoteVideo.play();
- // Gets local tracks
- var localStream = new MediaStream();
- pc.getSenders().forEach(function(sender) {
- localStream.addTrack(sender.track);
- });
- localVideo.srcObject = localStream;
- localVideo.play();
- });
- function endCall()
- {
- session.terminate();
- }
- </script>
- </head>
- <body>
- fsdfsafd
- <video id="remoteVideo"></video>
- <video id="localVideo" muted="muted"></video>
- <input type='text' id='txtUserName' value='test1@10.10.30.10'/>
- <button id="endCall" onclick="javascript:endCall();">End Call</button>
- <button id="callUser" onclick="callUser();">CAll User</button>
- </body>
- </html>
Add Comment
Please, Sign In to add comment