versatica/JsSIP — pull request #118 by frisb (2013-06-27 13:40:39+00:00)
Title: Added JsSIP.WebRTC.cacheUserMedia flag so that mic / camera access is only requested once

## Caching User Media

This simple modification resolves 2 key issues:

#### 1. Allow user media (camera / mic) access to only be requested once by the browser.

``` js
var configuration = {
'ws_servers': 'ws://sip-ws.example.com',
'uri': 'sip:alice@example.com',
'password': 'superpassword'
};

var coolPhone = new JsSIP.UA(configuration);

/* coolPhone EventHandlers wired up here */

// cache user media
JsSIP.WebRTC.cacheUserMedia = true;

coolPhone.start();

```
---
#### 2. Allow user media access to be requested outside of an RTCSession

``` js

// caching can be toggled on / off at any time during browser session
JsSIP.WebRTC.cacheUserMedia = true;

JsSIP.WebRTC.getUserMedia({ audio: true, video: true }, function (stream) {
console.log('got local media already');
console.log(stream);
}, function (e) {
console.log(e);
});

```