Presentation is loading. Please wait.

Presentation is loading. Please wait.

MediaStream ● Overview ● Definitions ● getUserMedia() ● Recording ● Cloning/composition.

Similar presentations


Presentation on theme: "MediaStream ● Overview ● Definitions ● getUserMedia() ● Recording ● Cloning/composition."— Presentation transcript:

1 MediaStream ● Overview ● Definitions ● getUserMedia() ● Recording ● Cloning/composition

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

3 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

4 MediaStream - Discussion ● Immutable MediaStream objects ● Track enabling/disabling ● B-side behavior if A-side disables a track ● Muted vs. disabled ● Should a multi-track MediaStream “end” if the user physically disconnects a camera? ●...

5 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)

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

7 getUserMedia() - Discussion ● What happens if the user doesn't (or cannot) grant permission to all requested media types? ● Behavior if MediaStreamOptions is null ●...

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

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

10 Recording - Discussion ● 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 ●...

11 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.

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

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

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

15 Cloning/composition - Discussion ● Synchronization ●...


Download ppt "MediaStream ● Overview ● Definitions ● getUserMedia() ● Recording ● Cloning/composition."

Similar presentations


Ads by Google