Skip to content

Commit e9da155

Browse files
authored
Merge pull request #16 from fippo/terminology
explainer: s/chunk/encodedFrame
2 parents 551bf52 + b6d0ef5 commit e9da155

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

explainer.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,25 @@ of an encoded frame and adds 4 bytes of padding.
7676
// Called on startup.
7777
},
7878

79-
async transform(chunk, controller) {
80-
let view = new DataView(chunk.data);
79+
async transform(encodedFrame, controller) {
80+
let view = new DataView(encodedFrame.data);
8181
// Create a new buffer with 4 additional bytes.
82-
let newData = new ArrayBuffer(chunk.data.byteLength + 4);
82+
let newData = new ArrayBuffer(encodedFrame.data.byteLength + 4);
8383
let newView = new DataView(newData);
8484

8585
// Fill the new buffer with a negated version of all
8686
// the bits in the original frame.
87-
for (let i = 0; i < chunk.data.byteLength; ++i)
87+
for (let i = 0; i < encodedFrame.data.byteLength; ++i)
8888
newView.setInt8(i, ~view.getInt8(i));
8989
// Set the padding bytes to zero.
9090
for (let i = 0; i < 4; ++i)
91-
newView.setInt8(chunk.data.byteLength + i, 0);
91+
newView.setInt8(encodedFrame.data.byteLength + i, 0);
9292

9393
// Replace the frame's data with the new buffer.
94-
chunk.data = newData;
94+
encodedFrame.data = newData;
9595

9696
// Send it to the output stream.
97-
controller.enqueue(chunk);
97+
controller.enqueue(encodedFrame);
9898
},
9999

100100
flush() {
@@ -127,21 +127,21 @@ pc.ontrack = e => {
127127
let receiverTransform = new TransformStream({
128128
start() {},
129129
flush() {},
130-
async transform(chunk, controller) {
130+
async transform(encodedFrame, controller) {
131131
// Reconstruct the original frame.
132-
let view = new DataView(chunk.data);
132+
let view = new DataView(encodedFrame.data);
133133

134134
// Ignore the last 4 bytes
135-
let newData = new ArrayBuffer(chunk.data.byteLength - 4);
135+
let newData = new ArrayBuffer(encodedFrame.data.byteLength - 4);
136136
let newView = new DataView(newData);
137137

138138
// Negate all bits in the incoming frame, ignoring the
139139
// last 4 bytes
140-
for (let i = 0; i < chunk.data.byteLength - 4; ++i)
140+
for (let i = 0; i < encodedFrame.data.byteLength - 4; ++i)
141141
newView.setInt8(i, ~view.getInt8(i));
142142

143-
chunk.data = newData;
144-
controller.enqueue(chunk);
143+
encodedFrame.data = newData;
144+
controller.enqueue(encodedFrame);
145145
},
146146
});
147147

0 commit comments

Comments
 (0)