GithubHelp home page GithubHelp logo

elmarti / meteor-video-chat Goto Github PK

View Code? Open in Web Editor NEW
33.0 10.0 8.0 602 KB

Simple id based video calling in meteor

Home Page: https://atmospherejs.com/elmarti/video-chat

License: MIT License

JavaScript 100.00%
meteor meteor-video-chat video webrtc peer-to-peer angular react blaze tdd

meteor-video-chat's Introduction

UNMAINTAINED - i can review PRs, but I don't work with Meteor anymore and would not recommend this solution

Meteor Video Chat

This extension allows you to implement user-to-user video calling in React, Angular and Blaze. This package now uses RTCFly

Example with React

Click here for the React example source code.

Example with Blaze

Click here for the Blaze example source code.

Stories in Ready Travis CI Maintainability

A note on previous versions

Meteor Video Chat used to use Meteor.VideoCallServices, however we have moved to a more modular system, opting for ES6 imports like so:

import { VideoCallServices } from 'meteor/elmarti:video-chat'; Old style code will be supported for the forseeable future, but we suggest moving over to the new format.

Usage with asteroid

The Meteor Video Chat client can be used by first running npm install meteor-video-chat, and then using the following mixin import


import { AsteroidVideoChatMixin } from 'meteor-video-chat';

After including this as an Asteroid mixin, as per the Asteroid page, you can access it like so:

    Asteroid.VideoCallServices;

init

Here you can set the RTCConfiguration. If you are testing outside of a LAN, you'll need to procure some STUN & TURN servers.

VideoCallServices.init({'iceServers': [{
    'urls': 'stun:stun.example.org'
  }]
});

Calling a user

To call a user, use the following method.

VideoCallServices.call(ICallParams);

These are the parameters that can be used:

interface ICallParams {
    id:string; //ID of the callee
    localElement: IHTMLMediaElement; //local HTMLElement
    remoteElement: IHTMLMediaElement; //remote HTMLElement
    video:boolean; //Do you want to show video?
    audio:boolean; //Do you want to show audio?
}

Deciding who can connect to whom

The follow method can be overridden on the server side to implement some kind of filtering. Returning false will cancel the call, and true will allow it to go ahead.

VideoCallServices.checkConnect = function(caller, target){
return *can caller and target call each other"
};

Answering a call

The first step is to handle the onReceiveCall callback and then to accept the call. The answerCall method accepts the ICallParams interfaces, just like the "call" method above

 VideoCallServices.onReceiveCall = (userId) => {
        VideoCallServices.answerCall(ICallParams);
 };

Muting local or remote videos

VideoCallServices.toggleLocalAudio();
VideoCallServices.toggleRemoteAudio();

Application state

The following values are stored in a reactive var

localMuted:boolean, 
remoteMuted:boolean, 
ringing:boolean,
inProgress:boolean

Getting the state

VideoCallServices.getState("localMuted");

Accessing the video (HTMLMediaElement) elements

const localVideo = VideoCallServices.getLocalVideo();
const remoteVideo = VideoCallServices.getRemoteVideo();

Ending call

Simply call

VideoCallServices.endCall();

Other events

The following method is invoked when the callee accepts the call.

VideoCallServices.onTargetAccept = () => {
}

The following method is invoked when either user ends the call

VideoCallServices.onTerminateCall = () => {
}

The following method invoked when the RTCPeerConnection instance has been created, making it possible to consitently mutate it or add a data channel

VideoCallServices.onPeerConnectionCreated = () => {
}

The following method is invoked on the caller browser when the callee rejects the call

VideoCallServices.onCallRejected = () => {
    
}

The following method is invoked on both the client and server whenever an error is caught. User is only passed on the server

VideoCallServices.setOnError(callback);

The onError section can also be used for handling errors thrown when obtaining the user media (Webcam/audio). See here for more info, or checkout the example.

This project is sponsored by the following:

BrowserStack

Sentry.io

meteor-video-chat's People

Contributors

elmarti avatar flaviouk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meteor-video-chat's Issues

Code smell in ICE candidate exchange process

Certain devices never seem to receive ICE candidates and it unclear as to why. The WebRTC spec needs to be reviewed and the exchange process needs to be checked to ensure that ICE candidate exchanges are not being blocked by synchronous user interaction.

TESTING: Improve travis.yml

At present the travis.yml file is generic and does not run the specific tests required for this package. The file should allow for integration/acceptance testing using headless browsers and BrowserStack Automate.

Make ICE exchange process more resilient

