Embed: android chrome workaround for webrtc with h264
This commit is contained in:
parent
abba35f655
commit
4d94bf78a8
2 changed files with 36 additions and 7 deletions
File diff suppressed because one or more lines are too long
|
@ -229,13 +229,42 @@ p.prototype.build = function (MistVideo,callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.connect = function(callback){
|
this.connect = function(callback){
|
||||||
thisWebRTCPlayer.isConnecting = true;
|
|
||||||
thisWebRTCPlayer.signaling = new WebRTCSignaling(thisWebRTCPlayer.on_event);
|
//chrome on android has a bug where H264 is not available immediately after the tab is opened: https://bugs.chromium.org/p/webrtc/issues/detail?id=11620
|
||||||
thisWebRTCPlayer.peerConn = new RTCPeerConnection();
|
//this workaround tries 5x with 100ms intervals before continuing
|
||||||
thisWebRTCPlayer.peerConn.ontrack = function(ev) {
|
function checkH264(n){
|
||||||
video.srcObject = ev.streams[0];
|
var p = new Promise(function(resolve,reject){
|
||||||
if (callback) { callback(); }
|
function promise_body(n){
|
||||||
|
var r = RTCRtpReceiver.getCapabilities("video");
|
||||||
|
for (var i = 0; i < r.codecs.length; i++) {
|
||||||
|
if (r.codecs[i].mimeType == "video/H264") {
|
||||||
|
resolve("H264 found :)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n > 0) { setTimeout(function(){
|
||||||
|
promise_body(n-1);
|
||||||
|
},100) }
|
||||||
|
else {
|
||||||
|
reject("H264 not found :(");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promise_body(n);
|
||||||
|
});
|
||||||
|
|
||||||
|
return p;
|
||||||
};
|
};
|
||||||
|
checkH264(5).catch(function(){
|
||||||
|
MistVideo.log("Beware: this device does not seem to be able to play H264.");
|
||||||
|
}).finally(function(){
|
||||||
|
thisWebRTCPlayer.isConnecting = true;
|
||||||
|
thisWebRTCPlayer.signaling = new WebRTCSignaling(thisWebRTCPlayer.on_event);
|
||||||
|
thisWebRTCPlayer.peerConn = new RTCPeerConnection();
|
||||||
|
thisWebRTCPlayer.peerConn.ontrack = function(ev) {
|
||||||
|
video.srcObject = ev.streams[0];
|
||||||
|
if (callback) { callback(); }
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.play = function(){
|
this.play = function(){
|
||||||
|
|
Loading…
Add table
Reference in a new issue