webrtc 学习资源 http://www.cnblogs.com/lingyunhu/p/3578218.html

Realtime/Working WebRTC Experiments

  1. It is a repository of uniquely experimented WebRTC demos; written by Muaz Khan!
  2. No special requirement! Just WebRTC compatible web-browser (e.g. chrome/firefox/opera on desktop/android)
  3. These demos/experiments are entirely client-side; i.e. no server installation needed!
  4. You can use all these demos in PHP/Python/Ruby/ASP.NET/etc. everywhere!

How to use?

Each demo has a unique directory. Simply download that directory, upload in your webserver and use it; and it'll work!

You don't need to modify any single line to use it. No single installation or modification is needed :)

Libraries

Library NameShort DescriptionDocDemos
RecordRTC.jsSupports cross-browser audio/video recordings!DocDemos
Translator.jsVoice & Text TranslatorDocDemos
RTCMultiConnection.jsSingle Library for Everything! Just imagine :)DocDemos
FileBufferReader.jsFile buffers reader & chunkifierDocDemos
getScreenId.jsSingle chrome extension for all domains! Again, imagine :)DocDemos
Conversation.jsEnjoy Skype-like Conversations! Oops :)DocDemos
DataChannel.jsSupports data-streaming among multiple peersDocDemos
getMediaElement.jsA library for audio/video media elements' layoutDocDemos
DetectRTC.jsA library for detecting WebRTC featuresDocDemos
ConcatenateBlobs.jsConcatenate Array of BlobsDocDemos
getStats.jsGet peers statisticsDocNone

Other libraries:

Other Repositories

  1. WebRTC Scalable Broadcast
  2. Reliable Signaling
  3. RTCMultiConnection.js
  4. RecordRTC.js
  5. Collaborate Canvas Designer
  6. Translator.js
  7. FileBufferReader.js
  8. Chrome-Extensions
  9. Firefox-Extensions
  10. DetectRTC.js
  11. getStats.js
  12. Conversation.js
  13. Ffmpeg.js
  14. DataChannel.js
  15. MultiRTC Demos
  16. XHR-Signaling
  17. PluginRTC: IE/Safari Plugins compatible WebRTC-Experiments
  18. ASP.NET MVC based WebRTC 1:1 Demo
  19. WebSync Signaling
  20. SdpSerializer.js

Experiments

Experiment NameShort DescriptionSourceDemo
Pre-recorded Media StreamingStream video files in realtime; same like webcam streaming!SourceDemo
Part of Screen SharingShare a region of the screen; not the entire screen!SourceDemo
Plugin-free Screen SharingShare the entire screenSourceDemo
One-Way BroadcastingSame like radio stations; transmit audio/video/screen streams in one-way direction. Though, it is browser-to-browser streaming!SourceDemo

Experiments

Experiment NamePrevious DemosNew Demos
video-conferencing / multi-user (group) video sharingDemo / SourceDemo / Source Code
file sharing / multi-user (group) files hangoutDemo / SourceDemo / Source Code
file sharing using SCTP data channelsDemo / ---- / Source Code
text chat / multi-user (group) text chatDemo / SourceDemo / Source Code
MultiRTCDemo / ---- / Source Code

WebRTC!

  1. desktopCapture API / Install App Store Extension
  2. tabCapture API / Install App Store Extension
  3. Desktop Sharing / Install App Store Extension
  4. File Sharing / Install App Store Extension

WebRTC!

  1. enable-screen-capturing

Experiments

Experiment NamePrevious DemosNew Demos
video-broadcastingDemo / SourceDemo / Source Code
audio-broadcastingDemo / SourceDemo / Source Code

One-to-One Calls

Experiment NameDemoSource Code
One-to-one WebRTC video chat using WebSocketDemoSource
One-to-one WebRTC video chat using socket.ioDemoSource
WebRTC 1-1 Audio/Video/Screen SharingSourceDemo
WebRTC 1-1 CallsSourceDemo

Single-Page / One-Page / Client Side

Experiment NameDemoSource Code
Switch streams from screen-sharing to audio+video. (Renegotiation)DemoSource
Share screen and audio/video from single peer connection!DemoSource
Text chat using RTCDataChannel APIsDemoSource
Simple video chatDemoSource
Sharing video - using socket.io for signalingDemoSource
Sharing video - using WebSockets for signalingDemoSource
Audio Only StreamingDemoSource
MediaStreamTrack.getSourcesDemoSource

Experiments to share tab/screen/desktop

Experiment NamePrevious DemosNew Demos
Plugin-free screen sharing / share the entire screenDemo / SourceDemo / Source Code
Desktop sharing / using desktopCapture APIsDemo / Source--
Tab sharing / using tabCapture APIsDemo / Source--

share region/part of the screen

Experiment NameDemoSource Code
Share part-of-screen RTCMultiConnectionDemoSource
Share part-of-screen using RTCDataChannel APIsDemoSource
Share part-of-screen using FirebaseDemoSource
A realtime chat using RTCDataChannelDemoSource
A realtime chat using FirebaseDemoSource

MediaStreamRecorder.js library

