Skip to content

Commit 6ff25f0

Browse files
authored
Merge pull request #26 from alvestrand/guidou/spec-metadata
Update explainer and metadata section of the spec
2 parents 7774dee + 08371aa commit 6ff25f0

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

explainer.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ iterations to support additional use cases such as:
4747

4848
<pre>
4949
const supportsInsertableStreams = window.RTCRtpSender &&
50-
!!RTCRtpSender.prototype.createEncodedVideoStreams;
50+
!!RTCRtpSender.prototype.createEncodedStreams;
5151
</pre>
5252

5353
1. Let an PeerConnection know that it should allow exposing the data flowing through it
@@ -60,8 +60,7 @@ streams. For example:
6060

6161
<pre>
6262
let pc = new RTCPeerConnection({
63-
forceEncodedVideoInsertableStreams: true,
64-
forceEncodedAudioInsertableStreams: true
63+
encodedInsertableStreams: true,
6564
});
6665
</pre>
6766

@@ -110,7 +109,7 @@ Transform stream to the track's sender.
110109
let stream = await navigator.mediaDevices.getUserMedia({video:true});
111110
let [track] = stream.getTracks();
112111
let videoSender = pc.addTrack(track, stream)
113-
let senderStreams = videoSender.getEncodedVideoStreams();
112+
let senderStreams = videoSender.createEncodedStreams();
114113

115114
// Do ICE and offer/answer exchange.
116115

@@ -122,7 +121,7 @@ senderStreams.readable
122121
4. Do the corresponding operations on the receiver side.
123122

124123
<pre>
125-
let pc = new RTCPeerConnection({forceEncodedVideoInsertableStreams: true});
124+
let pc = new RTCPeerConnection({encodedInsertableStreams: true});
126125
pc.ontrack = e => {
127126
let receiverTransform = new TransformStream({
128127
start() {},
@@ -145,7 +144,7 @@ pc.ontrack = e => {
145144
},
146145
});
147146

148-
let receiverStreams = e.receiver.createEncodedVideoStreams();
147+
let receiverStreams = e.receiver.createEncodedStreams();
149148
receiverStreams.readable
150149
.pipeThrough(receiverTransform)
151150
.pipeTo(receiverStreams.writable);
@@ -172,6 +171,23 @@ enum RTCEncodedVideoFrameType {
172171
"delta",
173172
};
174173

174+
// New dictionaries for video and audio metadata.
175+
dictionary RTCEncodedVideoFrameMetadata {
176+
long long frameId;
177+
sequence&lt;long long&gt; dependencies;
178+
unsigned short width;
179+
unsigned short height;
180+
long spatialIndex;
181+
long temporalIndex;
182+
long synchronizationSource;
183+
sequence&lt;long&gt; contributingSources;
184+
};
185+
186+
dictionary RTCEncodedAudioFrameMetadata {
187+
long synchronizationSource;
188+
sequence&lt;long&gt; contributingSources;
189+
};
190+
175191
// New interfaces to define encoded video and audio frames. Will eventually
176192
// re-use or extend the equivalent defined in WebCodecs.
177193
// The additionalData fields contain metadata about the frame and will
@@ -180,37 +196,27 @@ interface RTCEncodedVideoFrame {
180196
readonly attribute RTCEncodedVideoFrameType type;
181197
readonly attribute unsigned long long timestamp;
182198
attribute ArrayBuffer data;
183-
readonly attribute ArrayBuffer additionalData;
184-
readonly attribute unsigned long synchronizationSource;
199+
RTCVideoFrameMetadata getMetadata();
185200
};
186201

187202
interface RTCEncodedAudioFrame {
188203
readonly attribute unsigned long long timestamp;
189204
attribute ArrayBuffer data;
190-
readonly attribute ArrayBuffer additionalData;
191-
readonly attribute unsigned long synchronizationSource;
192-
readonly attribute FrozenArray<unsigned long> contributingSources;
205+
RTCAudioFrameMetadata getMetadata();
193206
};
194207

195-
196-
// New fields in RTCConfiguration
197-
dictionary RTCConfiguration {
198-
// ...
199-
boolean forceEncodedVideoInsertableStreams = false;
200-
boolean forceEncodedAudioInsertableStreams = false;
208+
// New field in RTCConfiguration
209+
partial dictionary RTCConfiguration {
210+
boolean encodedInsertableStreams = false;
201211
};
202212

203213
// New methods for RTCRtpSender and RTCRtpReceiver
204-
interface RTCRtpSender {
205-
// ...
206-
RTCInsertableStreams createEncodedVideoStreams();
207-
RTCInsertableStreams createEncodedAudioStreams();
214+
partial interface RTCRtpSender {
215+
RTCInsertableStreams createEncodedStreams();
208216
};
209217

210-
interface RTCRtpReceiver {
211-
// ...
212-
RTCInsertableStreams createEncodedVideoStreams();
213-
RTCInsertableStreams createEncodedAudioStreams();
218+
partial interface RTCRtpReceiver {
219+
RTCInsertableStreams createEncodedStreams();
214220
};
215221

216222
</pre>

index.bs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ enum RTCEncodedVideoFrameType {
9797
"delta",
9898
};
9999

100-
dictionary RTCVideoFrameMetadata {
101-
long synchronizationSource;
102-
sequence&lt;long&gt; contributingSources;
100+
dictionary RTCEncodedVideoFrameMetadata {
101+
long long frameId;
102+
sequence&lt;long long&gt; dependencies;
103+
unsigned short width;
104+
unsigned short height;
105+
long spatialIndex;
106+
long temporalIndex;
107+
long synchronizationSource;
108+
sequence&lt;long&gt; contributingSources;
103109
};
104110

105111
// New interfaces to define encoded video and audio frames. Will eventually
@@ -111,9 +117,9 @@ interface RTCEncodedVideoFrame {
111117
RTCVideoFrameMetadata getMetadata();
112118
};
113119

114-
dictionary RTCAudioFrameMetadata {
115-
long synchronizationSource;
116-
sequence&lt;long&gt; contributingSources;
120+
dictionary RTCEncodedAudioFrameMetadata {
121+
long synchronizationSource;
122+
sequence&lt;long&gt; contributingSources;
117123
};
118124

119125
interface RTCEncodedAudioFrame {
@@ -125,7 +131,7 @@ interface RTCEncodedAudioFrame {
125131

126132
// New fields in RTCConfiguration
127133
partial dictionary RTCConfiguration {
128-
boolean forceEncodedInsertableStreams = false;
134+
boolean encodedInsertableStreams = false;
129135
};
130136

131137
// New methods for RTCRtpSender and RTCRtpReceiver
@@ -150,7 +156,7 @@ Let the {{RTCRtpSender}} or {{RTCRtpReceiver}} have an internal slot,
150156
When {{RTCRtpSender/createEncodedStreams}}() is
151157
called, run the following steps:
152158

153-
* If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/forceEncodedInsertableStreams}} set to "true", throw an {{InvalidStateError}} and abort these steps.
159+
* If the {{RTCPeerConnection}}'s configuration does not have {{RTCConfiguration/encodedInsertableStreams}} set to "true", throw an {{InvalidStateError}} and abort these steps.
154160
* If the data source does not permit access, throw an {{InvalidAccessError}} and abort these steps.
155161
* If [[\Streams]] is not null, throw an {{InvalidStateError}}.
156162
* Create an {{RTCInsertableStreams}} object 's'.

0 commit comments

Comments
 (0)