DOMException: Error processing ICE candidate is inconsistently thrown on a number of platforms, causing the ICE exchange process to break. I need to check the format of ICE candidates across browsers as some use different object types, for example the sdp value is set instead of candidate.

ICE exchange format issue

ICE candidates are exchanged by using DDP to replicate a websocket based system. This was functional at first, however it was based on populating an array of ICE candidates with 'seen' flags. This worked however it was inefficient due to DDP emitting the entire array every time an ICE candidate was added for exchange. This has been altered to simply set the appropriate field as the value of the ICE candidate when the onicecandidate event is fired, which initially worked well, but errors have arised from the emergent system. This needs to be reviewed and tested.

ICE Failed - ice state change failed

Hi elmarti,

Thanks for the good work done packaging webrtc for meteor, the basic are very useful.
I'm testing a basic video chat app and I'm having an ICE Failed error.
Attached you will find my code : a basic html template - and the js that i'm using.
If you had any idea of what the issue might be it would be of great help.
Many Thanks,
Gaël

videoApp.txt

getUserMedia must be injected

In the next Alpha of CoreRTC, getUserMedia needs to be injected into the client initialisation with the other WebRTC methods.

Doesn't play well with large apps

At present, reactive events are registered in body.onRendered, however this seems to cause lots of issues with scope and unpredictable functionality. Need to devise a way to define where the functionality is called.

Exception in queued tasks

Ok, everything works now, I wasn't loading my template the right way.. lol
I'm getting this Exception console.log on server restart:

I20160710-12:01:31.405(-5)? Exception in queued task: Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
I20160710-12:01:31.406(-5)? at AccountsServer.userId (packages/accounts-base/accounts_server.js:82:13)
I20160710-12:01:31.406(-5)? at Object.Meteor.userId (packages/accounts-base/accounts_common.js:237:19)
I20160710-12:01:31.406(-5)? at Object.removed (packages/elmarti:video-chat-custom/services/server.js:51:39)
I20160710-12:01:31.406(-5)? at [object Object].observeChangesCallbacks.removed (packages/minimongo/observe.js:169:1)
I20160710-12:01:31.407(-5)? at self.applyChange.removed (packages/minimongo/observe.js:71:1)
I20160710-12:01:31.407(-5)? at packages/mongo/observe_multiplex.js:183:30
I20160710-12:01:31.409(-5)? at Function..each..forEach (packages/underscore/underscore.js:108:1)
I20160710-12:01:31.410(-5)? at Object.task (packages/mongo/observe_multiplex.js:177:9)
I20160710-12:01:31.410(-5)? at [object Object]._.extend._run (packages/meteor/fiber_helpers.js:147:1)
I20160710-12:01:31.412(-5)? at packages/meteor/fiber_helpers.js:125:1

Still works, but im not sure if I should be worried about that..
Also I get onaddstream is deprecated! Use peerConnection.ontrack instead. on firefox console

Improved cross-browser compatibility

At present, the system relies on basic polyfills to support a wider array of browsers, however it has been decided that a dedicated package should be used to ensure functionality across all compatible browsers.

Remove "Session" dependency

3 reasons: This package was removed from the core in 1.3, I opted for it due to my lack of understanding of meteor at the time and it is unnecessary to store the data in the global scope.

meteor-video-chat-example displays a blank page

Hi elmarti,
i'm currently testing meteor-video-chat 1.2.0
I downloaded meteor-video-chat-example to test it in my local meteor installation. I'm surprised because i just have a blank page. I also notice that there is only a header page in the directory.
In the version 0.4.13, there was a easy useful example.
Can you direct me on how to use this lastest version, in order to produce an app similar to the one you hosted on https://meteorvideochat.herokuapp.com/ ?
Thanks

Stream issue when using Edge.

When using Edge, the set up process stalls at point at which the ICE candidates and SDP are to be passed over the stream. No error is logged at the code in Rocket Chat Streamer seems to execute as expected. I couldn't see a WebSocket stream for Edge, leading me to believe that it's using its HTTP fallback.

broadcasting ...

Elmarti : Is brodcasting anywhere in your future plans ? Even though you are doing person to person video in this package , I need to broadcast audio only. Any suggestion ? ie an admin broadcast his microphone to all connected clients .

Thanks
Tom

Better handling of rejections

There should be a set of uniform errors for handling particular kinds of rejection, such as there being no media devices or the media devices being busy etc.

System wide error callback

Add callbacks on server and client to capture all errors. Client callback should be triggered by server errors invoked by the user and the server side one should take the userId as a parameter.

Testing System

