mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 11:27:49 +00:00
Bug 520908 - Use calculated duration from cloned decoder when initializing the clone. r=roc
This commit is contained in:
parent
fcdb53d826
commit
3af771c138
@ -1264,6 +1264,12 @@ nsresult nsHTMLMediaElement::InitializeDecoderAsClone(nsMediaDecoder* aOriginal)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
float duration = aOriginal->GetDuration();
|
||||
if (duration >= 0) {
|
||||
mDecoder->SetDuration(PRInt64(NS_round(duration * 1000)));
|
||||
mDecoder->SetSeekable(aOriginal->GetSeekable());
|
||||
}
|
||||
|
||||
nsMediaStream* stream = originalStream->CloneData(mDecoder);
|
||||
if (!stream) {
|
||||
mDecoder = nsnull;
|
||||
@ -1786,7 +1792,7 @@ already_AddRefed<nsIURI> nsHTMLMediaElement::GetNextSource()
|
||||
rv = mSourcePointer->GetStartOffset(&startOffset);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
if (startOffset == GetChildCount())
|
||||
if (PRUint32(startOffset) == GetChildCount())
|
||||
return nsnull; // No more children.
|
||||
|
||||
// Advance the range to the next child.
|
||||
|
@ -2058,6 +2058,7 @@ nsresult nsOggDecoder::Load(nsMediaStream* aStream,
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
mDecodeStateMachine->SetSeekable(mSeekable);
|
||||
mDecodeStateMachine->SetDuration(mDuration);
|
||||
}
|
||||
|
||||
ChangeState(PLAY_STATE_LOADING);
|
||||
|
@ -135,6 +135,8 @@ _TEST_FILES += \
|
||||
bug516323.ogv \
|
||||
bug520493.ogg \
|
||||
bug520500.ogg \
|
||||
bug520908.ogv \
|
||||
bug520908.ogv^headers^ \
|
||||
chain.ogv \
|
||||
dirac.ogg \
|
||||
seek.ogv \
|
||||
|
BIN
content/media/test/bug520908.ogv
Normal file
BIN
content/media/test/bug520908.ogv
Normal file
Binary file not shown.
2
content/media/test/bug520908.ogv^headers^
Normal file
2
content/media/test/bug520908.ogv^headers^
Normal file
@ -0,0 +1,2 @@
|
||||
X-Content-Duration: 9000
|
||||
|
@ -14,6 +14,8 @@ var gSmallTests = [
|
||||
{ name:"bug498855-3.ogv", type:"video/ogg", duration:0.2 },
|
||||
{ name:"bug504644.ogv", type:"video/ogg", duration:1.56 },
|
||||
{ name:"chain.ogv", type:"video/ogg", duration:Number.NaN },
|
||||
// Actual duration is ~200ms, we have X-Content-Duration lie about it.
|
||||
{ name:"bug520908.ogv", type:"video/ogg", duration:9000 },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
|
||||
|
@ -16,6 +16,12 @@ var testsWaiting = 0;
|
||||
|
||||
function cloneLoaded(event) {
|
||||
ok(true, "Clone loaded OK");
|
||||
var e = event.target;
|
||||
|
||||
if (e._expectedDuration) {
|
||||
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
|
||||
"Clone " + e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
|
||||
}
|
||||
|
||||
--testsWaiting;
|
||||
if (testsWaiting == 0) {
|
||||
@ -24,19 +30,31 @@ function cloneLoaded(event) {
|
||||
}
|
||||
|
||||
function tryClone(event) {
|
||||
var clone = event.target.cloneNode(false);
|
||||
clone.mozLoadFrom(event.target);
|
||||
is(clone.currentSrc, event.target.currentSrc, "Clone source OK");
|
||||
var e = event.target;
|
||||
var clone = e.cloneNode(false);
|
||||
|
||||
if (e._expectedDuration) {
|
||||
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
|
||||
e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
|
||||
clone._expectedDuration = e._expectedDuration;
|
||||
}
|
||||
|
||||
clone.mozLoadFrom(e);
|
||||
is(clone.currentSrc, e.currentSrc, "Clone source OK");
|
||||
|
||||
clone.addEventListener("loadeddata", cloneLoaded, false);
|
||||
}
|
||||
|
||||
// Find something we can play
|
||||
for (var i = 0; i < gSmallTests.length; ++i) {
|
||||
var elemType = /^audio/.test(gSmallTests[i].type) ? "audio" : "video";
|
||||
var test = gSmallTests[i];
|
||||
var elemType = /^audio/.test(test.type) ? "audio" : "video";
|
||||
var e = document.createElement(elemType);
|
||||
if (e.canPlayType(gSmallTests[i].type)) {
|
||||
e.src = gSmallTests[i].name;
|
||||
if (e.canPlayType(test.type)) {
|
||||
e.src = test.name;
|
||||
if (test.duration) {
|
||||
e._expectedDuration = test.duration;
|
||||
}
|
||||
e.addEventListener("loadeddata", tryClone, false);
|
||||
e.load();
|
||||
++testsWaiting;
|
||||
|
@ -17,14 +17,6 @@ var videos = [];
|
||||
|
||||
var testsWaiting = 0;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function startTests() {
|
||||
for (var i = 0; i < videos.length; ++i) {
|
||||
document.body.removeChild(videos[i]);
|
||||
|
@ -17,14 +17,6 @@ var videos = [];
|
||||
|
||||
var testsWaiting = 0;
|
||||
|
||||
function startTest() {
|
||||
if (completed)
|
||||
return false;
|
||||
v = document.getElementById('v');
|
||||
v.play();
|
||||
return false;
|
||||
}
|
||||
|
||||
function startTests() {
|
||||
for (var i = 0; i < videos.length; ++i) {
|
||||
document.body.removeChild(videos[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user