Git Product home page Git Product logo

Comments (8)

silviapfeiffer avatar silviapfeiffer commented on July 20, 2024

As long as you keep quickconnect as a JS API and glue as a HTML API, any required changes for interoperability make sense to me. :-)

from rtc-quickconnect.

DamonOehlman avatar DamonOehlman commented on July 20, 2024

Just made some tweaks to the examples in a branch to give a feel for what the API might look like:

diff

And here is the updated code from the conference example:

var quickconnect = require('rtc-quickconnect');
var crel = require('crel');

// create containers for our local and remote video
var local = crel('div', { class: 'local' });
var remote = crel('div', { class: 'remote' });
var peerMedia = {};

quickconnect('http://rtc.io/switchboard/', { ns: 'dctest' })
  // add some media (use rtc-captureclass) to configure the stream
  .addMedia('camera:0 min:1280x768', function(err, media) {
    media.render(local);
  })
  // when a peer is connected (and active) pass it to us for use
  .on('peer:connect', function(pc, id, data) {
    // render the remote streams
    pc.getRemoteStreams().forEach(renderRemote(id));
  })
  // when a peer leaves, remove teh media
  .on('peer:leave', function(id) {
    // remove media for the target peer from the dom
    (peerMedia[id] || []).splice(0).forEach(function(el) {
      el.parentNode.removeChild(el);
    });
  })

// render a remote video
function renderRemote(id) {
  // create the peer media list
  peerMedia[id] = peerMedia[id] || [];

  return function(stream) {
    peerMedia[id] = peerMedia[id].concat(media(stream).render(remote));
  }
}

/* extra code to handle dynamic html and css creation */

// add some basic styling
document.head.appendChild(crel('style', [
  '.local { position: absolute;  right: 10px; }',
  '.local video { max-width: 200px; }'
].join('\n')));

// add the local and remote elements
document.body.appendChild(local);
document.body.appendChild(remote);

from rtc-quickconnect.

DamonOehlman avatar DamonOehlman commented on July 20, 2024

Reworked the conference example again, I think it makes sense to keep rtc-media decoupled from rtc-quickconnect. Primarily because it means people can add media streams however they managed to capture them.

Updated sample code:

var quickconnect = require('rtc-quickconnect');
var media = require('rtc-media');
var crel = require('crel');

// create containers for our local and remote video
var local = crel('div', { class: 'local' });
var remote = crel('div', { class: 'remote' });
var media  
var peerMedia = {};

// capture local media
var localMedia = media();

// once media is captured, connect
localMedia.once('capture', function(stream) {
  quickconnect('http://rtc.io/switchboard/', { ns: 'dctest' })
    // broadcast our captured media to other participants in the room
    .broadcast(stream)
    // when a peer is connected (and active) pass it to us for use
    .on('peer:connect', function(pc, id, data) {
      // render the remote streams
      pc.getRemoteStreams().forEach(renderRemote(id));
    })
    // when a peer leaves, remove teh media
    .on('peer:leave', function(id) {
      // remove media for the target peer from the dom
      (peerMedia[id] || []).splice(0).forEach(function(el) {
        el.parentNode.removeChild(el);
      });
    })
});

// render the local media
localMedia.render(local);

// render a remote video
function renderRemote(id) {
  // create the peer media list
  peerMedia[id] = peerMedia[id] || [];

  return function(stream) {
    peerMedia[id] = peerMedia[id].concat(media(stream).render(remote));
  }
}

/* extra code to handle dynamic html and css creation */

// add some basic styling
document.head.appendChild(crel('style', [
  '.local { position: absolute;  right: 10px; }',
  '.local video { max-width: 200px; }'
].join('\n')));

// add the local and remote elements
document.body.appendChild(local);
document.body.appendChild(remote);

from rtc-quickconnect.

DamonOehlman avatar DamonOehlman commented on July 20, 2024

Conferencing example working as at 8a674f9 - only tested between Chrome 31 and Firefox 26 on Debian at this stage though.

from rtc-quickconnect.

silviapfeiffer avatar silviapfeiffer commented on July 20, 2024

Yes, please keep rtc-media separate - many people just want to use the camera input and not a peerconnection, so this is useful by itself.

from rtc-quickconnect.

DamonOehlman avatar DamonOehlman commented on July 20, 2024

That wasn't really what I meant... it's just more that rtc-media isn't in the dependency tree of quickconnect. rtc-media will most definitely remain separate and usable in it's own right :)

from rtc-quickconnect.

DamonOehlman avatar DamonOehlman commented on July 20, 2024

Though after re-reading my comment I can see how you got the impression it would be merged in...

from rtc-quickconnect.

DamonOehlman avatar DamonOehlman commented on July 20, 2024

Done - 0.8.1 released and working nicely with FF.

from rtc-quickconnect.

Related Issues (20)

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.