Unit/Tests must be written, along with a establishing a project protocol for testing across browser and front-end frameworks.

Display video call on a new window browser

Hi elmarti,
great job!

I'm building a video chat app using meteor-video-chat. All is ok with Modal (i'm still using version 0.4.13 ).
My aim is to display the video call in a new window browser ( with window.open() function ) like on facebook web video call system (it uses webrtc).

fb 1-compressed

I'm able to display the new window video call on the caller side; but not on the callee side.
Do you have any advise on how to do this?
Thanks.

Wiki

I will create an extensive wiki to guide the integration of this project.

Firefox 47 Possible bug?

Hey, so my stream is showing in chrome, but it doesn't work in the latest version of Firefox..
all i'm doing is:
Meteor.VideoCallServices.setLocalWebcam( 'myCamera' ); Meteor.VideoCallServices.loadLocalWebcam( true );

Other than that, I love this package! ;)

pause() and play() break reconnect process

As part of #48 it has been discovered that there are cross browser issues calling .pause() in relation to the async play() which causes the reconnection process to break.

A polyfill should be written to encapsulate the video objects and ensure that there is a consistent way to play, pause and change the stream seamlessly.

Session not defined?

I got this error when Im about to make a call:
ReferenceError: Session is not defined at _class.callRemote
I've looked at your code and can't find the Session variable declaration

Improve error logging

The error logging isn't great, there will need to be some breaking changes in the near future to make it more uniform. The key issues are that for some reason, it was decided that the onError callback would take 1 (2 on server) extra parameters - data and user. These are unnecessary as data can be passed in the Error object and the user can always be obtained from Meteor.user(). I believe that there was going to be some reactive code that wouldn't have this object set, but it has now emerged that this will always be available.

Use version 0.4.7

A complete rebuild of the video chat system is underway, I will not be developing the current design further. I aim to have a beta up this month, but until then use 0.4.7

Add reconnect attempts

As discovered in #46, the example app never seems to connect first time, but often does after a few tries. The previous Blaze specific version of the application used to reconnect when the ICEConnectionState was failed, which seemed to work most of the time and this should be repeated for this version.

Acceptance criteria

  • Developer can specify number of retry attempts before failing the call.
  • When Ice fails it should start the calling process over again until it has done it X amount of times.

Lock browser calling

When a particular browser receives a call, it should be the only one that subscribes to the data stream and triggers the onTerminateCall callback.

Stop empty objects from being parsed as RTCIceCandidates

   if( stream_data.candidate ){
                        if( typeof stream_data.candidate == "string")
                            stream_data.candidate = JSON.parse(stream_data.candidate);
                        const candidate = new RTCIceCandidate(stream_data.candidate);
                        if(this.peerConnection)
                            this.peerConnection.addIceCandidate(candidate).catch(err => {
                                this.onError(err, stream_data);
                            });
                    }

ICE exchange format issue

Ice candidates are not being transferred in the correct format, making connections outside of LAN impossible. I will debug in 14 hours time.

TESTING: Create cross browser testing system

Using browser stack and selenium create automated tests which follow the critical path of the extension. This should identify common cross-browser issues such as RTC typing issues and missing polyfills.

onError not working server side.

Discovered whilst fixing #39

Due to the way in which method calls are bound by Meteor.methods, it has made it hard to assign the onError method, the way in which was assumed would work.

I believe this is owed to the MVP being built in a waterfall fashion and the current lack of a testing system.

At present, the README says that a user should set the following

Meteor.VideoCallServices.onError = (err, data, user) => {
}```

however Meteor.VideoCallServices is currently undefined on the server side. 

The solution is to create this as an object literal with the onError method inside it. The Meteor methods can reference this directly because `this.onError` appears to no be possible as the method calls are bound to the `Meteor` object and not the `services` object. 

Improve defensive programming.

Situations like this (Where the user has jiggled into an odd state) should trigger some sort of callback.

TypeError: Cannot read property 'addIceCandidate' of undefined
  at n.<anonymous> (/69302e3cbf2e0da797ecf091567b0ab0cec68b05.js:135:3811)
  at None (/69302e3cbf2e0da797ecf091567b0ab0cec68b05.js:123:927)
  at Array.forEach (<anonymous>)
  at n.e [as emit] (/69302e3cbf2e0da797ecf091567b0ab0cec68b05.js:123:898)
  at t.<anonymous> (/69302e3cbf2e0da797ecf091567b0ab0cec68b05.js:123:3517)
...
(12 additional frame(s) were not displayed)

Support for mobile

Hi,
is there going to be support for device video access via Cordova?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.