@@ -76,25 +76,25 @@ of an encoded frame and adds 4 bytes of padding.
76
76
// Called on startup.
77
77
},
78
78
79
- async transform(chunk , controller) {
80
- let view = new DataView(chunk .data);
79
+ async transform(encodedFrame , controller) {
80
+ let view = new DataView(encodedFrame .data);
81
81
// 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);
83
83
let newView = new DataView(newData);
84
84
85
85
// Fill the new buffer with a negated version of all
86
86
// 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)
88
88
newView.setInt8(i, ~view.getInt8(i));
89
89
// Set the padding bytes to zero.
90
90
for (let i = 0; i < 4; ++i)
91
- newView.setInt8(chunk .data.byteLength + i, 0);
91
+ newView.setInt8(encodedFrame .data.byteLength + i, 0);
92
92
93
93
// Replace the frame's data with the new buffer.
94
- chunk .data = newData;
94
+ encodedFrame .data = newData;
95
95
96
96
// Send it to the output stream.
97
- controller.enqueue(chunk );
97
+ controller.enqueue(encodedFrame );
98
98
},
99
99
100
100
flush() {
@@ -127,21 +127,21 @@ pc.ontrack = e => {
127
127
let receiverTransform = new TransformStream({
128
128
start() {},
129
129
flush() {},
130
- async transform(chunk , controller) {
130
+ async transform(encodedFrame , controller) {
131
131
// Reconstruct the original frame.
132
- let view = new DataView(chunk .data);
132
+ let view = new DataView(encodedFrame .data);
133
133
134
134
// Ignore the last 4 bytes
135
- let newData = new ArrayBuffer(chunk .data.byteLength - 4);
135
+ let newData = new ArrayBuffer(encodedFrame .data.byteLength - 4);
136
136
let newView = new DataView(newData);
137
137
138
138
// Negate all bits in the incoming frame, ignoring the
139
139
// 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)
141
141
newView.setInt8(i, ~view.getInt8(i));
142
142
143
- chunk .data = newData;
144
- controller.enqueue(chunk );
143
+ encodedFrame .data = newData;
144
+ controller.enqueue(encodedFrame );
145
145
},
146
146
});
147
147
0 commit comments