Experiment NameDemoSource Code
Audio RecordingDemoSource
Video RecordingDemoSource
Gif RecordingDemoSource

Or RecordRTC entire Meeting using MediaStreamRecorder.js

DataChannel.js library

Experiment NameDemoSource Code
DataChannel basic demoDemoSource
Auto Session EstablishmentDemoSource
Share part-of-screen using DataChannel.jsDemoSource
Private ChatDemo----
Text Chat using Pusher and DataChannel.jsDemoSource

Experimental (Non-Functional)

Experiment NameDemoSource Code
Attaching Remote Audio StreamsDemoSource
mozCaptureStreamUntilEnded for pre-recorded media streamingDemoSource
Remote audio stream recordingDemoSource

RTCMultiConnection

Experiment NameDemoSource Code
AppRTC like RTCMultiConnection demo!DemoSource
MultiRTC! RTCMultiConnection all-in-one demo!DemoSource
Collaborative Canvas DesignerDemoSource
Conversation.js - Skype like libraryDemoSource
All-in-One testDemoSource
Multi-Broadcasters and Many ViewersDemoSource
Select Broadcaster at runtimeDemoSource
OneWay Screen & Two-Way AudioDemoSource
Stream Mp3 LiveDemoSource
Socket.io auto Open/Join roomsDemoSource
Screen Sharing & CroppingDemoSource
Share Part of Screen without cropping itDemoSource
getMediaDevices/enumerateDevicesDemoSource
Renegotiation & Mute/UnMute/StopDemoSource
Video-ConferencingDemoSource
Video BroadcastingDemoSource
Audio ConferencingDemoSource
Multi-streams attachmentDemoSource
Admin/Guest audio/video callingDemoSource
Session Re-initiation TestDemoSource
Preview Screenshot of the roomDemoSource
RecordRTC & RTCMultiConnectionDemoSource
Explains how to customize ice servers; and resolutionsDemoSource
Mute/Unmute and onmute/onunmuteDemoSource
One-page demo: Explains how to skip external signalling gatewaysDemoSource
Password Protect Rooms: Explains how to authenticate usersDemoSource
Session Management: Explains difference between "leave" and "close" methodsDemoSource
Multi-Sessions ManagementDemoSource
Customizing BandwidthDemoSource
Users ejection and presence detectionDemoSource
Multi-Session EstablishmentDemoSource
Group File Sharing + Text ChatDemoSource
Audio Conferencing + File Sharing + Text ChatDemoSource
Join with/without cameraDemoSource
Screen SharingDemoSource
One-to-One file sharingDemoSource
Manual session establishment + extra data transmissionDemoSource
Manual session establishment + extra data transmission + video conferencingDemoSource
takeSnapshot i.e. Take Snapshot of Local/Remote streamsDemoSource
Audio/Video/Screen sharing and recordingDemoSource
Broadcast Multiple-CamerasDemoSource
Remote Stream ForwardingDemoSource
WebRTC Scalable BroadcastSocketio/NodejsSource

Conversation.js

  1. AndroidRTC
  2. Search Users
  3. Cross-Language (Multi-Lingual) Text Chat
  4. Old Conversation.js demos

Documents for newcomers/newbies/beginners

A few documents for newbies and beginners
How to use RTCPeerConnection.js?
RTCDataChannel for Beginners
How to use RTCDataChannel? - single code for both canary and nightly
WebRTC for Beginners: A getting stared guide!
WebRTC for Newbies
How to switch streams?
How to echo cancellation? / Noise management?
STUN or TURN? Which one to prefer; and why?
WebRTC RTP Usage
webrtcpedia!
Are you want to learn WebRTC?
WebRTC Tips & Tricks
  1. http://muaz-khan.blogspot.com/search/label/WebRTC
  2. https://www.webrtc-experiment.com/#documentations
  3. https://www.facebook.com/WebRTC
  4. https://plus.google.com/+WebRTC-Experiment/posts

ffmpeg-asm.js && Ffmpeg Demos

Demo NameLive DemoSource Code
Transcoding WAV into OggLive DemoSource Code
Transcoding WebM into mp4Live DemoSource Code
Transcoding WebM into mp4; then merging WAV+mp4 into single mp4Live DemoSource Code
Recording Audio+Canvas and merging in single mp4Live DemoSource Code

Custom Signaling

  1. Socket.io over Node.js
  2. WebSocket over Node.js
  3. WebSync / ASP.NET MVC
  4. XHR Signaling
  5. openSignalingChannel

RecordRTC?

<script src="//cdn.webrtc-experiment.com/RecordRTC.js"></script>

Documentation page: http://recordrtc.org/RecordRTC.html

var recordRTC = RecordRTC(mediaStream, {
    type: 'video' // audio or video or gif or canvas
});

recordRTC.startRecording();

