Skip to content

Commit

Permalink
Tweaks to eme, web audio
Browse files Browse the repository at this point in the history
  • Loading branch information
samdutton committed Apr 11, 2014
1 parent cef91de commit 92a4269
Show file tree
Hide file tree
Showing 75 changed files with 2,950 additions and 1,010 deletions.
9 changes: 8 additions & 1 deletion .htaccess
Expand Up @@ -3,6 +3,9 @@ AddCharset UTF-8 .html
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript

RedirectMatch 301 /ajax /xhr
RedirectMatch 301 /alpha /videoalpha
RedirectMatch 301 /ck$ /eme/clearkey/src
RedirectMatch 301 /clearkey$ /eme/clearkey/src
RedirectMatch 301 /cpt$ /canplaytype
RedirectMatch 301 /datachannel /rtcdatachannel
RedirectMatch 301 /dc$ /rtcdatachannel
Expand All @@ -15,7 +18,7 @@ RedirectMatch 301 /geo$ /geolocation
RedirectMatch 301 /gum$ /getusermedia
RedirectMatch 301 /input$ /inputtypes
RedirectMatch 301 /location$ /geolocation
RedirectMatch 301 /map$ /track/map
RedirectMatch 301 /map$ /track/map/index.html
RedirectMatch 301 /mf$ /mediafragments
RedirectMatch 301 /mo$ /mutationobserver
RedirectMatch 301 /mr$ /mediarecorder
Expand All @@ -27,10 +30,14 @@ RedirectMatch 301 /pc$ /rtcpeerconnection
RedirectMatch 301 /peerconnection /rtcpeerconnection
RedirectMatch 301 /performance /navigationtiming
RedirectMatch 301 /pm$ /postmessage
RedirectMatch 301 /res$ /getusermedia/constraints
RedirectMatch 301 /search$ /chromesearch
RedirectMatch 301 /sources$ /getusermedia/sources/index.html
RedirectMatch 301 /sse$ /eventsource
RedirectMatch 301 /rt$ /resourcetiming
RedirectMatch 301 /summary$ /details
RedirectMatch 301 /ua$ /useragent
RedirectMatch 301 /wa$ /webaudio
RedirectMatch 301 /webintents /stnetnibew
RedirectMatch 301 /ws /webaudio
RedirectMatch 301 /ww$ /webworkers
Expand Down
2 changes: 1 addition & 1 deletion cors/index.html
Expand Up @@ -40,7 +40,7 @@ <h1><a href="../index.html" title="simpl.info home page">simpl.info</a> CORS</h1
var request = createCORSRequest("get", "http://www.thehillsarealive.net/cors.php");
if (request){
request.onload = function(){
document.getElementById("response").innerText = request.responseText;
document.getElementById("response").textContent = request.responseText;
};
request.send();
}
Expand Down
24 changes: 13 additions & 11 deletions eme/clearkey/src/js/main.js
@@ -1,11 +1,8 @@
// http://shawarma.kir/alcatraz/eme_fps.html

// Define a key: hardcoded in this example
var KEY = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);


// Key ID used for init data.
var keyID = '0123456789012345';
// Specify the Key System used: in this example, Clear Key
var keySystem = 'webkit-org.w3.clearkey';

var dataElement = document.querySelector('#data');
Expand All @@ -16,27 +13,32 @@ videoElement.addEventListener('webkitkeymessage', onKeyMessage);
videoElement.addEventListener('webkitkeyerror', onKeyError);
videoElement.addEventListener('webkitkeyadded', onKeyAdded);

// Handle the needkey event
function onNeedKey(e) {
logEvent(e);
logEvent('needkey', e);
// Generate a key request, specifying the Key System and media InitData
// e.target is the video
console.log('Generate key request with initData', e.initData);
e.target.webkitGenerateKeyRequest(keySystem, e.initData);
}

function onKeyAdded(e) {
logEvent(e);
logEvent('keyadded', e);
}

// Handle a key message, adding a key
function onKeyMessage(e) {
logEvent(e);
logEvent('keymessage', e);
var initData = e.message;
// e.target is the video
e.target.webkitAddKey(keySystem, KEY, initData);
}

function onKeyError(e){
console.log('Error: ', e)
}

