`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`WebRTC 1.0: Real-time Communication Between Browsers
`W3C Working Draft 27 October 2011
`
`This version:
`http://www.w3.org/TR/2011/WD-webrtc-20111027/
`Latest published version:
`http://www.w3.org/TR/webrtc/
`Latest editor's draft:
`http://dev.w3.org/2011/webrtc/editor/webrtc.html
`Previous version:
`none
`Editors:
`Adam Bergkvist, Ericsson
`Daniel C. Burnett, Voxeo
`Cullen Jennings, Cisco
`Anant Narayanan, Mozilla
`
`Initial Author of this Specification was Ian Hickson, Google Inc., with the following copyright statement:
`© Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA. You are granted a license to use,
`reproduce and create derivative works of this document.
`
`All subsequent changes since 26 July 2011 done by the W3C WebRTC Working Group are under the following Copyright:
`© 2011 W3C® (MIT, ERCIM, Keio), All Rights Reserved. Document use rules apply.
`
`For the entire publication on the W3C site the liability and trademark rules apply.
`
`Abstract
`
`This document defines a set of APIs that allow local media, including audio and video, to be requested
`from a platform, media to be sent over the network to another browser or device implementing the
`appropriate set of real-time protocols, and media received from another browser or device to be
`processed and displayed locally. This specification is being developed in conjunction with a protocol
`specification developed by the IETF RTCWEB group.
`Status of This Document
`
`This section describes the status of this document at the time of its publication. Other documents may
`supersede this document. A list of current W3C publications and the latest revision of this technical
`report can be found in the W3C technical reports index at http://www.w3.org/TR/.
`
`This document is a First Public Working Draft and is not complete. It is subject to major changes and,
`while early experimentations are encouraged, it is therefore not intended for implementation. The API is
`based on preliminary work done in the WHATWG. The Web Real-Time Communications Working Group
`expects this specification to evolve significantly based on:
`
`The outcomes of ongoing exchanges in the companion RTCWEB group at IETF to define the set of
`protocols that, together with this document, will enable real-time communications in Web browsers.
`Privacy issues that arise when exposing local capabilities and local streams.
`This version is outdated!
`Technical discussions within the group, on the data channel in particular.
`For the latest version, please look at https://www.w3.org/TR/webrtc/.
`Experience gained through early experimentations.
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`1/28
`
`▴ expand
`
`IPR2024-01305
`SportsCastr Inc. EX-2025
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`Feedback received from other groups and individuals.
`
`As the specification matures, the group hopes to strike the right balance between a low-level API that
`would enable interested parties to tweak potentially complex system parameters, and a more high-level
`API that Web developers can use without a priori technical knowledge about real-time communications.
`
`This document was published by the Web Real-Time Communications Working Group as a Working
`Draft. This document is intended to become a W3C Recommendation. If you wish to make comments
`regarding this document, please send them to public-webrtc@w3.org (subscribe, archives). All feedback
`is welcome.
`
`Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft
`document and may be updated, replaced or obsoleted by other documents at any time. It is
`inappropriate to cite this document as other than work in progress.
`
`This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C
`maintains a public list of any patent disclosures made in connection with the deliverables of the group;
`that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a
`patent which the individual believes contains Essential Claim(s) must disclose the information in
`accordance with section 6 of the W3C Patent Policy.
`Table of Contents
`
`1. Introduction
`2. Obtaining local multimedia content
`2.1 Definition
`2.1.1 NavigatorUserMedia
`2.1.1.1 Methods
`2.1.2 MediaStreamOptions
`2.1.2.1 Attributes
`2.1.3 NavigatorUserMediaSuccessCallback
`2.1.3.1 Methods
`2.1.4 NavigatorUserMediaError and NavigatorUserMediaErrorCallback
`2.1.4.1 Attributes
`2.1.4.2 Constants
`2.1.4.3 Methods
`2.2 Examples
`3. Stream API
`3.1 Introduction
`3.2 Interface definitions
`3.2.1 MediaStream
`3.2.1.1 Attributes
`3.2.1.2 Methods
`3.2.1.3 Constants
`3.2.2 LocalMediaStream
`3.2.2.1 Methods
`3.2.3 MediaStreamTrack
`3.2.3.1 Attributes
`3.2.4 MediaStreamRecorder
`3.2.4.1 Methods
`3.2.5 BlobCallback
`3.2.5.1 Methods
`3.2.6 URL
`3.2.6.1 Methods
`3.3 Examples
`4. Peer-to-peer connections
`4.1 PeerConnection
`4.1.1 Attributes
`4.1.2 Methods
`4.1.3 Constants
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`2/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`4.2 SignalingCallback
`4.2.1 Methods
`4.3 Examples
`5. The data stream
`6. Garbage collection
`7. Event definitions
`7.1 MediaStreamEvent
`7.1.1 Attributes
`7.1.2 Methods
`8. Event summary
`9. application/html-peer-connection-data
`A. Acknowledgements
`B. References
`B.1 Normative references
`B.2 Informative references
`1. Introduction
`
`This section is non-normative.
`
`There are a number of facets to video-conferencing in HTML:
`
`Getting a multimedia stream (video, audio, or both) from local devices (video cameras,
`microphones, Web cams) or from prerecorded files provided by the user.
`Recording such streams locally.
`Connecting to remote peers using NAT-traversal technologies such as ICE, STUN, and TURN.
`Sending the locally-produced streams to remote peers and receiving streams from remote peers.
`Displaying such streams (both the locally-produced ones and the remotely-obtained ones) locally
`using the video or audio elements.
`Sending arbitrary data to remote peers.
`
`This document defines the APIs used for these features. This specification is being developed in
`conjunction with a protocol specification developed by the IETF RTCWEB group.
`2. Obtaining local multimedia content
`
`2.1 Definition
`
`2.1.1 NavigatorUserMedia
`
`WebIDL
`
`[NoInterfaceObject]
`interface NavigatorUserMedia {
` void getUserMedia (MediaStreamOptions? options, NavigatorUserMediaSuccessCallback?
`successCallback, optional NavigatorUserMediaErrorCallback? errorCallback);
`};
`
`2.1.1.1 Methods
`
`getUserMedia
`Prompts the user for permission to use their Web cam or other video or audio input.
`
`The options argument is an object of type MediaStreamOptions. The object can contain the
`following boolean properties:
`
`"audio"
`The provided media needs to include audio data.
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`3/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`"video"
`The provided media needs to include video data.
`
`If the user accepts, the successCallback is invoked, with a suitable LocalMediaStream object as
`its argument.
`
`If the user declines, the errorCallback (if any) is invoked.
`
`When the getUserMedia() method is called, the user agent must run the following steps:
`
`1. Let options be the method's first argument.
`
`2. Let successCallback be the callback indicated by the method's second argument.
`
`3. Let errorCallback be the callback indicated by the method's third argument, if any, or null
`otherwise.
`
`4. If successCallback is null, abort these steps.
`
`5. Let audio be true.
`
`6. Let video be true.
`
`7. If the audio property in options is present and set to false, let audio be false.
`
`8. If the video property in options is present and set to false, let video be false.
`
`9. If both audio and video are still false, then throw a NOT_SUPPORTED_ERR exception and abort
`these steps.
`
`10. Return, and run the remaining steps asynchronously.
`
`11. Optionally, e.g. based on a previously-established user preference, for security reasons,
`or due to platform limitations, jump to the step labeled failure below.
`
`12. Prompt the user in a user-agent-specific manner for permission to provide the entry
`script's origin with a LocalMediaStream object representing a media stream.
`
`If audio is true, then the provided media should include an audio track. If audio is false,
`then the provided media must not include an audio track.
`
`If video is true, then the provided media should include a video track. If video is false,
`then the provided media must not include a video track.
`
`User agents are encouraged to default to using the user's primary or system default
`camera and/or microphone (as appropriate) to generate the media stream. User agents
`may allow users to use any media source, including pre-recorded media files.
`
`User agents may wish to offer the user more control over the provided media. For
`example, a user agent could offer to enable a camera light or flash, or to change settings
`such as the frame rate or shutter speed.
`
`If the user grants permission to use local recording devices, user agents are encouraged
`to include a prominent indicator that the devices are "hot" (i.e. an "on-air" or "recording"
`indicator).
`
`If the user denies permission, jump to the step labeled failure below. If the user never
`responds, this algorithm stalls on this step.
`
`13. Let stream be the LocalMediaStream object for which the user granted permission.
`
`14. Queue a task to invoke successCallback with stream as its argument.
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`4/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`15. Abort these steps.
`
`16. Failure: If errorCallback is null, abort these steps.
`
`17. Let error be a new NavigatorUserMediaError object whose code attribute has the numeric
`value 1 (PERMISSION_DENIED).
`
`18. Queue a task to invoke errorCallback with error as its argument.
`
`The task source for these tasks is the user interaction task source.
`
`Parameter
`Parameter
`options
`successCallback
`errorCallback
`
`TypeType
`MediaStreamOptions
`
`NavigatorUserMediaSuccessCallback
`
`NavigatorUserMediaErrorCallback
`
`DescriptionNullableNullable OptionalOptional Description
`
`
`
`
`✔
`✘
`✔
`✘
`✔
`✔
`
`No exceptions.
`Return type: void
`WebIDL
`
`Navigator implements NavigatorUserMedia;
`
`All instances of the Navigator type are defined to also implement the NavigatorUserMedia interface.
`
`2.1.2 MediaStreamOptions
`
`WebIDL
`
`[NoInterfaceObject]
`interface MediaStreamOptions {
` attribute boolean audio;
` attribute boolean video;
`};
`
`2.1.2.1 Attributes
`
`audio of type boolean
`Set to false if an audio track is not required, default is true
`No exceptions.
`
`video of type boolean
`Set to false if a video track is not required, default is true
`No exceptions.
`
`2.1.3 NavigatorUserMediaSuccessCallback
`
`WebIDL
`
`[Callback=FunctionOnly, NoInterfaceObject]
`interface NavigatorUserMediaSuccessCallback {
` void handleEvent (LocalMediaStream stream);
`};
`
`2.1.3.1 Methods
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`5/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`handleEvent
`(Explanation of handleEvent TBD)
`Parameter
`TypeType
`Parameter
`stream
`LocalMediaStream
`
`No exceptions.
`Return type: void
`
`DescriptionNullableNullable OptionalOptional Description
`
`
`
`
`✘
`✘
`
`2.1.4 NavigatorUserMediaError and NavigatorUserMediaErrorCallback
`
`WebIDL
`
`[NoInterfaceObject]
`interface NavigatorUserMediaError {
` const unsigned short PERMISSION_DENIED = 1;
` readonly attribute unsigned short code;
`};
`
`2.1.4.1 Attributes
`
`code of type unsigned short, readonly
`Returns the current error's error code. At this time, this will always be 1, for which the constant
`PERMISSION_DENIED is defined.
`No exceptions.
`
`2.1.4.2 Constants
`
`PERMISSION_DENIED of type unsigned short
`The user denied the page permission to use the user's media devices.
`
`WebIDL
`
`[Callback=FunctionOnly, NoInterfaceObject]
`interface NavigatorUserMediaErrorCallback {
` void handleEvent (NavigatorUserMediaError error);
`};
`
`2.1.4.3 Methods
`
`handleEvent
`(Explanation of handleEvent TBD)
`Parameter
`TypeType
`Parameter
`error
`NavigatorUserMediaError
`
`DescriptionNullableNullable OptionalOptional Description
`
`
`
`
`✘
`✘
`
`No exceptions.
`Return type: void
`
`2.2 Examples
`
`A voice chat feature in a game could attempt to get access to the user's microphone by calling
`the API as follows:
`
`<script>
` navigator.getUserMedia('audio', gotAudio);
` function gotAudio(stream) {
` // ... use 'stream' ...
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`6/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
` }
`</script>
`
`A video-conferencing system would ask for both audio and video:
`
`<script>
` function beginCall() {
` navigator.getUserMedia('audio,video user', gotStream);
` }
` function gotStream(stream) {
` // ... use 'stream' ...
` }
`</script>
`3. Stream API
`
`3.1 Introduction
`
`The MediaStream interface is used to represent streams of media data, typically (but not necessarily) of
`audio and/or video content, e.g. from a local camera or a remote site. The data from a MediaStream object
`does not necessarily have a canonical binary form; for example, it could just be "the video currently
`coming from the user's video camera". This allows user agents to manipulate media streams in whatever
`fashion is most suitable on the user's platform.
`
`Each MediaStream object can represent zero or more tracks, in particular audio and video tracks. Tracks
`can contain multiple channels of parallel data; for example a single audio track could have nine channels
`of audio data to represent a 7.2 surround sound audio track.
`
`Each track represented by a MediaStream object has a corresponding MediaStreamTrack object.
`
`A MediaStream object has an input and an output. The input depends on how the object was created: a
`LocalMediaStream object generated by a getUserMedia() call, for instance, might take its input from the
`user's local camera, while a MediaStream created by a PeerConnection object will take as input the data
`received from a remote peer. The output of the object controls how the object is used, e.g. what is saved
`if the object is written to a file, what is displayed if the object is used in a video element, or indeed what is
`transmitted to a remote peer if the object is used with a PeerConnection object.
`
`Each track in a MediaStream object can be disabled, meaning that it is muted in the object's output. All
`tracks are initially enabled.
`
`A MediaStream can be finished, indicating that its inputs have forever stopped providing data. When a
`MediaStream object is finished, all its tracks are muted regardless of whether they are enabled or disabled.
`
`The output of a MediaStream object must correspond to the tracks in its input. Muted audio tracks must be
`replaced with silence. Muted video tracks must be replaced with blackness.
`
`A new MediaStream object can be created from a list of MediaStreamTrack objects using the MediaStream()
`constructor. The list of MediaStreamTrack objects can be the track list of another stream, a subset of the
`track list of a stream or a composition of MediaStreamTrack objects from different MediaStream objects.
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`7/28
`
`
`
`12/7/24, 5:53 PM
`WebRTC 1.0: Real-time Communication Between Browsers
`The ability to duplicate a MediaStream, i.e. create a new MediaStream object from the track list of an existing
`stream, allows for greater control since separate MediaStream instances can be manipulated and
`consumed individually. This can be used, for instance, in a video-conferencing scenario to display the
`local video from the user's camera and microphone in a local monitor, while only transmitting the audio to
`the remote peer (e.g. in response to the user using a "video mute" feature). Combining tracks from
`different MediaStream objects into a new MediaStream makes it possible to, e.g., record selected tracks from
`a conversation involving several MediaStream objects with a single MediaStreamRecorder.
`
`The LocalMediaStream interface is used when the user agent is generating the stream's data (e.g. from a
`camera or streaming it from a local video file). It allows authors to control individual tracks during the
`generation of the content, e.g. to allow the user to temporarily disable a local camera during a video-
`conference chat.
`
`When a LocalMediaStream object is being generated from a local file (as opposed to a live audio/video
`source), the user agent should stream the data from the file in real time, not all at once. This reduces the
`ease with which pages can distinguish live video from pre-recorded video, which can help protect the
`user's privacy.
`
`3.2 Interface definitions
`
`3.2.1 MediaStream
`
`The MediaStream(trackList) constructor must return a new MediaStream object with a newly generated
`label. A new MediaStreamTrack object is created for every unique underlying media source in trackList and
`appended to the new MediaStream object's track list according to the track ordering constraints.
`
`A MediaStream object is said to end when the user agent learns that no more data will ever be forthcoming
`for this stream.
`
`When a MediaStream object ends for any reason (e.g. because the user rescinds the permission for the
`page to use the local camera, or because the data comes from a finite file and the file's end has been
`reached and the user has not requested that it be looped, or because the stream comes from a remote
`peer and the remote peer has permanently stopped sending data, it is said to be finished . When this
`happens for any reason other than the stop() method being invoked, the user agent must queue a task
`that runs the following steps:
`
`1. If the object's readyState attribute has the value ENDED (2) already, then abort these steps. (The
`stop() method was probably called just before the stream stopped for other reasons, e.g. the user
`clicked an in-page stop button and then the user-agent-provided stop button.)
`
`2. Set the object's readyState attribute to ENDED (2).
`
`3. Fire a simple event named ended at the object.
`
`As soon as a MediaStream object is finished, the stream's tracks start outputting only silence and/or
`blackness, as appropriate, as defined earlier.
`
`If the end of the stream was reached due to a user request, the task source for this task is the user
`interaction task source. Otherwise the task source for this task is the networking task source.
`
`WebIDL
`
`[Constructor (in MediaStreamTrackList trackList)]
`interface MediaStream {
` readonly attribute DOMString label;
` readonly attribute MediaStreamTrackList tracks;
` MediaStreamRecorder record ();
` const unsigned short LIVE = 1;
` const unsigned short ENDED = 2;
` readonly attribute unsigned short readyState;
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`8/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
` attribute Function? onended;
`};
`
`3.2.1.1 Attributes
`
`label of type DOMString, readonly
`Returns a label that is unique to this stream, so that streams can be recognized after they are
`sent through the PeerConnection API.
`No exceptions.
`
`onended of type Function, nullable
`This event handler, of type ended, must be supported by all objects implementing the
`MediaStream interface.
`No exceptions.
`
`readyState of type unsigned short, readonly
`The readyState attribute represents the state of the stream. It must return the value to which
`the user agent last set it (as defined below). It can have the following values: LIVE or ENDED.
`
`When a MediaStream object is created, its readyState attribute must be set to LIVE (1), unless it is
`being created using the MediaStream() constructor whose argument is a list of MediaStreamTrack
`objects whose underlying media sources will never produce any more data, in which case the
`MediaStream object must be created with its readyState attribute set to ENDED (2).
`
`No exceptions.
`
`tracks of type MediaStreamTrackList, readonly
`Returns a MediaStreamTrackList object representing the tracks that can be enabled and
`disabled.
`
`A MediaStream can have multiple audio and video sources (e.g. because the user has multiple
`microphones, or because the real source of the stream is a media resource with many media
`tracks). The stream represented by a MediaStream thus has zero or more tracks.
`
`The tracks attribute must return an array host object for objects of type MediaStreamTrack that is
`fixed length and read only. The same object must be returned each time the attribute is
`accessed. [WEBIDL]
`
`The array must contain the MediaStreamTrack objects that correspond to the the tracks of the
`stream. The relative order of all tracks in a user agent must be stable. All audio tracks must
`precede all video tracks. Tracks that come from a media resource whose format defines an
`order must be in the order defined by the format; tracks that come from a media resource
`whose format does not define an order must be in the relative order in which the tracks are
`declared in that media resource. Within these constraints, the order is user-agent defined.
`
`No exceptions.
`
`3.2.1.2 Methods
`
`record
`Begins recording the stream. The returned MediaStreamRecorder object provides access to the
`recorded data.
`
`When the record() method is invoked, the user agent must return a new MediaStreamRecorder
`object associated with the stream.
`
`No parameters.
`No exceptions.
`Return type: MediaStreamRecorder
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`9/28
`
`
`
`12/7/24, 5:53 PM
`3.2.1.3 Constants
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`ENDED of type unsigned short
`The stream has finished (the user agent is no longer receiving or generating data, and will
`never receive or generate more data for this stream).
`
`LIVE of type unsigned short
`The stream is active (the user agent is making a best-effort attempt to receive or generate
`data in real time).
`
`WebIDL
`
`MediaStream implements EventTarget;
`
`All instances of the MediaStream type are defined to also implement the EventTarget interface.
`
`3.2.2 LocalMediaStream
`
`WebIDL
`
`interface LocalMediaStream : MediaStream {
` void stop ();
`};
`
`3.2.2.1 Methods
`
`stop
`
`When a LocalMediaStream object's stop() method is invoked, the user agent must queue a task
`that runs the following steps:
`
`1. If the object's readyState attribute is in the ENDED (2) state, then abort these steps.
`
`2. Permanently stop the generation of data for the stream. If the data is being generated
`from a live source (e.g. a microphone or camera), and no other stream is being
`generated from a live source, then the user agent should remove any active "on-air"
`indicator. If the data is being generated from a prerecorded source (e.g. a video file), any
`remaining content in the file is ignored. The stream is finished. The stream's tracks start
`outputting only silence and/or blackness, as appropriate, as defined earlier.
`
`3. Set the object's readyState attribute to ENDED (2).
`
`4. Fire a simple event named ended at the object.
`
`The task source for the tasks queued for the stop() method is the DOM manipulation task
`source.
`
`No parameters.
`No exceptions.
`Return type: void
`
`3.2.3 MediaStreamTrack
`
`WebIDL
`
`typedef MediaStreamTrack[] MediaStreamTrackList;
`
`Throughout this specification, the identifier MediaStreamTrackList is used to refer to the array of
`MediaStreamTrack type.
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`10/28
`
`
`
`12/7/24, 5:53 PM
`
`WebIDL
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`interface MediaStreamTrack {
` readonly attribute DOMString kind;
` readonly attribute DOMString label;
` attribute boolean enabled;
`};
`
`3.2.3.1 Attributes
`
`enabled of type boolean
`The MediaStreamTrack.enabled attribute, on getting, must return the last value to which it was
`set. On setting, it must be set to the new value, and then, if the MediaStreamTrack object is still
`associated with a track, must enable the track if the new value is true, and disable it otherwise.
`Note
`Thus, after a MediaStreamTrack is disassociated from its track, its enabled attribute still
`changes value when set, it just doesn't do anything with that new value.
`
`No exceptions.
`
`kind of type DOMString, readonly
`The MediaStreamTrack.kind attribute must return the string "audio" if the object's corresponding
`track is or was an audio track, "video" if the corresponding track is or was a video track, and a
`user-agent defined string otherwise.
`
`No exceptions.
`
`label of type DOMString, readonly
`When a LocalMediaStream object is created, the user agent must generate a globally unique
`identifier string, and must initialize the object's label attribute to that string. Such strings must
`only use characters in the ranges U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D
`to U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E, and must be 36
`characters long.
`
`When a MediaStream is created to represent a stream obtained from a remote peer, the label
`attribute is initialized from information provided by the remote source.
`
`When a MediaStream is created from another using the MediaStream() constructor, the label
`attribute is initialized to a newly generated value.
`
`The label attribute must return the value to which it was initialized when the object was
`created.
`Note
`The label of a MediaStream object is unique to the source of the stream, but that does not
`mean it is not possible to end up with duplicates. For example, a locally generated stream
`could be sent from one user to a remote peer using PeerConnection, and then sent back to
`the original user in the same manner, in which case the original user will have multiple
`streams with the same label (the locally-generated one and the one received from the
`remote peer).
`
`User agents may label audio and video sources (e.g. "Internal microphone" or "External USB
`Webcam"). The MediaStreamTrack.label attribute must return the label of the object's
`corresponding track, if any. If the corresponding track has or had no label, the attribute must
`instead return the empty string.
`Note
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`11/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`Thus the kind and label attributes do not change value, even if the MediaStreamTrack
`object is disassociated from its corresponding track.
`
`No exceptions.
`
`3.2.4 MediaStreamRecorder
`
`WebIDL
`
`interface MediaStreamRecorder {
` voice getRecordedData (BlobCallback? callback);
`};
`
`3.2.4.1 Methods
`
`getRecordedData
`Creates a Blob of the recorded data, and invokes the provided callback with that Blob.
`
`When the getRecordedData() method is called, the user agent must run the following steps:
`
`1. Let callback be the callback indicated by the method's first argument.
`
`2. If callback is null, abort these steps.
`
`3. Let data be the data that was streamed by the MediaStream object from which the
`MediaStreamRecorder was created since the creation of the MediaStreamRecorder object.
`
`4. Return, and run the remaining steps asynchronously.
`
`5. Generate a file that containing data in a format supported by the user agent for use in
`audio and video elements.
`
`6. Let blob be a Blob object representing the contents of the file generated in the previous
`step. [FILE-API]
`
`7. Queue a task to invoke callback with blob as its argument.
`Note
`The getRecordedData() method can be called multiple times on one MediaStreamRecorder
`object; each time, it will create a new file as if this was the first time the method was
`being called. In particular, the method does not stop or reset the recording when the
`method is called.
`
`Parameter
`Parameter
`callback
`
`TypeType
`BlobCallback
`
`DescriptionNullableNullable OptionalOptional Description
`
`
`
`
`✔
`✘
`
`No exceptions.
`Return type: voice
`
`3.2.5 BlobCallback
`
`WebIDL
`
`[Callback=FunctionOnly, NoInterfaceObject]
`interface BlobCallback {
` void handleEvent (Blob blob);
`};
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`12/28
`
`
`
`12/7/24, 5:53 PM
`3.2.5.1 Methods
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
`handleEvent
`Def TBD
`Parameter
`Parameter
`blob
`
`No exceptions.
`Return type: void
`
`3.2.6 URL
`
`TypeType
`Blob
`
`DescriptionNullableNullable OptionalOptional Description
`
`
`
`
`✘
`✘
`
`Note that the following is actually only a partial interface, but ReSpec does not yet support that.
`
`WebIDL
`
`interface URL {
` static DOMString createObjectURL (MediaStream stream);
`};
`
`3.2.6.1 Methods
`
`createObjectURL
`Mints a Blob URL to refer to the given MediaStream.
`
`When the createObjectURL() method is called with a MediaStream argument, the user agent must
`return a unique Blob URL for the given MediaStream. [FILE-API]
`
`For audio and video streams, the data exposed on that stream must be in a format supported
`by the user agent for use in audio and video elements.
`
`A Blob URL is the same as what the File API specification calls a Blob URI, except that
`anything in the definition of that feature that refers to File and Blob objects is hereby extended
`to also apply to MediaStream and LocalMediaStream objects.
`
`Parameter
`Parameter
`stream
`
`TypeType
`MediaStream
`
`DescriptionNullableNullable OptionalOptional Description
`
`
`
`
`✘
`✘
`
`No exceptions.
`Return type: static DOMString
`3.3 Examples
`
`This sample code exposes a button. When clicked, the button is disabled and the user is
`prompted to offer a stream. The user can cause the button to be re-enabled by providing a
`stream (e.g. giving the page access to the local camera) and then disabling the stream (e.g.
`revoking that access).
`
`<input type="button" value="Start" onclick="start()" id="startBtn">
`<script>
` var startBtn = document.getElementById('startBtn');
` function start() {
` navigator.getUserMedia('audio,video', gotStream);
` startBtn.disabled = true;
` }
` function gotStream(stream) {
` stream.onended = function () {
` startBtn.disabled = false;
` }
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`13/28
`
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
`
` }
`</script>
`
`This example allows people to record a short audio message and upload it to the server. This
`example even shows rudimentary error handling.
`
`<input type="button" value="
`" onclick="msgRecord()" id="recBtn">
`<input type="button" value="◼" onclick="msgStop()" id="stopBtn" disabled>
`<p id="status">To start recording, press the
` button.</p>
`<script>
` var recBtn = document.getElementById('recBtn');
` var stopBtn = document.getElementById('stopBtn');
` function report(s) {
` document.getElementById('status').textContent = s;
` }
` function msgRecord() {
` report('Attempting to access microphone...');
` navigator.getUserMedia('audio', gotStream, noStream);
` recBtn.disabled = true;
` }
` var msgStream, msgStreamRecorder;
` function gotStream(stream) {
` report('Recording... To stop, press to ◼ button.');
` msgStream = stream;
` msgStreamRecorder = stream.record();
` stopBtn.disabled = false;
` stream.onended = function () {
` msgStop();
` }
` }
` function msgStop() {
` report('Creating file...');
` stopBtn.disabled = true;
` msgStream.onended = null;
` msgStream.stop();
` msgStreamRecorder.getRecordedData(msgSave);
` }
` function msgSave(blob) {
` report('Uploading file...');
` var x = new XMLHttpRequest();
` x.open('POST', 'uploadMessage');
` x.send(blob);
` x.onload = function () {
` report('Done! To record a new message, press the
` recBtn.disabled = false;
` };
` x.onerror = function () {
` report('Failed to upload message. To try recording a message again, press the
`button.');
` recBtn.disabled = false;
` };
` }
` function noStream() {
` report('Could not obtain access to your microphone. To try again, press the
` recBtn.disabled = false;
` }
`</script>
`
` button.');
`
`
`
` button.');
`
`This example allows people to take photos of themselves from the local video camera.
`
`<article>
` <style scoped>
` video { transform: scaleX(-1); }
` p { text-align: center; }
` </style>
` <h1>Snapshot Kiosk</h1>
` <section id="splash">
` <p id="errorMessage">Loading...</p>
` </section>
` <section id="app" hidden>
` <p><video id="monitor" autoplay></video> <canvas id="photo"></canvas>
`
`https://www.w3.org/TR/2011/WD-webrtc-20111027/
`
`14/28
`
`⚫
`⚫
`⚫
`⚫
`⚫
`
`
`12/7/24, 5:53 PM
`
`WebRTC 1.0: Real-time Communication Between Browsers
` <p><input type=button value="📷" onclick="snapshot()">
` </section>
` <script>
` navigator.getUserMedia('video user', gotStream, noStream);
` var video = document.getElementById('monitor');
` var canvas = document.getElementById('photo');
` function gotStream(stream) {
` video.src = URL.getObjectURL(stream);
` video.onerror = function () {
` stream.stop();
` };
` stream.onended = noStream;
` video.