This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25908 from davidflanagan/bug1079519-2
Bug 1079519 - Unable to play video clips during WEBRTC video call r=russn,djf
- Loading branch information
Showing
9 changed files
with
195 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Bug 1079519: If a WebRTC call (from the Hello app) is running in the | ||
* background, then the video decoding hardware may be in use, and the video | ||
* app will not be able to play h264 videos that require hardware decoding. | ||
* The <video> element does not have any way to report this condition currently | ||
* and instead just sits and waits its turn to use the hardware. | ||
* | ||
* This modules is a hacky workaround: if we do not get loadedmetadata | ||
* or timeupdate events quickly enough we assume that the video | ||
* hardware is in use and display an error message to the user. | ||
* | ||
* Bug 1093283 has been filed for a real fix to the video element and | ||
* if we get that fix, then we can check for this 'hardware in use' | ||
* condition explicitly and can remove this hack. | ||
*/ | ||
(function(exports) { | ||
'use strict'; | ||
|
||
exports.VideoLoadingChecker = VideoLoadingChecker; | ||
|
||
function VideoLoadingChecker(player, overlay, overlayTitle, overlayText) { | ||
this.player = player; | ||
this.overlay = overlay; | ||
this.overlayTitle = overlayTitle; | ||
this.overlayText = overlayText; | ||
} | ||
|
||
VideoLoadingChecker.prototype = { | ||
|
||
ensureVideoLoads: function vpc_ensureVideoLoads(callback) { | ||
var self = this; | ||
var videoLoadedTimeoutId = setTimeout(showOverlay.bind(null, this), 1000); | ||
this.player.addEventListener('loadedmetadata', handleLoadedMetadata); | ||
|
||
function handleLoadedMetadata() { | ||
|
||
// Video was loaded, don't display the 'video could not be loaded' | ||
// overlay (or hide it). | ||
clearTimeout(videoLoadedTimeoutId); | ||
videoLoadedTimeoutId = null; | ||
self.player.removeEventListener('loadedmetadata', handleLoadedMetadata); | ||
hideOverlay(self); | ||
if (callback) { | ||
callback(); | ||
} | ||
} | ||
}, | ||
|
||
ensureVideoPlays: function() { | ||
this.playingTimeout = setTimeout(showOverlay.bind(null, this), 1000); | ||
this.playingListener = this.cancelEnsureVideoPlays.bind(this); | ||
// When the video hardware is in use, we still get a playing event | ||
// after calling play(). So to ensure that playback is actually | ||
// happening, we listen for a timeupdate event instead. | ||
this.player.addEventListener('timeupdate', this.playingListener); | ||
}, | ||
|
||
cancelEnsureVideoPlays: function() { | ||
hideOverlay(this); | ||
if (this.playingTimeout) { | ||
clearTimeout(this.playingTimeout); | ||
this.playingTimeout = null; | ||
} | ||
if (this.playingListener) { | ||
this.player.removeEventListener('timeupdate', this.playingListener); | ||
this.playingListener = null; | ||
} | ||
} | ||
}; | ||
|
||
function showOverlay(checker) { | ||
checker.overlayTitle.setAttribute('data-l10n-id', | ||
'video-hardware-in-use-title'); | ||
checker.overlayText.setAttribute('data-l10n-id', | ||
'video-hardware-in-use-text'); | ||
checker.overlay.classList.remove('hidden'); | ||
} | ||
|
||
function hideOverlay(checker) { | ||
checker.overlay.classList.add('hidden'); | ||
} | ||
|
||
}(window)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
function VideoLoadingChecker(player, overlay, overlayTitle, overlayText) { | ||
this.player = player; | ||
this.overlay = overlay; | ||
this.overlayTitle = overlayTitle; | ||
this.overlayText = overlayText; | ||
this.callback = null; | ||
} | ||
|
||
VideoLoadingChecker.prototype = { | ||
|
||
ensureVideoLoads: function vpc_ensureVideoLoads(callback) { | ||
this.callback = callback; | ||
}, | ||
invokeLoadedMetadataCallback: function vpc_invokeLoadedMetadataCallback() { | ||
if (this.callback) { | ||
this.callback(); | ||
} | ||
}, | ||
resetLoadedMetadataCallback: function vpc_resetLoadedMetadataCallback() { | ||
this.callback = null; | ||
}, | ||
ensureVideoPlays: function() {}, | ||
cancelEnsureVideoPlays: function() {}, | ||
}; | ||
|
Oops, something went wrong.