function logEvent(e){
dataElement.innerHTML += e.type + ' event' + '<br />';
console.log(e);
function logEvent(eventName, e){
dataElement.innerHTML += eventName + ' event' + '<br />';
console.log(eventName, e);
}
1 change: 0 additions & 1 deletion mse/js/main.js
Expand Up @@ -19,7 +19,6 @@ mediaSource.addEventListener('sourceopen', function(e) {
var sourceBuffer = mediaSource.addSourceBuffer('video/webm; codecs="vorbis,vp8"');
console.log(sourceBuffer);


log('MediaSource readyState: ' + this.readyState);

GET(FILE, function(uInt8Array) {
Expand Down
Binary file added oz/areyouforreal.m4a
Binary file not shown.
Binary file added oz/bewdy.m4a
Binary file not shown.
Binary file added oz/bonzer.m4a
Binary file not shown.
Binary file added oz/fairdinkum.m4a
Binary file not shown.
Binary file added oz/fairgame.m4a
Binary file not shown.
Binary file added oz/gday.m4a
Binary file not shown.
Binary file added oz/getreal.m4a
Binary file not shown.
Binary file added oz/mate.m4a
Binary file not shown.
Binary file added oz/nodramas.m4a
Binary file not shown.
Binary file added oz/noworries.m4a
Binary file not shown.
Binary file added oz/piker.m4a
Binary file not shown.
Binary file added oz/rackoff.m4a
Binary file not shown.
Binary file added oz/ripper.m4a
Binary file not shown.
Binary file added oz/stoked.m4a
Binary file not shown.
Binary file added oz/tata.m4a
Binary file not shown.
Binary file added oz/toodleoo.m4a
Binary file not shown.
Binary file added oz/whinger.m4a
Binary file not shown.
12 changes: 12 additions & 0 deletions rtcpeerconnection/js/main.js
Expand Up @@ -4,6 +4,18 @@ var localStream, localPeerConnection, remotePeerConnection;
var localVideo = document.getElementById("localVideo");
var remoteVideo = document.getElementById("remoteVideo");

localVideo.addEventListener("loadedmetadata", function(){
trace("Local video currentSrc: " + this.currentSrc +
", videoWidth: " + this.videoWidth +
"px, videoHeight: " + this.videoHeight + "px");
});

remoteVideo.addEventListener("loadedmetadata", function(){
trace("Remote video currentSrc: " + this.currentSrc +
", videoWidth: " + this.videoWidth +
"px, videoHeight: " + this.videoHeight + "px");
});

var startButton = document.getElementById("startButton");
var callButton = document.getElementById("callButton");
var hangupButton = document.getElementById("hangupButton");
Expand Down
135 changes: 135 additions & 0 deletions test/adapter.js
@@ -0,0 +1,135 @@
var RTCPeerConnection = null;
var getUserMedia = null;
var attachMediaStream = null;
var reattachMediaStream = null;
var webrtcDetectedBrowser = null;
var webrtcDetectedVersion = null;

function trace(text) {
// This function is used for logging.
if (text[text.length - 1] == '\n') {
text = text.substring(0, text.length - 1);
}
console.log((performance.now() / 1000).toFixed(3) + ": " + text);
}

if (navigator.mozGetUserMedia) {
console.log("This appears to be Firefox");

webrtcDetectedBrowser = "firefox";

webrtcDetectedVersion =
parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1], 10);

// The RTCPeerConnection object.
RTCPeerConnection = mozRTCPeerConnection;

// The RTCSessionDescription object.
RTCSessionDescription = mozRTCSessionDescription;

// The RTCIceCandidate object.
RTCIceCandidate = mozRTCIceCandidate;

// Get UserMedia (only difference is the prefix).
// Code from Adam Barth.
getUserMedia = navigator.mozGetUserMedia.bind(navigator);

// Creates iceServer from the url for FF.
createIceServer = function(url, username, password) {
var iceServer = null;
var url_parts = url.split(':');
if (url_parts[0].indexOf('stun') === 0) {
// Create iceServer with stun url.
iceServer = { 'url': url };
} else if (url_parts[0].indexOf('turn') === 0) {
if (webrtcDetectedVersion < 27) {
// Create iceServer with turn url.
// Ignore the transport parameter from TURN url for FF version <=27.
var turn_url_parts = url.split("?");
// Return null for createIceServer if transport=tcp.
if (turn_url_parts[1].indexOf('transport=udp') === 0) {
iceServer = { 'url': turn_url_parts[0],
'credential': password,
'username': username };
}
} else {
// FF 27 and above supports transport parameters in TURN url,
// So passing in the full url to create iceServer.
iceServer = { 'url': url,
'credential': password,
'username': username };
}
}
return iceServer;
};

// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
console.log("Attaching media stream");
element.mozSrcObject = stream;
element.play();
};

reattachMediaStream = function(to, from) {
console.log("Reattaching media stream");
to.mozSrcObject = from.mozSrcObject;
to.play();
};

// // Fake get{Video,Audio}Tracks
// MediaStream.prototype.getVideoTracks = function() {
// return [];
// };

// MediaStream.prototype.getAudioTracks = function() {
// return [];
// };
} else if (navigator.webkitGetUserMedia) {
console.log("This appears to be Chrome");

webrtcDetectedBrowser = "chrome";
webrtcDetectedVersion =
parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2], 10);

// Creates iceServer from the url for Chrome.
createIceServer = function(url, username, password) {
var iceServer = null;
var url_parts = url.split(':');
if (url_parts[0].indexOf('stun') === 0) {
// Create iceServer with stun url.
iceServer = { 'url': url };
} else if (url_parts[0].indexOf('turn') === 0) {
// Chrome M28 & above uses below TURN format.
iceServer = { 'url': url,
'credential': password,
'username': username };
}
return iceServer;
};

// The RTCPeerConnection object.
RTCPeerConnection = webkitRTCPeerConnection;

// Get UserMedia (only difference is the prefix).
// Code from Adam Barth.
getUserMedia = navigator.webkitGetUserMedia.bind(navigator);

// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
if (typeof element.srcObject !== 'undefined') {
element.srcObject = stream;
} else if (typeof element.mozSrcObject !== 'undefined') {
element.mozSrcObject = stream;
} else if (typeof element.src !== 'undefined') {
element.src = URL.createObjectURL(stream);
} else {
console.log('Error attaching stream to element.');
}
};

reattachMediaStream = function(to, from) {
to.src = from.src;
};
} else {
console.log("Browser does not appear to be WebRTC-capable");
}

0 comments on commit 92a4269

Please sign in to comment.