Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Wait for datachannel #592

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7c898d3
The libwebp+canvas baseline.
ankh-g Nov 28, 2018
85c1a1f
mime_type: application/wasm
ankh-g Nov 29, 2018
fef8c8c
First cut on libvpx. Use ?libvpx=1 to try this.
ankh-g Nov 30, 2018
f1641cf
Encode a getUserMedia video frame with YUV and VP8.
ankh-g Nov 30, 2018
07d4ac7
Encode a stream of video frames.
ankh-g Nov 30, 2018
4d64bec
Allow to choose codec with ?codec=vp9.
ankh-g Nov 30, 2018
53d9e2e
First cut on VPX decoder. It can decode 1 frame.
ankh-g Nov 30, 2018
e7d45be
Decode YUV and print all the decoded frames.
ankh-g Nov 30, 2018
bac8b4c
One way video works. It's quite slow, though.
ankh-g Dec 1, 2018
3a8771d
Don't create temp <canvas> elements.
ankh-g Dec 1, 2018
166bed3
Print more stats and enable CPU profiling.
ankh-g Dec 1, 2018
315c5f3
/vpx-yuv now contains only the latest set of decoded frames
ankh-g Dec 1, 2018
eed912c
Switch to an optimized wasm build.
ankh-g Dec 1, 2018
d882f96
Remove unnecessary logs.
ankh-g Dec 3, 2018
c81770e
Add ?webrtc=1 option
steveanton Dec 3, 2018
f4d8e4f
resolve conflicts
steveanton Dec 3, 2018
788951e
Two-way video is working.
ankh-g Dec 3, 2018
925a89b
Merged with the ?webrtc=1 change.
ankh-g Dec 3, 2018
a96d9b4
Automatically send video when ?fps=10.
ankh-g Dec 3, 2018
036c848
Remove unnecessary mem allocs.
ankh-g Dec 4, 2018
51ae3b2
WebRTC with audio send stream bindings
steveanton Dec 4, 2018
d974687
Don't allocate temp IVF buffers.
ankh-g Dec 4, 2018
cb37033
Added UI stats in the top right.
ankh-g Dec 4, 2018
2e3a995
Added stats for IVF files.
ankh-g Dec 4, 2018
6dd2ceb
Updated libvpx wasm.
ankh-g Dec 4, 2018
5fb86fb
Added --enable-realtime-only
ankh-g Dec 4, 2018
7d1e324
Display the average stats values.
ankh-g Dec 4, 2018
4b3b385
Wire up AudioReceiveStream
steveanton Dec 4, 2018
2818889
Updated libvpx with -O2 and --profiling. 70+25 ms for enc+dec.
ankh-g Dec 4, 2018
eaf6e43
Merge branch 'wartc' of github.com:webrtc/apprtc into wartc
ankh-g Dec 4, 2018
1756464
Set bitrate to 1 Mbit/s to improve video quality.
ankh-g Dec 4, 2018
af52de4
?vsbr=200 can now set the desired video bitrate.
ankh-g Dec 4, 2018
d865ac5
Check for this.libvpx_ before loading it.
ankh-g Dec 4, 2018
7794bae
Removed _onBodyClick from webrtc.js
ankh-g Dec 4, 2018
51cca46
Not working version
Dec 4, 2018
9f53405
Send RTP packets over the RTCDataChannel.
ankh-g Dec 4, 2018
e248062
Disable local streams from webrtc, wait for data channel to be connec…
Dec 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Encode a stream of video frames.
On a mouse click it sends the current video frame to VP8
and prints the generated IVF packets. If the frame hasn't
changed much, the output is a small 200-500 bytes delta.
If the new frame is very different, then the output is a 5-6 KB
key-frame.
ankh-g committed Nov 30, 2018
commit 07d4ac7c564c32999c9d19ae806bd3c6cbcf0aea
24 changes: 16 additions & 8 deletions src/web_app/js/libvpx.js
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@

class LibVPX {
constructor() {
this._initialized = false;
this._previvfsize = 0;
this._loadWasm('/wasm/libvpx/libvpx.js');
}

@@ -40,8 +42,9 @@ class LibVPX {

encode(videoElement) {
const VP8 = 0x30385056;
const width = 640;
const height = 480;
const VP9 = 0x30395056;
const width = 240;
const height = 160;

// - Take a video frame from <video> to <canvas>.
// - Copy RGBA data to the WASM memory.
@@ -54,25 +57,30 @@ class LibVPX {
const context2d = canvas.getContext('2d');
context2d.drawImage(videoElement, 0, 0, width, height);
const {data:rgbaData} = context2d.getImageData(0, 0, width, height);
console.log('RGB data:', rgbaData);
console.log('RGB data:', rgbaData.length, 'bytes');
const rgbaSize = width * height * 4;
const yuvSize = width * height * 3 / 2; // 48 bits per 4 pixels
const rgbaPtr = _malloc(rgbaSize);
const yuvPtr = _malloc(yuvSize);
HEAP8.set(rgbaData, rgbaPtr);
_vpx_js_rgba_to_yuv420(yuvPtr, rgbaPtr, width, height);
const yuvData = new Uint8Array(HEAP8.buffer, yuvPtr, yuvSize);
console.log('YUV data:', yuvData);
console.log('YUV data:', yuvData.length, 'bytes');
FS.writeFile('/vpx-yuv', yuvData); // in-memory memfs emscripten file
_free(rgbaPtr);
_free(yuvPtr);

console.warn('initializing libvpx');
_vpx_js_encoder_init(VP8, width, height);
if (!this._initialized) {
console.warn('initializing libvpx');
_vpx_js_encoder_init(VP8, width, height);
this._initialized = true;
}

_vpx_js_encoder_process();
_vpx_js_encoder_exit(); // flushes all memory buffers, etc.
// _vpx_js_encoder_exit(); // flushes all memory buffers, etc.

const ivfData = FS.readFile('/vpx-ivf');
console.log('IVF data:', ivfData);
console.log('IVF data:', ivfData.length - this._previvfsize);
this._previvfsize = ivfData.length;
}
}
Binary file modified src/web_app/wasm/libvpx/libvpx.wasm
Binary file not shown.