recordRTC.stopRecording(function(videoURL) {
    video.src = videoURL;

    var blob = recordRTC.blob;
    var arrayBuffer = recordRTC.buffer;
    recordRTC.getDataURL(callback_function);
});
  1. RecordRTC to Node.js
  2. RecordRTC to PHP
  3. RecordRTC to ASP.NET MVC
  4. RecordRTC & HTML-2-Canvas i.e. Canvas/HTML Recording!
  5. MRecordRTC i.e. Multi-RecordRTC!
  6. RecordRTC on Ruby!
  7. RecordRTC over Socket.io
  8. ffmpeg-asm.js and RecordRTC! Audio/Video Merging & Transcoding!
  9. Recording Audio+Video in single WebM on Firefox
  10. RecordRTC / PHP / FFmpeg

RTCMultiConnection.js

You can write entire skype-like web-app using RTCMultiConnection! It supports all complex renegotiation scenarios!

<button >Open Room</button>
<button >Join Room</button><br />

<script src="//cdn.webrtc-experiment.com/RTCMultiConnection.js"> </script>
<script>
document.getElementById('openRoom').onclick = function() {
    new RTCMultiConnection().open();
};
document.getElementById('joinRoom').onclick = function() {
    new RTCMultiConnection().connect();
};
</script>

RTCMultiConnection Documentation

DataChannel.js / A library for RTCDataChannel APIs

<script src="//cdn.webrtc-experiment.com/DataChannel.js"> </script>
<script>
    var datachannel = new DataChannel();
    datachannel.onopen = function(remoteUserid) {};
    datachannel.onmessage = function(message, remoteUserid) {};

    // search for existing channels
    datachannel.connect();

    document.getElementById('new-channel').onclick = function() {
        datachannel.open(); // setup new channel
    };
</script>

DataChannel Documentation

Demo

Translator.js is a JavaScript library built top on Google Speech-Recognition & Translation API to transcript and translate voice and text. It supports many locales and brings globalization in WebRTC!

<script src="//cdn.webrtc-experiment.com/Translator.js"> </script>
var translator = new Translator();

translator.voiceToText(function (text) {
    console.log('Your voice as text!', text);
}, 'your-language');

translator.translateLanguage(textToConvert, {
    from: 'language-of-the-text',
    to: 'convert-into',
    callback: function (translatedText) {
        console.log('translated text', translatedText);
    }
});

translator.speakTextUsingRobot(textToPlay);

translator.speakTextUsingGoogleSpeaker({
    textToSpeak: 'text-to-convert',
    targetLanguage: 'your-language'
});

Demo

FileBufferReader is a JavaScript library reads file and returns chunkified array-buffers. The resulting buffers can be shared using WebRTC data channels or socket.io.

var fileBufferReader = new FileBufferReader();

fileBufferReader.readAsArrayBuffer(file, function(uuid) {
    // var file         = fileBufferReader.chunks[uuid];
    // var listOfChunks = file.listOfChunks;

    // get first chunk, and send using WebRTC data channels
    // NEVER send chunks in loop; otherwise you'll face issues in slow networks
    // remote peer should notify if it is ready for next chunk
    fileBufferReader.getNextChunk(uuid, function(nextChunk, isLastChunk) {
        if(isLastChunk) {
            alert('File Successfully sent.');
        }
        // sending using WebRTC data channels
        datachannel.send(nextChunk);
    });
});

datachannel.onmessage = function(event) {
    var chunk = event.data;

    if (chunk instanceof ArrayBuffer || chunk instanceof DataView) {
        // array buffers are passed using WebRTC data channels
        // need to convert data back into JavaScript objects

        fileBufferReader.convertToObject(chunk, function(object) {
            datachannel.onmessage({
                data: object
            });
        });
        return;
    }

    // if you passed "extra-data", you can access it here:
    // chunk.extra.senderUserName or whatever else

    // if target peer requested next chunk
    if(chunk.readyForNextChunk) {
        fileBufferReader.getNextChunk(chunk.uuid, function(nextChunk, isLastChunk) {
            if(isLastChunk) {
                alert('File Successfully sent.');
            }
            // sending using WebRTC data channels
            datachannel.send(nextChunk);
        });
        return;
    }

    // if chunk is received
    fileBufferReader.addChunk(chunk, function(promptNextChunk) {
        // request next chunk
        datachannel.send(promptNextChunk);
    });
};

Demo

Simply use getScreenId.js and enjoy screen capturing from any domain. You don't need to deploy chrome extension yourself. You can refer your users to install this chrome extension instead. Also,getScreenId.js auto-fallbacks to command-line based screen capturing if chrome extension isn't installed or disabled. getScreenId.js throws clear exceptions which is helpful for end-user experiences.

<script src="//cdn.WebRTC-Experiment.com/getScreenId.js"></script>

<script>
getScreenId(function (error, sourceId, screen_constraints) {
    navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
    navigator.getUserMedia(screen_constraints, function (stream) {
        document.querySelector('video').src = URL.createObjectURL(stream);
    }, function (error) {
        console.error(error);
    });
});
</script>

Signaling?

Browser Support

WebRTC Experiments works fine on following web-browsers:

BrowserSupport
FirefoxStable / Aurora / Nightly
Google ChromeStable / Canary / Beta / Dev
OperaStable / NEXT
AndroidChrome / Firefox / Opera

Credits