Presentation is loading. Please wait.

Presentation is loading. Please wait.

MediaStream ● Definitions ● Common operations with example code (recording, cloning,...) ● Topics for discussion ● I prepared a few ● Suggestions from.

Similar presentations


Presentation on theme: "MediaStream ● Definitions ● Common operations with example code (recording, cloning,...) ● Topics for discussion ● I prepared a few ● Suggestions from."— Presentation transcript:

1 MediaStream ● Definitions ● Common operations with example code (recording, cloning,...) ● Topics for discussion ● I prepared a few ● Suggestions from the WG

2 Definitions (API level) ● MediaStream ● Represents stream of media data ● High-level – platform managed for performance ● Contains a list of tracks ● May end ● MediaStreamTrack ● Can consist of multiple channels of parallel data (5.1 audio) ● An instance can only belong to one MediaStream ● Can be enabled or disabled

3 Overview MediaStream MediaStreamTrackList MediaStreamTrack... 0..n tracks audio tracks precede video tracks a track can either be enabled or disabled

4 getUserMedia() ● Requires user consent to produce a LocalMediaStream object ● Arguments ● Options object (nullable) ● Success callback (nullable) ● Error callback (nullable) ● Example: Request an audio/video stream and show a self-view (no error handling)

5 getUserMedia() - Example navigator.getUserMedia({"audio": true, "video": true}, successCallback); function successCallback(stream) { // show the stream selfView.src = URL.createObjectURL(stream); }

6 Recording ● API entry point: MediaStream.record() ● MediaStreamRecorder ● getRecordedData(cb) - callback to retrieve recorded data ● Example: Record five seconds of a MediaStream

7 Recording - Example var recorder = stream.record(); setTimeout(function () { recorder.getRecordedData(blobCallback); }, 5000); function blobCallback(blob) {... }

8 Recording – Issues ● getRecordedData() can be called multiple times ● UA must continue to record until the MediaStream ends ● Developer can not dispose a MediaStreamRecorder without ending the corresponding MediaStream ● Old recording approach ● Possible to stop a MediaStreamRecorder ● Synchronous data retrieval may be problematic

9 Cloning ● Use the MediaStream() constructor ● Why? ● Create new MediaStream objects (without prompting user) ● Example: Clone a MediaStream to show the original in a self-view, and send the clone over a PeerConnection.

10 Cloning - Example var streamClone = new MediaStream(stream.tracks); selfView.src = URL.createObjectURL(stream); peerConn.addStream(streamClone); // toggle video off streamClone.tracks[1].enabled = false;

11 Composition ● Again, use the MediaStream() constructor ● Example: Record the audio conversation in a p2p conference with two peers to a single file.

12 Composition - Example var combinedAudioStream = new MediaStream( peerConn.localStreams[0], peerConn.remoteStreams[0]); var recorder = combinedAudioStream.record();

13 Topics for Discussion ● What happens if the user doesn't (or cannot) grant permission to all requested media types? ● Immutable MediaStream objects ● B-side behavior if A-side disables a track ● Should a multi-track MediaStream “end” if the user physically disconnects a camera? ● Recording ●...


Download ppt "MediaStream ● Definitions ● Common operations with example code (recording, cloning,...) ● Topics for discussion ● I prepared a few ● Suggestions from."

Similar presentations


Ads by Google