mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge from mozilla-central to mozilla-inbound - DONTBUILD (no actual diffs from 7134aa74087d)
This commit is contained in:
commit
8e44d827ce
@ -180,13 +180,16 @@ HTMLLabelIterator::Next()
|
|||||||
nsAccessible* walkUp = mAcc->Parent();
|
nsAccessible* walkUp = mAcc->Parent();
|
||||||
while (walkUp && !walkUp->IsDoc()) {
|
while (walkUp && !walkUp->IsDoc()) {
|
||||||
nsIContent* walkUpElm = walkUp->GetContent();
|
nsIContent* walkUpElm = walkUp->GetContent();
|
||||||
if (walkUpElm->Tag() == nsGkAtoms::label) {
|
if (walkUpElm->IsHTML()) {
|
||||||
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
|
if (walkUpElm->Tag() == nsGkAtoms::label &&
|
||||||
return walkUp;
|
!walkUpElm->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
|
||||||
}
|
mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
|
||||||
|
return walkUp;
|
||||||
|
}
|
||||||
|
|
||||||
if (walkUpElm->Tag() == nsGkAtoms::form)
|
if (walkUpElm->Tag() == nsGkAtoms::form)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
walkUp = walkUp->Parent();
|
walkUp = walkUp->Parent();
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,18 @@ namespace statistics {
|
|||||||
inline void A11yInitialized()
|
inline void A11yInitialized()
|
||||||
{ Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED, true); }
|
{ Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED, true); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report that ISimpleDOM* has been used.
|
||||||
|
*/
|
||||||
|
inline void ISimpleDOMUsed()
|
||||||
|
{ Telemetry::Accumulate(Telemetry::ISIMPLE_DOM_USAGE, 1); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report that IAccessibleTable has been used.
|
||||||
|
*/
|
||||||
|
inline void IAccessibleTableUsed()
|
||||||
|
{ Telemetry::Accumulate(Telemetry::IACCESSIBLE_TABLE_USAGE, 1); }
|
||||||
|
|
||||||
} // namespace statistics
|
} // namespace statistics
|
||||||
} // namespace a11y
|
} // namespace a11y
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -49,10 +49,13 @@
|
|||||||
#include "nsIWinAccessNode.h"
|
#include "nsIWinAccessNode.h"
|
||||||
#include "nsAccessNodeWrap.h"
|
#include "nsAccessNodeWrap.h"
|
||||||
#include "nsWinUtils.h"
|
#include "nsWinUtils.h"
|
||||||
|
#include "Statistics.h"
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
||||||
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
#define CANT_QUERY_ASSERTION_MSG \
|
#define CANT_QUERY_ASSERTION_MSG \
|
||||||
"Subclass of CAccessibleTable doesn't implement nsIAccessibleTable"\
|
"Subclass of CAccessibleTable doesn't implement nsIAccessibleTable"\
|
||||||
|
|
||||||
@ -64,6 +67,7 @@ CAccessibleTable::QueryInterface(REFIID iid, void** ppv)
|
|||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
|
|
||||||
if (IID_IAccessibleTable == iid) {
|
if (IID_IAccessibleTable == iid) {
|
||||||
|
statistics::IAccessibleTableUsed();
|
||||||
*ppv = static_cast<IAccessibleTable*>(this);
|
*ppv = static_cast<IAccessibleTable*>(this);
|
||||||
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "nsCoreUtils.h"
|
#include "nsCoreUtils.h"
|
||||||
#include "nsRootAccessible.h"
|
#include "nsRootAccessible.h"
|
||||||
#include "nsWinUtils.h"
|
#include "nsWinUtils.h"
|
||||||
|
#include "Statistics.h"
|
||||||
|
|
||||||
#include "nsAttrName.h"
|
#include "nsAttrName.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
@ -59,6 +60,7 @@
|
|||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
/// the accessible library and cached methods
|
/// the accessible library and cached methods
|
||||||
HINSTANCE nsAccessNodeWrap::gmAccLib = nsnull;
|
HINSTANCE nsAccessNodeWrap::gmAccLib = nsnull;
|
||||||
@ -120,11 +122,14 @@ STDMETHODIMP nsAccessNodeWrap::QueryInterface(REFIID iid, void** ppv)
|
|||||||
{
|
{
|
||||||
*ppv = nsnull;
|
*ppv = nsnull;
|
||||||
|
|
||||||
if (IID_IUnknown == iid || IID_ISimpleDOMNode == iid)
|
if (IID_IUnknown == iid) {
|
||||||
*ppv = static_cast<ISimpleDOMNode*>(this);
|
*ppv = static_cast<ISimpleDOMNode*>(this);
|
||||||
|
} else if (IID_ISimpleDOMNode == iid) {
|
||||||
if (nsnull == *ppv)
|
statistics::ISimpleDOMUsed();
|
||||||
|
*ppv = static_cast<ISimpleDOMNode*>(this);
|
||||||
|
} else {
|
||||||
return E_NOINTERFACE; //iid not supported.
|
return E_NOINTERFACE; //iid not supported.
|
||||||
|
}
|
||||||
|
|
||||||
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#include "nsIAccessibilityService.h"
|
#include "nsIAccessibilityService.h"
|
||||||
#include "nsRootAccessible.h"
|
#include "nsRootAccessible.h"
|
||||||
#include "nsWinUtils.h"
|
#include "nsWinUtils.h"
|
||||||
|
#include "Statistics.h"
|
||||||
|
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
#include "nsIDocShellTreeNode.h"
|
#include "nsIDocShellTreeNode.h"
|
||||||
@ -54,6 +55,8 @@
|
|||||||
#include "nsIViewManager.h"
|
#include "nsIViewManager.h"
|
||||||
#include "nsIWebNavigation.h"
|
#include "nsIWebNavigation.h"
|
||||||
|
|
||||||
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
/* For documentation of the accessibility architecture,
|
/* For documentation of the accessibility architecture,
|
||||||
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
|
* see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
|
||||||
*/
|
*/
|
||||||
@ -91,12 +94,11 @@ STDMETHODIMP nsDocAccessibleWrap::QueryInterface(REFIID iid, void** ppv)
|
|||||||
{
|
{
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
|
|
||||||
if (IID_ISimpleDOMDocument == iid)
|
if (IID_ISimpleDOMDocument != iid)
|
||||||
*ppv = static_cast<ISimpleDOMDocument*>(this);
|
|
||||||
|
|
||||||
if (NULL == *ppv)
|
|
||||||
return nsHyperTextAccessibleWrap::QueryInterface(iid, ppv);
|
return nsHyperTextAccessibleWrap::QueryInterface(iid, ppv);
|
||||||
|
|
||||||
|
statistics::ISimpleDOMUsed();
|
||||||
|
*ppv = static_cast<ISimpleDOMDocument*>(this);
|
||||||
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "nsCoreUtils.h"
|
#include "nsCoreUtils.h"
|
||||||
#include "nsDocAccessible.h"
|
#include "nsDocAccessible.h"
|
||||||
|
#include "Statistics.h"
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
#include "nsFontMetrics.h"
|
#include "nsFontMetrics.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
@ -48,6 +49,8 @@
|
|||||||
|
|
||||||
#include "gfxFont.h"
|
#include "gfxFont.h"
|
||||||
|
|
||||||
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// nsTextAccessibleWrap Accessible
|
// nsTextAccessibleWrap Accessible
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -72,11 +75,14 @@ STDMETHODIMP nsTextAccessibleWrap::QueryInterface(REFIID iid, void** ppv)
|
|||||||
{
|
{
|
||||||
*ppv = nsnull;
|
*ppv = nsnull;
|
||||||
|
|
||||||
if (IID_IUnknown == iid || IID_ISimpleDOMText == iid)
|
if (IID_IUnknown == iid) {
|
||||||
*ppv = static_cast<ISimpleDOMText*>(this);
|
*ppv = static_cast<ISimpleDOMText*>(this);
|
||||||
|
} else if (IID_ISimpleDOMText == iid) {
|
||||||
if (nsnull == *ppv)
|
statistics::ISimpleDOMUsed();
|
||||||
|
*ppv = static_cast<ISimpleDOMText*>(this);
|
||||||
|
} else {
|
||||||
return nsAccessibleWrap::QueryInterface(iid, ppv);
|
return nsAccessibleWrap::QueryInterface(iid, ppv);
|
||||||
|
}
|
||||||
|
|
||||||
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -170,11 +170,13 @@
|
|||||||
testName("combo4", "Subscribe to ATOM feed.");
|
testName("combo4", "Subscribe to ATOM feed.");
|
||||||
|
|
||||||
testName("comboinmiddle2", "Play the Haliluya sound when new mail arrives");
|
testName("comboinmiddle2", "Play the Haliluya sound when new mail arrives");
|
||||||
testName("combo5", "Play the Haliluya sound when new mail arrives");
|
testName("combo5", null); // label isn't used as a name for control
|
||||||
testName("checkbox", "Play the Haliluya sound when new mail arrives");
|
testName("checkbox", "Play the Haliluya sound when new mail arrives");
|
||||||
|
testName("comboinmiddle3", "Play the Haliluya sound when new mail arrives");
|
||||||
|
testName("combo6", "Play the Haliluya sound when new mail arrives");
|
||||||
|
|
||||||
testName("comboinend", "This day was sunny");
|
testName("comboinend", "This day was sunny");
|
||||||
testName("combo6", "This day was");
|
testName("combo7", "This day was");
|
||||||
|
|
||||||
testName("textboxinend", "This day was sunny");
|
testName("textboxinend", "This day was sunny");
|
||||||
testName("textbox2", "This day was");
|
testName("textbox2", "This day was");
|
||||||
@ -213,6 +215,11 @@
|
|||||||
title="Use placeholder as name if name is otherwise empty">
|
title="Use placeholder as name if name is otherwise empty">
|
||||||
Mozilla Bug 604391
|
Mozilla Bug 604391
|
||||||
</a>
|
</a>
|
||||||
|
<a target="_blank"
|
||||||
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=669312"
|
||||||
|
title="Accessible name is duplicated when input has a label associated uisng for/id and is wrapped around the input">
|
||||||
|
Mozilla Bug 669312
|
||||||
|
</a>
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
<div id="content" style="display: none"></div>
|
<div id="content" style="display: none"></div>
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
@ -437,10 +444,18 @@
|
|||||||
</label>
|
</label>
|
||||||
<input id="checkbox" type="checkbox" />
|
<input id="checkbox" type="checkbox" />
|
||||||
|
|
||||||
|
<label id="comboinmiddle3" for="combo6">Play the
|
||||||
|
<select id="combo6">
|
||||||
|
<option>Haliluya</option>
|
||||||
|
<option>Hurra</option>
|
||||||
|
</select>
|
||||||
|
sound when new mail arrives
|
||||||
|
</label>
|
||||||
|
|
||||||
<!-- at the end (without and with whitespaces) -->
|
<!-- at the end (without and with whitespaces) -->
|
||||||
<label id="comboinend">
|
<label id="comboinend">
|
||||||
This day was
|
This day was
|
||||||
<select id="combo6" name="occupation">
|
<select id="combo7" name="occupation">
|
||||||
<option>sunny</option>
|
<option>sunny</option>
|
||||||
<option>rainy</option>
|
<option>rainy</option>
|
||||||
</select></label>
|
</select></label>
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
testRelation("control1_11", RELATION_LABELLED_BY, "label1_11");
|
testRelation("control1_11", RELATION_LABELLED_BY, "label1_11");
|
||||||
testRelation("control1_12", RELATION_LABELLED_BY, "label1_12");
|
testRelation("control1_12", RELATION_LABELLED_BY, "label1_12");
|
||||||
|
|
||||||
|
testRelation("label1_13", RELATION_LABEL_FOR, null);
|
||||||
|
testRelation("control1_13", RELATION_LABELLED_BY, null);
|
||||||
|
testRelation("control1_14", RELATION_LABELLED_BY, "label1_14");
|
||||||
|
|
||||||
// aria-labelledby
|
// aria-labelledby
|
||||||
testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
|
testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
|
||||||
testRelation("checkbox2", RELATION_LABELLED_BY, "label2");
|
testRelation("checkbox2", RELATION_LABELLED_BY, "label2");
|
||||||
@ -157,6 +161,11 @@
|
|||||||
title="make HTML <output> accessible">
|
title="make HTML <output> accessible">
|
||||||
Mozilla Bug 558036
|
Mozilla Bug 558036
|
||||||
</a>
|
</a>
|
||||||
|
<a target="_blank"
|
||||||
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=682790"
|
||||||
|
title="Ignore implicit label association when it's associated explicitly">
|
||||||
|
Mozilla Bug 682790
|
||||||
|
</a>
|
||||||
<a target="_blank"
|
<a target="_blank"
|
||||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=687393"
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=687393"
|
||||||
title="HTML select options gets relation from containing label">
|
title="HTML select options gets relation from containing label">
|
||||||
@ -204,6 +213,13 @@
|
|||||||
<progress id="control1_12"></progress>
|
<progress id="control1_12"></progress>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label id="label1_13" for="">Label
|
||||||
|
<input id="control1_13">
|
||||||
|
</label>
|
||||||
|
<label id="label1_14" for="control1_14">Label
|
||||||
|
<input id="control1_14">
|
||||||
|
</label>
|
||||||
|
|
||||||
<span id="label2">label</span>
|
<span id="label2">label</span>
|
||||||
<span role="checkbox" id="checkbox2" aria-labelledby="label2"></span>
|
<span role="checkbox" id="checkbox2" aria-labelledby="label2"></span>
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ public:
|
|||||||
already_AddRefed<nsILoadGroup> GetDocumentLoadGroup();
|
already_AddRefed<nsILoadGroup> GetDocumentLoadGroup();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns PR_TRUE if the media has played or completed a seek.
|
* Returns true if the media has played or completed a seek.
|
||||||
* Used by video frame to determine whether to paint the poster.
|
* Used by video frame to determine whether to paint the poster.
|
||||||
*/
|
*/
|
||||||
bool GetPlayedOrSeeked() const { return mHasPlayedOrSeeked; }
|
bool GetPlayedOrSeeked() const { return mHasPlayedOrSeeked; }
|
||||||
@ -343,7 +343,7 @@ public:
|
|||||||
void SetRequestHeaders(nsIHttpChannel* aChannel);
|
void SetRequestHeaders(nsIHttpChannel* aChannel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a timeupdate event. If aPeriodic is PR_TRUE, the event will only
|
* Fires a timeupdate event. If aPeriodic is true, the event will only
|
||||||
* be fired if we've not fired a timeupdate event (for any reason) in the
|
* be fired if we've not fired a timeupdate event (for any reason) in the
|
||||||
* last 250ms, as required by the spec when the current time is periodically
|
* last 250ms, as required by the spec when the current time is periodically
|
||||||
* increasing during playback.
|
* increasing during playback.
|
||||||
@ -639,7 +639,7 @@ protected:
|
|||||||
// An audio stream for writing audio directly from JS.
|
// An audio stream for writing audio directly from JS.
|
||||||
nsRefPtr<nsAudioStream> mAudioStream;
|
nsRefPtr<nsAudioStream> mAudioStream;
|
||||||
|
|
||||||
// PR_TRUE if MozAudioAvailable events can be safely dispatched, based on
|
// True if MozAudioAvailable events can be safely dispatched, based on
|
||||||
// a media and element same-origin check.
|
// a media and element same-origin check.
|
||||||
bool mAllowAudioData;
|
bool mAllowAudioData;
|
||||||
|
|
||||||
@ -679,57 +679,57 @@ protected:
|
|||||||
// to raise the 'waiting' event as per 4.7.1.8 in HTML 5 specification.
|
// to raise the 'waiting' event as per 4.7.1.8 in HTML 5 specification.
|
||||||
bool mPlayingBeforeSeek;
|
bool mPlayingBeforeSeek;
|
||||||
|
|
||||||
// PR_TRUE iff this element is paused because the document is inactive
|
// True iff this element is paused because the document is inactive
|
||||||
bool mPausedForInactiveDocument;
|
bool mPausedForInactiveDocument;
|
||||||
|
|
||||||
// PR_TRUE if we've reported a "waiting" event since the last
|
// True if we've reported a "waiting" event since the last
|
||||||
// readyState change to HAVE_CURRENT_DATA.
|
// readyState change to HAVE_CURRENT_DATA.
|
||||||
bool mWaitingFired;
|
bool mWaitingFired;
|
||||||
|
|
||||||
// PR_TRUE if we're running the "load()" method.
|
// True if we're running the "load()" method.
|
||||||
bool mIsRunningLoadMethod;
|
bool mIsRunningLoadMethod;
|
||||||
|
|
||||||
// PR_TRUE if we're loading the resource from the child source elements.
|
// True if we're loading the resource from the child source elements.
|
||||||
bool mIsLoadingFromSourceChildren;
|
bool mIsLoadingFromSourceChildren;
|
||||||
|
|
||||||
// PR_TRUE if we're delaying the "load" event. They are delayed until either
|
// True if we're delaying the "load" event. They are delayed until either
|
||||||
// an error occurs, or the first frame is loaded.
|
// an error occurs, or the first frame is loaded.
|
||||||
bool mDelayingLoadEvent;
|
bool mDelayingLoadEvent;
|
||||||
|
|
||||||
// PR_TRUE when we've got a task queued to call SelectResource(),
|
// True when we've got a task queued to call SelectResource(),
|
||||||
// or while we're running SelectResource().
|
// or while we're running SelectResource().
|
||||||
bool mIsRunningSelectResource;
|
bool mIsRunningSelectResource;
|
||||||
|
|
||||||
// PR_TRUE if we suspended the decoder because we were paused,
|
// True if we suspended the decoder because we were paused,
|
||||||
// preloading metadata is enabled, autoplay was not enabled, and we loaded
|
// preloading metadata is enabled, autoplay was not enabled, and we loaded
|
||||||
// the first frame.
|
// the first frame.
|
||||||
bool mSuspendedAfterFirstFrame;
|
bool mSuspendedAfterFirstFrame;
|
||||||
|
|
||||||
// PR_TRUE if we are allowed to suspend the decoder because we were paused,
|
// True if we are allowed to suspend the decoder because we were paused,
|
||||||
// preloading metdata was enabled, autoplay was not enabled, and we loaded
|
// preloading metdata was enabled, autoplay was not enabled, and we loaded
|
||||||
// the first frame.
|
// the first frame.
|
||||||
bool mAllowSuspendAfterFirstFrame;
|
bool mAllowSuspendAfterFirstFrame;
|
||||||
|
|
||||||
// PR_TRUE if we've played or completed a seek. We use this to determine
|
// True if we've played or completed a seek. We use this to determine
|
||||||
// when the poster frame should be shown.
|
// when the poster frame should be shown.
|
||||||
bool mHasPlayedOrSeeked;
|
bool mHasPlayedOrSeeked;
|
||||||
|
|
||||||
// PR_TRUE if we've added a reference to ourselves to keep the element
|
// True if we've added a reference to ourselves to keep the element
|
||||||
// alive while no-one is referencing it but the element may still fire
|
// alive while no-one is referencing it but the element may still fire
|
||||||
// events of its own accord.
|
// events of its own accord.
|
||||||
bool mHasSelfReference;
|
bool mHasSelfReference;
|
||||||
|
|
||||||
// PR_TRUE if we've received a notification that the engine is shutting
|
// True if we've received a notification that the engine is shutting
|
||||||
// down.
|
// down.
|
||||||
bool mShuttingDown;
|
bool mShuttingDown;
|
||||||
|
|
||||||
// PR_TRUE if we've suspended a load in the resource selection algorithm
|
// True if we've suspended a load in the resource selection algorithm
|
||||||
// due to loading a preload:none media. When PR_TRUE, the resource we'll
|
// due to loading a preload:none media. When true, the resource we'll
|
||||||
// load when the user initiates either playback or an explicit load is
|
// load when the user initiates either playback or an explicit load is
|
||||||
// stored in mPreloadURI.
|
// stored in mPreloadURI.
|
||||||
bool mLoadIsSuspended;
|
bool mLoadIsSuspended;
|
||||||
|
|
||||||
// PR_TRUE if a same-origin check has been done for the media element and resource.
|
// True if a same-origin check has been done for the media element and resource.
|
||||||
bool mMediaSecurityVerified;
|
bool mMediaSecurityVerified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ nsHTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext,
|
|||||||
// 'preload' set to 'auto' (since the script must intend to
|
// 'preload' set to 'auto' (since the script must intend to
|
||||||
// play the audio)
|
// play the audio)
|
||||||
nsresult rv = SetAttr(kNameSpaceID_None, nsGkAtoms::preload,
|
nsresult rv = SetAttr(kNameSpaceID_None, nsGkAtoms::preload,
|
||||||
NS_LITERAL_STRING("auto"), PR_TRUE);
|
NS_LITERAL_STRING("auto"), true);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ nsHTMLAudioElement::Initialize(nsISupports* aOwner, JSContext* aContext,
|
|||||||
if (!str.init(aContext, jsstr))
|
if (!str.init(aContext, jsstr))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = SetAttr(kNameSpaceID_None, nsGkAtoms::src, str, PR_TRUE);
|
rv = SetAttr(kNameSpaceID_None, nsGkAtoms::src, str, true);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
@ -267,5 +267,5 @@ nsresult nsHTMLAudioElement::SetAcceptHeader(nsIHttpChannel* aChannel)
|
|||||||
|
|
||||||
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
||||||
value,
|
value,
|
||||||
PR_FALSE);
|
false);
|
||||||
}
|
}
|
||||||
|
@ -227,8 +227,8 @@ public:
|
|||||||
return nsContentUtils::DispatchTrustedEvent(mElement->GetOwnerDoc(),
|
return nsContentUtils::DispatchTrustedEvent(mElement->GetOwnerDoc(),
|
||||||
mSource,
|
mSource,
|
||||||
NS_LITERAL_STRING("error"),
|
NS_LITERAL_STRING("error"),
|
||||||
PR_FALSE,
|
false,
|
||||||
PR_TRUE);
|
true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ NS_IMETHODIMP nsHTMLMediaElement::GetError(nsIDOMMediaError * *aError)
|
|||||||
/* readonly attribute boolean ended; */
|
/* readonly attribute boolean ended; */
|
||||||
NS_IMETHODIMP nsHTMLMediaElement::GetEnded(bool *aEnded)
|
NS_IMETHODIMP nsHTMLMediaElement::GetEnded(bool *aEnded)
|
||||||
{
|
{
|
||||||
*aEnded = mDecoder ? mDecoder->IsEnded() : PR_FALSE;
|
*aEnded = mDecoder ? mDecoder->IsEnded() : false;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ nsHTMLMediaElement::OnChannelRedirect(nsIChannel *aChannel,
|
|||||||
http = do_QueryInterface(aNewChannel);
|
http = do_QueryInterface(aNewChannel);
|
||||||
NS_ENSURE_STATE(http);
|
NS_ENSURE_STATE(http);
|
||||||
|
|
||||||
nsresult rv = http->SetRequestHeader(rangeHdr, rangeVal, PR_FALSE);
|
nsresult rv = http->SetRequestHeader(rangeHdr, rangeVal, false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,11 +490,11 @@ void nsHTMLMediaElement::AbortExistingLoads()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mError = nsnull;
|
mError = nsnull;
|
||||||
mLoadedFirstFrame = PR_FALSE;
|
mLoadedFirstFrame = false;
|
||||||
mAutoplaying = PR_TRUE;
|
mAutoplaying = true;
|
||||||
mIsLoadingFromSourceChildren = PR_FALSE;
|
mIsLoadingFromSourceChildren = false;
|
||||||
mSuspendedAfterFirstFrame = PR_FALSE;
|
mSuspendedAfterFirstFrame = false;
|
||||||
mAllowSuspendAfterFirstFrame = PR_TRUE;
|
mAllowSuspendAfterFirstFrame = true;
|
||||||
mSourcePointer = nsnull;
|
mSourcePointer = nsnull;
|
||||||
|
|
||||||
// TODO: The playback rate must be set to the default playback rate.
|
// TODO: The playback rate must be set to the default playback rate.
|
||||||
@ -502,14 +502,14 @@ void nsHTMLMediaElement::AbortExistingLoads()
|
|||||||
if (mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
|
if (mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
||||||
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING);
|
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING);
|
||||||
mPaused = PR_TRUE;
|
mPaused = true;
|
||||||
|
|
||||||
if (fireTimeUpdate) {
|
if (fireTimeUpdate) {
|
||||||
// Since we destroyed the decoder above, the current playback position
|
// Since we destroyed the decoder above, the current playback position
|
||||||
// will now be reported as 0. The playback position was non-zero when
|
// will now be reported as 0. The playback position was non-zero when
|
||||||
// we destroyed the decoder, so fire a timeupdate event so that the
|
// we destroyed the decoder, so fire a timeupdate event so that the
|
||||||
// change will be reflected in the controls.
|
// change will be reflected in the controls.
|
||||||
FireTimeUpdate(PR_FALSE);
|
FireTimeUpdate(false);
|
||||||
}
|
}
|
||||||
DispatchEvent(NS_LITERAL_STRING("emptied"));
|
DispatchEvent(NS_LITERAL_STRING("emptied"));
|
||||||
}
|
}
|
||||||
@ -518,7 +518,7 @@ void nsHTMLMediaElement::AbortExistingLoads()
|
|||||||
// things which can affect AddRemoveSelfReference
|
// things which can affect AddRemoveSelfReference
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
|
|
||||||
mIsRunningSelectResource = PR_FALSE;
|
mIsRunningSelectResource = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::NoSupportedMediaSourceError()
|
void nsHTMLMediaElement::NoSupportedMediaSourceError()
|
||||||
@ -529,7 +529,7 @@ void nsHTMLMediaElement::NoSupportedMediaSourceError()
|
|||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
||||||
// This clears mDelayingLoadEvent, so AddRemoveSelfReference will be called
|
// This clears mDelayingLoadEvent, so AddRemoveSelfReference will be called
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (nsHTMLMediaElement::*SyncSectionFn)();
|
typedef void (nsHTMLMediaElement::*SyncSectionFn)();
|
||||||
@ -573,7 +573,7 @@ void AsyncAwaitStableState(nsHTMLMediaElement* aElement,
|
|||||||
|
|
||||||
void nsHTMLMediaElement::QueueLoadFromSourceTask()
|
void nsHTMLMediaElement::QueueLoadFromSourceTask()
|
||||||
{
|
{
|
||||||
ChangeDelayLoadStatus(PR_TRUE);
|
ChangeDelayLoadStatus(true);
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
||||||
AsyncAwaitStableState(this, &nsHTMLMediaElement::LoadFromSourceChildren);
|
AsyncAwaitStableState(this, &nsHTMLMediaElement::LoadFromSourceChildren);
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ void nsHTMLMediaElement::QueueSelectResourceTask()
|
|||||||
// Don't allow multiple async select resource calls to be queued.
|
// Don't allow multiple async select resource calls to be queued.
|
||||||
if (mIsRunningSelectResource)
|
if (mIsRunningSelectResource)
|
||||||
return;
|
return;
|
||||||
mIsRunningSelectResource = PR_TRUE;
|
mIsRunningSelectResource = true;
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
||||||
AsyncAwaitStableState(this, &nsHTMLMediaElement::SelectResource);
|
AsyncAwaitStableState(this, &nsHTMLMediaElement::SelectResource);
|
||||||
}
|
}
|
||||||
@ -593,11 +593,11 @@ NS_IMETHODIMP nsHTMLMediaElement::Load()
|
|||||||
{
|
{
|
||||||
if (mIsRunningLoadMethod)
|
if (mIsRunningLoadMethod)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
SetPlayedOrSeeked(PR_FALSE);
|
SetPlayedOrSeeked(false);
|
||||||
mIsRunningLoadMethod = PR_TRUE;
|
mIsRunningLoadMethod = true;
|
||||||
AbortExistingLoads();
|
AbortExistingLoads();
|
||||||
QueueSelectResourceTask();
|
QueueSelectResourceTask();
|
||||||
mIsRunningLoadMethod = PR_FALSE;
|
mIsRunningLoadMethod = false;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,10 +608,10 @@ static bool HasSourceChildren(nsIContent *aElement)
|
|||||||
child = child->GetNextSibling()) {
|
child = child->GetNextSibling()) {
|
||||||
if (child->IsHTML(nsGkAtoms::source))
|
if (child->IsHTML(nsGkAtoms::source))
|
||||||
{
|
{
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::SelectResource()
|
void nsHTMLMediaElement::SelectResource()
|
||||||
@ -621,12 +621,12 @@ void nsHTMLMediaElement::SelectResource()
|
|||||||
// element children, abort the load.
|
// element children, abort the load.
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
||||||
// This clears mDelayingLoadEvent, so AddRemoveSelfReference will be called
|
// This clears mDelayingLoadEvent, so AddRemoveSelfReference will be called
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
mIsRunningSelectResource = PR_FALSE;
|
mIsRunningSelectResource = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeDelayLoadStatus(PR_TRUE);
|
ChangeDelayLoadStatus(true);
|
||||||
|
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
||||||
// Load event was delayed, and still is, so no need to call
|
// Load event was delayed, and still is, so no need to call
|
||||||
@ -648,23 +648,23 @@ void nsHTMLMediaElement::SelectResource()
|
|||||||
// preload:none media, suspend the load here before we make any
|
// preload:none media, suspend the load here before we make any
|
||||||
// network requests.
|
// network requests.
|
||||||
SuspendLoad(uri);
|
SuspendLoad(uri);
|
||||||
mIsRunningSelectResource = PR_FALSE;
|
mIsRunningSelectResource = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = LoadResource(uri);
|
rv = LoadResource(uri);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
mIsRunningSelectResource = PR_FALSE;
|
mIsRunningSelectResource = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NoSupportedMediaSourceError();
|
NoSupportedMediaSourceError();
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, the source elements will be used.
|
// Otherwise, the source elements will be used.
|
||||||
mIsLoadingFromSourceChildren = PR_TRUE;
|
mIsLoadingFromSourceChildren = true;
|
||||||
LoadFromSourceChildren();
|
LoadFromSourceChildren();
|
||||||
}
|
}
|
||||||
mIsRunningSelectResource = PR_FALSE;
|
mIsRunningSelectResource = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::NotifyLoadError()
|
void nsHTMLMediaElement::NotifyLoadError()
|
||||||
@ -694,7 +694,7 @@ void nsHTMLMediaElement::NotifyAudioAvailable(float* aFrameBuffer,
|
|||||||
nsCOMPtr<nsIPrincipal> principal = GetCurrentPrincipal();
|
nsCOMPtr<nsIPrincipal> principal = GetCurrentPrincipal();
|
||||||
nsresult rv = NodePrincipal()->Subsumes(principal, &mAllowAudioData);
|
nsresult rv = NodePrincipal()->Subsumes(principal, &mAllowAudioData);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mAllowAudioData = PR_FALSE;
|
mAllowAudioData = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -708,12 +708,12 @@ bool nsHTMLMediaElement::MayHaveAudioAvailableEventListener()
|
|||||||
// |var a = new Audio()| with no parent document.
|
// |var a = new Audio()| with no parent document.
|
||||||
nsIDocument *document = GetDocument();
|
nsIDocument *document = GetDocument();
|
||||||
if (!document) {
|
if (!document) {
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPIDOMWindow *window = document->GetInnerWindow();
|
nsPIDOMWindow *window = document->GetInnerWindow();
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return window->HasAudioAvailableEventListeners();
|
return window->HasAudioAvailableEventListeners();
|
||||||
@ -725,7 +725,7 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
|
|||||||
"Should delay load event (if in document) during load");
|
"Should delay load event (if in document) during load");
|
||||||
NS_ASSERTION(mIsLoadingFromSourceChildren,
|
NS_ASSERTION(mIsLoadingFromSourceChildren,
|
||||||
"Must remember we're loading from source children");
|
"Must remember we're loading from source children");
|
||||||
while (PR_TRUE) {
|
while (true) {
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsIContent* child = GetNextSource();
|
nsIContent* child = GetNextSource();
|
||||||
if (!child) {
|
if (!child) {
|
||||||
@ -733,7 +733,7 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
|
|||||||
// the media element.
|
// the media element.
|
||||||
mLoadWaitStatus = WAITING_FOR_SOURCE;
|
mLoadWaitStatus = WAITING_FOR_SOURCE;
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE;
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,19 +785,19 @@ void nsHTMLMediaElement::LoadFromSourceChildren()
|
|||||||
|
|
||||||
void nsHTMLMediaElement::SuspendLoad(nsIURI* aURI)
|
void nsHTMLMediaElement::SuspendLoad(nsIURI* aURI)
|
||||||
{
|
{
|
||||||
mLoadIsSuspended = PR_TRUE;
|
mLoadIsSuspended = true;
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("suspend"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("suspend"));
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::ResumeLoad(PreloadAction aAction)
|
void nsHTMLMediaElement::ResumeLoad(PreloadAction aAction)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mLoadIsSuspended, "Can only resume preload if halted for one");
|
NS_ASSERTION(mLoadIsSuspended, "Can only resume preload if halted for one");
|
||||||
nsCOMPtr<nsIURI> uri = mLoadingSrc;
|
nsCOMPtr<nsIURI> uri = mLoadingSrc;
|
||||||
mLoadIsSuspended = PR_FALSE;
|
mLoadIsSuspended = false;
|
||||||
mPreloadAction = aAction;
|
mPreloadAction = aAction;
|
||||||
ChangeDelayLoadStatus(PR_TRUE);
|
ChangeDelayLoadStatus(true);
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING;
|
||||||
if (!mIsLoadingFromSourceChildren) {
|
if (!mIsLoadingFromSourceChildren) {
|
||||||
// We were loading from the element's src attribute.
|
// We were loading from the element's src attribute.
|
||||||
@ -881,7 +881,7 @@ void nsHTMLMediaElement::UpdatePreloadAction()
|
|||||||
|
|
||||||
} else if (nextAction == nsHTMLMediaElement::PRELOAD_METADATA) {
|
} else if (nextAction == nsHTMLMediaElement::PRELOAD_METADATA) {
|
||||||
// Ensure that the video can be suspended after first frame.
|
// Ensure that the video can be suspended after first frame.
|
||||||
mAllowSuspendAfterFirstFrame = PR_TRUE;
|
mAllowSuspendAfterFirstFrame = true;
|
||||||
if (mLoadIsSuspended) {
|
if (mLoadIsSuspended) {
|
||||||
// Our load was previouly suspended due to the media having preload
|
// Our load was previouly suspended due to the media having preload
|
||||||
// value "none". The preload value has changed to preload:metadata, so
|
// value "none". The preload value has changed to preload:metadata, so
|
||||||
@ -964,7 +964,7 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
|
|||||||
new nsCORSListenerProxy(loadListener,
|
new nsCORSListenerProxy(loadListener,
|
||||||
NodePrincipal(),
|
NodePrincipal(),
|
||||||
channel,
|
channel,
|
||||||
PR_FALSE,
|
false,
|
||||||
&rv);
|
&rv);
|
||||||
} else {
|
} else {
|
||||||
rv = nsContentUtils::GetSecurityManager()->
|
rv = nsContentUtils::GetSecurityManager()->
|
||||||
@ -982,7 +982,7 @@ nsresult nsHTMLMediaElement::LoadResource(nsIURI* aURI)
|
|||||||
// requests, and therefore seeking, early.
|
// requests, and therefore seeking, early.
|
||||||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"),
|
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"),
|
||||||
NS_LITERAL_CSTRING("bytes=0-"),
|
NS_LITERAL_CSTRING("bytes=0-"),
|
||||||
PR_FALSE);
|
false);
|
||||||
|
|
||||||
SetRequestHeaders(hc);
|
SetRequestHeaders(hc);
|
||||||
}
|
}
|
||||||
@ -1011,11 +1011,11 @@ nsresult nsHTMLMediaElement::LoadWithChannel(nsIChannel *aChannel,
|
|||||||
|
|
||||||
AbortExistingLoads();
|
AbortExistingLoads();
|
||||||
|
|
||||||
ChangeDelayLoadStatus(PR_TRUE);
|
ChangeDelayLoadStatus(true);
|
||||||
|
|
||||||
nsresult rv = InitializeDecoderForChannel(aChannel, aListener);
|
nsresult rv = InitializeDecoderForChannel(aChannel, aListener);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,11 +1035,11 @@ NS_IMETHODIMP nsHTMLMediaElement::MozLoadFrom(nsIDOMHTMLMediaElement* aOther)
|
|||||||
if (!other || !other->mDecoder)
|
if (!other || !other->mDecoder)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
ChangeDelayLoadStatus(PR_TRUE);
|
ChangeDelayLoadStatus(true);
|
||||||
|
|
||||||
nsresult rv = InitializeDecoderAsClone(other->mDecoder);
|
nsresult rv = InitializeDecoderAsClone(other->mDecoder);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,13 +1150,13 @@ NS_IMETHODIMP nsHTMLMediaElement::Pause()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool oldPaused = mPaused;
|
bool oldPaused = mPaused;
|
||||||
mPaused = PR_TRUE;
|
mPaused = true;
|
||||||
mAutoplaying = PR_FALSE;
|
mAutoplaying = false;
|
||||||
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
|
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
|
|
||||||
if (!oldPaused) {
|
if (!oldPaused) {
|
||||||
FireTimeUpdate(PR_FALSE);
|
FireTimeUpdate(false);
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("pause"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("pause"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,27 +1276,27 @@ nsHTMLMediaElement::nsHTMLMediaElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
|||||||
mLastCurrentTime(0.0),
|
mLastCurrentTime(0.0),
|
||||||
mFragmentStart(-1.0),
|
mFragmentStart(-1.0),
|
||||||
mFragmentEnd(-1.0),
|
mFragmentEnd(-1.0),
|
||||||
mAllowAudioData(PR_FALSE),
|
mAllowAudioData(false),
|
||||||
mBegun(PR_FALSE),
|
mBegun(false),
|
||||||
mLoadedFirstFrame(PR_FALSE),
|
mLoadedFirstFrame(false),
|
||||||
mAutoplaying(PR_TRUE),
|
mAutoplaying(true),
|
||||||
mAutoplayEnabled(PR_TRUE),
|
mAutoplayEnabled(true),
|
||||||
mPaused(PR_TRUE),
|
mPaused(true),
|
||||||
mMuted(PR_FALSE),
|
mMuted(false),
|
||||||
mPlayingBeforeSeek(PR_FALSE),
|
mPlayingBeforeSeek(false),
|
||||||
mPausedForInactiveDocument(PR_FALSE),
|
mPausedForInactiveDocument(false),
|
||||||
mWaitingFired(PR_FALSE),
|
mWaitingFired(false),
|
||||||
mIsRunningLoadMethod(PR_FALSE),
|
mIsRunningLoadMethod(false),
|
||||||
mIsLoadingFromSourceChildren(PR_FALSE),
|
mIsLoadingFromSourceChildren(false),
|
||||||
mDelayingLoadEvent(PR_FALSE),
|
mDelayingLoadEvent(false),
|
||||||
mIsRunningSelectResource(PR_FALSE),
|
mIsRunningSelectResource(false),
|
||||||
mSuspendedAfterFirstFrame(PR_FALSE),
|
mSuspendedAfterFirstFrame(false),
|
||||||
mAllowSuspendAfterFirstFrame(PR_TRUE),
|
mAllowSuspendAfterFirstFrame(true),
|
||||||
mHasPlayedOrSeeked(PR_FALSE),
|
mHasPlayedOrSeeked(false),
|
||||||
mHasSelfReference(PR_FALSE),
|
mHasSelfReference(false),
|
||||||
mShuttingDown(PR_FALSE),
|
mShuttingDown(false),
|
||||||
mLoadIsSuspended(PR_FALSE),
|
mLoadIsSuspended(false),
|
||||||
mMediaSecurityVerified(PR_FALSE)
|
mMediaSecurityVerified(false)
|
||||||
{
|
{
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
if (!gMediaElementLog) {
|
if (!gMediaElementLog) {
|
||||||
@ -1333,12 +1333,12 @@ nsHTMLMediaElement::~nsHTMLMediaElement()
|
|||||||
|
|
||||||
void nsHTMLMediaElement::StopSuspendingAfterFirstFrame()
|
void nsHTMLMediaElement::StopSuspendingAfterFirstFrame()
|
||||||
{
|
{
|
||||||
mAllowSuspendAfterFirstFrame = PR_FALSE;
|
mAllowSuspendAfterFirstFrame = false;
|
||||||
if (!mSuspendedAfterFirstFrame)
|
if (!mSuspendedAfterFirstFrame)
|
||||||
return;
|
return;
|
||||||
mSuspendedAfterFirstFrame = PR_FALSE;
|
mSuspendedAfterFirstFrame = false;
|
||||||
if (mDecoder) {
|
if (mDecoder) {
|
||||||
mDecoder->Resume(PR_TRUE);
|
mDecoder->Resume(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1360,7 +1360,7 @@ void nsHTMLMediaElement::SetPlayedOrSeeked(bool aValue)
|
|||||||
NS_IMETHODIMP nsHTMLMediaElement::Play()
|
NS_IMETHODIMP nsHTMLMediaElement::Play()
|
||||||
{
|
{
|
||||||
StopSuspendingAfterFirstFrame();
|
StopSuspendingAfterFirstFrame();
|
||||||
SetPlayedOrSeeked(PR_TRUE);
|
SetPlayedOrSeeked(true);
|
||||||
|
|
||||||
if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
|
if (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
|
||||||
nsresult rv = Load();
|
nsresult rv = Load();
|
||||||
@ -1388,7 +1388,7 @@ NS_IMETHODIMP nsHTMLMediaElement::Play()
|
|||||||
break;
|
break;
|
||||||
case nsIDOMHTMLMediaElement::HAVE_METADATA:
|
case nsIDOMHTMLMediaElement::HAVE_METADATA:
|
||||||
case nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA:
|
case nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA:
|
||||||
FireTimeUpdate(PR_FALSE);
|
FireTimeUpdate(false);
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("waiting"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("waiting"));
|
||||||
break;
|
break;
|
||||||
case nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA:
|
case nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA:
|
||||||
@ -1398,8 +1398,8 @@ NS_IMETHODIMP nsHTMLMediaElement::Play()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPaused = PR_FALSE;
|
mPaused = false;
|
||||||
mAutoplaying = PR_FALSE;
|
mAutoplaying = false;
|
||||||
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
|
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
|
||||||
// and our preload status.
|
// and our preload status.
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
@ -1430,10 +1430,10 @@ bool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
|
|||||||
return aResult.ParseDoubleValue(aValue);
|
return aResult.ParseDoubleValue(aValue);
|
||||||
}
|
}
|
||||||
else if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
else if (ParseImageAttribute(aAttribute, aValue, aResult)) {
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
else if (aAttribute == nsGkAtoms::preload) {
|
else if (aAttribute == nsGkAtoms::preload) {
|
||||||
return aResult.ParseEnumValue(aValue, kPreloadTable, PR_FALSE);
|
return aResult.ParseEnumValue(aValue, kPreloadTable, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1535,12 +1535,12 @@ static bool IsRawEnabled()
|
|||||||
static bool IsRawType(const nsACString& aType)
|
static bool IsRawType(const nsACString& aType)
|
||||||
{
|
{
|
||||||
if (!IsRawEnabled())
|
if (!IsRawEnabled())
|
||||||
return PR_FALSE;
|
return false;
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gRawTypes); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gRawTypes); ++i) {
|
||||||
if (aType.EqualsASCII(gRawTypes[i]))
|
if (aType.EqualsASCII(gRawTypes[i]))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef MOZ_OGG
|
#ifdef MOZ_OGG
|
||||||
@ -1568,12 +1568,12 @@ bool
|
|||||||
nsHTMLMediaElement::IsOggType(const nsACString& aType)
|
nsHTMLMediaElement::IsOggType(const nsACString& aType)
|
||||||
{
|
{
|
||||||
if (!IsOggEnabled())
|
if (!IsOggEnabled())
|
||||||
return PR_FALSE;
|
return false;
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gOggTypes); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gOggTypes); ++i) {
|
||||||
if (aType.EqualsASCII(gOggTypes[i]))
|
if (aType.EqualsASCII(gOggTypes[i]))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1603,12 +1603,12 @@ bool
|
|||||||
nsHTMLMediaElement::IsWaveType(const nsACString& aType)
|
nsHTMLMediaElement::IsWaveType(const nsACString& aType)
|
||||||
{
|
{
|
||||||
if (!IsWaveEnabled())
|
if (!IsWaveEnabled())
|
||||||
return PR_FALSE;
|
return false;
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gWaveTypes); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gWaveTypes); ++i) {
|
||||||
if (aType.EqualsASCII(gWaveTypes[i]))
|
if (aType.EqualsASCII(gWaveTypes[i]))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1635,12 +1635,12 @@ bool
|
|||||||
nsHTMLMediaElement::IsWebMType(const nsACString& aType)
|
nsHTMLMediaElement::IsWebMType(const nsACString& aType)
|
||||||
{
|
{
|
||||||
if (!IsWebMEnabled())
|
if (!IsWebMEnabled())
|
||||||
return PR_FALSE;
|
return false;
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gWebMTypes); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gWebMTypes); ++i) {
|
||||||
if (aType.EqualsASCII(gWebMTypes[i]))
|
if (aType.EqualsASCII(gWebMTypes[i]))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1681,22 +1681,22 @@ bool nsHTMLMediaElement::ShouldHandleMediaType(const char* aMIMEType)
|
|||||||
{
|
{
|
||||||
#ifdef MOZ_RAW
|
#ifdef MOZ_RAW
|
||||||
if (IsRawType(nsDependentCString(aMIMEType)))
|
if (IsRawType(nsDependentCString(aMIMEType)))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MOZ_OGG
|
#ifdef MOZ_OGG
|
||||||
if (IsOggType(nsDependentCString(aMIMEType)))
|
if (IsOggType(nsDependentCString(aMIMEType)))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MOZ_WEBM
|
#ifdef MOZ_WEBM
|
||||||
if (IsWebMType(nsDependentCString(aMIMEType)))
|
if (IsWebMType(nsDependentCString(aMIMEType)))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
// We should not return true for Wave types, since there are some
|
// We should not return true for Wave types, since there are some
|
||||||
// Wave codecs actually in use in the wild that we don't support, and
|
// Wave codecs actually in use in the wild that we don't support, and
|
||||||
// we should allow those to be handled by plugins or helper apps.
|
// we should allow those to be handled by plugins or helper apps.
|
||||||
// Furthermore people can play Wave files on most platforms by other
|
// Furthermore people can play Wave files on most platforms by other
|
||||||
// means.
|
// means.
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -1704,9 +1704,9 @@ CodecListContains(char const *const * aCodecs, const nsAString& aCodec)
|
|||||||
{
|
{
|
||||||
for (PRInt32 i = 0; aCodecs[i]; ++i) {
|
for (PRInt32 i = 0; aCodecs[i]; ++i) {
|
||||||
if (aCodec.EqualsASCII(aCodecs[i]))
|
if (aCodec.EqualsASCII(aCodecs[i]))
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
@ -1879,10 +1879,10 @@ nsresult nsHTMLMediaElement::FinishDecoderSetup(nsMediaDecoder* aDecoder)
|
|||||||
mLoadingSrc = nsnull;
|
mLoadingSrc = nsnull;
|
||||||
|
|
||||||
// Force a same-origin check before allowing events for this media resource.
|
// Force a same-origin check before allowing events for this media resource.
|
||||||
mMediaSecurityVerified = PR_FALSE;
|
mMediaSecurityVerified = false;
|
||||||
|
|
||||||
// The new stream has not been suspended by us.
|
// The new stream has not been suspended by us.
|
||||||
mPausedForInactiveDocument = PR_FALSE;
|
mPausedForInactiveDocument = false;
|
||||||
// But we may want to suspend it now.
|
// But we may want to suspend it now.
|
||||||
// This will also do an AddRemoveSelfReference.
|
// This will also do an AddRemoveSelfReference.
|
||||||
NotifyOwnerDocumentActivityChanged();
|
NotifyOwnerDocumentActivityChanged();
|
||||||
@ -1892,13 +1892,13 @@ nsresult nsHTMLMediaElement::FinishDecoderSetup(nsMediaDecoder* aDecoder)
|
|||||||
mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
|
mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
|
||||||
|
|
||||||
if (!mPaused) {
|
if (!mPaused) {
|
||||||
SetPlayedOrSeeked(PR_TRUE);
|
SetPlayedOrSeeked(true);
|
||||||
if (!mPausedForInactiveDocument) {
|
if (!mPausedForInactiveDocument) {
|
||||||
rv = mDecoder->Play();
|
rv = mDecoder->Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mBegun = PR_TRUE;
|
mBegun = true;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1977,7 +1977,7 @@ void nsHTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded)
|
|||||||
ChangeReadyState(aResourceFullyLoaded ?
|
ChangeReadyState(aResourceFullyLoaded ?
|
||||||
nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA :
|
nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA :
|
||||||
nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);
|
nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
|
|
||||||
NS_ASSERTION(!mSuspendedAfterFirstFrame, "Should not have already suspended");
|
NS_ASSERTION(!mSuspendedAfterFirstFrame, "Should not have already suspended");
|
||||||
|
|
||||||
@ -1985,14 +1985,14 @@ void nsHTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded)
|
|||||||
!aResourceFullyLoaded &&
|
!aResourceFullyLoaded &&
|
||||||
!HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) &&
|
!HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) &&
|
||||||
mPreloadAction == nsHTMLMediaElement::PRELOAD_METADATA) {
|
mPreloadAction == nsHTMLMediaElement::PRELOAD_METADATA) {
|
||||||
mSuspendedAfterFirstFrame = PR_TRUE;
|
mSuspendedAfterFirstFrame = true;
|
||||||
mDecoder->Suspend();
|
mDecoder->Suspend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::ResourceLoaded()
|
void nsHTMLMediaElement::ResourceLoaded()
|
||||||
{
|
{
|
||||||
mBegun = PR_FALSE;
|
mBegun = false;
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA) {
|
if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA) {
|
||||||
@ -2040,7 +2040,7 @@ void nsHTMLMediaElement::Error(PRUint16 aErrorCode)
|
|||||||
aErrorCode == nsIDOMMediaError::MEDIA_ERR_ABORTED,
|
aErrorCode == nsIDOMMediaError::MEDIA_ERR_ABORTED,
|
||||||
"Only use nsIDOMMediaError codes!");
|
"Only use nsIDOMMediaError codes!");
|
||||||
mError = new nsMediaError(aErrorCode);
|
mError = new nsMediaError(aErrorCode);
|
||||||
mBegun = PR_FALSE;
|
mBegun = false;
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
|
||||||
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {
|
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {
|
||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_EMPTY;
|
||||||
@ -2049,7 +2049,7 @@ void nsHTMLMediaElement::Error(PRUint16 aErrorCode)
|
|||||||
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
mNetworkState = nsIDOMHTMLMediaElement::NETWORK_IDLE;
|
||||||
}
|
}
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
ChangeDelayLoadStatus(PR_FALSE);
|
ChangeDelayLoadStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::PlaybackEnded()
|
void nsHTMLMediaElement::PlaybackEnded()
|
||||||
@ -2063,20 +2063,20 @@ void nsHTMLMediaElement::PlaybackEnded()
|
|||||||
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
|
||||||
}
|
}
|
||||||
|
|
||||||
FireTimeUpdate(PR_FALSE);
|
FireTimeUpdate(false);
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("ended"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("ended"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::SeekStarted()
|
void nsHTMLMediaElement::SeekStarted()
|
||||||
{
|
{
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("seeking"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("seeking"));
|
||||||
FireTimeUpdate(PR_FALSE);
|
FireTimeUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsHTMLMediaElement::SeekCompleted()
|
void nsHTMLMediaElement::SeekCompleted()
|
||||||
{
|
{
|
||||||
mPlayingBeforeSeek = PR_FALSE;
|
mPlayingBeforeSeek = false;
|
||||||
SetPlayedOrSeeked(PR_TRUE);
|
SetPlayedOrSeeked(true);
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("seeked"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("seeked"));
|
||||||
// We changed whether we're seeking so we need to AddRemoveSelfReference
|
// We changed whether we're seeking so we need to AddRemoveSelfReference
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
@ -2125,9 +2125,9 @@ void nsHTMLMediaElement::UpdateReadyStateForData(NextFrameStatus aNextFrame)
|
|||||||
if (aNextFrame != NEXT_FRAME_AVAILABLE) {
|
if (aNextFrame != NEXT_FRAME_AVAILABLE) {
|
||||||
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);
|
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA);
|
||||||
if (!mWaitingFired && aNextFrame == NEXT_FRAME_UNAVAILABLE_BUFFERING) {
|
if (!mWaitingFired && aNextFrame == NEXT_FRAME_UNAVAILABLE_BUFFERING) {
|
||||||
FireTimeUpdate(PR_FALSE);
|
FireTimeUpdate(false);
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("waiting"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("waiting"));
|
||||||
mWaitingFired = PR_TRUE;
|
mWaitingFired = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2184,11 +2184,11 @@ void nsHTMLMediaElement::ChangeReadyState(nsMediaReadyState aState)
|
|||||||
!mLoadedFirstFrame)
|
!mLoadedFirstFrame)
|
||||||
{
|
{
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("loadeddata"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("loadeddata"));
|
||||||
mLoadedFirstFrame = PR_TRUE;
|
mLoadedFirstFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA) {
|
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA) {
|
||||||
mWaitingFired = PR_FALSE;
|
mWaitingFired = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldState < nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA &&
|
if (oldState < nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA &&
|
||||||
@ -2224,12 +2224,12 @@ bool nsHTMLMediaElement::CanActivateAutoplay()
|
|||||||
void nsHTMLMediaElement::NotifyAutoplayDataReady()
|
void nsHTMLMediaElement::NotifyAutoplayDataReady()
|
||||||
{
|
{
|
||||||
if (CanActivateAutoplay()) {
|
if (CanActivateAutoplay()) {
|
||||||
mPaused = PR_FALSE;
|
mPaused = false;
|
||||||
// We changed mPaused which can affect AddRemoveSelfReference
|
// We changed mPaused which can affect AddRemoveSelfReference
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
|
|
||||||
if (mDecoder) {
|
if (mDecoder) {
|
||||||
SetPlayedOrSeeked(PR_TRUE);
|
SetPlayedOrSeeked(true);
|
||||||
mDecoder->Play();
|
mDecoder->Play();
|
||||||
}
|
}
|
||||||
DispatchAsyncEvent(NS_LITERAL_STRING("play"));
|
DispatchAsyncEvent(NS_LITERAL_STRING("play"));
|
||||||
@ -2258,7 +2258,7 @@ ImageContainer* nsHTMLMediaElement::GetImageContainer()
|
|||||||
|
|
||||||
mImageContainer = manager->CreateImageContainer();
|
mImageContainer = manager->CreateImageContainer();
|
||||||
if (manager->IsCompositingCheap()) {
|
if (manager->IsCompositingCheap()) {
|
||||||
mImageContainer->SetDelayedConversion(PR_TRUE);
|
mImageContainer->SetDelayedConversion(true);
|
||||||
}
|
}
|
||||||
return mImageContainer;
|
return mImageContainer;
|
||||||
}
|
}
|
||||||
@ -2284,7 +2284,7 @@ nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = audioavailableEvent->InitAudioAvailableEvent(NS_LITERAL_STRING("MozAudioAvailable"),
|
rv = audioavailableEvent->InitAudioAvailableEvent(NS_LITERAL_STRING("MozAudioAvailable"),
|
||||||
PR_TRUE, PR_TRUE, frameBuffer.forget(), aFrameBufferLength,
|
true, true, frameBuffer.forget(), aFrameBufferLength,
|
||||||
aTime, mAllowAudioData);
|
aTime, mAllowAudioData);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
@ -2307,8 +2307,8 @@ nsresult nsHTMLMediaElement::DispatchEvent(const nsAString& aName)
|
|||||||
return nsContentUtils::DispatchTrustedEvent(GetOwnerDoc(),
|
return nsContentUtils::DispatchTrustedEvent(GetOwnerDoc(),
|
||||||
static_cast<nsIContent*>(this),
|
static_cast<nsIContent*>(this),
|
||||||
aName,
|
aName,
|
||||||
PR_FALSE,
|
false,
|
||||||
PR_TRUE);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsHTMLMediaElement::DispatchAsyncEvent(const nsAString& aName)
|
nsresult nsHTMLMediaElement::DispatchAsyncEvent(const nsAString& aName)
|
||||||
@ -2353,7 +2353,7 @@ bool nsHTMLMediaElement::IsPlaybackEnded() const
|
|||||||
// the current playback position is equal to the effective end of the media resource.
|
// the current playback position is equal to the effective end of the media resource.
|
||||||
// See bug 449157.
|
// See bug 449157.
|
||||||
return mNetworkState >= nsIDOMHTMLMediaElement::HAVE_METADATA &&
|
return mNetworkState >= nsIDOMHTMLMediaElement::HAVE_METADATA &&
|
||||||
mDecoder ? mDecoder->IsEnded() : PR_FALSE;
|
mDecoder ? mDecoder->IsEnded() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIPrincipal> nsHTMLMediaElement::GetCurrentPrincipal()
|
already_AddRefed<nsIPrincipal> nsHTMLMediaElement::GetCurrentPrincipal()
|
||||||
@ -2384,7 +2384,7 @@ void nsHTMLMediaElement::NotifyOwnerDocumentActivityChanged()
|
|||||||
mDecoder->Pause();
|
mDecoder->Pause();
|
||||||
mDecoder->Suspend();
|
mDecoder->Suspend();
|
||||||
} else {
|
} else {
|
||||||
mDecoder->Resume(PR_FALSE);
|
mDecoder->Resume(false);
|
||||||
DispatchPendingMediaEvents();
|
DispatchPendingMediaEvents();
|
||||||
if (!mPaused && !mDecoder->IsEnded()) {
|
if (!mPaused && !mDecoder->IsEnded()) {
|
||||||
mDecoder->Play();
|
mDecoder->Play();
|
||||||
@ -2445,7 +2445,7 @@ nsresult nsHTMLMediaElement::Observe(nsISupports* aSubject,
|
|||||||
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
||||||
|
|
||||||
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||||
mShuttingDown = PR_TRUE;
|
mShuttingDown = true;
|
||||||
AddRemoveSelfReference();
|
AddRemoveSelfReference();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -2498,11 +2498,11 @@ nsIContent* nsHTMLMediaElement::GetNextSource()
|
|||||||
rv = mSourcePointer->SelectNodeContents(thisDomNode);
|
rv = mSourcePointer->SelectNodeContents(thisDomNode);
|
||||||
if (NS_FAILED(rv)) return nsnull;
|
if (NS_FAILED(rv)) return nsnull;
|
||||||
|
|
||||||
rv = mSourcePointer->Collapse(PR_TRUE);
|
rv = mSourcePointer->Collapse(true);
|
||||||
if (NS_FAILED(rv)) return nsnull;
|
if (NS_FAILED(rv)) return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (PR_TRUE) {
|
while (true) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsCOMPtr<nsIDOMNode> startContainer;
|
nsCOMPtr<nsIDOMNode> startContainer;
|
||||||
rv = mSourcePointer->GetStartContainer(getter_AddRefs(startContainer));
|
rv = mSourcePointer->GetStartContainer(getter_AddRefs(startContainer));
|
||||||
@ -2552,7 +2552,7 @@ void nsHTMLMediaElement::ChangeDelayLoadStatus(bool aDelay) {
|
|||||||
LOG(PR_LOG_DEBUG, ("%p ChangeDelayLoadStatus(%d) doc=0x%p", this, aDelay, mLoadBlockedDoc.get()));
|
LOG(PR_LOG_DEBUG, ("%p ChangeDelayLoadStatus(%d) doc=0x%p", this, aDelay, mLoadBlockedDoc.get()));
|
||||||
// mLoadBlockedDoc might be null due to GC unlinking
|
// mLoadBlockedDoc might be null due to GC unlinking
|
||||||
if (mLoadBlockedDoc) {
|
if (mLoadBlockedDoc) {
|
||||||
mLoadBlockedDoc->UnblockOnload(PR_FALSE);
|
mLoadBlockedDoc->UnblockOnload(false);
|
||||||
mLoadBlockedDoc = nsnull;
|
mLoadBlockedDoc = nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2622,7 +2622,7 @@ void nsHTMLMediaElement::SetRequestHeaders(nsIHttpChannel* aChannel)
|
|||||||
// So, disable the standard "Accept-Encoding: gzip,deflate" that we usually send.
|
// So, disable the standard "Accept-Encoding: gzip,deflate" that we usually send.
|
||||||
// See bug 614760.
|
// See bug 614760.
|
||||||
aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept-Encoding"),
|
aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept-Encoding"),
|
||||||
NS_LITERAL_CSTRING(""), PR_FALSE);
|
NS_LITERAL_CSTRING(""), false);
|
||||||
|
|
||||||
// Set the Referer header
|
// Set the Referer header
|
||||||
nsIDocument* doc = GetOwnerDoc();
|
nsIDocument* doc = GetOwnerDoc();
|
||||||
|
@ -176,7 +176,7 @@ nsresult nsHTMLVideoElement::SetAcceptHeader(nsIHttpChannel* aChannel)
|
|||||||
|
|
||||||
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
return aChannel->SetRequestHeader(NS_LITERAL_CSTRING("Accept"),
|
||||||
value,
|
value,
|
||||||
PR_FALSE);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_URI_ATTR(nsHTMLVideoElement, Poster, poster)
|
NS_IMPL_URI_ATTR(nsHTMLVideoElement, Poster, poster)
|
||||||
|
@ -39,12 +39,12 @@
|
|||||||
#include "nsMathUtils.h"
|
#include "nsMathUtils.h"
|
||||||
#include "prtypes.h"
|
#include "prtypes.h"
|
||||||
|
|
||||||
// Adds two 32bit unsigned numbers, retuns PR_TRUE if addition succeeded,
|
// Adds two 32bit unsigned numbers, retuns true if addition succeeded,
|
||||||
// or PR_FALSE the if addition would result in an overflow.
|
// or false the if addition would result in an overflow.
|
||||||
bool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult) {
|
bool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult) {
|
||||||
PRUint64 rl = static_cast<PRUint64>(a) + static_cast<PRUint64>(b);
|
PRUint64 rl = static_cast<PRUint64>(a) + static_cast<PRUint64>(b);
|
||||||
if (rl > PR_UINT32_MAX) {
|
if (rl > PR_UINT32_MAX) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
aResult = static_cast<PRUint32>(rl);
|
aResult = static_cast<PRUint32>(rl);
|
||||||
return true;
|
return true;
|
||||||
@ -52,35 +52,35 @@ bool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult) {
|
|||||||
|
|
||||||
bool MulOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult)
|
bool MulOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult)
|
||||||
{
|
{
|
||||||
// 32 bit integer multiplication with overflow checking. Returns PR_TRUE
|
// 32 bit integer multiplication with overflow checking. Returns true
|
||||||
// if the multiplication was successful, or PR_FALSE if the operation resulted
|
// if the multiplication was successful, or false if the operation resulted
|
||||||
// in an integer overflow.
|
// in an integer overflow.
|
||||||
PRUint64 a64 = a;
|
PRUint64 a64 = a;
|
||||||
PRUint64 b64 = b;
|
PRUint64 b64 = b;
|
||||||
PRUint64 r64 = a64 * b64;
|
PRUint64 r64 = a64 * b64;
|
||||||
if (r64 > PR_UINT32_MAX)
|
if (r64 > PR_UINT32_MAX)
|
||||||
return PR_FALSE;
|
return false;
|
||||||
aResult = static_cast<PRUint32>(r64);
|
aResult = static_cast<PRUint32>(r64);
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds two 64bit numbers, retuns PR_TRUE if addition succeeded, or PR_FALSE
|
// Adds two 64bit numbers, retuns true if addition succeeded, or false
|
||||||
// if addition would result in an overflow.
|
// if addition would result in an overflow.
|
||||||
bool AddOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
bool AddOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
||||||
if (b < 1) {
|
if (b < 1) {
|
||||||
if (PR_INT64_MIN - b <= a) {
|
if (PR_INT64_MIN - b <= a) {
|
||||||
aResult = a + b;
|
aResult = a + b;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (PR_INT64_MAX - b >= a) {
|
} else if (PR_INT64_MAX - b >= a) {
|
||||||
aResult = a + b;
|
aResult = a + b;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 64 bit integer multiplication with overflow checking. Returns PR_TRUE
|
// 64 bit integer multiplication with overflow checking. Returns true
|
||||||
// if the multiplication was successful, or PR_FALSE if the operation resulted
|
// if the multiplication was successful, or false if the operation resulted
|
||||||
// in an integer overflow.
|
// in an integer overflow.
|
||||||
bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
||||||
// We break a multiplication a * b into of sign_a * sign_b * abs(a) * abs(b)
|
// We break a multiplication a * b into of sign_a * sign_b * abs(a) * abs(b)
|
||||||
@ -113,9 +113,9 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
|||||||
NS_ASSERTION(a == PR_INT64_MIN, "How else can this happen?");
|
NS_ASSERTION(a == PR_INT64_MIN, "How else can this happen?");
|
||||||
if (b == 0 || b == 1) {
|
if (b == 0 || b == 1) {
|
||||||
aResult = a * b;
|
aResult = a * b;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,9 +123,9 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
|||||||
NS_ASSERTION(b == PR_INT64_MIN, "How else can this happen?");
|
NS_ASSERTION(b == PR_INT64_MIN, "How else can this happen?");
|
||||||
if (a == 0 || a == 1) {
|
if (a == 0 || a == 1) {
|
||||||
aResult = a * b;
|
aResult = a * b;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
|||||||
// are non-zero, this will overflow as it's shifted by 64.
|
// are non-zero, this will overflow as it's shifted by 64.
|
||||||
// Abort if this overflows.
|
// Abort if this overflows.
|
||||||
if (a_hi != 0 && b_hi != 0) {
|
if (a_hi != 0 && b_hi != 0) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can now assume that either a_hi or b_hi is 0.
|
// We can now assume that either a_hi or b_hi is 0.
|
||||||
@ -156,24 +156,24 @@ bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult) {
|
|||||||
PRInt64 q = a_hi * b_lo + a_lo * b_hi;
|
PRInt64 q = a_hi * b_lo + a_lo * b_hi;
|
||||||
if (q > PR_INT32_MAX) {
|
if (q > PR_INT32_MAX) {
|
||||||
// q will overflow when we shift by 32; abort.
|
// q will overflow when we shift by 32; abort.
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
q <<= 32;
|
q <<= 32;
|
||||||
|
|
||||||
// Both a_lo and b_lo are less than INT32_MAX, so can't overflow.
|
// Both a_lo and b_lo are less than INT32_MAX, so can't overflow.
|
||||||
PRUint64 lo = a_lo * b_lo;
|
PRUint64 lo = a_lo * b_lo;
|
||||||
if (lo > PR_INT64_MAX) {
|
if (lo > PR_INT64_MAX) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the final result. We must check for overflow during addition.
|
// Add the final result. We must check for overflow during addition.
|
||||||
if (!AddOverflow(q, static_cast<PRInt64>(lo), aResult)) {
|
if (!AddOverflow(q, static_cast<PRInt64>(lo), aResult)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aResult *= sign;
|
aResult *= sign;
|
||||||
NS_ASSERTION(a * b == aResult, "We didn't overflow, but result is wrong!");
|
NS_ASSERTION(a * b == aResult, "We didn't overflow, but result is wrong!");
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts from number of audio frames to microseconds, given the specified
|
// Converts from number of audio frames to microseconds, given the specified
|
||||||
@ -182,9 +182,9 @@ bool FramesToUsecs(PRInt64 aFrames, PRUint32 aRate, PRInt64& aOutUsecs)
|
|||||||
{
|
{
|
||||||
PRInt64 x;
|
PRInt64 x;
|
||||||
if (!MulOverflow(aFrames, USECS_PER_S, x))
|
if (!MulOverflow(aFrames, USECS_PER_S, x))
|
||||||
return PR_FALSE;
|
return false;
|
||||||
aOutUsecs = x / aRate;
|
aOutUsecs = x / aRate;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts from microseconds to number of audio frames, given the specified
|
// Converts from microseconds to number of audio frames, given the specified
|
||||||
@ -193,9 +193,9 @@ bool UsecsToFrames(PRInt64 aUsecs, PRUint32 aRate, PRInt64& aOutFrames)
|
|||||||
{
|
{
|
||||||
PRInt64 x;
|
PRInt64 x;
|
||||||
if (!MulOverflow(aUsecs, aRate, x))
|
if (!MulOverflow(aUsecs, aRate, x))
|
||||||
return PR_FALSE;
|
return false;
|
||||||
aOutFrames = x / USECS_PER_S;
|
aOutFrames = x / USECS_PER_S;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRInt32 ConditionDimension(float aValue)
|
static PRInt32 ConditionDimension(float aValue)
|
||||||
|
@ -110,33 +110,33 @@ private:
|
|||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
// Adds two 32bit unsigned numbers, retuns PR_TRUE if addition succeeded,
|
// Adds two 32bit unsigned numbers, retuns true if addition succeeded,
|
||||||
// or PR_FALSE the if addition would result in an overflow.
|
// or false the if addition would result in an overflow.
|
||||||
bool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult);
|
bool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult);
|
||||||
|
|
||||||
// 32 bit integer multiplication with overflow checking. Returns PR_TRUE
|
// 32 bit integer multiplication with overflow checking. Returns true
|
||||||
// if the multiplication was successful, or PR_FALSE if the operation resulted
|
// if the multiplication was successful, or false if the operation resulted
|
||||||
// in an integer overflow.
|
// in an integer overflow.
|
||||||
bool MulOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult);
|
bool MulOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult);
|
||||||
|
|
||||||
// Adds two 64bit numbers, retuns PR_TRUE if addition succeeded, or PR_FALSE
|
// Adds two 64bit numbers, retuns true if addition succeeded, or false
|
||||||
// if addition would result in an overflow.
|
// if addition would result in an overflow.
|
||||||
bool AddOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult);
|
bool AddOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult);
|
||||||
|
|
||||||
// 64 bit integer multiplication with overflow checking. Returns PR_TRUE
|
// 64 bit integer multiplication with overflow checking. Returns true
|
||||||
// if the multiplication was successful, or PR_FALSE if the operation resulted
|
// if the multiplication was successful, or false if the operation resulted
|
||||||
// in an integer overflow.
|
// in an integer overflow.
|
||||||
bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult);
|
bool MulOverflow(PRInt64 a, PRInt64 b, PRInt64& aResult);
|
||||||
|
|
||||||
// Converts from number of audio frames (aFrames) to microseconds, given
|
// Converts from number of audio frames (aFrames) to microseconds, given
|
||||||
// the specified audio rate (aRate). Stores result in aOutUsecs. Returns PR_TRUE
|
// the specified audio rate (aRate). Stores result in aOutUsecs. Returns true
|
||||||
// if the operation succeeded, or PR_FALSE if there was an integer overflow
|
// if the operation succeeded, or false if there was an integer overflow
|
||||||
// while calulating the conversion.
|
// while calulating the conversion.
|
||||||
bool FramesToUsecs(PRInt64 aFrames, PRUint32 aRate, PRInt64& aOutUsecs);
|
bool FramesToUsecs(PRInt64 aFrames, PRUint32 aRate, PRInt64& aOutUsecs);
|
||||||
|
|
||||||
// Converts from microseconds (aUsecs) to number of audio frames, given the
|
// Converts from microseconds (aUsecs) to number of audio frames, given the
|
||||||
// specified audio rate (aRate). Stores the result in aOutFrames. Returns
|
// specified audio rate (aRate). Stores the result in aOutFrames. Returns
|
||||||
// PR_TRUE if the operation succeeded, or PR_FALSE if there was an integer
|
// true if the operation succeeded, or false if there was an integer
|
||||||
// overflow while calulating the conversion.
|
// overflow while calulating the conversion.
|
||||||
bool UsecsToFrames(PRInt64 aUsecs, PRUint32 aRate, PRInt64& aOutFrames);
|
bool UsecsToFrames(PRInt64 aUsecs, PRUint32 aRate, PRInt64& aOutFrames);
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ class nsNativeAudioStream : public nsAudioStream
|
|||||||
|
|
||||||
SampleFormat mFormat;
|
SampleFormat mFormat;
|
||||||
|
|
||||||
// PR_TRUE if this audio stream is paused.
|
// True if this audio stream is paused.
|
||||||
bool mPaused;
|
bool mPaused;
|
||||||
|
|
||||||
// PR_TRUE if this stream has encountered an error.
|
// True if this stream has encountered an error.
|
||||||
bool mInError;
|
bool mInError;
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -148,7 +148,7 @@ private:
|
|||||||
|
|
||||||
PRInt32 mBytesPerFrame;
|
PRInt32 mBytesPerFrame;
|
||||||
|
|
||||||
// PR_TRUE if this audio stream is paused.
|
// True if this audio stream is paused.
|
||||||
bool mPaused;
|
bool mPaused;
|
||||||
|
|
||||||
friend class AudioInitEvent;
|
friend class AudioInitEvent;
|
||||||
@ -393,8 +393,8 @@ nsNativeAudioStream::nsNativeAudioStream() :
|
|||||||
mRate(0),
|
mRate(0),
|
||||||
mChannels(0),
|
mChannels(0),
|
||||||
mFormat(FORMAT_S16_LE),
|
mFormat(FORMAT_S16_LE),
|
||||||
mPaused(PR_FALSE),
|
mPaused(false),
|
||||||
mInError(PR_FALSE)
|
mInError(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ nsresult nsNativeAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFo
|
|||||||
aRate,
|
aRate,
|
||||||
aNumChannels) != SA_SUCCESS) {
|
aNumChannels) != SA_SUCCESS) {
|
||||||
mAudioHandle = nsnull;
|
mAudioHandle = nsnull;
|
||||||
mInError = PR_TRUE;
|
mInError = true;
|
||||||
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_create_pcm error"));
|
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_create_pcm error"));
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
@ -426,11 +426,11 @@ nsresult nsNativeAudioStream::Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFo
|
|||||||
if (sa_stream_open(static_cast<sa_stream_t*>(mAudioHandle)) != SA_SUCCESS) {
|
if (sa_stream_open(static_cast<sa_stream_t*>(mAudioHandle)) != SA_SUCCESS) {
|
||||||
sa_stream_destroy(static_cast<sa_stream_t*>(mAudioHandle));
|
sa_stream_destroy(static_cast<sa_stream_t*>(mAudioHandle));
|
||||||
mAudioHandle = nsnull;
|
mAudioHandle = nsnull;
|
||||||
mInError = PR_TRUE;
|
mInError = true;
|
||||||
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_open error"));
|
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_open error"));
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
mInError = PR_FALSE;
|
mInError = false;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -442,7 +442,7 @@ void nsNativeAudioStream::Shutdown()
|
|||||||
|
|
||||||
sa_stream_destroy(static_cast<sa_stream_t*>(mAudioHandle));
|
sa_stream_destroy(static_cast<sa_stream_t*>(mAudioHandle));
|
||||||
mAudioHandle = nsnull;
|
mAudioHandle = nsnull;
|
||||||
mInError = PR_TRUE;
|
mInError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsNativeAudioStream::Write(const void* aBuf, PRUint32 aFrames)
|
nsresult nsNativeAudioStream::Write(const void* aBuf, PRUint32 aFrames)
|
||||||
@ -501,7 +501,7 @@ nsresult nsNativeAudioStream::Write(const void* aBuf, PRUint32 aFrames)
|
|||||||
samples * sizeof(short)) != SA_SUCCESS)
|
samples * sizeof(short)) != SA_SUCCESS)
|
||||||
{
|
{
|
||||||
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_write error"));
|
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_write error"));
|
||||||
mInError = PR_TRUE;
|
mInError = true;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -528,7 +528,7 @@ void nsNativeAudioStream::SetVolume(double aVolume)
|
|||||||
#if defined(SA_PER_STREAM_VOLUME)
|
#if defined(SA_PER_STREAM_VOLUME)
|
||||||
if (sa_stream_set_volume_abs(static_cast<sa_stream_t*>(mAudioHandle), aVolume) != SA_SUCCESS) {
|
if (sa_stream_set_volume_abs(static_cast<sa_stream_t*>(mAudioHandle), aVolume) != SA_SUCCESS) {
|
||||||
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_set_volume_abs error"));
|
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_set_volume_abs error"));
|
||||||
mInError = PR_TRUE;
|
mInError = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
mVolume = aVolume;
|
mVolume = aVolume;
|
||||||
@ -545,7 +545,7 @@ void nsNativeAudioStream::Drain()
|
|||||||
int r = sa_stream_drain(static_cast<sa_stream_t*>(mAudioHandle));
|
int r = sa_stream_drain(static_cast<sa_stream_t*>(mAudioHandle));
|
||||||
if (r != SA_SUCCESS && r != SA_ERROR_INVALID) {
|
if (r != SA_SUCCESS && r != SA_ERROR_INVALID) {
|
||||||
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_drain error"));
|
PR_LOG(gAudioStreamLog, PR_LOG_ERROR, ("nsNativeAudioStream: sa_stream_drain error"));
|
||||||
mInError = PR_TRUE;
|
mInError = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ void nsNativeAudioStream::Pause()
|
|||||||
{
|
{
|
||||||
if (mInError)
|
if (mInError)
|
||||||
return;
|
return;
|
||||||
mPaused = PR_TRUE;
|
mPaused = true;
|
||||||
sa_stream_pause(static_cast<sa_stream_t*>(mAudioHandle));
|
sa_stream_pause(static_cast<sa_stream_t*>(mAudioHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ void nsNativeAudioStream::Resume()
|
|||||||
{
|
{
|
||||||
if (mInError)
|
if (mInError)
|
||||||
return;
|
return;
|
||||||
mPaused = PR_FALSE;
|
mPaused = false;
|
||||||
sa_stream_resume(static_cast<sa_stream_t*>(mAudioHandle));
|
sa_stream_resume(static_cast<sa_stream_t*>(mAudioHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,7 +617,7 @@ nsRemotedAudioStream::nsRemotedAudioStream()
|
|||||||
mRate(0),
|
mRate(0),
|
||||||
mChannels(0),
|
mChannels(0),
|
||||||
mBytesPerFrame(0),
|
mBytesPerFrame(0),
|
||||||
mPaused(PR_FALSE)
|
mPaused(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
nsRemotedAudioStream::~nsRemotedAudioStream()
|
nsRemotedAudioStream::~nsRemotedAudioStream()
|
||||||
@ -715,20 +715,20 @@ nsRemotedAudioStream::Drain()
|
|||||||
void
|
void
|
||||||
nsRemotedAudioStream::Pause()
|
nsRemotedAudioStream::Pause()
|
||||||
{
|
{
|
||||||
mPaused = PR_TRUE;
|
mPaused = true;
|
||||||
if (!mAudioChild)
|
if (!mAudioChild)
|
||||||
return;
|
return;
|
||||||
nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mAudioChild, PR_TRUE);
|
nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mAudioChild, true);
|
||||||
NS_DispatchToMainThread(event);
|
NS_DispatchToMainThread(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsRemotedAudioStream::Resume()
|
nsRemotedAudioStream::Resume()
|
||||||
{
|
{
|
||||||
mPaused = PR_FALSE;
|
mPaused = false;
|
||||||
if (!mAudioChild)
|
if (!mAudioChild)
|
||||||
return;
|
return;
|
||||||
nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mAudioChild, PR_FALSE);
|
nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mAudioChild, false);
|
||||||
NS_DispatchToMainThread(event);
|
NS_DispatchToMainThread(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
// was opened, of the audio hardware.
|
// was opened, of the audio hardware.
|
||||||
virtual PRInt64 GetPositionInFrames() = 0;
|
virtual PRInt64 GetPositionInFrames() = 0;
|
||||||
|
|
||||||
// Returns PR_TRUE when the audio stream is paused.
|
// Returns true when the audio stream is paused.
|
||||||
virtual bool IsPaused() = 0;
|
virtual bool IsPaused() = 0;
|
||||||
|
|
||||||
// Returns the minimum number of audio frames which must be written before
|
// Returns the minimum number of audio frames which must be written before
|
||||||
|
@ -113,13 +113,13 @@ nsBuiltinDecoder::nsBuiltinDecoder() :
|
|||||||
mInitialVolume(0.0),
|
mInitialVolume(0.0),
|
||||||
mRequestedSeekTime(-1.0),
|
mRequestedSeekTime(-1.0),
|
||||||
mDuration(-1),
|
mDuration(-1),
|
||||||
mSeekable(PR_TRUE),
|
mSeekable(true),
|
||||||
mReentrantMonitor("media.decoder"),
|
mReentrantMonitor("media.decoder"),
|
||||||
mPlayState(PLAY_STATE_PAUSED),
|
mPlayState(PLAY_STATE_PAUSED),
|
||||||
mNextState(PLAY_STATE_PAUSED),
|
mNextState(PLAY_STATE_PAUSED),
|
||||||
mResourceLoaded(PR_FALSE),
|
mResourceLoaded(false),
|
||||||
mIgnoreProgressData(PR_FALSE),
|
mIgnoreProgressData(false),
|
||||||
mInfiniteStream(PR_FALSE)
|
mInfiniteStream(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsBuiltinDecoder);
|
MOZ_COUNT_CTOR(nsBuiltinDecoder);
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||||
@ -134,11 +134,11 @@ bool nsBuiltinDecoder::Init(nsHTMLMediaElement* aElement)
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||||
if (!nsMediaDecoder::Init(aElement))
|
if (!nsMediaDecoder::Init(aElement))
|
||||||
return PR_FALSE;
|
return false;
|
||||||
|
|
||||||
nsContentUtils::RegisterShutdownObserver(this);
|
nsContentUtils::RegisterShutdownObserver(this);
|
||||||
mImageContainer = aElement->GetImageContainer();
|
mImageContainer = aElement->GetImageContainer();
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsBuiltinDecoder::Shutdown()
|
void nsBuiltinDecoder::Shutdown()
|
||||||
@ -148,7 +148,7 @@ void nsBuiltinDecoder::Shutdown()
|
|||||||
if (mShuttingDown)
|
if (mShuttingDown)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mShuttingDown = PR_TRUE;
|
mShuttingDown = true;
|
||||||
|
|
||||||
// This changes the decoder state to SHUTDOWN and does other things
|
// This changes the decoder state to SHUTDOWN and does other things
|
||||||
// necessary to unblock the state machine thread if it's blocked, so
|
// necessary to unblock the state machine thread if it's blocked, so
|
||||||
@ -270,9 +270,9 @@ nsresult nsBuiltinDecoder::Play()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns PR_TRUE if aValue is inside a range of aRanges, and put the range
|
* Returns true if aValue is inside a range of aRanges, and put the range
|
||||||
* index in aIntervalIndex if it is not null.
|
* index in aIntervalIndex if it is not null.
|
||||||
* If aValue is not inside a range, PR_FALSE is returned, and aIntervalIndex, if
|
* If aValue is not inside a range, false is returned, and aIntervalIndex, if
|
||||||
* not null, is set to the index of the range which ends immediatly before aValue
|
* not null, is set to the index of the range which ends immediatly before aValue
|
||||||
* (and can be -1 if aValue is before aRanges.Start(0)).
|
* (and can be -1 if aValue is before aRanges.Start(0)).
|
||||||
*/
|
*/
|
||||||
@ -284,16 +284,16 @@ static bool IsInRanges(nsTimeRanges& aRanges, double aValue, PRInt32& aIntervalI
|
|||||||
aRanges.Start(i, &start);
|
aRanges.Start(i, &start);
|
||||||
if (start > aValue) {
|
if (start > aValue) {
|
||||||
aIntervalIndex = i - 1;
|
aIntervalIndex = i - 1;
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
aRanges.End(i, &end);
|
aRanges.End(i, &end);
|
||||||
if (aValue <= end) {
|
if (aValue <= end) {
|
||||||
aIntervalIndex = i;
|
aIntervalIndex = i;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aIntervalIndex = length - 1;
|
aIntervalIndex = length - 1;
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsBuiltinDecoder::Seek(double aTime)
|
nsresult nsBuiltinDecoder::Seek(double aTime)
|
||||||
@ -429,7 +429,7 @@ void nsBuiltinDecoder::MetadataLoaded(PRUint32 aChannels,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mDuration == -1) {
|
if (mDuration == -1) {
|
||||||
SetInfinite(PR_TRUE);
|
SetInfinite(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mElement && notifyElement) {
|
if (mElement && notifyElement) {
|
||||||
@ -492,9 +492,9 @@ void nsBuiltinDecoder::ResourceLoaded()
|
|||||||
if (mIgnoreProgressData || mResourceLoaded || mPlayState == PLAY_STATE_LOADING)
|
if (mIgnoreProgressData || mResourceLoaded || mPlayState == PLAY_STATE_LOADING)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Progress(PR_FALSE);
|
Progress(false);
|
||||||
|
|
||||||
mResourceLoaded = PR_TRUE;
|
mResourceLoaded = true;
|
||||||
StopProgress();
|
StopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,7 +554,7 @@ void nsBuiltinDecoder::PlaybackEnded()
|
|||||||
// This must be called after |mElement->PlaybackEnded()| call above, in order
|
// This must be called after |mElement->PlaybackEnded()| call above, in order
|
||||||
// to fire the required durationchange.
|
// to fire the required durationchange.
|
||||||
if (IsInfinite()) {
|
if (IsInfinite()) {
|
||||||
SetInfinite(PR_FALSE);
|
SetInfinite(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,9 +590,9 @@ nsBuiltinDecoder::GetStatistics()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result.mDownloadRate = 0;
|
result.mDownloadRate = 0;
|
||||||
result.mDownloadRateReliable = PR_TRUE;
|
result.mDownloadRateReliable = true;
|
||||||
result.mPlaybackRate = 0;
|
result.mPlaybackRate = 0;
|
||||||
result.mPlaybackRateReliable = PR_TRUE;
|
result.mPlaybackRateReliable = true;
|
||||||
result.mDecoderPosition = 0;
|
result.mDecoderPosition = 0;
|
||||||
result.mPlaybackPosition = 0;
|
result.mPlaybackPosition = 0;
|
||||||
result.mDownloadPosition = 0;
|
result.mDownloadPosition = 0;
|
||||||
@ -610,7 +610,7 @@ double nsBuiltinDecoder::ComputePlaybackRate(bool* aReliable)
|
|||||||
|
|
||||||
PRInt64 length = mStream ? mStream->GetLength() : -1;
|
PRInt64 length = mStream ? mStream->GetLength() : -1;
|
||||||
if (mDuration >= 0 && length >= 0) {
|
if (mDuration >= 0 && length >= 0) {
|
||||||
*aReliable = PR_TRUE;
|
*aReliable = true;
|
||||||
return length * static_cast<double>(USECS_PER_S) / mDuration;
|
return length * static_cast<double>(USECS_PER_S) / mDuration;
|
||||||
}
|
}
|
||||||
return mPlaybackStatistics.GetRateAtLastStop(aReliable);
|
return mPlaybackStatistics.GetRateAtLastStop(aReliable);
|
||||||
@ -653,7 +653,7 @@ void nsBuiltinDecoder::NotifyBytesDownloaded()
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||||
UpdateReadyStateForData();
|
UpdateReadyStateForData();
|
||||||
Progress(PR_FALSE);
|
Progress(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsBuiltinDecoder::NotifyDownloadEnded(nsresult aStatus)
|
void nsBuiltinDecoder::NotifyDownloadEnded(nsresult aStatus)
|
||||||
@ -744,7 +744,7 @@ void nsBuiltinDecoder::SeekingStopped()
|
|||||||
// in operation.
|
// in operation.
|
||||||
if (mRequestedSeekTime >= 0.0) {
|
if (mRequestedSeekTime >= 0.0) {
|
||||||
ChangeState(PLAY_STATE_SEEKING);
|
ChangeState(PLAY_STATE_SEEKING);
|
||||||
seekWasAborted = PR_TRUE;
|
seekWasAborted = true;
|
||||||
} else {
|
} else {
|
||||||
UnpinForSeek();
|
UnpinForSeek();
|
||||||
ChangeState(mNextState);
|
ChangeState(mNextState);
|
||||||
@ -777,10 +777,10 @@ void nsBuiltinDecoder::SeekingStoppedAtEnd()
|
|||||||
// in operation.
|
// in operation.
|
||||||
if (mRequestedSeekTime >= 0.0) {
|
if (mRequestedSeekTime >= 0.0) {
|
||||||
ChangeState(PLAY_STATE_SEEKING);
|
ChangeState(PLAY_STATE_SEEKING);
|
||||||
seekWasAborted = PR_TRUE;
|
seekWasAborted = true;
|
||||||
} else {
|
} else {
|
||||||
UnpinForSeek();
|
UnpinForSeek();
|
||||||
fireEnded = PR_TRUE;
|
fireEnded = true;
|
||||||
ChangeState(PLAY_STATE_ENDED);
|
ChangeState(PLAY_STATE_ENDED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -952,7 +952,7 @@ void nsBuiltinDecoder::Suspend()
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||||
if (mStream) {
|
if (mStream) {
|
||||||
mStream->Suspend(PR_TRUE);
|
mStream->Suspend(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +973,7 @@ void nsBuiltinDecoder::StopProgressUpdates()
|
|||||||
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
||||||
"Should be on state machine or decode thread.");
|
"Should be on state machine or decode thread.");
|
||||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
mIgnoreProgressData = PR_TRUE;
|
mIgnoreProgressData = true;
|
||||||
if (mStream) {
|
if (mStream) {
|
||||||
mStream->SetReadMode(nsMediaCacheStream::MODE_METADATA);
|
mStream->SetReadMode(nsMediaCacheStream::MODE_METADATA);
|
||||||
}
|
}
|
||||||
@ -984,7 +984,7 @@ void nsBuiltinDecoder::StartProgressUpdates()
|
|||||||
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
||||||
"Should be on state machine or decode thread.");
|
"Should be on state machine or decode thread.");
|
||||||
GetReentrantMonitor().AssertCurrentThreadIn();
|
GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
mIgnoreProgressData = PR_FALSE;
|
mIgnoreProgressData = false;
|
||||||
if (mStream) {
|
if (mStream) {
|
||||||
mStream->SetReadMode(nsMediaCacheStream::MODE_PLAYBACK);
|
mStream->SetReadMode(nsMediaCacheStream::MODE_PLAYBACK);
|
||||||
mDecoderPosition = mPlaybackPosition = mStream->Tell();
|
mDecoderPosition = mPlaybackPosition = mStream->Tell();
|
||||||
|
@ -288,7 +288,7 @@ public:
|
|||||||
// on the appropriate threads.
|
// on the appropriate threads.
|
||||||
virtual bool OnDecodeThread() const = 0;
|
virtual bool OnDecodeThread() const = 0;
|
||||||
|
|
||||||
// Returns PR_TRUE if the current thread is the state machine thread.
|
// Returns true if the current thread is the state machine thread.
|
||||||
virtual bool OnStateMachineThread() const = 0;
|
virtual bool OnStateMachineThread() const = 0;
|
||||||
|
|
||||||
virtual nsHTMLMediaElement::NextFrameStatus GetNextFrameStatus() = 0;
|
virtual nsHTMLMediaElement::NextFrameStatus GetNextFrameStatus() = 0;
|
||||||
@ -316,7 +316,7 @@ public:
|
|||||||
// before calling this.
|
// before calling this.
|
||||||
virtual void SetSeekable(bool aSeekable) = 0;
|
virtual void SetSeekable(bool aSeekable) = 0;
|
||||||
|
|
||||||
// Returns PR_TRUE if the media resource can seek into unbuffered ranges,
|
// Returns true if the media resource can seek into unbuffered ranges,
|
||||||
// as set by SetSeekable(). The decoder monitor must be obtained before
|
// as set by SetSeekable(). The decoder monitor must be obtained before
|
||||||
// calling this.
|
// calling this.
|
||||||
virtual bool IsSeekable() = 0;
|
virtual bool IsSeekable() = 0;
|
||||||
@ -419,11 +419,11 @@ class nsBuiltinDecoder : public nsMediaDecoder
|
|||||||
// Call on the main thread only.
|
// Call on the main thread only.
|
||||||
virtual void NetworkError();
|
virtual void NetworkError();
|
||||||
|
|
||||||
// Call from any thread safely. Return PR_TRUE if we are currently
|
// Call from any thread safely. Return true if we are currently
|
||||||
// seeking in the media resource.
|
// seeking in the media resource.
|
||||||
virtual bool IsSeeking() const;
|
virtual bool IsSeeking() const;
|
||||||
|
|
||||||
// Return PR_TRUE if the decoder has reached the end of playback.
|
// Return true if the decoder has reached the end of playback.
|
||||||
// Call on the main thread only.
|
// Call on the main thread only.
|
||||||
virtual bool IsEnded() const;
|
virtual bool IsEnded() const;
|
||||||
|
|
||||||
@ -435,7 +435,7 @@ class nsBuiltinDecoder : public nsMediaDecoder
|
|||||||
// Set a flag indicating whether seeking is supported
|
// Set a flag indicating whether seeking is supported
|
||||||
virtual void SetSeekable(bool aSeekable);
|
virtual void SetSeekable(bool aSeekable);
|
||||||
|
|
||||||
// Return PR_TRUE if seeking is supported.
|
// Return true if seeking is supported.
|
||||||
virtual bool IsSeekable();
|
virtual bool IsSeekable();
|
||||||
|
|
||||||
virtual nsresult GetSeekable(nsTimeRanges* aSeekable);
|
virtual nsresult GetSeekable(nsTimeRanges* aSeekable);
|
||||||
@ -704,7 +704,7 @@ public:
|
|||||||
// locked before accessing.
|
// locked before accessing.
|
||||||
bool mIgnoreProgressData;
|
bool mIgnoreProgressData;
|
||||||
|
|
||||||
// PR_TRUE if the stream is infinite (e.g. a webradio).
|
// True if the stream is infinite (e.g. a webradio).
|
||||||
bool mInfiniteStream;
|
bool mInfiniteStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ public:
|
|||||||
mAudioChannels(0),
|
mAudioChannels(0),
|
||||||
mDisplay(0,0),
|
mDisplay(0,0),
|
||||||
mStereoMode(mozilla::layers::STEREO_MODE_MONO),
|
mStereoMode(mozilla::layers::STEREO_MODE_MONO),
|
||||||
mHasAudio(PR_FALSE),
|
mHasAudio(false),
|
||||||
mHasVideo(PR_FALSE)
|
mHasVideo(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Returns PR_TRUE if it's safe to use aPicture as the picture to be
|
// Returns true if it's safe to use aPicture as the picture to be
|
||||||
// extracted inside a frame of size aFrame, and scaled up to and displayed
|
// extracted inside a frame of size aFrame, and scaled up to and displayed
|
||||||
// at a size of aDisplay. You should validate the frame, picture, and
|
// at a size of aDisplay. You should validate the frame, picture, and
|
||||||
// display regions before using them to display video frames.
|
// display regions before using them to display video frames.
|
||||||
@ -83,10 +83,10 @@ public:
|
|||||||
// Indicates the frame layout for single track stereo videos.
|
// Indicates the frame layout for single track stereo videos.
|
||||||
mozilla::layers::StereoMode mStereoMode;
|
mozilla::layers::StereoMode mStereoMode;
|
||||||
|
|
||||||
// PR_TRUE if we have an active audio bitstream.
|
// True if we have an active audio bitstream.
|
||||||
bool mHasAudio;
|
bool mHasAudio;
|
||||||
|
|
||||||
// PR_TRUE if we have an active video bitstream.
|
// True if we have an active video bitstream.
|
||||||
bool mHasVideo;
|
bool mHasVideo;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ public:
|
|||||||
// This frame's image.
|
// This frame's image.
|
||||||
nsRefPtr<Image> mImage;
|
nsRefPtr<Image> mImage;
|
||||||
|
|
||||||
// When PR_TRUE, denotes that this frame is identical to the frame that
|
// When true, denotes that this frame is identical to the frame that
|
||||||
// came before; it's a duplicate. mBuffer will be empty.
|
// came before; it's a duplicate. mBuffer will be empty.
|
||||||
bool mDuplicate;
|
bool mDuplicate;
|
||||||
bool mKeyframe;
|
bool mKeyframe;
|
||||||
@ -236,8 +236,8 @@ public:
|
|||||||
mTime(aTime),
|
mTime(aTime),
|
||||||
mEndTime(aEndTime),
|
mEndTime(aEndTime),
|
||||||
mTimecode(aTimecode),
|
mTimecode(aTimecode),
|
||||||
mDuplicate(PR_TRUE),
|
mDuplicate(true),
|
||||||
mKeyframe(PR_FALSE)
|
mKeyframe(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(VideoData);
|
MOZ_COUNT_CTOR(VideoData);
|
||||||
NS_ASSERTION(aEndTime >= aTime, "Frame must start before it ends.");
|
NS_ASSERTION(aEndTime >= aTime, "Frame must start before it ends.");
|
||||||
@ -254,7 +254,7 @@ public:
|
|||||||
mTime(aTime),
|
mTime(aTime),
|
||||||
mEndTime(aEndTime),
|
mEndTime(aEndTime),
|
||||||
mTimecode(aTimecode),
|
mTimecode(aTimecode),
|
||||||
mDuplicate(PR_FALSE),
|
mDuplicate(false),
|
||||||
mKeyframe(aKeyframe)
|
mKeyframe(aKeyframe)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(VideoData);
|
MOZ_COUNT_CTOR(VideoData);
|
||||||
@ -338,7 +338,7 @@ template <class T> class MediaQueue : private nsDeque {
|
|||||||
T* x = PopFront();
|
T* x = PopFront();
|
||||||
delete x;
|
delete x;
|
||||||
}
|
}
|
||||||
mEndOfStream = PR_FALSE;
|
mEndOfStream = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtEndOfStream() {
|
bool AtEndOfStream() {
|
||||||
@ -346,7 +346,7 @@ template <class T> class MediaQueue : private nsDeque {
|
|||||||
return GetSize() == 0 && mEndOfStream;
|
return GetSize() == 0 && mEndOfStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns PR_TRUE if the media queue has had it last item added to it.
|
// Returns true if the media queue has had it last item added to it.
|
||||||
// This happens when the media stream has been completely decoded. Note this
|
// This happens when the media stream has been completely decoded. Note this
|
||||||
// does not mean that the corresponding stream has finished playback.
|
// does not mean that the corresponding stream has finished playback.
|
||||||
bool IsFinished() {
|
bool IsFinished() {
|
||||||
@ -357,7 +357,7 @@ template <class T> class MediaQueue : private nsDeque {
|
|||||||
// Informs the media queue that it won't be receiving any more items.
|
// Informs the media queue that it won't be receiving any more items.
|
||||||
void Finish() {
|
void Finish() {
|
||||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
mEndOfStream = PR_TRUE;
|
mEndOfStream = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the approximate number of microseconds of items in the queue.
|
// Returns the approximate number of microseconds of items in the queue.
|
||||||
@ -379,7 +379,7 @@ template <class T> class MediaQueue : private nsDeque {
|
|||||||
private:
|
private:
|
||||||
mutable ReentrantMonitor mReentrantMonitor;
|
mutable ReentrantMonitor mReentrantMonitor;
|
||||||
|
|
||||||
// PR_TRUE when we've decoded the last frame of data in the
|
// True when we've decoded the last frame of data in the
|
||||||
// bitstream for which we're queueing frame data.
|
// bitstream for which we're queueing frame data.
|
||||||
bool mEndOfStream;
|
bool mEndOfStream;
|
||||||
};
|
};
|
||||||
@ -404,14 +404,14 @@ public:
|
|||||||
virtual nsresult ResetDecode();
|
virtual nsresult ResetDecode();
|
||||||
|
|
||||||
// Decodes an unspecified amount of audio data, enqueuing the audio data
|
// Decodes an unspecified amount of audio data, enqueuing the audio data
|
||||||
// in mAudioQueue. Returns PR_TRUE when there's more audio to decode,
|
// in mAudioQueue. Returns true when there's more audio to decode,
|
||||||
// PR_FALSE if the audio is finished, end of file has been reached,
|
// false if the audio is finished, end of file has been reached,
|
||||||
// or an un-recoverable read error has occured.
|
// or an un-recoverable read error has occured.
|
||||||
virtual bool DecodeAudioData() = 0;
|
virtual bool DecodeAudioData() = 0;
|
||||||
|
|
||||||
// Reads and decodes one video frame. Packets with a timestamp less
|
// Reads and decodes one video frame. Packets with a timestamp less
|
||||||
// than aTimeThreshold will be decoded (unless they're not keyframes
|
// than aTimeThreshold will be decoded (unless they're not keyframes
|
||||||
// and aKeyframeSkip is PR_TRUE), but will not be added to the queue.
|
// and aKeyframeSkip is true), but will not be added to the queue.
|
||||||
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
|
virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
|
||||||
PRInt64 aTimeThreshold) = 0;
|
PRInt64 aTimeThreshold) = 0;
|
||||||
|
|
||||||
|
@ -204,20 +204,20 @@ nsBuiltinDecoderStateMachine::nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDe
|
|||||||
mAudioEndTime(-1),
|
mAudioEndTime(-1),
|
||||||
mVideoFrameEndTime(-1),
|
mVideoFrameEndTime(-1),
|
||||||
mVolume(1.0),
|
mVolume(1.0),
|
||||||
mSeekable(PR_TRUE),
|
mSeekable(true),
|
||||||
mPositionChangeQueued(PR_FALSE),
|
mPositionChangeQueued(false),
|
||||||
mAudioCompleted(PR_FALSE),
|
mAudioCompleted(false),
|
||||||
mGotDurationFromMetaData(PR_FALSE),
|
mGotDurationFromMetaData(false),
|
||||||
mStopDecodeThread(PR_TRUE),
|
mStopDecodeThread(true),
|
||||||
mDecodeThreadIdle(PR_FALSE),
|
mDecodeThreadIdle(false),
|
||||||
mStopAudioThread(PR_TRUE),
|
mStopAudioThread(true),
|
||||||
mQuickBuffering(PR_FALSE),
|
mQuickBuffering(false),
|
||||||
mIsRunning(PR_FALSE),
|
mIsRunning(false),
|
||||||
mRunAgain(PR_FALSE),
|
mRunAgain(false),
|
||||||
mDispatchedRunEvent(PR_FALSE),
|
mDispatchedRunEvent(false),
|
||||||
mDecodeThreadWaiting(PR_FALSE),
|
mDecodeThreadWaiting(false),
|
||||||
mEventManager(aDecoder),
|
mRealTime(aRealTime),
|
||||||
mRealTime(aRealTime)
|
mEventManager(aDecoder)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsBuiltinDecoderStateMachine);
|
MOZ_COUNT_CTOR(nsBuiltinDecoderStateMachine);
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||||
@ -232,7 +232,7 @@ nsBuiltinDecoderStateMachine::nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDe
|
|||||||
|
|
||||||
// only enable realtime mode when "media.realtime_decoder.enabled" is true.
|
// only enable realtime mode when "media.realtime_decoder.enabled" is true.
|
||||||
if (Preferences::GetBool("media.realtime_decoder.enabled", false) == false)
|
if (Preferences::GetBool("media.realtime_decoder.enabled", false) == false)
|
||||||
mRealTime = PR_FALSE;
|
mRealTime = false;
|
||||||
|
|
||||||
mBufferingWait = mRealTime ? 0 : BUFFERING_WAIT;
|
mBufferingWait = mRealTime ? 0 : BUFFERING_WAIT;
|
||||||
mLowDataThresholdUsecs = mRealTime ? 0 : LOW_DATA_THRESHOLD_USECS;
|
mLowDataThresholdUsecs = mRealTime ? 0 : LOW_DATA_THRESHOLD_USECS;
|
||||||
@ -311,7 +311,7 @@ void nsBuiltinDecoderStateMachine::DecodeThreadRun()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDecodeThreadIdle = PR_TRUE;
|
mDecodeThreadIdle = true;
|
||||||
LOG(PR_LOG_DEBUG, ("%p Decode thread finished", mDecoder.get()));
|
LOG(PR_LOG_DEBUG, ("%p Decode thread finished", mDecoder.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
|
|||||||
|
|
||||||
// If the video decode is falling behind the audio, we'll start dropping the
|
// If the video decode is falling behind the audio, we'll start dropping the
|
||||||
// inter-frames up until the next keyframe which is at or before the current
|
// inter-frames up until the next keyframe which is at or before the current
|
||||||
// playback position. skipToNextKeyframe is PR_TRUE if we're currently
|
// playback position. skipToNextKeyframe is true if we're currently
|
||||||
// skipping up to the next keyframe.
|
// skipping up to the next keyframe.
|
||||||
bool skipToNextKeyframe = false;
|
bool skipToNextKeyframe = false;
|
||||||
|
|
||||||
@ -367,14 +367,14 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
|
|||||||
if (videoPump &&
|
if (videoPump &&
|
||||||
static_cast<PRUint32>(videoQueue.GetSize()) >= videoPumpThreshold)
|
static_cast<PRUint32>(videoQueue.GetSize()) >= videoPumpThreshold)
|
||||||
{
|
{
|
||||||
videoPump = PR_FALSE;
|
videoPump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't want to consider skipping to the next keyframe if we've
|
// We don't want to consider skipping to the next keyframe if we've
|
||||||
// only just started up the decode loop, so wait until we've decoded
|
// only just started up the decode loop, so wait until we've decoded
|
||||||
// some audio data before enabling the keyframe skip logic on audio.
|
// some audio data before enabling the keyframe skip logic on audio.
|
||||||
if (audioPump && GetDecodedAudioDuration() >= audioPumpThreshold) {
|
if (audioPump && GetDecodedAudioDuration() >= audioPumpThreshold) {
|
||||||
audioPump = PR_FALSE;
|
audioPump = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll skip the video decode to the nearest keyframe if we're low on
|
// We'll skip the video decode to the nearest keyframe if we're low on
|
||||||
@ -393,7 +393,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
|
|||||||
!HasLowUndecodedData())
|
!HasLowUndecodedData())
|
||||||
|
|
||||||
{
|
{
|
||||||
skipToNextKeyframe = PR_TRUE;
|
skipToNextKeyframe = true;
|
||||||
LOG(PR_LOG_DEBUG, ("%p Skipping video decode to the next keyframe", mDecoder.get()));
|
LOG(PR_LOG_DEBUG, ("%p Skipping video decode to the next keyframe", mDecoder.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
|
|||||||
// monitor which will wake us up shortly after we sleep, thus preventing
|
// monitor which will wake us up shortly after we sleep, thus preventing
|
||||||
// both the decode and audio push threads waiting at the same time.
|
// both the decode and audio push threads waiting at the same time.
|
||||||
// See bug 620326.
|
// See bug 620326.
|
||||||
mDecodeThreadWaiting = PR_TRUE;
|
mDecodeThreadWaiting = true;
|
||||||
if (mDecoder->GetState() != nsBuiltinDecoder::PLAY_STATE_PLAYING) {
|
if (mDecoder->GetState() != nsBuiltinDecoder::PLAY_STATE_PLAYING) {
|
||||||
// We're not playing, and the decode is about to wait. This means
|
// We're not playing, and the decode is about to wait. This means
|
||||||
// the decode thread may not be needed in future. Signal the state
|
// the decode thread may not be needed in future. Signal the state
|
||||||
@ -468,7 +468,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
|
|||||||
ScheduleStateMachine();
|
ScheduleStateMachine();
|
||||||
}
|
}
|
||||||
mDecoder->GetReentrantMonitor().Wait();
|
mDecoder->GetReentrantMonitor().Wait();
|
||||||
mDecodeThreadWaiting = PR_FALSE;
|
mDecodeThreadWaiting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End decode loop.
|
} // End decode loop.
|
||||||
@ -504,7 +504,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
|
|||||||
PRInt32 minWriteFrames = -1;
|
PRInt32 minWriteFrames = -1;
|
||||||
{
|
{
|
||||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||||
mAudioCompleted = PR_FALSE;
|
mAudioCompleted = false;
|
||||||
audioStartTime = mAudioStartTime;
|
audioStartTime = mAudioStartTime;
|
||||||
channels = mInfo.mAudioChannels;
|
channels = mInfo.mAudioChannels;
|
||||||
rate = mInfo.mAudioRate;
|
rate = mInfo.mAudioRate;
|
||||||
@ -707,7 +707,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
|
|||||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||||
mAudioStream = nsnull;
|
mAudioStream = nsnull;
|
||||||
mEventManager.Clear();
|
mEventManager.Clear();
|
||||||
mAudioCompleted = PR_TRUE;
|
mAudioCompleted = true;
|
||||||
UpdateReadyState();
|
UpdateReadyState();
|
||||||
// Kick the decode thread; it may be sleeping waiting for this to finish.
|
// Kick the decode thread; it may be sleeping waiting for this to finish.
|
||||||
mDecoder->GetReentrantMonitor().NotifyAll();
|
mDecoder->GetReentrantMonitor().NotifyAll();
|
||||||
@ -859,7 +859,7 @@ void nsBuiltinDecoderStateMachine::UpdatePlaybackPosition(PRInt64 aTime)
|
|||||||
|
|
||||||
bool fragmentEnded = mFragmentEndTime >= 0 && GetMediaTime() >= mFragmentEndTime;
|
bool fragmentEnded = mFragmentEndTime >= 0 && GetMediaTime() >= mFragmentEndTime;
|
||||||
if (!mPositionChangeQueued || fragmentEnded) {
|
if (!mPositionChangeQueued || fragmentEnded) {
|
||||||
mPositionChangeQueued = PR_TRUE;
|
mPositionChangeQueued = true;
|
||||||
nsCOMPtr<nsIRunnable> event =
|
nsCOMPtr<nsIRunnable> event =
|
||||||
NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::PlaybackPositionChanged);
|
NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::PlaybackPositionChanged);
|
||||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||||
@ -878,7 +878,7 @@ void nsBuiltinDecoderStateMachine::ClearPositionChangeFlag()
|
|||||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
|
|
||||||
mPositionChangeQueued = PR_FALSE;
|
mPositionChangeQueued = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsHTMLMediaElement::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameStatus()
|
nsHTMLMediaElement::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameStatus()
|
||||||
@ -1007,7 +1007,7 @@ void nsBuiltinDecoderStateMachine::ResetPlayback()
|
|||||||
mVideoFrameEndTime = -1;
|
mVideoFrameEndTime = -1;
|
||||||
mAudioStartTime = -1;
|
mAudioStartTime = -1;
|
||||||
mAudioEndTime = -1;
|
mAudioEndTime = -1;
|
||||||
mAudioCompleted = PR_FALSE;
|
mAudioCompleted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsBuiltinDecoderStateMachine::Seek(double aTime)
|
void nsBuiltinDecoderStateMachine::Seek(double aTime)
|
||||||
@ -1044,7 +1044,7 @@ void nsBuiltinDecoderStateMachine::StopDecodeThread()
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
||||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
mStopDecodeThread = PR_TRUE;
|
mStopDecodeThread = true;
|
||||||
mDecoder->GetReentrantMonitor().NotifyAll();
|
mDecoder->GetReentrantMonitor().NotifyAll();
|
||||||
if (mDecodeThread) {
|
if (mDecodeThread) {
|
||||||
LOG(PR_LOG_DEBUG, ("%p Shutdown decode thread", mDecoder.get()));
|
LOG(PR_LOG_DEBUG, ("%p Shutdown decode thread", mDecoder.get()));
|
||||||
@ -1053,14 +1053,14 @@ void nsBuiltinDecoderStateMachine::StopDecodeThread()
|
|||||||
mDecodeThread->Shutdown();
|
mDecodeThread->Shutdown();
|
||||||
}
|
}
|
||||||
mDecodeThread = nsnull;
|
mDecodeThread = nsnull;
|
||||||
mDecodeThreadIdle = PR_FALSE;
|
mDecodeThreadIdle = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsBuiltinDecoderStateMachine::StopAudioThread()
|
void nsBuiltinDecoderStateMachine::StopAudioThread()
|
||||||
{
|
{
|
||||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
mStopAudioThread = PR_TRUE;
|
mStopAudioThread = true;
|
||||||
mDecoder->GetReentrantMonitor().NotifyAll();
|
mDecoder->GetReentrantMonitor().NotifyAll();
|
||||||
if (mAudioThread) {
|
if (mAudioThread) {
|
||||||
LOG(PR_LOG_DEBUG, ("%p Shutdown audio thread", mDecoder.get()));
|
LOG(PR_LOG_DEBUG, ("%p Shutdown audio thread", mDecoder.get()));
|
||||||
@ -1077,7 +1077,7 @@ nsBuiltinDecoderStateMachine::StartDecodeThread()
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
||||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
mStopDecodeThread = PR_FALSE;
|
mStopDecodeThread = false;
|
||||||
if ((mDecodeThread && !mDecodeThreadIdle) || mState >= DECODER_STATE_COMPLETED)
|
if ((mDecodeThread && !mDecodeThreadIdle) || mState >= DECODER_STATE_COMPLETED)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
@ -1093,7 +1093,7 @@ nsBuiltinDecoderStateMachine::StartDecodeThread()
|
|||||||
nsCOMPtr<nsIRunnable> event =
|
nsCOMPtr<nsIRunnable> event =
|
||||||
NS_NewRunnableMethod(this, &nsBuiltinDecoderStateMachine::DecodeThreadRun);
|
NS_NewRunnableMethod(this, &nsBuiltinDecoderStateMachine::DecodeThreadRun);
|
||||||
mDecodeThread->Dispatch(event, NS_DISPATCH_NORMAL);
|
mDecodeThread->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||||
mDecodeThreadIdle = PR_FALSE;
|
mDecodeThreadIdle = false;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,7 +1103,7 @@ nsBuiltinDecoderStateMachine::StartAudioThread()
|
|||||||
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
NS_ASSERTION(OnStateMachineThread() || OnDecodeThread(),
|
||||||
"Should be on state machine or decode thread.");
|
"Should be on state machine or decode thread.");
|
||||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
mStopAudioThread = PR_FALSE;
|
mStopAudioThread = false;
|
||||||
if (HasAudio() && !mAudioThread) {
|
if (HasAudio() && !mAudioThread) {
|
||||||
nsresult rv = NS_NewThread(getter_AddRefs(mAudioThread),
|
nsresult rv = NS_NewThread(getter_AddRefs(mAudioThread),
|
||||||
nsnull,
|
nsnull,
|
||||||
@ -1384,7 +1384,7 @@ void nsBuiltinDecoderStateMachine::DecodeSeek()
|
|||||||
// Reset quick buffering status. This ensures that if we began the
|
// Reset quick buffering status. This ensures that if we began the
|
||||||
// seek while quick-buffering, we won't bypass quick buffering mode
|
// seek while quick-buffering, we won't bypass quick buffering mode
|
||||||
// if we need to buffer after the seek.
|
// if we need to buffer after the seek.
|
||||||
mQuickBuffering = PR_FALSE;
|
mQuickBuffering = false;
|
||||||
|
|
||||||
ScheduleStateMachine();
|
ScheduleStateMachine();
|
||||||
}
|
}
|
||||||
@ -1918,22 +1918,22 @@ nsresult nsBuiltinDecoderStateMachine::CallRunStateMachine()
|
|||||||
{
|
{
|
||||||
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||||
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
|
||||||
// This will be set to PR_TRUE by ScheduleStateMachine() if it's called
|
// This will be set to true by ScheduleStateMachine() if it's called
|
||||||
// while we're in RunStateMachine().
|
// while we're in RunStateMachine().
|
||||||
mRunAgain = PR_FALSE;
|
mRunAgain = false;
|
||||||
|
|
||||||
// Set to PR_TRUE whenever we dispatch an event to run this state machine.
|
// Set to true whenever we dispatch an event to run this state machine.
|
||||||
// This flag prevents us from dispatching
|
// This flag prevents us from dispatching
|
||||||
mDispatchedRunEvent = PR_FALSE;
|
mDispatchedRunEvent = false;
|
||||||
|
|
||||||
mTimeout = TimeStamp();
|
mTimeout = TimeStamp();
|
||||||
|
|
||||||
mIsRunning = PR_TRUE;
|
mIsRunning = true;
|
||||||
nsresult res = RunStateMachine();
|
nsresult res = RunStateMachine();
|
||||||
mIsRunning = PR_FALSE;
|
mIsRunning = false;
|
||||||
|
|
||||||
if (mRunAgain && !mDispatchedRunEvent) {
|
if (mRunAgain && !mDispatchedRunEvent) {
|
||||||
mDispatchedRunEvent = PR_TRUE;
|
mDispatchedRunEvent = true;
|
||||||
return NS_DispatchToCurrentThread(this);
|
return NS_DispatchToCurrentThread(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1952,7 +1952,7 @@ void nsBuiltinDecoderStateMachine::TimeoutExpired()
|
|||||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||||
NS_ASSERTION(OnStateMachineThread(), "Must be on state machine thread");
|
NS_ASSERTION(OnStateMachineThread(), "Must be on state machine thread");
|
||||||
if (mIsRunning) {
|
if (mIsRunning) {
|
||||||
mRunAgain = PR_TRUE;
|
mRunAgain = true;
|
||||||
} else if (!mDispatchedRunEvent) {
|
} else if (!mDispatchedRunEvent) {
|
||||||
// We don't have an event dispatched to run the state machine, so we
|
// We don't have an event dispatched to run the state machine, so we
|
||||||
// can just run it from here.
|
// can just run it from here.
|
||||||
@ -1998,12 +1998,12 @@ nsresult nsBuiltinDecoderStateMachine::ScheduleStateMachine(PRInt64 aUsecs) {
|
|||||||
if (mIsRunning) {
|
if (mIsRunning) {
|
||||||
// We're currently running this state machine on the state machine
|
// We're currently running this state machine on the state machine
|
||||||
// thread. Signal it to run again once it finishes its current cycle.
|
// thread. Signal it to run again once it finishes its current cycle.
|
||||||
mRunAgain = PR_TRUE;
|
mRunAgain = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
} else if (!mDispatchedRunEvent) {
|
} else if (!mDispatchedRunEvent) {
|
||||||
// We're not currently running this state machine on the state machine
|
// We're not currently running this state machine on the state machine
|
||||||
// thread. Dispatch an event to run one cycle of the state machine.
|
// thread. Dispatch an event to run one cycle of the state machine.
|
||||||
mDispatchedRunEvent = PR_TRUE;
|
mDispatchedRunEvent = true;
|
||||||
return gStateMachineThread->Dispatch(this, NS_DISPATCH_NORMAL);
|
return gStateMachineThread->Dispatch(this, NS_DISPATCH_NORMAL);
|
||||||
}
|
}
|
||||||
// We're not currently running this state machine on the state machine
|
// We're not currently running this state machine on the state machine
|
||||||
|
@ -269,11 +269,11 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Returns PR_TRUE if we've got less than aAudioUsecs microseconds of decoded
|
// Returns true if we've got less than aAudioUsecs microseconds of decoded
|
||||||
// and playable data. The decoder monitor must be held.
|
// and playable data. The decoder monitor must be held.
|
||||||
bool HasLowDecodedData(PRInt64 aAudioUsecs) const;
|
bool HasLowDecodedData(PRInt64 aAudioUsecs) const;
|
||||||
|
|
||||||
// Returns PR_TRUE if we're running low on data which is not yet decoded.
|
// Returns true if we're running low on data which is not yet decoded.
|
||||||
// The decoder monitor must be held.
|
// The decoder monitor must be held.
|
||||||
bool HasLowUndecodedData() const;
|
bool HasLowUndecodedData() const;
|
||||||
|
|
||||||
@ -287,11 +287,11 @@ protected:
|
|||||||
// must be held.
|
// must be held.
|
||||||
PRInt64 AudioDecodedUsecs() const;
|
PRInt64 AudioDecodedUsecs() const;
|
||||||
|
|
||||||
// Returns PR_TRUE when there's decoded audio waiting to play.
|
// Returns true when there's decoded audio waiting to play.
|
||||||
// The decoder monitor must be held.
|
// The decoder monitor must be held.
|
||||||
bool HasFutureAudio() const;
|
bool HasFutureAudio() const;
|
||||||
|
|
||||||
// Returns PR_TRUE if we recently exited "quick buffering" mode.
|
// Returns true if we recently exited "quick buffering" mode.
|
||||||
bool JustExitedQuickBuffering();
|
bool JustExitedQuickBuffering();
|
||||||
|
|
||||||
// Waits on the decoder ReentrantMonitor for aUsecs microseconds. If the decoder
|
// Waits on the decoder ReentrantMonitor for aUsecs microseconds. If the decoder
|
||||||
@ -388,7 +388,7 @@ protected:
|
|||||||
// thread. The decoder monitor must be held.
|
// thread. The decoder monitor must be held.
|
||||||
void StartDecoding();
|
void StartDecoding();
|
||||||
|
|
||||||
// Returns PR_TRUE if we're currently playing. The decoder monitor must
|
// Returns true if we're currently playing. The decoder monitor must
|
||||||
// be held.
|
// be held.
|
||||||
bool IsPlaying();
|
bool IsPlaying();
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ protected:
|
|||||||
return !mTimeout.IsNull() || mRunAgain;
|
return !mTimeout.IsNull() || mRunAgain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns PR_TRUE if we're not playing and the decode thread has filled its
|
// Returns true if we're not playing and the decode thread has filled its
|
||||||
// decode buffers and is waiting. We can shut the decode thread down in this
|
// decode buffers and is waiting. We can shut the decode thread down in this
|
||||||
// case as it may not be needed again.
|
// case as it may not be needed again.
|
||||||
bool IsPausedAndDecoderWaiting();
|
bool IsPausedAndDecoderWaiting();
|
||||||
@ -560,71 +560,71 @@ protected:
|
|||||||
// Time at which we started decoding. Synchronised via decoder monitor.
|
// Time at which we started decoding. Synchronised via decoder monitor.
|
||||||
TimeStamp mDecodeStartTime;
|
TimeStamp mDecodeStartTime;
|
||||||
|
|
||||||
// PR_TRUE if the media resource can be seeked. Accessed from the state
|
// True if the media resource can be seeked. Accessed from the state
|
||||||
// machine and main threads. Synchronised via decoder monitor.
|
// machine and main threads. Synchronised via decoder monitor.
|
||||||
bool mSeekable;
|
bool mSeekable;
|
||||||
|
|
||||||
// PR_TRUE if an event to notify about a change in the playback
|
// True if an event to notify about a change in the playback
|
||||||
// position has been queued, but not yet run. It is set to PR_FALSE when
|
// position has been queued, but not yet run. It is set to false when
|
||||||
// the event is run. This allows coalescing of these events as they can be
|
// the event is run. This allows coalescing of these events as they can be
|
||||||
// produced many times per second. Synchronised via decoder monitor.
|
// produced many times per second. Synchronised via decoder monitor.
|
||||||
// Accessed on main and state machine threads.
|
// Accessed on main and state machine threads.
|
||||||
bool mPositionChangeQueued;
|
bool mPositionChangeQueued;
|
||||||
|
|
||||||
// PR_TRUE if the audio playback thread has finished. It is finished
|
// True if the audio playback thread has finished. It is finished
|
||||||
// when either all the audio frames in the Vorbis bitstream have completed
|
// when either all the audio frames in the Vorbis bitstream have completed
|
||||||
// playing, or we've moved into shutdown state, and the threads are to be
|
// playing, or we've moved into shutdown state, and the threads are to be
|
||||||
// destroyed. Written by the audio playback thread and read and written by
|
// destroyed. Written by the audio playback thread and read and written by
|
||||||
// the state machine thread. Synchronised via decoder monitor.
|
// the state machine thread. Synchronised via decoder monitor.
|
||||||
bool mAudioCompleted;
|
bool mAudioCompleted;
|
||||||
|
|
||||||
// PR_TRUE if mDuration has a value obtained from an HTTP header, or from
|
// True if mDuration has a value obtained from an HTTP header, or from
|
||||||
// the media index/metadata. Accessed on the state machine thread.
|
// the media index/metadata. Accessed on the state machine thread.
|
||||||
bool mGotDurationFromMetaData;
|
bool mGotDurationFromMetaData;
|
||||||
|
|
||||||
// PR_FALSE while decode thread should be running. Accessed state machine
|
// False while decode thread should be running. Accessed state machine
|
||||||
// and decode threads. Syncrhonised by decoder monitor.
|
// and decode threads. Syncrhonised by decoder monitor.
|
||||||
bool mStopDecodeThread;
|
bool mStopDecodeThread;
|
||||||
|
|
||||||
// PR_TRUE when the decode thread run function has finished, but the thread
|
// True when the decode thread run function has finished, but the thread
|
||||||
// has not necessarily been shut down yet. This can happen if we switch
|
// has not necessarily been shut down yet. This can happen if we switch
|
||||||
// from COMPLETED state to SEEKING before the state machine has a chance
|
// from COMPLETED state to SEEKING before the state machine has a chance
|
||||||
// to run in the COMPLETED state and shutdown the decode thread.
|
// to run in the COMPLETED state and shutdown the decode thread.
|
||||||
// Synchronised by the decoder monitor.
|
// Synchronised by the decoder monitor.
|
||||||
bool mDecodeThreadIdle;
|
bool mDecodeThreadIdle;
|
||||||
|
|
||||||
// PR_FALSE while audio thread should be running. Accessed state machine
|
// False while audio thread should be running. Accessed state machine
|
||||||
// and audio threads. Syncrhonised by decoder monitor.
|
// and audio threads. Syncrhonised by decoder monitor.
|
||||||
bool mStopAudioThread;
|
bool mStopAudioThread;
|
||||||
|
|
||||||
// If this is PR_TRUE while we're in buffering mode, we can exit early,
|
// If this is true while we're in buffering mode, we can exit early,
|
||||||
// as it's likely we may be able to playback. This happens when we enter
|
// as it's likely we may be able to playback. This happens when we enter
|
||||||
// buffering mode soon after the decode starts, because the decode-ahead
|
// buffering mode soon after the decode starts, because the decode-ahead
|
||||||
// ran fast enough to exhaust all data while the download is starting up.
|
// ran fast enough to exhaust all data while the download is starting up.
|
||||||
// Synchronised via decoder monitor.
|
// Synchronised via decoder monitor.
|
||||||
bool mQuickBuffering;
|
bool mQuickBuffering;
|
||||||
|
|
||||||
// PR_TRUE if the shared state machine thread is currently running this
|
// True if the shared state machine thread is currently running this
|
||||||
// state machine.
|
// state machine.
|
||||||
bool mIsRunning;
|
bool mIsRunning;
|
||||||
|
|
||||||
// PR_TRUE if we should run the state machine again once the current
|
// True if we should run the state machine again once the current
|
||||||
// state machine run has finished.
|
// state machine run has finished.
|
||||||
bool mRunAgain;
|
bool mRunAgain;
|
||||||
|
|
||||||
// PR_TRUE if we've dispatched an event to run the state machine. It's
|
// True if we've dispatched an event to run the state machine. It's
|
||||||
// imperative that we don't dispatch multiple events to run the state
|
// imperative that we don't dispatch multiple events to run the state
|
||||||
// machine at the same time, as our code assume all events are synchronous.
|
// machine at the same time, as our code assume all events are synchronous.
|
||||||
// If we dispatch multiple events, the second event can run while the
|
// If we dispatch multiple events, the second event can run while the
|
||||||
// first is shutting down a thread, causing inconsistent state.
|
// first is shutting down a thread, causing inconsistent state.
|
||||||
bool mDispatchedRunEvent;
|
bool mDispatchedRunEvent;
|
||||||
|
|
||||||
// PR_TRUE if the decode thread has gone filled its buffers and is now
|
// True if the decode thread has gone filled its buffers and is now
|
||||||
// waiting to be awakened before it continues decoding. Synchronized
|
// waiting to be awakened before it continues decoding. Synchronized
|
||||||
// by the decoder monitor.
|
// by the decoder monitor.
|
||||||
bool mDecodeThreadWaiting;
|
bool mDecodeThreadWaiting;
|
||||||
|
|
||||||
// true is we are decoding a realtime stream, like a camera stream
|
// True is we are decoding a realtime stream, like a camera stream
|
||||||
bool mRealTime;
|
bool mRealTime;
|
||||||
|
|
||||||
PRUint32 mBufferingWait;
|
PRUint32 mBufferingWait;
|
||||||
|
@ -121,7 +121,7 @@ void nsMediaCacheFlusher::Init()
|
|||||||
nsCOMPtr<nsIObserverService> observerService =
|
nsCOMPtr<nsIObserverService> observerService =
|
||||||
mozilla::services::GetObserverService();
|
mozilla::services::GetObserverService();
|
||||||
if (observerService) {
|
if (observerService) {
|
||||||
observerService->AddObserver(gMediaCacheFlusher, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
observerService->AddObserver(gMediaCacheFlusher, NS_PRIVATE_BROWSING_SWITCH_TOPIC, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,9 +135,9 @@ public:
|
|||||||
|
|
||||||
nsMediaCache() : mNextResourceID(1),
|
nsMediaCache() : mNextResourceID(1),
|
||||||
mReentrantMonitor("nsMediaCache.mReentrantMonitor"),
|
mReentrantMonitor("nsMediaCache.mReentrantMonitor"),
|
||||||
mFD(nsnull), mFDCurrentPos(0), mUpdateQueued(PR_FALSE)
|
mFD(nsnull), mFDCurrentPos(0), mUpdateQueued(false)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
, mInUpdate(PR_FALSE)
|
, mInUpdate(false)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsMediaCache);
|
MOZ_COUNT_CTOR(nsMediaCache);
|
||||||
@ -781,10 +781,10 @@ nsMediaCache::BlockIsReusable(PRInt32 aBlockIndex)
|
|||||||
nsMediaCacheStream* stream = block->mOwners[i].mStream;
|
nsMediaCacheStream* stream = block->mOwners[i].mStream;
|
||||||
if (stream->mPinCount > 0 ||
|
if (stream->mPinCount > 0 ||
|
||||||
stream->mStreamOffset/BLOCK_SIZE == block->mOwners[i].mStreamBlock) {
|
stream->mStreamOffset/BLOCK_SIZE == block->mOwners[i].mStreamBlock) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1092,9 +1092,9 @@ nsMediaCache::Update()
|
|||||||
|
|
||||||
{
|
{
|
||||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
mUpdateQueued = PR_FALSE;
|
mUpdateQueued = false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mInUpdate = PR_TRUE;
|
mInUpdate = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRInt32 maxBlocks = GetMaxBlocks();
|
PRInt32 maxBlocks = GetMaxBlocks();
|
||||||
@ -1264,31 +1264,31 @@ nsMediaCache::Update()
|
|||||||
// We're reading to try to catch up to where the current stream
|
// We're reading to try to catch up to where the current stream
|
||||||
// reader wants to be. Better not stop.
|
// reader wants to be. Better not stop.
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p catching up", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p catching up", stream));
|
||||||
enableReading = PR_TRUE;
|
enableReading = true;
|
||||||
} else if (desiredOffset < stream->mStreamOffset + BLOCK_SIZE) {
|
} else if (desiredOffset < stream->mStreamOffset + BLOCK_SIZE) {
|
||||||
// The stream reader is waiting for us, or nearly so. Better feed it.
|
// The stream reader is waiting for us, or nearly so. Better feed it.
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p feeding reader", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p feeding reader", stream));
|
||||||
enableReading = PR_TRUE;
|
enableReading = true;
|
||||||
} else if (!stream->mIsSeekable &&
|
} else if (!stream->mIsSeekable &&
|
||||||
nonSeekableReadaheadBlockCount >= maxBlocks*NONSEEKABLE_READAHEAD_MAX) {
|
nonSeekableReadaheadBlockCount >= maxBlocks*NONSEEKABLE_READAHEAD_MAX) {
|
||||||
// This stream is not seekable and there are already too many blocks
|
// This stream is not seekable and there are already too many blocks
|
||||||
// being cached for readahead for nonseekable streams (which we can't
|
// being cached for readahead for nonseekable streams (which we can't
|
||||||
// free). So stop reading ahead now.
|
// free). So stop reading ahead now.
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p throttling non-seekable readahead", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p throttling non-seekable readahead", stream));
|
||||||
enableReading = PR_FALSE;
|
enableReading = false;
|
||||||
} else if (mIndex.Length() > PRUint32(maxBlocks)) {
|
} else if (mIndex.Length() > PRUint32(maxBlocks)) {
|
||||||
// We're in the process of bringing the cache size back to the
|
// We're in the process of bringing the cache size back to the
|
||||||
// desired limit, so don't bring in more data yet
|
// desired limit, so don't bring in more data yet
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p throttling to reduce cache size", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p throttling to reduce cache size", stream));
|
||||||
enableReading = PR_FALSE;
|
enableReading = false;
|
||||||
} else if (freeBlockCount > 0 || mIndex.Length() < PRUint32(maxBlocks)) {
|
} else if (freeBlockCount > 0 || mIndex.Length() < PRUint32(maxBlocks)) {
|
||||||
// Free blocks in the cache, so keep reading
|
// Free blocks in the cache, so keep reading
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p reading since there are free blocks", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p reading since there are free blocks", stream));
|
||||||
enableReading = PR_TRUE;
|
enableReading = true;
|
||||||
} else if (latestNextUse <= TimeDuration(0)) {
|
} else if (latestNextUse <= TimeDuration(0)) {
|
||||||
// No reusable blocks, so can't read anything
|
// No reusable blocks, so can't read anything
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p throttling due to no reusable blocks", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p throttling due to no reusable blocks", stream));
|
||||||
enableReading = PR_FALSE;
|
enableReading = false;
|
||||||
} else {
|
} else {
|
||||||
// Read ahead if the data we expect to read is more valuable than
|
// Read ahead if the data we expect to read is more valuable than
|
||||||
// the least valuable block in the main part of the cache
|
// the least valuable block in the main part of the cache
|
||||||
@ -1306,7 +1306,7 @@ nsMediaCache::Update()
|
|||||||
other->mChannelOffset/BLOCK_SIZE == desiredOffset/BLOCK_SIZE) {
|
other->mChannelOffset/BLOCK_SIZE == desiredOffset/BLOCK_SIZE) {
|
||||||
// This block is already going to be read by the other stream.
|
// This block is already going to be read by the other stream.
|
||||||
// So don't try to read it from this stream as well.
|
// So don't try to read it from this stream as well.
|
||||||
enableReading = PR_FALSE;
|
enableReading = false;
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p waiting on same block (%lld) from stream %p",
|
LOG(PR_LOG_DEBUG, ("Stream %p waiting on same block (%lld) from stream %p",
|
||||||
stream, desiredOffset/BLOCK_SIZE, other));
|
stream, desiredOffset/BLOCK_SIZE, other));
|
||||||
break;
|
break;
|
||||||
@ -1330,7 +1330,7 @@ nsMediaCache::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mInUpdate = PR_FALSE;
|
mInUpdate = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,19 +1350,19 @@ nsMediaCache::Update()
|
|||||||
(long long)stream->mChannelOffset, stream->mCacheSuspended));
|
(long long)stream->mChannelOffset, stream->mCacheSuspended));
|
||||||
rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
|
rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
|
||||||
stream->mCacheSuspended);
|
stream->mCacheSuspended);
|
||||||
stream->mCacheSuspended = PR_FALSE;
|
stream->mCacheSuspended = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESUME:
|
case RESUME:
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p Resumed", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p Resumed", stream));
|
||||||
rv = stream->mClient->CacheClientResume();
|
rv = stream->mClient->CacheClientResume();
|
||||||
stream->mCacheSuspended = PR_FALSE;
|
stream->mCacheSuspended = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SUSPEND:
|
case SUSPEND:
|
||||||
LOG(PR_LOG_DEBUG, ("Stream %p Suspended", stream));
|
LOG(PR_LOG_DEBUG, ("Stream %p Suspended", stream));
|
||||||
rv = stream->mClient->CacheClientSuspend();
|
rv = stream->mClient->CacheClientSuspend();
|
||||||
stream->mCacheSuspended = PR_TRUE;
|
stream->mCacheSuspended = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1402,7 +1402,7 @@ nsMediaCache::QueueUpdate()
|
|||||||
"Queuing an update while we're in an update");
|
"Queuing an update while we're in an update");
|
||||||
if (mUpdateQueued)
|
if (mUpdateQueued)
|
||||||
return;
|
return;
|
||||||
mUpdateQueued = PR_TRUE;
|
mUpdateQueued = true;
|
||||||
nsCOMPtr<nsIRunnable> event = new UpdateEvent();
|
nsCOMPtr<nsIRunnable> event = new UpdateEvent();
|
||||||
NS_DispatchToMainThread(event);
|
NS_DispatchToMainThread(event);
|
||||||
}
|
}
|
||||||
@ -1748,7 +1748,7 @@ nsMediaCacheStream::UpdatePrincipal(nsIPrincipal* aPrincipal)
|
|||||||
|
|
||||||
// Principals are not equal, so set mPrincipal to a null principal.
|
// Principals are not equal, so set mPrincipal to a null principal.
|
||||||
mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||||
mUsingNullPrincipal = PR_TRUE;
|
mUsingNullPrincipal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1782,7 +1782,7 @@ nsMediaCacheStream::NotifyDataReceived(PRInt64 aSize, const char* aData,
|
|||||||
if (blockOffset == 0) {
|
if (blockOffset == 0) {
|
||||||
// We've just started filling this buffer so now is a good time
|
// We've just started filling this buffer so now is a good time
|
||||||
// to clear this flag.
|
// to clear this flag.
|
||||||
mMetadataInPartialBlockBuffer = PR_FALSE;
|
mMetadataInPartialBlockBuffer = false;
|
||||||
}
|
}
|
||||||
memcpy(reinterpret_cast<char*>(mPartialBlockBuffer) + blockOffset,
|
memcpy(reinterpret_cast<char*>(mPartialBlockBuffer) + blockOffset,
|
||||||
data, chunkSize);
|
data, chunkSize);
|
||||||
@ -1900,7 +1900,7 @@ nsMediaCacheStream::CloseInternal(ReentrantMonitorAutoEnter& aReentrantMonitor)
|
|||||||
|
|
||||||
if (mClosed)
|
if (mClosed)
|
||||||
return;
|
return;
|
||||||
mClosed = PR_TRUE;
|
mClosed = true;
|
||||||
gMediaCache->ReleaseStreamBlocks(this);
|
gMediaCache->ReleaseStreamBlocks(this);
|
||||||
// Wake up any blocked readers
|
// Wake up any blocked readers
|
||||||
aReentrantMonitor.NotifyAll();
|
aReentrantMonitor.NotifyAll();
|
||||||
@ -1953,7 +1953,7 @@ nsMediaCacheStream::IsDataCachedToEndOfStream(PRInt64 aOffset)
|
|||||||
{
|
{
|
||||||
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
||||||
if (mStreamLength < 0)
|
if (mStreamLength < 0)
|
||||||
return PR_FALSE;
|
return false;
|
||||||
return GetCachedDataEndInternal(aOffset) >= mStreamLength;
|
return GetCachedDataEndInternal(aOffset) >= mStreamLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2008,7 +2008,7 @@ nsMediaCacheStream::GetNextCachedDataInternal(PRInt64 aOffset)
|
|||||||
// Count the number of uncached blocks
|
// Count the number of uncached blocks
|
||||||
bool hasPartialBlock = (mChannelOffset % BLOCK_SIZE) != 0;
|
bool hasPartialBlock = (mChannelOffset % BLOCK_SIZE) != 0;
|
||||||
PRUint32 blockIndex = startBlockIndex + 1;
|
PRUint32 blockIndex = startBlockIndex + 1;
|
||||||
while (PR_TRUE) {
|
while (true) {
|
||||||
if ((hasPartialBlock && blockIndex == channelBlockIndex) ||
|
if ((hasPartialBlock && blockIndex == channelBlockIndex) ||
|
||||||
(blockIndex < mBlocks.Length() && mBlocks[blockIndex] != -1)) {
|
(blockIndex < mBlocks.Length() && mBlocks[blockIndex] != -1)) {
|
||||||
// We at the incoming channel block, which has has data in it,
|
// We at the incoming channel block, which has has data in it,
|
||||||
@ -2129,7 +2129,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes)
|
|||||||
memcpy(aBuffer + count,
|
memcpy(aBuffer + count,
|
||||||
reinterpret_cast<char*>(mPartialBlockBuffer) + offsetInStreamBlock, bytes);
|
reinterpret_cast<char*>(mPartialBlockBuffer) + offsetInStreamBlock, bytes);
|
||||||
if (mCurrentMode == MODE_METADATA) {
|
if (mCurrentMode == MODE_METADATA) {
|
||||||
mMetadataInPartialBlockBuffer = PR_TRUE;
|
mMetadataInPartialBlockBuffer = true;
|
||||||
}
|
}
|
||||||
gMediaCache->NoteBlockUsage(this, cacheBlock, mCurrentMode, TimeStamp::Now());
|
gMediaCache->NoteBlockUsage(this, cacheBlock, mCurrentMode, TimeStamp::Now());
|
||||||
} else {
|
} else {
|
||||||
@ -2243,7 +2243,7 @@ nsMediaCacheStream::Init()
|
|||||||
if (!gMediaCache)
|
if (!gMediaCache)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
gMediaCache->OpenStream(this);
|
gMediaCache->OpenStream(this);
|
||||||
mInitialized = PR_TRUE;
|
mInitialized = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2267,7 +2267,7 @@ nsMediaCacheStream::InitAsClone(nsMediaCacheStream* aOriginal)
|
|||||||
|
|
||||||
// Cloned streams are initially suspended, since there is no channel open
|
// Cloned streams are initially suspended, since there is no channel open
|
||||||
// initially for a clone.
|
// initially for a clone.
|
||||||
mCacheSuspended = PR_TRUE;
|
mCacheSuspended = true;
|
||||||
|
|
||||||
for (PRUint32 i = 0; i < aOriginal->mBlocks.Length(); ++i) {
|
for (PRUint32 i = 0; i < aOriginal->mBlocks.Length(); ++i) {
|
||||||
PRInt32 cacheBlockIndex = aOriginal->mBlocks[i];
|
PRInt32 cacheBlockIndex = aOriginal->mBlocks[i];
|
||||||
|
@ -226,14 +226,14 @@ public:
|
|||||||
// aClient provides the underlying transport that cache will use to read
|
// aClient provides the underlying transport that cache will use to read
|
||||||
// data for this stream.
|
// data for this stream.
|
||||||
nsMediaCacheStream(nsMediaChannelStream* aClient)
|
nsMediaCacheStream(nsMediaChannelStream* aClient)
|
||||||
: mClient(aClient), mResourceID(0), mInitialized(PR_FALSE),
|
: mClient(aClient), mResourceID(0), mInitialized(false),
|
||||||
mIsSeekable(PR_FALSE), mCacheSuspended(PR_FALSE),
|
mIsSeekable(false), mCacheSuspended(false),
|
||||||
mUsingNullPrincipal(PR_FALSE),
|
mUsingNullPrincipal(false),
|
||||||
mChannelOffset(0), mStreamLength(-1),
|
mChannelOffset(0), mStreamLength(-1),
|
||||||
mStreamOffset(0), mPlaybackBytesPerSecond(10000),
|
mStreamOffset(0), mPlaybackBytesPerSecond(10000),
|
||||||
mPinCount(0), mCurrentMode(MODE_PLAYBACK),
|
mPinCount(0), mCurrentMode(MODE_PLAYBACK),
|
||||||
mMetadataInPartialBlockBuffer(PR_FALSE),
|
mMetadataInPartialBlockBuffer(false),
|
||||||
mClosed(PR_FALSE) {}
|
mClosed(false) {}
|
||||||
~nsMediaCacheStream();
|
~nsMediaCacheStream();
|
||||||
|
|
||||||
// Set up this stream with the cache. Can fail on OOM. One
|
// Set up this stream with the cache. Can fail on OOM. One
|
||||||
@ -452,11 +452,11 @@ private:
|
|||||||
|
|
||||||
// The last reported seekability state for the underlying channel
|
// The last reported seekability state for the underlying channel
|
||||||
bool mIsSeekable;
|
bool mIsSeekable;
|
||||||
// true if the cache has suspended our channel because the cache is
|
// True if the cache has suspended our channel because the cache is
|
||||||
// full and the priority of the data that would be received is lower
|
// full and the priority of the data that would be received is lower
|
||||||
// than the priority of the data already in the cache
|
// than the priority of the data already in the cache
|
||||||
bool mCacheSuspended;
|
bool mCacheSuspended;
|
||||||
// true if mPrincipal is a null principal because we saw data from
|
// True if mPrincipal is a null principal because we saw data from
|
||||||
// multiple origins
|
// multiple origins
|
||||||
bool mUsingNullPrincipal;
|
bool mUsingNullPrincipal;
|
||||||
// The offset where the next data from the channel will arrive
|
// The offset where the next data from the channel will arrive
|
||||||
@ -488,7 +488,7 @@ private:
|
|||||||
PRUint32 mPinCount;
|
PRUint32 mPinCount;
|
||||||
// The last reported read mode
|
// The last reported read mode
|
||||||
ReadMode mCurrentMode;
|
ReadMode mCurrentMode;
|
||||||
// true if some data in mPartialBlockBuffer has been read as metadata
|
// True if some data in mPartialBlockBuffer has been read as metadata
|
||||||
bool mMetadataInPartialBlockBuffer;
|
bool mMetadataInPartialBlockBuffer;
|
||||||
// Set to true when the stream has been closed either explicitly or
|
// Set to true when the stream has been closed either explicitly or
|
||||||
// due to an internal cache error
|
// due to an internal cache error
|
||||||
|
@ -76,10 +76,10 @@ nsMediaDecoder::nsMediaDecoder() :
|
|||||||
mRGBHeight(-1),
|
mRGBHeight(-1),
|
||||||
mVideoUpdateLock("nsMediaDecoder.mVideoUpdateLock"),
|
mVideoUpdateLock("nsMediaDecoder.mVideoUpdateLock"),
|
||||||
mFrameBufferLength(0),
|
mFrameBufferLength(0),
|
||||||
mPinnedForSeek(PR_FALSE),
|
mPinnedForSeek(false),
|
||||||
mSizeChanged(PR_FALSE),
|
mSizeChanged(false),
|
||||||
mImageContainerSizeChanged(PR_FALSE),
|
mImageContainerSizeChanged(false),
|
||||||
mShuttingDown(PR_FALSE)
|
mShuttingDown(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsMediaDecoder);
|
MOZ_COUNT_CTOR(nsMediaDecoder);
|
||||||
MediaMemoryReporter::AddMediaDecoder(this);
|
MediaMemoryReporter::AddMediaDecoder(this);
|
||||||
@ -94,7 +94,7 @@ nsMediaDecoder::~nsMediaDecoder()
|
|||||||
bool nsMediaDecoder::Init(nsHTMLMediaElement* aElement)
|
bool nsMediaDecoder::Init(nsHTMLMediaElement* aElement)
|
||||||
{
|
{
|
||||||
mElement = aElement;
|
mElement = aElement;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsMediaDecoder::Shutdown()
|
void nsMediaDecoder::Shutdown()
|
||||||
@ -131,11 +131,11 @@ void nsMediaDecoder::Invalidate()
|
|||||||
|
|
||||||
// Get mImageContainerSizeChanged while holding the lock.
|
// Get mImageContainerSizeChanged while holding the lock.
|
||||||
invalidateFrame = mImageContainerSizeChanged;
|
invalidateFrame = mImageContainerSizeChanged;
|
||||||
mImageContainerSizeChanged = PR_FALSE;
|
mImageContainerSizeChanged = false;
|
||||||
|
|
||||||
if (mSizeChanged) {
|
if (mSizeChanged) {
|
||||||
mElement->UpdateMediaSize(nsIntSize(mRGBWidth, mRGBHeight));
|
mElement->UpdateMediaSize(nsIntSize(mRGBWidth, mRGBHeight));
|
||||||
mSizeChanged = PR_FALSE;
|
mSizeChanged = false;
|
||||||
|
|
||||||
if (frame) {
|
if (frame) {
|
||||||
nsPresContext* presContext = frame->PresContext();
|
nsPresContext* presContext = frame->PresContext();
|
||||||
@ -162,7 +162,7 @@ void nsMediaDecoder::Invalidate()
|
|||||||
static void ProgressCallback(nsITimer* aTimer, void* aClosure)
|
static void ProgressCallback(nsITimer* aTimer, void* aClosure)
|
||||||
{
|
{
|
||||||
nsMediaDecoder* decoder = static_cast<nsMediaDecoder*>(aClosure);
|
nsMediaDecoder* decoder = static_cast<nsMediaDecoder*>(aClosure);
|
||||||
decoder->Progress(PR_TRUE);
|
decoder->Progress(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsMediaDecoder::Progress(bool aTimer)
|
void nsMediaDecoder::Progress(bool aTimer)
|
||||||
@ -221,7 +221,7 @@ void nsMediaDecoder::FireTimeUpdate()
|
|||||||
{
|
{
|
||||||
if (!mElement)
|
if (!mElement)
|
||||||
return;
|
return;
|
||||||
mElement->FireTimeUpdate(PR_TRUE);
|
mElement->FireTimeUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsMediaDecoder::SetVideoData(const gfxIntSize& aSize,
|
void nsMediaDecoder::SetVideoData(const gfxIntSize& aSize,
|
||||||
@ -233,7 +233,7 @@ void nsMediaDecoder::SetVideoData(const gfxIntSize& aSize,
|
|||||||
if (mRGBWidth != aSize.width || mRGBHeight != aSize.height) {
|
if (mRGBWidth != aSize.width || mRGBHeight != aSize.height) {
|
||||||
mRGBWidth = aSize.width;
|
mRGBWidth = aSize.width;
|
||||||
mRGBHeight = aSize.height;
|
mRGBHeight = aSize.height;
|
||||||
mSizeChanged = PR_TRUE;
|
mSizeChanged = true;
|
||||||
}
|
}
|
||||||
if (mImageContainer && aImage) {
|
if (mImageContainer && aImage) {
|
||||||
gfxIntSize oldFrameSize = mImageContainer->GetCurrentSize();
|
gfxIntSize oldFrameSize = mImageContainer->GetCurrentSize();
|
||||||
@ -246,7 +246,7 @@ void nsMediaDecoder::SetVideoData(const gfxIntSize& aSize,
|
|||||||
mImageContainer->SetCurrentImage(aImage);
|
mImageContainer->SetCurrentImage(aImage);
|
||||||
gfxIntSize newFrameSize = mImageContainer->GetCurrentSize();
|
gfxIntSize newFrameSize = mImageContainer->GetCurrentSize();
|
||||||
if (oldFrameSize != newFrameSize) {
|
if (oldFrameSize != newFrameSize) {
|
||||||
mImageContainerSizeChanged = PR_TRUE;
|
mImageContainerSizeChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ void nsMediaDecoder::PinForSeek()
|
|||||||
if (!stream || mPinnedForSeek) {
|
if (!stream || mPinnedForSeek) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mPinnedForSeek = PR_TRUE;
|
mPinnedForSeek = true;
|
||||||
stream->Pin();
|
stream->Pin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ void nsMediaDecoder::UnpinForSeek()
|
|||||||
if (!stream || !mPinnedForSeek) {
|
if (!stream || !mPinnedForSeek) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mPinnedForSeek = PR_FALSE;
|
mPinnedForSeek = false;
|
||||||
stream->Unpin();
|
stream->Unpin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ bool nsMediaDecoder::CanPlayThrough()
|
|||||||
{
|
{
|
||||||
Statistics stats = GetStatistics();
|
Statistics stats = GetStatistics();
|
||||||
if (!stats.mDownloadRateReliable || !stats.mPlaybackRateReliable) {
|
if (!stats.mDownloadRateReliable || !stats.mPlaybackRateReliable) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
PRInt64 bytesToDownload = stats.mTotalBytes - stats.mDownloadPosition;
|
PRInt64 bytesToDownload = stats.mTotalBytes - stats.mDownloadPosition;
|
||||||
PRInt64 bytesToPlayback = stats.mTotalBytes - stats.mPlaybackPosition;
|
PRInt64 bytesToPlayback = stats.mTotalBytes - stats.mPlaybackPosition;
|
||||||
@ -293,7 +293,7 @@ bool nsMediaDecoder::CanPlayThrough()
|
|||||||
if (timeToDownload > timeToPlay) {
|
if (timeToDownload > timeToPlay) {
|
||||||
// Estimated time to download is greater than the estimated time to play.
|
// Estimated time to download is greater than the estimated time to play.
|
||||||
// We probably can't play through without having to stop to buffer.
|
// We probably can't play through without having to stop to buffer.
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Estimated time to download is less than the estimated time to play.
|
// Estimated time to download is less than the estimated time to play.
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
virtual nsMediaDecoder* Clone() = 0;
|
virtual nsMediaDecoder* Clone() = 0;
|
||||||
|
|
||||||
// Perform any initialization required for the decoder.
|
// Perform any initialization required for the decoder.
|
||||||
// Return PR_TRUE on successful initialisation, PR_FALSE
|
// Return true on successful initialisation, false
|
||||||
// on failure.
|
// on failure.
|
||||||
virtual bool Init(nsHTMLMediaElement* aElement);
|
virtual bool Init(nsHTMLMediaElement* aElement);
|
||||||
|
|
||||||
@ -150,11 +150,11 @@ public:
|
|||||||
// Called if the media file encounters a network error.
|
// Called if the media file encounters a network error.
|
||||||
virtual void NetworkError() = 0;
|
virtual void NetworkError() = 0;
|
||||||
|
|
||||||
// Call from any thread safely. Return PR_TRUE if we are currently
|
// Call from any thread safely. Return true if we are currently
|
||||||
// seeking in the media resource.
|
// seeking in the media resource.
|
||||||
virtual bool IsSeeking() const = 0;
|
virtual bool IsSeeking() const = 0;
|
||||||
|
|
||||||
// Return PR_TRUE if the decoder has reached the end of playback.
|
// Return true if the decoder has reached the end of playback.
|
||||||
// Call in the main thread only.
|
// Call in the main thread only.
|
||||||
virtual bool IsEnded() const = 0;
|
virtual bool IsEnded() const = 0;
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ public:
|
|||||||
// Set a flag indicating whether seeking is supported
|
// Set a flag indicating whether seeking is supported
|
||||||
virtual void SetSeekable(bool aSeekable) = 0;
|
virtual void SetSeekable(bool aSeekable) = 0;
|
||||||
|
|
||||||
// Return PR_TRUE if seeking is supported.
|
// Return true if seeking is supported.
|
||||||
virtual bool IsSeekable() = 0;
|
virtual bool IsSeekable() = 0;
|
||||||
|
|
||||||
// Return the time ranges that can be seeked into.
|
// Return the time ranges that can be seeked into.
|
||||||
@ -304,7 +304,7 @@ public:
|
|||||||
virtual void Invalidate();
|
virtual void Invalidate();
|
||||||
|
|
||||||
// Fire progress events if needed according to the time and byte
|
// Fire progress events if needed according to the time and byte
|
||||||
// constraints outlined in the specification. aTimer is PR_TRUE
|
// constraints outlined in the specification. aTimer is true
|
||||||
// if the method is called as a result of the progress timer rather
|
// if the method is called as a result of the progress timer rather
|
||||||
// than the result of downloaded data.
|
// than the result of downloaded data.
|
||||||
virtual void Progress(bool aTimer);
|
virtual void Progress(bool aTimer);
|
||||||
@ -346,7 +346,7 @@ public:
|
|||||||
// media element when it is restored from the bfcache, or when we need
|
// media element when it is restored from the bfcache, or when we need
|
||||||
// to stop throttling the download. Call on the main thread only.
|
// to stop throttling the download. Call on the main thread only.
|
||||||
// The download will only actually resume once as many Resume calls
|
// The download will only actually resume once as many Resume calls
|
||||||
// have been made as Suspend calls. When aForceBuffering is PR_TRUE,
|
// have been made as Suspend calls. When aForceBuffering is true,
|
||||||
// we force the decoder to go into buffering state before resuming
|
// we force the decoder to go into buffering state before resuming
|
||||||
// playback.
|
// playback.
|
||||||
virtual void Resume(bool aForceBuffering) = 0;
|
virtual void Resume(bool aForceBuffering) = 0;
|
||||||
@ -386,7 +386,7 @@ public:
|
|||||||
// are buffered and playable.
|
// are buffered and playable.
|
||||||
virtual nsresult GetBuffered(nsTimeRanges* aBuffered) = 0;
|
virtual nsresult GetBuffered(nsTimeRanges* aBuffered) = 0;
|
||||||
|
|
||||||
// Returns PR_TRUE if we can play the entire media through without stopping
|
// Returns true if we can play the entire media through without stopping
|
||||||
// to buffer, given the current download and playback rates.
|
// to buffer, given the current download and playback rates.
|
||||||
bool CanPlayThrough();
|
bool CanPlayThrough();
|
||||||
|
|
||||||
@ -459,17 +459,17 @@ protected:
|
|||||||
// The framebuffer size to use for audioavailable events.
|
// The framebuffer size to use for audioavailable events.
|
||||||
PRUint32 mFrameBufferLength;
|
PRUint32 mFrameBufferLength;
|
||||||
|
|
||||||
// PR_TRUE when our media stream has been pinned. We pin the stream
|
// True when our media stream has been pinned. We pin the stream
|
||||||
// while seeking.
|
// while seeking.
|
||||||
bool mPinnedForSeek;
|
bool mPinnedForSeek;
|
||||||
|
|
||||||
// Set to PR_TRUE when the video width, height or pixel aspect ratio is
|
// Set to true when the video width, height or pixel aspect ratio is
|
||||||
// changed by SetVideoData(). The next call to Invalidate() will recalculate
|
// changed by SetVideoData(). The next call to Invalidate() will recalculate
|
||||||
// and update the intrinsic size on the element, request a frame reflow and
|
// and update the intrinsic size on the element, request a frame reflow and
|
||||||
// then reset this flag.
|
// then reset this flag.
|
||||||
bool mSizeChanged;
|
bool mSizeChanged;
|
||||||
|
|
||||||
// Set to PR_TRUE in SetVideoData() if the new image has a different size
|
// Set to true in SetVideoData() if the new image has a different size
|
||||||
// than the current image. The image size is also affected by transforms
|
// than the current image. The image size is also affected by transforms
|
||||||
// so this can be true even if mSizeChanged is false, for example when
|
// so this can be true even if mSizeChanged is false, for example when
|
||||||
// zooming. The next call to Invalidate() will call nsIFrame::Invalidate
|
// zooming. The next call to Invalidate() will call nsIFrame::Invalidate
|
||||||
|
@ -71,11 +71,11 @@ nsMediaChannelStream::nsMediaChannelStream(nsMediaDecoder* aDecoder,
|
|||||||
nsIChannel* aChannel, nsIURI* aURI)
|
nsIChannel* aChannel, nsIURI* aURI)
|
||||||
: nsMediaStream(aDecoder, aChannel, aURI),
|
: nsMediaStream(aDecoder, aChannel, aURI),
|
||||||
mOffset(0), mSuspendCount(0),
|
mOffset(0), mSuspendCount(0),
|
||||||
mReopenOnError(PR_FALSE), mIgnoreClose(PR_FALSE),
|
mReopenOnError(false), mIgnoreClose(false),
|
||||||
mCacheStream(this),
|
mCacheStream(this),
|
||||||
mLock("nsMediaChannelStream.mLock"),
|
mLock("nsMediaChannelStream.mLock"),
|
||||||
mCacheSuspendCount(0),
|
mCacheSuspendCount(0),
|
||||||
mIgnoreResume(PR_FALSE)
|
mIgnoreResume(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
|||||||
mDecoder->SetDuration(duration);
|
mDecoder->SetDuration(duration);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mDecoder->SetInfinite(PR_TRUE);
|
mDecoder->SetInfinite(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
|||||||
mOffset = 0;
|
mOffset = 0;
|
||||||
|
|
||||||
// The server claimed it supported range requests. It lied.
|
// The server claimed it supported range requests. It lied.
|
||||||
acceptsRanges = PR_FALSE;
|
acceptsRanges = false;
|
||||||
} else if (mOffset == 0 &&
|
} else if (mOffset == 0 &&
|
||||||
(responseStatus == HTTP_OK_CODE ||
|
(responseStatus == HTTP_OK_CODE ||
|
||||||
responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
|
responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
|
||||||
@ -263,7 +263,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
|||||||
responseStatus == HTTP_PARTIAL_RESPONSE_CODE || acceptsRanges;
|
responseStatus == HTTP_PARTIAL_RESPONSE_CODE || acceptsRanges;
|
||||||
|
|
||||||
if (seekable) {
|
if (seekable) {
|
||||||
mDecoder->SetInfinite(PR_FALSE);
|
mDecoder->SetInfinite(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mDecoder->SetSeekable(seekable);
|
mDecoder->SetSeekable(seekable);
|
||||||
@ -274,7 +274,7 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
|||||||
bool fromCache = false;
|
bool fromCache = false;
|
||||||
rv = cc->IsFromCache(&fromCache);
|
rv = cc->IsFromCache(&fromCache);
|
||||||
if (NS_SUCCEEDED(rv) && !fromCache) {
|
if (NS_SUCCEEDED(rv) && !fromCache) {
|
||||||
cc->SetCacheAsFile(PR_TRUE);
|
cc->SetCacheAsFile(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,19 +283,19 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
|||||||
mChannelStatistics.Start(TimeStamp::Now());
|
mChannelStatistics.Start(TimeStamp::Now());
|
||||||
}
|
}
|
||||||
|
|
||||||
mReopenOnError = PR_FALSE;
|
mReopenOnError = false;
|
||||||
mIgnoreClose = PR_FALSE;
|
mIgnoreClose = false;
|
||||||
if (mSuspendCount > 0) {
|
if (mSuspendCount > 0) {
|
||||||
// Re-suspend the channel if it needs to be suspended
|
// Re-suspend the channel if it needs to be suspended
|
||||||
// No need to call PossiblySuspend here since the channel is
|
// No need to call PossiblySuspend here since the channel is
|
||||||
// definitely in the right state for us in OneStartRequest.
|
// definitely in the right state for us in OneStartRequest.
|
||||||
mChannel->Suspend();
|
mChannel->Suspend();
|
||||||
mIgnoreResume = PR_FALSE;
|
mIgnoreResume = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fires an initial progress event and sets up the stall counter so stall events
|
// Fires an initial progress event and sets up the stall counter so stall events
|
||||||
// fire if no download occurs within the required time frame.
|
// fire if no download occurs within the required time frame.
|
||||||
mDecoder->Progress(PR_FALSE);
|
mDecoder->Progress(false);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ nsMediaChannelStream::OnStopRequest(nsIRequest* aRequest, nsresult aStatus)
|
|||||||
// If the stream did close normally, then if the server is seekable we'll
|
// If the stream did close normally, then if the server is seekable we'll
|
||||||
// just seek to the end of the resource and get an HTTP 416 error because
|
// just seek to the end of the resource and get an HTTP 416 error because
|
||||||
// there's nothing there, so this isn't bad.
|
// there's nothing there, so this isn't bad.
|
||||||
nsresult rv = CacheClientSeek(mOffset, PR_FALSE);
|
nsresult rv = CacheClientSeek(mOffset, false);
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
// If the reopen/reseek fails, just fall through and treat this
|
// If the reopen/reseek fails, just fall through and treat this
|
||||||
@ -338,7 +338,7 @@ nsMediaChannelStream::OnStopRequest(nsIRequest* aRequest, nsresult aStatus)
|
|||||||
// requests owned by video documents to ensure the load group fires
|
// requests owned by video documents to ensure the load group fires
|
||||||
// OnStopRequest when restoring from session history.
|
// OnStopRequest when restoring from session history.
|
||||||
if (mLoadInBackground) {
|
if (mLoadInBackground) {
|
||||||
mLoadInBackground = PR_FALSE;
|
mLoadInBackground = false;
|
||||||
|
|
||||||
nsLoadFlags loadFlags;
|
nsLoadFlags loadFlags;
|
||||||
DebugOnly<nsresult> rv = mChannel->GetLoadFlags(&loadFlags);
|
DebugOnly<nsresult> rv = mChannel->GetLoadFlags(&loadFlags);
|
||||||
@ -470,7 +470,7 @@ nsresult nsMediaChannelStream::OpenChannel(nsIStreamListener** aStreamListener)
|
|||||||
new nsCORSListenerProxy(mListener,
|
new nsCORSListenerProxy(mListener,
|
||||||
element->NodePrincipal(),
|
element->NodePrincipal(),
|
||||||
mChannel,
|
mChannel,
|
||||||
PR_FALSE,
|
false,
|
||||||
&rv);
|
&rv);
|
||||||
listener = crossSiteListener;
|
listener = crossSiteListener;
|
||||||
NS_ENSURE_TRUE(crossSiteListener, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(crossSiteListener, NS_ERROR_OUT_OF_MEMORY);
|
||||||
@ -503,7 +503,7 @@ void nsMediaChannelStream::SetupChannelHeaders()
|
|||||||
nsCAutoString rangeString("bytes=");
|
nsCAutoString rangeString("bytes=");
|
||||||
rangeString.AppendInt(mOffset);
|
rangeString.AppendInt(mOffset);
|
||||||
rangeString.Append("-");
|
rangeString.Append("-");
|
||||||
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, PR_FALSE);
|
hc->SetRequestHeader(NS_LITERAL_CSTRING("Range"), rangeString, false);
|
||||||
|
|
||||||
// Send Accept header for video and audio types only (Bug 489071)
|
// Send Accept header for video and audio types only (Bug 489071)
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread");
|
NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread");
|
||||||
@ -632,7 +632,7 @@ void nsMediaChannelStream::Suspend(bool aCloseImmediately)
|
|||||||
if (mChannel) {
|
if (mChannel) {
|
||||||
if (aCloseImmediately && mCacheStream.IsSeekable()) {
|
if (aCloseImmediately && mCacheStream.IsSeekable()) {
|
||||||
// Kill off our channel right now, but don't tell anyone about it.
|
// Kill off our channel right now, but don't tell anyone about it.
|
||||||
mIgnoreClose = PR_TRUE;
|
mIgnoreClose = true;
|
||||||
CloseChannel();
|
CloseChannel();
|
||||||
element->DownloadSuspended();
|
element->DownloadSuspended();
|
||||||
} else if (mSuspendCount == 0) {
|
} else if (mSuspendCount == 0) {
|
||||||
@ -670,7 +670,7 @@ void nsMediaChannelStream::Resume()
|
|||||||
}
|
}
|
||||||
// if an error occurs after Resume, assume it's because the server
|
// if an error occurs after Resume, assume it's because the server
|
||||||
// timed out the connection and we should reopen it.
|
// timed out the connection and we should reopen it.
|
||||||
mReopenOnError = PR_TRUE;
|
mReopenOnError = true;
|
||||||
PossiblyResume();
|
PossiblyResume();
|
||||||
element->DownloadResumed();
|
element->DownloadResumed();
|
||||||
} else {
|
} else {
|
||||||
@ -683,7 +683,7 @@ void nsMediaChannelStream::Resume()
|
|||||||
if (totalLength < 0 || mOffset < totalLength) {
|
if (totalLength < 0 || mOffset < totalLength) {
|
||||||
// There is (or may be) data to read at mOffset, so start reading it.
|
// There is (or may be) data to read at mOffset, so start reading it.
|
||||||
// Need to recreate the channel.
|
// Need to recreate the channel.
|
||||||
CacheClientSeek(mOffset, PR_FALSE);
|
CacheClientSeek(mOffset, false);
|
||||||
}
|
}
|
||||||
element->DownloadResumed();
|
element->DownloadResumed();
|
||||||
}
|
}
|
||||||
@ -792,7 +792,7 @@ nsMediaChannelStream::CacheClientSuspend()
|
|||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
++mCacheSuspendCount;
|
++mCacheSuspendCount;
|
||||||
}
|
}
|
||||||
Suspend(PR_FALSE);
|
Suspend(false);
|
||||||
|
|
||||||
mDecoder->NotifySuspendedStatusChanged();
|
mDecoder->NotifySuspendedStatusChanged();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -888,9 +888,9 @@ nsMediaChannelStream::PossiblySuspend()
|
|||||||
nsresult rv = mChannel->IsPending(&isPending);
|
nsresult rv = mChannel->IsPending(&isPending);
|
||||||
if (NS_SUCCEEDED(rv) && isPending) {
|
if (NS_SUCCEEDED(rv) && isPending) {
|
||||||
mChannel->Suspend();
|
mChannel->Suspend();
|
||||||
mIgnoreResume = PR_FALSE;
|
mIgnoreResume = false;
|
||||||
} else {
|
} else {
|
||||||
mIgnoreResume = PR_TRUE;
|
mIgnoreResume = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,7 +900,7 @@ nsMediaChannelStream::PossiblyResume()
|
|||||||
if (!mIgnoreResume) {
|
if (!mIgnoreResume) {
|
||||||
mChannel->Resume();
|
mChannel->Resume();
|
||||||
} else {
|
} else {
|
||||||
mIgnoreResume = PR_FALSE;
|
mIgnoreResume = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,7 +940,7 @@ public:
|
|||||||
virtual double GetDownloadRate(bool* aIsReliable)
|
virtual double GetDownloadRate(bool* aIsReliable)
|
||||||
{
|
{
|
||||||
// The data's all already here
|
// The data's all already here
|
||||||
*aIsReliable = PR_TRUE;
|
*aIsReliable = true;
|
||||||
return 100*1024*1024; // arbitray, use 100MB/s
|
return 100*1024*1024; // arbitray, use 100MB/s
|
||||||
}
|
}
|
||||||
virtual PRInt64 GetLength() { return mSize; }
|
virtual PRInt64 GetLength() { return mSize; }
|
||||||
@ -1196,7 +1196,7 @@ nsMediaStream::Create(nsMediaDecoder* aDecoder, nsIChannel* aChannel)
|
|||||||
|
|
||||||
void nsMediaStream::MoveLoadsToBackground() {
|
void nsMediaStream::MoveLoadsToBackground() {
|
||||||
NS_ASSERTION(!mLoadInBackground, "Why are you calling this more than once?");
|
NS_ASSERTION(!mLoadInBackground, "Why are you calling this more than once?");
|
||||||
mLoadInBackground = PR_TRUE;
|
mLoadInBackground = true;
|
||||||
if (!mChannel) {
|
if (!mChannel) {
|
||||||
// No channel, resource is probably already loaded.
|
// No channel, resource is probably already loaded.
|
||||||
return;
|
return;
|
||||||
|
@ -80,19 +80,19 @@ public:
|
|||||||
mLastStartTime = TimeStamp();
|
mLastStartTime = TimeStamp();
|
||||||
mAccumulatedTime = TimeDuration(0);
|
mAccumulatedTime = TimeDuration(0);
|
||||||
mAccumulatedBytes = 0;
|
mAccumulatedBytes = 0;
|
||||||
mIsStarted = PR_FALSE;
|
mIsStarted = false;
|
||||||
}
|
}
|
||||||
void Start(TimeStamp aNow) {
|
void Start(TimeStamp aNow) {
|
||||||
if (mIsStarted)
|
if (mIsStarted)
|
||||||
return;
|
return;
|
||||||
mLastStartTime = aNow;
|
mLastStartTime = aNow;
|
||||||
mIsStarted = PR_TRUE;
|
mIsStarted = true;
|
||||||
}
|
}
|
||||||
void Stop(TimeStamp aNow) {
|
void Stop(TimeStamp aNow) {
|
||||||
if (!mIsStarted)
|
if (!mIsStarted)
|
||||||
return;
|
return;
|
||||||
mAccumulatedTime += aNow - mLastStartTime;
|
mAccumulatedTime += aNow - mLastStartTime;
|
||||||
mIsStarted = PR_FALSE;
|
mIsStarted = false;
|
||||||
}
|
}
|
||||||
void AddBytes(PRInt64 aBytes) {
|
void AddBytes(PRInt64 aBytes) {
|
||||||
if (!mIsStarted) {
|
if (!mIsStarted) {
|
||||||
@ -304,7 +304,7 @@ protected:
|
|||||||
mDecoder(aDecoder),
|
mDecoder(aDecoder),
|
||||||
mChannel(aChannel),
|
mChannel(aChannel),
|
||||||
mURI(aURI),
|
mURI(aURI),
|
||||||
mLoadInBackground(PR_FALSE)
|
mLoadInBackground(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsMediaStream);
|
MOZ_COUNT_CTOR(nsMediaStream);
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ protected:
|
|||||||
// main thread only.
|
// main thread only.
|
||||||
nsCOMPtr<nsIURI> mURI;
|
nsCOMPtr<nsIURI> mURI;
|
||||||
|
|
||||||
// PR_TRUE if MoveLoadsToBackground() has been called, i.e. the load event
|
// True if MoveLoadsToBackground() has been called, i.e. the load event
|
||||||
// has been fired, and all channel loads will be in the background.
|
// has been fired, and all channel loads will be in the background.
|
||||||
bool mLoadInBackground;
|
bool mLoadInBackground;
|
||||||
};
|
};
|
||||||
@ -378,7 +378,7 @@ public:
|
|||||||
virtual void Suspend(bool aCloseImmediately);
|
virtual void Suspend(bool aCloseImmediately);
|
||||||
virtual void Resume();
|
virtual void Resume();
|
||||||
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
|
virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
|
||||||
// Return PR_TRUE if the stream has been closed.
|
// Return true if the stream has been closed.
|
||||||
bool IsClosed() const { return mCacheStream.IsClosed(); }
|
bool IsClosed() const { return mCacheStream.IsClosed(); }
|
||||||
virtual nsMediaStream* CloneData(nsMediaDecoder* aDecoder);
|
virtual nsMediaStream* CloneData(nsMediaDecoder* aDecoder);
|
||||||
virtual nsresult ReadFromCache(char* aBuffer, PRInt64 aOffset, PRUint32 aCount);
|
virtual nsresult ReadFromCache(char* aBuffer, PRInt64 aOffset, PRUint32 aCount);
|
||||||
@ -480,7 +480,7 @@ protected:
|
|||||||
nsChannelStatistics mChannelStatistics;
|
nsChannelStatistics mChannelStatistics;
|
||||||
PRUint32 mCacheSuspendCount;
|
PRUint32 mCacheSuspendCount;
|
||||||
|
|
||||||
// PR_TRUE if we couldn't suspend the stream and we therefore don't want
|
// True if we couldn't suspend the stream and we therefore don't want
|
||||||
// to resume later. This is usually due to the channel not being in the
|
// to resume later. This is usually due to the channel not being in the
|
||||||
// isPending state at the time of the suspend request.
|
// isPending state at the time of the suspend request.
|
||||||
bool mIgnoreResume;
|
bool mIgnoreResume;
|
||||||
|
@ -63,7 +63,7 @@ nsOggCodecState::Create(ogg_page* aPage)
|
|||||||
} else if (aPage->body_len > 8 && memcmp(aPage->body, "fishead\0", 8) == 0) {
|
} else if (aPage->body_len > 8 && memcmp(aPage->body, "fishead\0", 8) == 0) {
|
||||||
codecState = new nsSkeletonState(aPage);
|
codecState = new nsSkeletonState(aPage);
|
||||||
} else {
|
} else {
|
||||||
codecState = new nsOggCodecState(aPage, PR_FALSE);
|
codecState = new nsOggCodecState(aPage, false);
|
||||||
}
|
}
|
||||||
return codecState->nsOggCodecState::Init() ? codecState.forget() : nsnull;
|
return codecState->nsOggCodecState::Init() ? codecState.forget() : nsnull;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,8 @@ ogg_packet* nsOggCodecState::PacketOut() {
|
|||||||
nsresult nsOggCodecState::PageIn(ogg_page* aPage) {
|
nsresult nsOggCodecState::PageIn(ogg_page* aPage) {
|
||||||
if (!mActive)
|
if (!mActive)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
NS_ASSERTION(ogg_page_serialno(aPage) == mSerial, "Page must be for this stream!");
|
NS_ASSERTION(static_cast<PRUint32>(ogg_page_serialno(aPage)) == mSerial,
|
||||||
|
"Page must be for this stream!");
|
||||||
if (ogg_stream_pagein(&mState, aPage) == -1)
|
if (ogg_stream_pagein(&mState, aPage) == -1)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
int r;
|
int r;
|
||||||
@ -184,7 +185,7 @@ nsresult nsOggCodecState::PageIn(ogg_page* aPage) {
|
|||||||
|
|
||||||
nsresult nsOggCodecState::PacketOutUntilGranulepos(bool& aFoundGranulepos) {
|
nsresult nsOggCodecState::PacketOutUntilGranulepos(bool& aFoundGranulepos) {
|
||||||
int r;
|
int r;
|
||||||
aFoundGranulepos = PR_FALSE;
|
aFoundGranulepos = false;
|
||||||
// Extract packets from the sync state until either no more packets
|
// Extract packets from the sync state until either no more packets
|
||||||
// come out, or we get a data packet with non -1 granulepos.
|
// come out, or we get a data packet with non -1 granulepos.
|
||||||
do {
|
do {
|
||||||
@ -212,7 +213,7 @@ nsresult nsOggCodecState::PacketOutUntilGranulepos(bool& aFoundGranulepos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsTheoraState::nsTheoraState(ogg_page* aBosPage) :
|
nsTheoraState::nsTheoraState(ogg_page* aBosPage) :
|
||||||
nsOggCodecState(aBosPage, PR_TRUE),
|
nsOggCodecState(aBosPage, true),
|
||||||
mSetup(0),
|
mSetup(0),
|
||||||
mCtx(0),
|
mCtx(0),
|
||||||
mPixelAspectRatio(0)
|
mPixelAspectRatio(0)
|
||||||
@ -232,7 +233,7 @@ nsTheoraState::~nsTheoraState() {
|
|||||||
|
|
||||||
bool nsTheoraState::Init() {
|
bool nsTheoraState::Init() {
|
||||||
if (!mActive)
|
if (!mActive)
|
||||||
return PR_FALSE;
|
return false;
|
||||||
|
|
||||||
PRInt64 n = mInfo.aspect_numerator;
|
PRInt64 n = mInfo.aspect_numerator;
|
||||||
PRInt64 d = mInfo.aspect_denominator;
|
PRInt64 d = mInfo.aspect_denominator;
|
||||||
@ -245,15 +246,15 @@ bool nsTheoraState::Init() {
|
|||||||
nsIntSize frame(mInfo.frame_width, mInfo.frame_height);
|
nsIntSize frame(mInfo.frame_width, mInfo.frame_height);
|
||||||
nsIntRect picture(mInfo.pic_x, mInfo.pic_y, mInfo.pic_width, mInfo.pic_height);
|
nsIntRect picture(mInfo.pic_x, mInfo.pic_y, mInfo.pic_width, mInfo.pic_height);
|
||||||
if (!nsVideoInfo::ValidateVideoRegion(frame, picture, frame)) {
|
if (!nsVideoInfo::ValidateVideoRegion(frame, picture, frame)) {
|
||||||
return mActive = PR_FALSE;
|
return mActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCtx = th_decode_alloc(&mInfo, mSetup);
|
mCtx = th_decode_alloc(&mInfo, mSetup);
|
||||||
if (mCtx == NULL) {
|
if (mCtx == NULL) {
|
||||||
return mActive = PR_FALSE;
|
return mActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -283,11 +284,11 @@ nsTheoraState::DecodeHeader(ogg_packet* aPacket)
|
|||||||
if (ret < 0 || mPacketCount > 3) {
|
if (ret < 0 || mPacketCount > 3) {
|
||||||
// We've received an error, or the first three packets weren't valid
|
// We've received an error, or the first three packets weren't valid
|
||||||
// header packets, assume bad input, and don't activate the bitstream.
|
// header packets, assume bad input, and don't activate the bitstream.
|
||||||
mDoneReadingHeaders = PR_TRUE;
|
mDoneReadingHeaders = true;
|
||||||
} else if (ret > 0 && isSetupHeader && mPacketCount == 3) {
|
} else if (ret > 0 && isSetupHeader && mPacketCount == 3) {
|
||||||
// Successfully read the three header packets.
|
// Successfully read the three header packets.
|
||||||
mDoneReadingHeaders = PR_TRUE;
|
mDoneReadingHeaders = true;
|
||||||
mActive = PR_TRUE;
|
mActive = true;
|
||||||
}
|
}
|
||||||
return mDoneReadingHeaders;
|
return mDoneReadingHeaders;
|
||||||
}
|
}
|
||||||
@ -306,8 +307,8 @@ nsTheoraState::IsHeader(ogg_packet* aPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# define TH_VERSION_CHECK(_info,_maj,_min,_sub) \
|
# define TH_VERSION_CHECK(_info,_maj,_min,_sub) \
|
||||||
((_info)->version_major>(_maj)||(_info)->version_major==(_maj)&& \
|
(((_info)->version_major>(_maj)||(_info)->version_major==(_maj))&& \
|
||||||
((_info)->version_minor>(_min)||(_info)->version_minor==(_min)&& \
|
(((_info)->version_minor>(_min)||(_info)->version_minor==(_min))&& \
|
||||||
(_info)->version_subminor>=(_sub)))
|
(_info)->version_subminor>=(_sub)))
|
||||||
|
|
||||||
PRInt64 nsTheoraState::Time(th_info* aInfo, PRInt64 aGranulepos)
|
PRInt64 nsTheoraState::Time(th_info* aInfo, PRInt64 aGranulepos)
|
||||||
@ -507,7 +508,7 @@ nsresult nsVorbisState::Reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsVorbisState::nsVorbisState(ogg_page* aBosPage) :
|
nsVorbisState::nsVorbisState(ogg_page* aBosPage) :
|
||||||
nsOggCodecState(aBosPage, PR_TRUE),
|
nsOggCodecState(aBosPage, true),
|
||||||
mPrevVorbisBlockSize(0),
|
mPrevVorbisBlockSize(0),
|
||||||
mGranulepos(0)
|
mGranulepos(0)
|
||||||
{
|
{
|
||||||
@ -553,12 +554,12 @@ bool nsVorbisState::DecodeHeader(ogg_packet* aPacket) {
|
|||||||
if (ret < 0 || mPacketCount > 3) {
|
if (ret < 0 || mPacketCount > 3) {
|
||||||
// We've received an error, or the first three packets weren't valid
|
// We've received an error, or the first three packets weren't valid
|
||||||
// header packets, assume bad input, and deactivate the bitstream.
|
// header packets, assume bad input, and deactivate the bitstream.
|
||||||
mDoneReadingHeaders = PR_TRUE;
|
mDoneReadingHeaders = true;
|
||||||
mActive = PR_FALSE;
|
mActive = false;
|
||||||
} else if (ret == 0 && isSetupHeader && mPacketCount == 3) {
|
} else if (ret == 0 && isSetupHeader && mPacketCount == 3) {
|
||||||
// Successfully read the three header packets.
|
// Successfully read the three header packets.
|
||||||
// The bitstream remains active.
|
// The bitstream remains active.
|
||||||
mDoneReadingHeaders = PR_TRUE;
|
mDoneReadingHeaders = true;
|
||||||
}
|
}
|
||||||
return mDoneReadingHeaders;
|
return mDoneReadingHeaders;
|
||||||
}
|
}
|
||||||
@ -566,12 +567,12 @@ bool nsVorbisState::DecodeHeader(ogg_packet* aPacket) {
|
|||||||
bool nsVorbisState::Init()
|
bool nsVorbisState::Init()
|
||||||
{
|
{
|
||||||
if (!mActive)
|
if (!mActive)
|
||||||
return PR_FALSE;
|
return false;
|
||||||
|
|
||||||
int ret = vorbis_synthesis_init(&mDsp, &mInfo);
|
int ret = vorbis_synthesis_init(&mDsp, &mInfo);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
NS_WARNING("vorbis_synthesis_init() failed initializing vorbis bitstream");
|
NS_WARNING("vorbis_synthesis_init() failed initializing vorbis bitstream");
|
||||||
return mActive = PR_FALSE;
|
return mActive = false;
|
||||||
}
|
}
|
||||||
ret = vorbis_block_init(&mDsp, &mBlock);
|
ret = vorbis_block_init(&mDsp, &mBlock);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
@ -579,9 +580,9 @@ bool nsVorbisState::Init()
|
|||||||
if (mActive) {
|
if (mActive) {
|
||||||
vorbis_dsp_clear(&mDsp);
|
vorbis_dsp_clear(&mDsp);
|
||||||
}
|
}
|
||||||
return mActive = PR_FALSE;
|
return mActive = false;
|
||||||
}
|
}
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt64 nsVorbisState::Time(PRInt64 granulepos)
|
PRInt64 nsVorbisState::Time(PRInt64 granulepos)
|
||||||
@ -611,7 +612,7 @@ nsVorbisState::IsHeader(ogg_packet* aPacket)
|
|||||||
// Any packet with its first bit set cannot be a data packet, it's a
|
// Any packet with its first bit set cannot be a data packet, it's a
|
||||||
// (possibly invalid) header packet.
|
// (possibly invalid) header packet.
|
||||||
// See: http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-610004.2.1
|
// See: http://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-610004.2.1
|
||||||
return aPacket->bytes > 0 ? (aPacket->packet[0] & 0x1) : PR_FALSE;
|
return aPacket->bytes > 0 ? (aPacket->packet[0] & 0x1) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
@ -756,7 +757,7 @@ nsresult nsVorbisState::ReconstructVorbisGranulepos()
|
|||||||
|
|
||||||
|
|
||||||
nsSkeletonState::nsSkeletonState(ogg_page* aBosPage)
|
nsSkeletonState::nsSkeletonState(ogg_page* aBosPage)
|
||||||
: nsOggCodecState(aBosPage, PR_TRUE),
|
: nsOggCodecState(aBosPage, true),
|
||||||
mVersion(0),
|
mVersion(0),
|
||||||
mPresentationTime(0),
|
mPresentationTime(0),
|
||||||
mLength(0)
|
mLength(0)
|
||||||
@ -863,7 +864,7 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
NS_ASSERTION(aPacket->bytes >= SKELETON_4_0_MIN_INDEX_LEN,
|
NS_ASSERTION(aPacket->bytes >= SKELETON_4_0_MIN_INDEX_LEN,
|
||||||
"Index must be at least minimum size");
|
"Index must be at least minimum size");
|
||||||
if (!mActive) {
|
if (!mActive) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint32 serialno = LEUint32(aPacket->packet + INDEX_SERIALNO_OFFSET);
|
PRUint32 serialno = LEUint32(aPacket->packet + INDEX_SERIALNO_OFFSET);
|
||||||
@ -877,14 +878,14 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
if (timeDenom == 0) {
|
if (timeDenom == 0) {
|
||||||
LOG(PR_LOG_DEBUG, ("Ogg Skeleton Index packet for stream %u has 0 "
|
LOG(PR_LOG_DEBUG, ("Ogg Skeleton Index packet for stream %u has 0 "
|
||||||
"timestamp denominator.", serialno));
|
"timestamp denominator.", serialno));
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the start time.
|
// Extract the start time.
|
||||||
n = LEInt64(p + INDEX_FIRST_NUMER_OFFSET);
|
n = LEInt64(p + INDEX_FIRST_NUMER_OFFSET);
|
||||||
PRInt64 t;
|
PRInt64 t;
|
||||||
if (!MulOverflow(n, USECS_PER_S, t)) {
|
if (!MulOverflow(n, USECS_PER_S, t)) {
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
} else {
|
} else {
|
||||||
startTime = t / timeDenom;
|
startTime = t / timeDenom;
|
||||||
}
|
}
|
||||||
@ -892,7 +893,7 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
// Extract the end time.
|
// Extract the end time.
|
||||||
n = LEInt64(p + INDEX_LAST_NUMER_OFFSET);
|
n = LEInt64(p + INDEX_LAST_NUMER_OFFSET);
|
||||||
if (!MulOverflow(n, USECS_PER_S, t)) {
|
if (!MulOverflow(n, USECS_PER_S, t)) {
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
} else {
|
} else {
|
||||||
endTime = t / timeDenom;
|
endTime = t / timeDenom;
|
||||||
}
|
}
|
||||||
@ -903,7 +904,7 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
if (!MulOverflow(numKeyPoints, MIN_KEY_POINT_SIZE, minPacketSize) ||
|
if (!MulOverflow(numKeyPoints, MIN_KEY_POINT_SIZE, minPacketSize) ||
|
||||||
!AddOverflow(INDEX_KEYPOINT_OFFSET, minPacketSize, minPacketSize))
|
!AddOverflow(INDEX_KEYPOINT_OFFSET, minPacketSize, minPacketSize))
|
||||||
{
|
{
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt64 sizeofIndex = aPacket->bytes - INDEX_KEYPOINT_OFFSET;
|
PRInt64 sizeofIndex = aPacket->bytes - INDEX_KEYPOINT_OFFSET;
|
||||||
@ -922,7 +923,7 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
"(%lld) in index packet for stream %u.",
|
"(%lld) in index packet for stream %u.",
|
||||||
numKeyPoints,
|
numKeyPoints,
|
||||||
serialno));
|
serialno));
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoPtr<nsKeyFrameIndex> keyPoints(new nsKeyFrameIndex(startTime, endTime));
|
nsAutoPtr<nsKeyFrameIndex> keyPoints(new nsKeyFrameIndex(startTime, endTime));
|
||||||
@ -942,18 +943,18 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
offset > mLength ||
|
offset > mLength ||
|
||||||
offset < 0)
|
offset < 0)
|
||||||
{
|
{
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
}
|
}
|
||||||
p = ReadVariableLengthInt(p, limit, delta);
|
p = ReadVariableLengthInt(p, limit, delta);
|
||||||
if (!AddOverflow(time, delta, time) ||
|
if (!AddOverflow(time, delta, time) ||
|
||||||
time > endTime ||
|
time > endTime ||
|
||||||
time < startTime)
|
time < startTime)
|
||||||
{
|
{
|
||||||
return (mActive = PR_FALSE);
|
return (mActive = false);
|
||||||
}
|
}
|
||||||
PRInt64 timeUsecs = 0;
|
PRInt64 timeUsecs = 0;
|
||||||
if (!MulOverflow(time, USECS_PER_S, timeUsecs))
|
if (!MulOverflow(time, USECS_PER_S, timeUsecs))
|
||||||
return mActive = PR_FALSE;
|
return mActive = false;
|
||||||
timeUsecs /= timeDenom;
|
timeUsecs /= timeDenom;
|
||||||
keyPoints->Add(offset, timeUsecs);
|
keyPoints->Add(offset, timeUsecs);
|
||||||
numKeyPointsRead++;
|
numKeyPointsRead++;
|
||||||
@ -966,7 +967,7 @@ bool nsSkeletonState::DecodeIndex(ogg_packet* aPacket)
|
|||||||
|
|
||||||
LOG(PR_LOG_DEBUG, ("Loaded %d keypoints for Skeleton on stream %u",
|
LOG(PR_LOG_DEBUG, ("Loaded %d keypoints for Skeleton on stream %u",
|
||||||
keyPointsRead, serialno));
|
keyPointsRead, serialno));
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsSkeletonState::IndexedSeekTargetForTrack(PRUint32 aSerialno,
|
nsresult nsSkeletonState::IndexedSeekTargetForTrack(PRUint32 aSerialno,
|
||||||
@ -1082,8 +1083,8 @@ bool nsSkeletonState::DecodeHeader(ogg_packet* aPacket)
|
|||||||
aPacket->bytes < SKELETON_4_0_MIN_HEADER_LEN)
|
aPacket->bytes < SKELETON_4_0_MIN_HEADER_LEN)
|
||||||
{
|
{
|
||||||
// We can only care to parse Skeleton version 4.0+.
|
// We can only care to parse Skeleton version 4.0+.
|
||||||
mActive = PR_FALSE;
|
mActive = false;
|
||||||
return mDoneReadingHeaders = PR_TRUE;
|
return mDoneReadingHeaders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the segment length.
|
// Extract the segment length.
|
||||||
@ -1095,19 +1096,19 @@ bool nsSkeletonState::DecodeHeader(ogg_packet* aPacket)
|
|||||||
bool init = mIndex.Init();
|
bool init = mIndex.Init();
|
||||||
if (!init) {
|
if (!init) {
|
||||||
NS_WARNING("Failed to initialize Ogg skeleton serialno-to-index map");
|
NS_WARNING("Failed to initialize Ogg skeleton serialno-to-index map");
|
||||||
mActive = PR_FALSE;
|
mActive = false;
|
||||||
return mDoneReadingHeaders = PR_TRUE;
|
return mDoneReadingHeaders = true;
|
||||||
}
|
}
|
||||||
mActive = PR_TRUE;
|
mActive = true;
|
||||||
} else if (IsSkeletonIndex(aPacket) && mVersion >= SKELETON_VERSION(4,0)) {
|
} else if (IsSkeletonIndex(aPacket) && mVersion >= SKELETON_VERSION(4,0)) {
|
||||||
if (!DecodeIndex(aPacket)) {
|
if (!DecodeIndex(aPacket)) {
|
||||||
// Failed to parse index, or invalid/hostile index. DecodeIndex() will
|
// Failed to parse index, or invalid/hostile index. DecodeIndex() will
|
||||||
// have deactivated the track.
|
// have deactivated the track.
|
||||||
return mDoneReadingHeaders = PR_TRUE;
|
return mDoneReadingHeaders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (aPacket->e_o_s) {
|
} else if (aPacket->e_o_s) {
|
||||||
mDoneReadingHeaders = PR_TRUE;
|
mDoneReadingHeaders = true;
|
||||||
}
|
}
|
||||||
return mDoneReadingHeaders;
|
return mDoneReadingHeaders;
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,9 @@ public:
|
|||||||
|
|
||||||
virtual CodecType GetType() { return TYPE_UNKNOWN; }
|
virtual CodecType GetType() { return TYPE_UNKNOWN; }
|
||||||
|
|
||||||
// Reads a header packet. Returns PR_TRUE when last header has been read.
|
// Reads a header packet. Returns true when last header has been read.
|
||||||
virtual bool DecodeHeader(ogg_packet* aPacket) {
|
virtual bool DecodeHeader(ogg_packet* aPacket) {
|
||||||
return (mDoneReadingHeaders = PR_TRUE);
|
return (mDoneReadingHeaders = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the end time that a granulepos represents.
|
// Returns the end time that a granulepos represents.
|
||||||
@ -125,22 +125,22 @@ public:
|
|||||||
// Initializes the codec state.
|
// Initializes the codec state.
|
||||||
virtual bool Init();
|
virtual bool Init();
|
||||||
|
|
||||||
// Returns PR_TRUE when this bitstream has finished reading all its
|
// Returns true when this bitstream has finished reading all its
|
||||||
// header packets.
|
// header packets.
|
||||||
bool DoneReadingHeaders() { return mDoneReadingHeaders; }
|
bool DoneReadingHeaders() { return mDoneReadingHeaders; }
|
||||||
|
|
||||||
// Deactivates the bitstream. Only the primary video and audio bitstreams
|
// Deactivates the bitstream. Only the primary video and audio bitstreams
|
||||||
// should be active.
|
// should be active.
|
||||||
void Deactivate() {
|
void Deactivate() {
|
||||||
mActive = PR_FALSE;
|
mActive = false;
|
||||||
mDoneReadingHeaders = PR_TRUE;
|
mDoneReadingHeaders = true;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resets decoding state.
|
// Resets decoding state.
|
||||||
virtual nsresult Reset();
|
virtual nsresult Reset();
|
||||||
|
|
||||||
// Returns PR_TRUE if the nsOggCodecState thinks this packet is a header
|
// Returns true if the nsOggCodecState thinks this packet is a header
|
||||||
// packet. Note this does not verify the validity of the header packet,
|
// packet. Note this does not verify the validity of the header packet,
|
||||||
// it just guarantees that the packet is marked as a header packet (i.e.
|
// it just guarantees that the packet is marked as a header packet (i.e.
|
||||||
// it is definintely not a data packet). Do not use this to identify
|
// it is definintely not a data packet). Do not use this to identify
|
||||||
@ -183,13 +183,13 @@ public:
|
|||||||
// Is the bitstream active; whether we're decoding and playing this bitstream.
|
// Is the bitstream active; whether we're decoding and playing this bitstream.
|
||||||
bool mActive;
|
bool mActive;
|
||||||
|
|
||||||
// PR_TRUE when all headers packets have been read.
|
// True when all headers packets have been read.
|
||||||
bool mDoneReadingHeaders;
|
bool mDoneReadingHeaders;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Constructs a new nsOggCodecState. aActive denotes whether the stream is
|
// Constructs a new nsOggCodecState. aActive denotes whether the stream is
|
||||||
// active. For streams of unsupported or unknown types, aActive should be
|
// active. For streams of unsupported or unknown types, aActive should be
|
||||||
// PR_FALSE.
|
// false.
|
||||||
nsOggCodecState(ogg_page* aBosPage, bool aActive);
|
nsOggCodecState(ogg_page* aBosPage, bool aActive);
|
||||||
|
|
||||||
// Deallocates all packets stored in mUnstamped, and clears the array.
|
// Deallocates all packets stored in mUnstamped, and clears the array.
|
||||||
@ -331,7 +331,7 @@ public:
|
|||||||
bool Init() { return true; }
|
bool Init() { return true; }
|
||||||
bool IsHeader(ogg_packet* aPacket) { return true; }
|
bool IsHeader(ogg_packet* aPacket) { return true; }
|
||||||
|
|
||||||
// Return PR_TRUE if the given time (in milliseconds) is within
|
// Return true if the given time (in milliseconds) is within
|
||||||
// the presentation time defined in the skeleton track.
|
// the presentation time defined in the skeleton track.
|
||||||
bool IsPresentable(PRInt64 aTime) { return aTime >= mPresentationTime; }
|
bool IsPresentable(PRInt64 aTime) { return aTime >= mPresentationTime; }
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Decodes an index packet. Returns PR_FALSE on failure.
|
// Decodes an index packet. Returns false on failure.
|
||||||
bool DecodeIndex(ogg_packet* aPacket);
|
bool DecodeIndex(ogg_packet* aPacket);
|
||||||
|
|
||||||
// Gets the keypoint you must seek to in order to get the keyframe required
|
// Gets the keypoint you must seek to in order to get the keyframe required
|
||||||
|
@ -191,7 +191,7 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
// We've encountered a non Beginning Of Stream page. No more BOS pages
|
// We've encountered a non Beginning Of Stream page. No more BOS pages
|
||||||
// can follow in this Ogg segment, so there will be no other bitstreams
|
// can follow in this Ogg segment, so there will be no other bitstreams
|
||||||
// in the Ogg (unless it's invalid).
|
// in the Ogg (unless it's invalid).
|
||||||
readAllBOS = PR_TRUE;
|
readAllBOS = true;
|
||||||
} else if (!mCodecStates.Get(serial, nsnull)) {
|
} else if (!mCodecStates.Get(serial, nsnull)) {
|
||||||
// We've not encountered a stream with this serial number before. Create
|
// We've not encountered a stream with this serial number before. Create
|
||||||
// an nsOggCodecState to demux it, and map that to the nsOggCodecState
|
// an nsOggCodecState to demux it, and map that to the nsOggCodecState
|
||||||
@ -262,7 +262,7 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
mTheoraState->mInfo.frame_height);
|
mTheoraState->mInfo.frame_height);
|
||||||
if (nsVideoInfo::ValidateVideoRegion(frameSize, picture, displaySize)) {
|
if (nsVideoInfo::ValidateVideoRegion(frameSize, picture, displaySize)) {
|
||||||
// Video track's frame sizes will not overflow. Activate the video track.
|
// Video track's frame sizes will not overflow. Activate the video track.
|
||||||
mInfo.mHasVideo = PR_TRUE;
|
mInfo.mHasVideo = true;
|
||||||
mInfo.mDisplay = displaySize;
|
mInfo.mDisplay = displaySize;
|
||||||
mPicture = picture;
|
mPicture = picture;
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mVorbisState && ReadHeaders(mVorbisState)) {
|
if (mVorbisState && ReadHeaders(mVorbisState)) {
|
||||||
mInfo.mHasAudio = PR_TRUE;
|
mInfo.mHasAudio = true;
|
||||||
mInfo.mAudioRate = mVorbisState->mInfo.rate;
|
mInfo.mAudioRate = mVorbisState->mInfo.rate;
|
||||||
mInfo.mAudioChannels = mVorbisState->mInfo.channels;
|
mInfo.mAudioChannels = mVorbisState->mInfo.channels;
|
||||||
// Copy Vorbis info data for time computations on other threads.
|
// Copy Vorbis info data for time computations on other threads.
|
||||||
@ -399,7 +399,7 @@ bool nsOggReader::DecodeAudioData()
|
|||||||
} while (packet && mVorbisState->IsHeader(packet));
|
} while (packet && mVorbisState->IsHeader(packet));
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
mAudioQueue.Finish();
|
mAudioQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(packet && packet->granulepos != -1,
|
NS_ASSERTION(packet && packet->granulepos != -1,
|
||||||
@ -411,10 +411,10 @@ bool nsOggReader::DecodeAudioData()
|
|||||||
// file while trying to decode, so inform the audio queue that there'll
|
// file while trying to decode, so inform the audio queue that there'll
|
||||||
// be no more samples.
|
// be no more samples.
|
||||||
mAudioQueue.Finish();
|
mAudioQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsOggReader::DecodeTheora(ogg_packet* aPacket, PRInt64 aTimeThreshold)
|
nsresult nsOggReader::DecodeTheora(ogg_packet* aPacket, PRInt64 aTimeThreshold)
|
||||||
@ -502,7 +502,7 @@ bool nsOggReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
} while (packet && mTheoraState->IsHeader(packet));
|
} while (packet && mTheoraState->IsHeader(packet));
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
mVideoQueue.Finish();
|
mVideoQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
nsAutoReleasePacket autoRelease(packet);
|
nsAutoReleasePacket autoRelease(packet);
|
||||||
|
|
||||||
@ -514,11 +514,11 @@ bool nsOggReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
if (!aKeyframeSkip ||
|
if (!aKeyframeSkip ||
|
||||||
(th_packet_iskeyframe(packet) && frameEndTime >= aTimeThreshold))
|
(th_packet_iskeyframe(packet) && frameEndTime >= aTimeThreshold))
|
||||||
{
|
{
|
||||||
aKeyframeSkip = PR_FALSE;
|
aKeyframeSkip = false;
|
||||||
nsresult res = DecodeTheora(packet, aTimeThreshold);
|
nsresult res = DecodeTheora(packet, aTimeThreshold);
|
||||||
decoded++;
|
decoded++;
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,10 +526,10 @@ bool nsOggReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
// We've encountered an end of bitstream packet. Inform the queue that
|
// We've encountered an end of bitstream packet. Inform the queue that
|
||||||
// there will be no more frames.
|
// there will be no more frames.
|
||||||
mVideoQueue.Finish();
|
mVideoQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt64 nsOggReader::ReadOggPage(ogg_page* aPage)
|
PRInt64 nsOggReader::ReadOggPage(ogg_page* aPage)
|
||||||
@ -643,7 +643,7 @@ PRInt64 nsOggReader::RangeEndTime(PRInt64 aEndOffset)
|
|||||||
nsMediaStream* stream = mDecoder->GetCurrentStream();
|
nsMediaStream* stream = mDecoder->GetCurrentStream();
|
||||||
NS_ENSURE_TRUE(stream != nsnull, -1);
|
NS_ENSURE_TRUE(stream != nsnull, -1);
|
||||||
PRInt64 position = stream->Tell();
|
PRInt64 position = stream->Tell();
|
||||||
PRInt64 endTime = RangeEndTime(0, aEndOffset, PR_FALSE);
|
PRInt64 endTime = RangeEndTime(0, aEndOffset, false);
|
||||||
nsresult res = stream->Seek(nsISeekableStream::NS_SEEK_SET, position);
|
nsresult res = stream->Seek(nsISeekableStream::NS_SEEK_SET, position);
|
||||||
NS_ENSURE_SUCCESS(res, -1);
|
NS_ENSURE_SUCCESS(res, -1);
|
||||||
return endTime;
|
return endTime;
|
||||||
@ -669,7 +669,7 @@ PRInt64 nsOggReader::RangeEndTime(PRInt64 aStartOffset,
|
|||||||
PRUint32 checksumAfterSeek = 0;
|
PRUint32 checksumAfterSeek = 0;
|
||||||
PRUint32 prevChecksumAfterSeek = 0;
|
PRUint32 prevChecksumAfterSeek = 0;
|
||||||
bool mustBackOff = false;
|
bool mustBackOff = false;
|
||||||
while (PR_TRUE) {
|
while (true) {
|
||||||
ogg_page page;
|
ogg_page page;
|
||||||
int ret = ogg_sync_pageseek(&sync.mState, &page);
|
int ret = ogg_sync_pageseek(&sync.mState, &page);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
@ -680,7 +680,7 @@ PRInt64 nsOggReader::RangeEndTime(PRInt64 aStartOffset,
|
|||||||
// We have encountered a page before, or we're at the end of file.
|
// We have encountered a page before, or we're at the end of file.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mustBackOff = PR_FALSE;
|
mustBackOff = false;
|
||||||
prevChecksumAfterSeek = checksumAfterSeek;
|
prevChecksumAfterSeek = checksumAfterSeek;
|
||||||
checksumAfterSeek = 0;
|
checksumAfterSeek = 0;
|
||||||
ogg_sync_reset(&sync.mState);
|
ogg_sync_reset(&sync.mState);
|
||||||
@ -739,7 +739,7 @@ PRInt64 nsOggReader::RangeEndTime(PRInt64 aStartOffset,
|
|||||||
// after the last backoff/seek. Since we've already scanned after this
|
// after the last backoff/seek. Since we've already scanned after this
|
||||||
// page and failed to find an end time, we may as well backoff again and
|
// page and failed to find an end time, we may as well backoff again and
|
||||||
// try to find an end time from an earlier page.
|
// try to find an end time from an earlier page.
|
||||||
mustBackOff = PR_TRUE;
|
mustBackOff = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -895,7 +895,7 @@ nsOggReader::IndexedSeekResult nsOggReader::SeekToKeyframeUsingIndex(PRInt64 aTa
|
|||||||
int skippedBytes = 0;
|
int skippedBytes = 0;
|
||||||
PageSyncResult syncres = PageSync(stream,
|
PageSyncResult syncres = PageSync(stream,
|
||||||
&mOggState,
|
&mOggState,
|
||||||
PR_FALSE,
|
false,
|
||||||
mPageOffset,
|
mPageOffset,
|
||||||
stream->GetLength(),
|
stream->GetLength(),
|
||||||
&page,
|
&page,
|
||||||
@ -970,7 +970,7 @@ nsresult nsOggReader::SeekInBufferedRange(PRInt64 aTarget,
|
|||||||
keyframeTime,
|
keyframeTime,
|
||||||
aStartTime,
|
aStartTime,
|
||||||
aEndTime,
|
aEndTime,
|
||||||
PR_FALSE);
|
false);
|
||||||
res = SeekBisection(keyframeTime, k, SEEK_FUZZ_USECS);
|
res = SeekBisection(keyframeTime, k, SEEK_FUZZ_USECS);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@ -1002,7 +1002,7 @@ nsresult nsOggReader::SeekInUnbuffered(PRInt64 aTarget,
|
|||||||
PRInt64 seekTarget = NS_MAX(aStartTime, aTarget - keyframeOffsetMs);
|
PRInt64 seekTarget = NS_MAX(aStartTime, aTarget - keyframeOffsetMs);
|
||||||
// Minimize the bisection search space using the known timestamps from the
|
// Minimize the bisection search space using the known timestamps from the
|
||||||
// buffered ranges.
|
// buffered ranges.
|
||||||
SeekRange k = SelectSeekRange(aRanges, seekTarget, aStartTime, aEndTime, PR_FALSE);
|
SeekRange k = SelectSeekRange(aRanges, seekTarget, aStartTime, aEndTime, false);
|
||||||
return SeekBisection(seekTarget, k, SEEK_FUZZ_USECS);
|
return SeekBisection(seekTarget, k, SEEK_FUZZ_USECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1044,7 +1044,7 @@ nsresult nsOggReader::Seek(PRInt64 aTarget,
|
|||||||
NS_ENSURE_SUCCESS(res,res);
|
NS_ENSURE_SUCCESS(res,res);
|
||||||
|
|
||||||
// Figure out if the seek target lies in a buffered range.
|
// Figure out if the seek target lies in a buffered range.
|
||||||
SeekRange r = SelectSeekRange(ranges, aTarget, aStartTime, aEndTime, PR_TRUE);
|
SeekRange r = SelectSeekRange(ranges, aTarget, aStartTime, aEndTime, true);
|
||||||
|
|
||||||
if (!r.IsNull()) {
|
if (!r.IsNull()) {
|
||||||
// We know the buffered range in which the seek target lies, do a
|
// We know the buffered range in which the seek target lies, do a
|
||||||
@ -1171,7 +1171,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
|
|||||||
// Seek via bisection search. Loop until we find the offset where the page
|
// Seek via bisection search. Loop until we find the offset where the page
|
||||||
// before the offset is before the seek target, and the page after the offset
|
// before the offset is before the seek target, and the page after the offset
|
||||||
// is after the seek target.
|
// is after the seek target.
|
||||||
while (PR_TRUE) {
|
while (true) {
|
||||||
ogg_int64_t duration = 0;
|
ogg_int64_t duration = 0;
|
||||||
double target = 0;
|
double target = 0;
|
||||||
ogg_int64_t interval = 0;
|
ogg_int64_t interval = 0;
|
||||||
@ -1186,7 +1186,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
|
|||||||
// Guess where we should bisect to, based on the bit rate and the time
|
// Guess where we should bisect to, based on the bit rate and the time
|
||||||
// remaining in the interval. Loop until we can determine the time at
|
// remaining in the interval. Loop until we can determine the time at
|
||||||
// the guess offset.
|
// the guess offset.
|
||||||
while (PR_TRUE) {
|
while (true) {
|
||||||
|
|
||||||
// Discard any previously buffered packets/pages.
|
// Discard any previously buffered packets/pages.
|
||||||
if (NS_FAILED(ResetDecode())) {
|
if (NS_FAILED(ResetDecode())) {
|
||||||
@ -1229,8 +1229,8 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
|
|||||||
|
|
||||||
backsteps = NS_MIN(backsteps + 1, maxBackStep);
|
backsteps = NS_MIN(backsteps + 1, maxBackStep);
|
||||||
// We reset mustBackoff. If we still need to backoff further, it will
|
// We reset mustBackoff. If we still need to backoff further, it will
|
||||||
// be set to PR_TRUE again.
|
// be set to true again.
|
||||||
mustBackoff = PR_FALSE;
|
mustBackoff = false;
|
||||||
} else {
|
} else {
|
||||||
backsteps = 0;
|
backsteps = 0;
|
||||||
}
|
}
|
||||||
@ -1254,7 +1254,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
|
|||||||
// make a bisection decision based on our location in the media.
|
// make a bisection decision based on our location in the media.
|
||||||
PageSyncResult res = PageSync(stream,
|
PageSyncResult res = PageSync(stream,
|
||||||
&mOggState,
|
&mOggState,
|
||||||
PR_FALSE,
|
false,
|
||||||
guess,
|
guess,
|
||||||
endOffset,
|
endOffset,
|
||||||
&page,
|
&page,
|
||||||
@ -1271,7 +1271,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
|
|||||||
// Our guess was too close to the end, we've ended up reading the end
|
// Our guess was too close to the end, we've ended up reading the end
|
||||||
// page. Backoff exponentially from the end point, in case the last
|
// page. Backoff exponentially from the end point, in case the last
|
||||||
// page/frame/sample is huge.
|
// page/frame/sample is huge.
|
||||||
mustBackoff = PR_TRUE;
|
mustBackoff = true;
|
||||||
SEEK_LOG(PR_LOG_DEBUG, ("Hit the end of range, backing off"));
|
SEEK_LOG(PR_LOG_DEBUG, ("Hit the end of range, backing off"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1336,7 +1336,7 @@ nsresult nsOggReader::SeekBisection(PRInt64 aTarget,
|
|||||||
|
|
||||||
// We should backoff; cause the guess to back off from the end, so
|
// We should backoff; cause the guess to back off from the end, so
|
||||||
// that we've got more room to capture.
|
// that we've got more room to capture.
|
||||||
mustBackoff = PR_TRUE;
|
mustBackoff = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1438,7 +1438,7 @@ nsresult nsOggReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
|
|||||||
PRInt32 discard;
|
PRInt32 discard;
|
||||||
PageSyncResult res = PageSync(stream,
|
PageSyncResult res = PageSync(stream,
|
||||||
&sync.mState,
|
&sync.mState,
|
||||||
PR_TRUE,
|
true,
|
||||||
startOffset,
|
startOffset,
|
||||||
endOffset,
|
endOffset,
|
||||||
&page,
|
&page,
|
||||||
@ -1484,7 +1484,7 @@ nsresult nsOggReader::GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime)
|
|||||||
if (startTime != -1) {
|
if (startTime != -1) {
|
||||||
// We were able to find a start time for that range, see if we can
|
// We were able to find a start time for that range, see if we can
|
||||||
// find an end time.
|
// find an end time.
|
||||||
PRInt64 endTime = RangeEndTime(startOffset, endOffset, PR_TRUE);
|
PRInt64 endTime = RangeEndTime(startOffset, endOffset, true);
|
||||||
if (endTime != -1) {
|
if (endTime != -1) {
|
||||||
aBuffered->Add((startTime - aStartTime) / static_cast<double>(USECS_PER_S),
|
aBuffered->Add((startTime - aStartTime) / static_cast<double>(USECS_PER_S),
|
||||||
(endTime - aStartTime) / static_cast<double>(USECS_PER_S));
|
(endTime - aStartTime) / static_cast<double>(USECS_PER_S));
|
||||||
@ -1500,9 +1500,9 @@ bool nsOggReader::IsKnownStream(PRUint32 aSerial)
|
|||||||
for (PRUint32 i = 0; i < mKnownStreams.Length(); i++) {
|
for (PRUint32 i = 0; i < mKnownStreams.Length(); i++) {
|
||||||
PRUint32 serial = mKnownStreams[i];
|
PRUint32 serial = mKnownStreams[i];
|
||||||
if (serial == aSerial) {
|
if (serial == aSerial) {
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ private:
|
|||||||
// aEndOffset. If bool aCachedDataOnly is true, then we'll only read
|
// aEndOffset. If bool aCachedDataOnly is true, then we'll only read
|
||||||
// from data which is cached in the media cached, otherwise we'll do
|
// from data which is cached in the media cached, otherwise we'll do
|
||||||
// regular blocking reads from the media stream. If bool aCachedDataOnly
|
// regular blocking reads from the media stream. If bool aCachedDataOnly
|
||||||
// is PR_TRUE, this can safely be called on the main thread, otherwise it
|
// is true, this can safely be called on the main thread, otherwise it
|
||||||
// must be called on the state machine thread.
|
// must be called on the state machine thread.
|
||||||
PRInt64 RangeEndTime(PRInt64 aStartOffset,
|
PRInt64 RangeEndTime(PRInt64 aStartOffset,
|
||||||
PRInt64 aEndOffset,
|
PRInt64 aEndOffset,
|
||||||
@ -199,9 +199,9 @@ private:
|
|||||||
|
|
||||||
// Returns the range in which you should perform a seek bisection if
|
// Returns the range in which you should perform a seek bisection if
|
||||||
// you wish to seek to aTarget usecs, given the known (buffered) byte ranges
|
// you wish to seek to aTarget usecs, given the known (buffered) byte ranges
|
||||||
// in aRanges. If aExact is PR_TRUE, we only return an exact copy of a
|
// in aRanges. If aExact is true, we only return an exact copy of a
|
||||||
// range in which aTarget lies, or a null range if aTarget isn't contained
|
// range in which aTarget lies, or a null range if aTarget isn't contained
|
||||||
// in any of the (buffered) ranges. Otherwise, when aExact is PR_FALSE,
|
// in any of the (buffered) ranges. Otherwise, when aExact is false,
|
||||||
// we'll construct the smallest possible range we can, based on the times
|
// we'll construct the smallest possible range we can, based on the times
|
||||||
// and byte offsets known in aRanges. We can then use this to minimize our
|
// and byte offsets known in aRanges. We can then use this to minimize our
|
||||||
// bisection's search space when the target isn't in a known buffered range.
|
// bisection's search space when the target isn't in a known buffered range.
|
||||||
@ -229,7 +229,7 @@ private:
|
|||||||
|
|
||||||
// Reads and decodes header packets for aState, until either header decode
|
// Reads and decodes header packets for aState, until either header decode
|
||||||
// fails, or is complete. Initializes the codec state before returning.
|
// fails, or is complete. Initializes the codec state before returning.
|
||||||
// Returns PR_TRUE if reading headers and initializtion of the stream
|
// Returns true if reading headers and initializtion of the stream
|
||||||
// succeeds.
|
// succeeds.
|
||||||
bool ReadHeaders(nsOggCodecState* aState);
|
bool ReadHeaders(nsOggCodecState* aState);
|
||||||
|
|
||||||
|
@ -40,5 +40,5 @@
|
|||||||
|
|
||||||
nsDecoderStateMachine* nsRawDecoder::CreateStateMachine()
|
nsDecoderStateMachine* nsRawDecoder::CreateStateMachine()
|
||||||
{
|
{
|
||||||
return new nsBuiltinDecoderStateMachine(this, new nsRawReader(this), PR_TRUE);
|
return new nsBuiltinDecoderStateMachine(this, new nsRawReader(this), true);
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,8 @@ nsresult nsRawReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo.mHasVideo = PR_TRUE;
|
mInfo.mHasVideo = true;
|
||||||
mInfo.mHasAudio = PR_FALSE;
|
mInfo.mHasAudio = false;
|
||||||
mInfo.mDisplay = display;
|
mInfo.mDisplay = display;
|
||||||
|
|
||||||
mFrameRate = static_cast<float>(mMetadata.framerateNumerator) /
|
mFrameRate = static_cast<float>(mMetadata.framerateNumerator) /
|
||||||
@ -145,11 +145,11 @@ nsresult nsRawReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
|
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
|
||||||
"Should be on state machine thread or decode thread.");
|
"Should be on state machine thread or decode thread.");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper method that either reads until it gets aLength bytes
|
// Helper method that either reads until it gets aLength bytes
|
||||||
// or returns PR_FALSE
|
// or returns false
|
||||||
bool nsRawReader::ReadFromStream(nsMediaStream *aStream, PRUint8* aBuf,
|
bool nsRawReader::ReadFromStream(nsMediaStream *aStream, PRUint8* aBuf,
|
||||||
PRUint32 aLength)
|
PRUint32 aLength)
|
||||||
{
|
{
|
||||||
@ -158,17 +158,17 @@ bool nsRawReader::ReadFromStream(nsMediaStream *aStream, PRUint8* aBuf,
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
rv = aStream->Read(reinterpret_cast<char*>(aBuf), aLength, &bytesRead);
|
rv = aStream->Read(reinterpret_cast<char*>(aBuf), aLength, &bytesRead);
|
||||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
NS_ENSURE_SUCCESS(rv, false);
|
||||||
|
|
||||||
if (bytesRead == 0) {
|
if (bytesRead == 0) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aLength -= bytesRead;
|
aLength -= bytesRead;
|
||||||
aBuf += bytesRead;
|
aBuf += bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsRawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
bool nsRawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||||
@ -183,7 +183,7 @@ bool nsRawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
nsMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
nsMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
|
||||||
|
|
||||||
if (!mFrameSize)
|
if (!mFrameSize)
|
||||||
return PR_FALSE; // Metadata read failed. We should refuse to play.
|
return false; // Metadata read failed. We should refuse to play.
|
||||||
|
|
||||||
PRInt64 currentFrameTime = USECS_PER_S * mCurrentFrame / mFrameRate;
|
PRInt64 currentFrameTime = USECS_PER_S * mCurrentFrame / mFrameRate;
|
||||||
PRUint32 length = mFrameSize - sizeof(nsRawPacketHeader);
|
PRUint32 length = mFrameSize - sizeof(nsRawPacketHeader);
|
||||||
@ -200,11 +200,11 @@ bool nsRawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
if (!(ReadFromStream(stream, reinterpret_cast<PRUint8*>(&header),
|
if (!(ReadFromStream(stream, reinterpret_cast<PRUint8*>(&header),
|
||||||
sizeof(header))) ||
|
sizeof(header))) ||
|
||||||
!(header.packetID == 0xFF && header.codecID == RAW_ID /* "YUV" */)) {
|
!(header.packetID == 0xFF && header.codecID == RAW_ID /* "YUV" */)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadFromStream(stream, buffer, length)) {
|
if (!ReadFromStream(stream, buffer, length)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
parsed++;
|
parsed++;
|
||||||
@ -244,14 +244,14 @@ bool nsRawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
-1,
|
-1,
|
||||||
mPicture);
|
mPicture);
|
||||||
if (!v)
|
if (!v)
|
||||||
return PR_FALSE;
|
return false;
|
||||||
|
|
||||||
mVideoQueue.Push(v);
|
mVideoQueue.Push(v);
|
||||||
mCurrentFrame++;
|
mCurrentFrame++;
|
||||||
decoded++;
|
decoded++;
|
||||||
currentFrameTime += USECS_PER_S / mFrameRate;
|
currentFrameTime += USECS_PER_S / mFrameRate;
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsRawReader::Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
|
nsresult nsRawReader::Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
|
||||||
|
@ -58,12 +58,12 @@ public:
|
|||||||
|
|
||||||
virtual bool HasAudio()
|
virtual bool HasAudio()
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasVideo()
|
virtual bool HasVideo()
|
||||||
{
|
{
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
|
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
|
||||||
|
@ -159,8 +159,8 @@ nsresult nsWaveReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo.mHasAudio = PR_TRUE;
|
mInfo.mHasAudio = true;
|
||||||
mInfo.mHasVideo = PR_FALSE;
|
mInfo.mHasVideo = false;
|
||||||
mInfo.mAudioRate = mSampleRate;
|
mInfo.mAudioRate = mSampleRate;
|
||||||
mInfo.mAudioChannels = mChannels;
|
mInfo.mAudioChannels = mChannels;
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ bool nsWaveReader::DecodeAudioData()
|
|||||||
|
|
||||||
if (!ReadAll(dataBuffer, readSize)) {
|
if (!ReadAll(dataBuffer, readSize)) {
|
||||||
mAudioQueue.Finish();
|
mAudioQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert data to samples
|
// convert data to samples
|
||||||
@ -236,7 +236,7 @@ bool nsWaveReader::DecodeAudioData()
|
|||||||
sampleBuffer.forget(),
|
sampleBuffer.forget(),
|
||||||
mChannels));
|
mChannels));
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsWaveReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
bool nsWaveReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||||
@ -244,7 +244,7 @@ bool nsWaveReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
|
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
|
||||||
|
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
|
nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
|
||||||
@ -298,10 +298,10 @@ nsWaveReader::ReadAll(char* aBuf, PRInt64 aSize, PRInt64* aBytesRead)
|
|||||||
PRUint32 read = 0;
|
PRUint32 read = 0;
|
||||||
if (NS_FAILED(mDecoder->GetCurrentStream()->Read(aBuf + got, PRUint32(aSize - got), &read))) {
|
if (NS_FAILED(mDecoder->GetCurrentStream()->Read(aBuf + got, PRUint32(aSize - got), &read))) {
|
||||||
NS_WARNING("Stream read failed");
|
NS_WARNING("Stream read failed");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (read == 0) {
|
if (read == 0) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
mDecoder->NotifyBytesConsumed(read);
|
mDecoder->NotifyBytesConsumed(read);
|
||||||
got += read;
|
got += read;
|
||||||
@ -309,7 +309,7 @@ nsWaveReader::ReadAll(char* aBuf, PRInt64 aSize, PRInt64* aBytesRead)
|
|||||||
*aBytesRead = got;
|
*aBytesRead = got;
|
||||||
}
|
}
|
||||||
} while (got != aSize);
|
} while (got != aSize);
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -322,13 +322,13 @@ nsWaveReader::LoadRIFFChunk()
|
|||||||
"LoadRIFFChunk called when stream in invalid state");
|
"LoadRIFFChunk called when stream in invalid state");
|
||||||
|
|
||||||
if (!ReadAll(riffHeader, sizeof(riffHeader))) {
|
if (!ReadAll(riffHeader, sizeof(riffHeader))) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_STATIC_ASSERT(sizeof(PRUint32) * 2 <= RIFF_INITIAL_SIZE);
|
PR_STATIC_ASSERT(sizeof(PRUint32) * 2 <= RIFF_INITIAL_SIZE);
|
||||||
if (ReadUint32BE(&p) != RIFF_CHUNK_MAGIC) {
|
if (ReadUint32BE(&p) != RIFF_CHUNK_MAGIC) {
|
||||||
NS_WARNING("Stream data not in RIFF format");
|
NS_WARNING("Stream data not in RIFF format");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip over RIFF size field.
|
// Skip over RIFF size field.
|
||||||
@ -336,10 +336,10 @@ nsWaveReader::LoadRIFFChunk()
|
|||||||
|
|
||||||
if (ReadUint32BE(&p) != WAVE_CHUNK_MAGIC) {
|
if (ReadUint32BE(&p) != WAVE_CHUNK_MAGIC) {
|
||||||
NS_WARNING("Expected WAVE chunk");
|
NS_WARNING("Expected WAVE chunk");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -354,7 +354,7 @@ nsWaveReader::ScanForwardUntil(PRUint32 aWantedChunk, PRUint32* aChunkSize)
|
|||||||
const char* p = chunkHeader;
|
const char* p = chunkHeader;
|
||||||
|
|
||||||
if (!ReadAll(chunkHeader, sizeof(chunkHeader))) {
|
if (!ReadAll(chunkHeader, sizeof(chunkHeader))) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_STATIC_ASSERT(sizeof(PRUint32) * 2 <= CHUNK_HEADER_SIZE);
|
PR_STATIC_ASSERT(sizeof(PRUint32) * 2 <= CHUNK_HEADER_SIZE);
|
||||||
@ -363,7 +363,7 @@ nsWaveReader::ScanForwardUntil(PRUint32 aWantedChunk, PRUint32* aChunkSize)
|
|||||||
|
|
||||||
if (magic == aWantedChunk) {
|
if (magic == aWantedChunk) {
|
||||||
*aChunkSize = chunkSize;
|
*aChunkSize = chunkSize;
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RIFF chunks are two-byte aligned, so round up if necessary.
|
// RIFF chunks are two-byte aligned, so round up if necessary.
|
||||||
@ -375,7 +375,7 @@ nsWaveReader::ScanForwardUntil(PRUint32 aWantedChunk, PRUint32* aChunkSize)
|
|||||||
while (chunkSize > 0) {
|
while (chunkSize > 0) {
|
||||||
PRUint32 size = NS_MIN(chunkSize, MAX_CHUNK_SIZE);
|
PRUint32 size = NS_MIN(chunkSize, MAX_CHUNK_SIZE);
|
||||||
if (!ReadAll(chunk.get(), size)) {
|
if (!ReadAll(chunk.get(), size)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
chunkSize -= size;
|
chunkSize -= size;
|
||||||
}
|
}
|
||||||
@ -396,11 +396,11 @@ nsWaveReader::LoadFormatChunk()
|
|||||||
// The "format" chunk may not directly follow the "riff" chunk, so skip
|
// The "format" chunk may not directly follow the "riff" chunk, so skip
|
||||||
// over any intermediate chunks.
|
// over any intermediate chunks.
|
||||||
if (!ScanForwardUntil(FRMT_CHUNK_MAGIC, &fmtSize)) {
|
if (!ScanForwardUntil(FRMT_CHUNK_MAGIC, &fmtSize)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadAll(waveFormat, sizeof(waveFormat))) {
|
if (!ReadAll(waveFormat, sizeof(waveFormat))) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_STATIC_ASSERT(sizeof(PRUint16) +
|
PR_STATIC_ASSERT(sizeof(PRUint16) +
|
||||||
@ -411,7 +411,7 @@ nsWaveReader::LoadFormatChunk()
|
|||||||
sizeof(PRUint16) <= sizeof(waveFormat));
|
sizeof(PRUint16) <= sizeof(waveFormat));
|
||||||
if (ReadUint16LE(&p) != WAVE_FORMAT_ENCODING_PCM) {
|
if (ReadUint16LE(&p) != WAVE_FORMAT_ENCODING_PCM) {
|
||||||
NS_WARNING("WAVE is not uncompressed PCM, compressed encodings are not supported");
|
NS_WARNING("WAVE is not uncompressed PCM, compressed encodings are not supported");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
channels = ReadUint16LE(&p);
|
channels = ReadUint16LE(&p);
|
||||||
@ -434,14 +434,14 @@ nsWaveReader::LoadFormatChunk()
|
|||||||
const char* p = extLength;
|
const char* p = extLength;
|
||||||
|
|
||||||
if (!ReadAll(extLength, sizeof(extLength))) {
|
if (!ReadAll(extLength, sizeof(extLength))) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_STATIC_ASSERT(sizeof(PRUint16) <= sizeof(extLength));
|
PR_STATIC_ASSERT(sizeof(PRUint16) <= sizeof(extLength));
|
||||||
PRUint16 extra = ReadUint16LE(&p);
|
PRUint16 extra = ReadUint16LE(&p);
|
||||||
if (fmtSize - (WAVE_FORMAT_CHUNK_SIZE + 2) != extra) {
|
if (fmtSize - (WAVE_FORMAT_CHUNK_SIZE + 2) != extra) {
|
||||||
NS_WARNING("Invalid extended format chunk size");
|
NS_WARNING("Invalid extended format chunk size");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
extra += extra % 2;
|
extra += extra % 2;
|
||||||
|
|
||||||
@ -449,7 +449,7 @@ nsWaveReader::LoadFormatChunk()
|
|||||||
PR_STATIC_ASSERT(PR_UINT16_MAX + (PR_UINT16_MAX % 2) < UINT_MAX / sizeof(char));
|
PR_STATIC_ASSERT(PR_UINT16_MAX + (PR_UINT16_MAX % 2) < UINT_MAX / sizeof(char));
|
||||||
nsAutoArrayPtr<char> chunkExtension(new char[extra]);
|
nsAutoArrayPtr<char> chunkExtension(new char[extra]);
|
||||||
if (!ReadAll(chunkExtension.get(), extra)) {
|
if (!ReadAll(chunkExtension.get(), extra)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,7 +466,7 @@ nsWaveReader::LoadFormatChunk()
|
|||||||
(frameSize != 1 && frameSize != 2 && frameSize != 4) ||
|
(frameSize != 1 && frameSize != 2 && frameSize != 4) ||
|
||||||
(sampleFormat != 8 && sampleFormat != 16)) {
|
(sampleFormat != 8 && sampleFormat != 16)) {
|
||||||
NS_WARNING("Invalid WAVE metadata");
|
NS_WARNING("Invalid WAVE metadata");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
|
||||||
@ -478,7 +478,7 @@ nsWaveReader::LoadFormatChunk()
|
|||||||
} else {
|
} else {
|
||||||
mSampleFormat = nsAudioStream::FORMAT_S16_LE;
|
mSampleFormat = nsAudioStream::FORMAT_S16_LE;
|
||||||
}
|
}
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -492,19 +492,19 @@ nsWaveReader::FindDataOffset()
|
|||||||
// over any intermediate chunks.
|
// over any intermediate chunks.
|
||||||
PRUint32 length;
|
PRUint32 length;
|
||||||
if (!ScanForwardUntil(DATA_CHUNK_MAGIC, &length)) {
|
if (!ScanForwardUntil(DATA_CHUNK_MAGIC, &length)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt64 offset = mDecoder->GetCurrentStream()->Tell();
|
PRInt64 offset = mDecoder->GetCurrentStream()->Tell();
|
||||||
if (offset <= 0 || offset > PR_UINT32_MAX) {
|
if (offset <= 0 || offset > PR_UINT32_MAX) {
|
||||||
NS_WARNING("PCM data offset out of range");
|
NS_WARNING("PCM data offset out of range");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
|
||||||
mWaveLength = length;
|
mWaveLength = length;
|
||||||
mWavePCMOffset = PRUint32(offset);
|
mWavePCMOffset = PRUint32(offset);
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
@ -55,12 +55,12 @@ public:
|
|||||||
|
|
||||||
virtual bool HasAudio()
|
virtual bool HasAudio()
|
||||||
{
|
{
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool HasVideo()
|
virtual bool HasVideo()
|
||||||
{
|
{
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
|
virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
|
||||||
|
@ -97,7 +97,7 @@ static int webm_read(void *aBuffer, size_t aLength, void *aUserData)
|
|||||||
PRUint32 bytes = 0;
|
PRUint32 bytes = 0;
|
||||||
rv = stream->Read(p, aLength, &bytes);
|
rv = stream->Read(p, aLength, &bytes);
|
||||||
if (bytes == 0) {
|
if (bytes == 0) {
|
||||||
eof = PR_TRUE;
|
eof = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
decoder->NotifyBytesConsumed(bytes);
|
decoder->NotifyBytesConsumed(bytes);
|
||||||
@ -136,8 +136,8 @@ nsWebMReader::nsWebMReader(nsBuiltinDecoder* aDecoder)
|
|||||||
mAudioTrack(0),
|
mAudioTrack(0),
|
||||||
mAudioStartUsec(-1),
|
mAudioStartUsec(-1),
|
||||||
mAudioFrames(0),
|
mAudioFrames(0),
|
||||||
mHasVideo(PR_FALSE),
|
mHasVideo(false),
|
||||||
mHasAudio(PR_FALSE)
|
mHasAudio(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(nsWebMReader);
|
MOZ_COUNT_CTOR(nsWebMReader);
|
||||||
}
|
}
|
||||||
@ -235,8 +235,8 @@ nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mInfo.mHasAudio = PR_FALSE;
|
mInfo.mHasAudio = false;
|
||||||
mInfo.mHasVideo = PR_FALSE;
|
mInfo.mHasVideo = false;
|
||||||
for (PRUint32 track = 0; track < ntracks; ++track) {
|
for (PRUint32 track = 0; track < ntracks; ++track) {
|
||||||
int id = nestegg_track_codec_id(mContext, track);
|
int id = nestegg_track_codec_id(mContext, track);
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
@ -281,8 +281,8 @@ nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mVideoTrack = track;
|
mVideoTrack = track;
|
||||||
mHasVideo = PR_TRUE;
|
mHasVideo = true;
|
||||||
mInfo.mHasVideo = PR_TRUE;
|
mInfo.mHasVideo = true;
|
||||||
|
|
||||||
mInfo.mDisplay = displaySize;
|
mInfo.mDisplay = displaySize;
|
||||||
mPicture = pictureRect;
|
mPicture = pictureRect;
|
||||||
@ -336,8 +336,8 @@ nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAudioTrack = track;
|
mAudioTrack = track;
|
||||||
mHasAudio = PR_TRUE;
|
mHasAudio = true;
|
||||||
mInfo.mHasAudio = PR_TRUE;
|
mInfo.mHasAudio = true;
|
||||||
|
|
||||||
// Get the Vorbis header data
|
// Get the Vorbis header data
|
||||||
unsigned int nheaders = 0;
|
unsigned int nheaders = 0;
|
||||||
@ -357,7 +357,7 @@ nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ogg_packet opacket = InitOggPacket(data, length, header == 0, PR_FALSE, 0);
|
ogg_packet opacket = InitOggPacket(data, length, header == 0, false, 0);
|
||||||
|
|
||||||
r = vorbis_synthesis_headerin(&mVorbisInfo,
|
r = vorbis_synthesis_headerin(&mVorbisInfo,
|
||||||
&mVorbisComment,
|
&mVorbisComment,
|
||||||
@ -415,13 +415,13 @@ bool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
|||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
r = nestegg_packet_count(aPacket, &count);
|
r = nestegg_packet_count(aPacket, &count);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t tstamp = 0;
|
uint64_t tstamp = 0;
|
||||||
r = nestegg_packet_tstamp(aPacket, &tstamp);
|
r = nestegg_packet_tstamp(aPacket, &tstamp);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRUint32 rate = mVorbisDsp.vi->rate;
|
const PRUint32 rate = mVorbisDsp.vi->rate;
|
||||||
@ -438,16 +438,16 @@ bool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
|||||||
PRInt64 tstamp_frames = 0;
|
PRInt64 tstamp_frames = 0;
|
||||||
if (!UsecsToFrames(tstamp_usecs, rate, tstamp_frames)) {
|
if (!UsecsToFrames(tstamp_usecs, rate, tstamp_frames)) {
|
||||||
NS_WARNING("Int overflow converting WebM timestamp to frames");
|
NS_WARNING("Int overflow converting WebM timestamp to frames");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
PRInt64 decoded_frames = 0;
|
PRInt64 decoded_frames = 0;
|
||||||
if (!UsecsToFrames(mAudioStartUsec, rate, decoded_frames)) {
|
if (!UsecsToFrames(mAudioStartUsec, rate, decoded_frames)) {
|
||||||
NS_WARNING("Int overflow converting WebM start time to frames");
|
NS_WARNING("Int overflow converting WebM start time to frames");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (!AddOverflow(decoded_frames, mAudioFrames, decoded_frames)) {
|
if (!AddOverflow(decoded_frames, mAudioFrames, decoded_frames)) {
|
||||||
NS_WARNING("Int overflow adding decoded_frames");
|
NS_WARNING("Int overflow adding decoded_frames");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (tstamp_frames > decoded_frames) {
|
if (tstamp_frames > decoded_frames) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -467,18 +467,18 @@ bool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
|||||||
size_t length;
|
size_t length;
|
||||||
r = nestegg_packet_data(aPacket, i, &data, &length);
|
r = nestegg_packet_data(aPacket, i, &data, &length);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ogg_packet opacket = InitOggPacket(data, length, PR_FALSE, PR_FALSE, -1);
|
ogg_packet opacket = InitOggPacket(data, length, false, false, -1);
|
||||||
|
|
||||||
if (vorbis_synthesis(&mVorbisBlock, &opacket) != 0) {
|
if (vorbis_synthesis(&mVorbisBlock, &opacket) != 0) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vorbis_synthesis_blockin(&mVorbisDsp,
|
if (vorbis_synthesis_blockin(&mVorbisDsp,
|
||||||
&mVorbisBlock) != 0) {
|
&mVorbisBlock) != 0) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VorbisPCMValue** pcm = 0;
|
VorbisPCMValue** pcm = 0;
|
||||||
@ -495,12 +495,12 @@ bool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
|||||||
PRInt64 duration = 0;
|
PRInt64 duration = 0;
|
||||||
if (!FramesToUsecs(frames, rate, duration)) {
|
if (!FramesToUsecs(frames, rate, duration)) {
|
||||||
NS_WARNING("Int overflow converting WebM audio duration");
|
NS_WARNING("Int overflow converting WebM audio duration");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
PRInt64 total_duration = 0;
|
PRInt64 total_duration = 0;
|
||||||
if (!FramesToUsecs(total_frames, rate, total_duration)) {
|
if (!FramesToUsecs(total_frames, rate, total_duration)) {
|
||||||
NS_WARNING("Int overflow converting WebM audio total_duration");
|
NS_WARNING("Int overflow converting WebM audio total_duration");
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt64 time = tstamp_usecs + total_duration;
|
PRInt64 time = tstamp_usecs + total_duration;
|
||||||
@ -513,12 +513,12 @@ bool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
|
|||||||
mChannels));
|
mChannels));
|
||||||
mAudioFrames += frames;
|
mAudioFrames += frames;
|
||||||
if (vorbis_synthesis_read(&mVorbisDsp, frames) != 0) {
|
if (vorbis_synthesis_read(&mVorbisDsp, frames) != 0) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsReturnRef<NesteggPacketHolder> nsWebMReader::NextPacket(TrackType aTrackType)
|
nsReturnRef<NesteggPacketHolder> nsWebMReader::NextPacket(TrackType aTrackType)
|
||||||
@ -578,7 +578,7 @@ nsReturnRef<NesteggPacketHolder> nsWebMReader::NextPacket(TrackType aTrackType)
|
|||||||
if (hasType && ourTrack == track) {
|
if (hasType && ourTrack == track) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (PR_TRUE);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return holder.out();
|
return holder.out();
|
||||||
@ -591,7 +591,7 @@ bool nsWebMReader::DecodeAudioData()
|
|||||||
nsAutoRef<NesteggPacketHolder> holder(NextPacket(AUDIO));
|
nsAutoRef<NesteggPacketHolder> holder(NextPacket(AUDIO));
|
||||||
if (!holder) {
|
if (!holder) {
|
||||||
mAudioQueue.Finish();
|
mAudioQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DecodeAudioPacket(holder->mPacket, holder->mOffset);
|
return DecodeAudioPacket(holder->mPacket, holder->mOffset);
|
||||||
@ -610,26 +610,26 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
nsAutoRef<NesteggPacketHolder> holder(NextPacket(VIDEO));
|
nsAutoRef<NesteggPacketHolder> holder(NextPacket(VIDEO));
|
||||||
if (!holder) {
|
if (!holder) {
|
||||||
mVideoQueue.Finish();
|
mVideoQueue.Finish();
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nestegg_packet* packet = holder->mPacket;
|
nestegg_packet* packet = holder->mPacket;
|
||||||
unsigned int track = 0;
|
unsigned int track = 0;
|
||||||
int r = nestegg_packet_track(packet, &track);
|
int r = nestegg_packet_track(packet, &track);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
r = nestegg_packet_count(packet, &count);
|
r = nestegg_packet_count(packet, &count);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t tstamp = 0;
|
uint64_t tstamp = 0;
|
||||||
r = nestegg_packet_tstamp(packet, &tstamp);
|
r = nestegg_packet_tstamp(packet, &tstamp);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The end time of this frame is the start time of the next frame. Fetch
|
// The end time of this frame is the start time of the next frame. Fetch
|
||||||
@ -642,7 +642,7 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
if (next_holder) {
|
if (next_holder) {
|
||||||
r = nestegg_packet_tstamp(next_holder->mPacket, &next_tstamp);
|
r = nestegg_packet_tstamp(next_holder->mPacket, &next_tstamp);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
mVideoPackets.PushFront(next_holder.disown());
|
mVideoPackets.PushFront(next_holder.disown());
|
||||||
} else {
|
} else {
|
||||||
@ -651,7 +651,7 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
static_cast<nsBuiltinDecoderStateMachine*>(mDecoder->GetStateMachine());
|
static_cast<nsBuiltinDecoderStateMachine*>(mDecoder->GetStateMachine());
|
||||||
PRInt64 endTime = s->GetEndMediaTime();
|
PRInt64 endTime = s->GetEndMediaTime();
|
||||||
if (endTime == -1) {
|
if (endTime == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
next_tstamp = endTime * NS_PER_USEC;
|
next_tstamp = endTime * NS_PER_USEC;
|
||||||
}
|
}
|
||||||
@ -663,7 +663,7 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
size_t length;
|
size_t length;
|
||||||
r = nestegg_packet_data(packet, i, &data, &length);
|
r = nestegg_packet_data(packet, i, &data, &length);
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vpx_codec_stream_info_t si;
|
vpx_codec_stream_info_t si;
|
||||||
@ -677,11 +677,11 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aKeyframeSkip && si.is_kf) {
|
if (aKeyframeSkip && si.is_kf) {
|
||||||
aKeyframeSkip = PR_FALSE;
|
aKeyframeSkip = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vpx_codec_decode(&mVP8, data, length, NULL, 0)) {
|
if (vpx_codec_decode(&mVP8, data, length, NULL, 0)) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the timestamp of the video frame is less than
|
// If the timestamp of the video frame is less than
|
||||||
@ -716,7 +716,8 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
b.mPlanes[2].mWidth = img->d_w >> img->x_chroma_shift;
|
b.mPlanes[2].mWidth = img->d_w >> img->x_chroma_shift;
|
||||||
|
|
||||||
nsIntRect picture = mPicture;
|
nsIntRect picture = mPicture;
|
||||||
if (img->d_w != mInitialFrame.width || img->d_h != mInitialFrame.height) {
|
if (img->d_w != static_cast<PRUint32>(mInitialFrame.width) ||
|
||||||
|
img->d_h != static_cast<PRUint32>(mInitialFrame.height)) {
|
||||||
// Frame size is different from what the container reports. This is legal
|
// Frame size is different from what the container reports. This is legal
|
||||||
// in WebM, and we will preserve the ratio of the crop rectangle as it
|
// in WebM, and we will preserve the ratio of the crop rectangle as it
|
||||||
// was reported relative to the picture size reported by the container.
|
// was reported relative to the picture size reported by the container.
|
||||||
@ -736,7 +737,7 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
-1,
|
-1,
|
||||||
picture);
|
picture);
|
||||||
if (!v) {
|
if (!v) {
|
||||||
return PR_FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
parsed++;
|
parsed++;
|
||||||
decoded++;
|
decoded++;
|
||||||
@ -746,7 +747,7 @@ bool nsWebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsWebMReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime,
|
nsresult nsWebMReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime,
|
||||||
|
@ -179,8 +179,8 @@ private:
|
|||||||
PRInt64 aGranulepos);
|
PRInt64 aGranulepos);
|
||||||
|
|
||||||
// Decode a nestegg packet of audio data. Push the audio data on the
|
// Decode a nestegg packet of audio data. Push the audio data on the
|
||||||
// audio queue. Returns PR_TRUE when there's more audio to decode,
|
// audio queue. Returns true when there's more audio to decode,
|
||||||
// PR_FALSE if the audio is finished, end of file has been reached,
|
// false if the audio is finished, end of file has been reached,
|
||||||
// or an un-recoverable read error has occured. The reader's monitor
|
// or an un-recoverable read error has occured. The reader's monitor
|
||||||
// must be held during this call. This function will free the packet
|
// must be held during this call. This function will free the packet
|
||||||
// so the caller must not use the packet after calling.
|
// so the caller must not use the packet after calling.
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
* http://www.w3.org/TR/DOM-Level-2-Style
|
* http://www.w3.org/TR/DOM-Level-2-Style
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[builtinclass, scriptable, uuid(79b66107-f9d2-42ac-bc68-b558d79037ec)]
|
[builtinclass, scriptable, uuid(519ae4fa-0fee-4aaa-bcb9-34b503236801)]
|
||||||
interface nsIDOMCSS2Properties : nsISupports
|
interface nsIDOMCSS2Properties : nsISupports
|
||||||
{
|
{
|
||||||
attribute DOMString background;
|
attribute DOMString background;
|
||||||
@ -684,6 +684,18 @@ interface nsIDOMCSS2Properties : nsISupports
|
|||||||
attribute DOMString MozTransformOrigin;
|
attribute DOMString MozTransformOrigin;
|
||||||
// raises(DOMException) on setting
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
|
attribute DOMString MozPerspective;
|
||||||
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
|
attribute DOMString MozPerspectiveOrigin;
|
||||||
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
|
attribute DOMString MozBackfaceVisibility;
|
||||||
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
|
attribute DOMString MozTransformStyle;
|
||||||
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
attribute DOMString MozWindowShadow;
|
attribute DOMString MozWindowShadow;
|
||||||
// raises(DOMException) on setting
|
// raises(DOMException) on setting
|
||||||
|
|
||||||
|
@ -1366,18 +1366,6 @@ BasicLayerManager::PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<gfxASurface>
|
|
||||||
BasicLayerManager::PopGroupToSurface(gfxContext *aTarget, gfxContext *aPushed)
|
|
||||||
{
|
|
||||||
if (!aTarget)
|
|
||||||
return nsnull;
|
|
||||||
nsRefPtr<gfxASurface> current = aPushed->CurrentSurface();
|
|
||||||
NS_ASSERTION(!mCachedSurface.IsSurface(current), "Should never be popping cached surface here!");
|
|
||||||
nsRefPtr<gfxPattern> pat = aTarget->PopGroup();
|
|
||||||
current = pat->GetSurface();
|
|
||||||
return current.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
|
BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
|
||||||
{
|
{
|
||||||
@ -1845,8 +1833,6 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
|||||||
aTarget->SetMatrix(transform);
|
aTarget->SetMatrix(transform);
|
||||||
} else {
|
} else {
|
||||||
aTarget->SetMatrix(gfxMatrix());
|
aTarget->SetMatrix(gfxMatrix());
|
||||||
// Save so we can restore clipping after PushGroupForLayer changes it.
|
|
||||||
aTarget->Save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const nsIntRegion& visibleRegion = aLayer->GetEffectiveVisibleRegion();
|
const nsIntRegion& visibleRegion = aLayer->GetEffectiveVisibleRegion();
|
||||||
@ -1863,17 +1849,24 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
|||||||
|
|
||||||
// Try to annotate currentSurface with a region of pixels that have been
|
// Try to annotate currentSurface with a region of pixels that have been
|
||||||
// (or will be) painted opaque, if no such region is currently set.
|
// (or will be) painted opaque, if no such region is currently set.
|
||||||
|
const nsIntRect& bounds = visibleRegion.GetBounds();
|
||||||
if (targetOpaqueRect.IsEmpty() && visibleRegion.GetNumRects() == 1 &&
|
if (targetOpaqueRect.IsEmpty() && visibleRegion.GetNumRects() == 1 &&
|
||||||
(aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
|
(aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE) &&
|
||||||
!transform.HasNonAxisAlignedTransform()) {
|
!transform.HasNonAxisAlignedTransform()) {
|
||||||
const nsIntRect& bounds = visibleRegion.GetBounds();
|
|
||||||
currentSurface->SetOpaqueRect(
|
currentSurface->SetOpaqueRect(
|
||||||
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
|
aTarget->UserToDevice(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)));
|
||||||
pushedTargetOpaqueRect = PR_TRUE;
|
pushedTargetOpaqueRect = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<gfxContext> groupTarget;
|
nsRefPtr<gfxContext> groupTarget;
|
||||||
if (needsGroup) {
|
nsRefPtr<gfxASurface> untransformedSurface;
|
||||||
|
if (!is2D) {
|
||||||
|
untransformedSurface =
|
||||||
|
gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(bounds.width, bounds.height),
|
||||||
|
gfxASurface::CONTENT_COLOR_ALPHA);
|
||||||
|
untransformedSurface->SetDeviceOffset(gfxPoint(-bounds.x, -bounds.y));
|
||||||
|
groupTarget = new gfxContext(untransformedSurface);
|
||||||
|
} else if (needsGroup) {
|
||||||
groupTarget = PushGroupForLayer(aTarget, aLayer, aLayer->GetEffectiveVisibleRegion(),
|
groupTarget = PushGroupForLayer(aTarget, aLayer, aLayer->GetEffectiveVisibleRegion(),
|
||||||
&needsClipToVisibleRegion);
|
&needsClipToVisibleRegion);
|
||||||
} else {
|
} else {
|
||||||
@ -1911,16 +1904,14 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
|
|||||||
if (is2D) {
|
if (is2D) {
|
||||||
PopGroupToSourceWithCachedSurface(aTarget, groupTarget);
|
PopGroupToSourceWithCachedSurface(aTarget, groupTarget);
|
||||||
} else {
|
} else {
|
||||||
nsRefPtr<gfxASurface> sourceSurface = PopGroupToSurface(aTarget, groupTarget);
|
NS_ABORT_IF_FALSE(untransformedSurface,
|
||||||
aTarget->Restore();
|
"We should always allocate an untransformed surface with 3d transforms!");
|
||||||
NS_ABORT_IF_FALSE(sourceSurface, "PopGroup should always return a surface pattern");
|
|
||||||
gfxRect bounds = visibleRegion.GetBounds();
|
|
||||||
|
|
||||||
gfxPoint offset;
|
gfxPoint offset;
|
||||||
bool dontBlit = needsClipToVisibleRegion || mTransactionIncomplete ||
|
bool dontBlit = needsClipToVisibleRegion || mTransactionIncomplete ||
|
||||||
aLayer->GetEffectiveOpacity() != 1.0f;
|
aLayer->GetEffectiveOpacity() != 1.0f;
|
||||||
nsRefPtr<gfxASurface> result =
|
nsRefPtr<gfxASurface> result =
|
||||||
Transform3D(sourceSurface, aTarget, bounds,
|
Transform3D(untransformedSurface, aTarget, bounds,
|
||||||
effectiveTransform, offset, dontBlit);
|
effectiveTransform, offset, dontBlit);
|
||||||
|
|
||||||
blitComplete = !result;
|
blitComplete = !result;
|
||||||
|
@ -172,7 +172,6 @@ public:
|
|||||||
already_AddRefed<gfxContext> PushGroupWithCachedSurface(gfxContext *aTarget,
|
already_AddRefed<gfxContext> PushGroupWithCachedSurface(gfxContext *aTarget,
|
||||||
gfxASurface::gfxContentType aContent);
|
gfxASurface::gfxContentType aContent);
|
||||||
void PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxContext *aPushed);
|
void PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxContext *aPushed);
|
||||||
already_AddRefed<gfxASurface> PopGroupToSurface(gfxContext *aTarget, gfxContext *aPushed);
|
|
||||||
|
|
||||||
virtual bool IsCompositingCheap() { return false; }
|
virtual bool IsCompositingCheap() { return false; }
|
||||||
virtual bool HasShadowManagerInternal() const { return false; }
|
virtual bool HasShadowManagerInternal() const { return false; }
|
||||||
|
@ -1528,9 +1528,6 @@ WrapPreserve3DList(nsIFrame *aFrame, nsDisplayListBuilder *aBuilder, nsDisplayLi
|
|||||||
if (childFrame->GetParent()->Preserves3DChildren()) {
|
if (childFrame->GetParent()->Preserves3DChildren()) {
|
||||||
switch (item->GetType()) {
|
switch (item->GetType()) {
|
||||||
case nsDisplayItem::TYPE_TRANSFORM: {
|
case nsDisplayItem::TYPE_TRANSFORM: {
|
||||||
// The child transform frame should always preserve 3d. In the cases where preserve-3d is disabled
|
|
||||||
// such as clipping, this would be wrapped in a clip display object, and we wouldn't reach this point.
|
|
||||||
NS_ASSERTION(childFrame->Preserves3D(), "Child transform frame must preserve 3d!");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case nsDisplayItem::TYPE_WRAP_LIST: {
|
case nsDisplayItem::TYPE_WRAP_LIST: {
|
||||||
|
@ -273,8 +273,8 @@ include text-transform/reftest.list
|
|||||||
# -moz-transform/
|
# -moz-transform/
|
||||||
include transform/reftest.list
|
include transform/reftest.list
|
||||||
|
|
||||||
# 3d transforms - disabled currently
|
# 3d transforms
|
||||||
#include transform-3d/reftest.list
|
include transform-3d/reftest.list
|
||||||
|
|
||||||
# unicode/ (verify that we don't do expend effort doing unicode-aware case checks)
|
# unicode/ (verify that we don't do expend effort doing unicode-aware case checks)
|
||||||
include unicode/reftest.list
|
include unicode/reftest.list
|
||||||
|
@ -352,12 +352,6 @@ nsCSSProps::LookupProperty(const nsACString& aProperty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == eCSSProperty_perspective || res == eCSSProperty_perspective_origin ||
|
|
||||||
res == eCSSProperty_backface_visibility || res == eCSSProperty_transform_style) {
|
|
||||||
return eCSSProperty_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,12 +373,6 @@ nsCSSProps::LookupProperty(const nsAString& aProperty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == eCSSProperty_perspective || res == eCSSProperty_perspective_origin ||
|
|
||||||
res == eCSSProperty_backface_visibility || res == eCSSProperty_transform_style) {
|
|
||||||
return eCSSProperty_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,15 +67,6 @@ public:
|
|||||||
|
|
||||||
NS_DECL_NSICSSDECLARATION
|
NS_DECL_NSICSSDECLARATION
|
||||||
|
|
||||||
NS_IMETHOD GetMozPerspective(nsAString_internal&);
|
|
||||||
NS_IMETHOD SetMozPerspective(const nsAString_internal&);
|
|
||||||
NS_IMETHOD GetMozPerspectiveOrigin(nsAString_internal&);
|
|
||||||
NS_IMETHOD SetMozPerspectiveOrigin(const nsAString_internal&);
|
|
||||||
NS_IMETHOD GetMozBackfaceVisibility(nsAString_internal&);
|
|
||||||
NS_IMETHOD SetMozBackfaceVisibility(const nsAString_internal&);
|
|
||||||
NS_IMETHOD GetMozTransformStyle(nsAString_internal&);
|
|
||||||
NS_IMETHOD SetMozTransformStyle(const nsAString_internal&);
|
|
||||||
|
|
||||||
// Require subclasses to implement |GetParentRule|.
|
// Require subclasses to implement |GetParentRule|.
|
||||||
//NS_DECL_NSIDOMCSSSTYLEDECLARATION
|
//NS_DECL_NSIDOMCSSSTYLEDECLARATION
|
||||||
NS_IMETHOD GetCssText(nsAString & aCssText);
|
NS_IMETHOD GetCssText(nsAString & aCssText);
|
||||||
|
@ -193,14 +193,6 @@ print_array(const char *aName,
|
|||||||
// catch if they do.
|
// catch if they do.
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(p->propName, "-moz-perspective") == 0 ||
|
|
||||||
strcmp(p->propName, "-moz-perspective-origin") == 0 ||
|
|
||||||
strcmp(p->propName, "-moz-backface-visibility") == 0 ||
|
|
||||||
strcmp(p->propName, "-moz-transform-style") == 0) {
|
|
||||||
++j;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
first = 0;
|
first = 0;
|
||||||
else
|
else
|
||||||
|
@ -981,6 +981,57 @@ var gCSSProperties = {
|
|||||||
"border", "center red", "right diagonal",
|
"border", "center red", "right diagonal",
|
||||||
"#00ffff bottom"]
|
"#00ffff bottom"]
|
||||||
},
|
},
|
||||||
|
"-moz-perspective-origin": {
|
||||||
|
domProp: "MozPerspectiveOrigin",
|
||||||
|
inherited: false,
|
||||||
|
type: CSS_TYPE_LONGHAND,
|
||||||
|
/* no subproperties */
|
||||||
|
prerequisites: { "width": "10px", "height": "10px", "display": "block"},
|
||||||
|
initial_values: [ "50% 50%", "center", "center center" ],
|
||||||
|
other_values: [ "25% 25%", "5px 5px", "20% 3em", "0 0", "0in 1in",
|
||||||
|
"top", "bottom","top left", "top right",
|
||||||
|
"top center", "center left", "center right",
|
||||||
|
"bottom left", "bottom right", "bottom center",
|
||||||
|
"20% center", "5px center", "13in bottom",
|
||||||
|
"left 50px", "right 13%", "center 40px",
|
||||||
|
"-moz-calc(20px)",
|
||||||
|
"-moz-calc(20px) 10px",
|
||||||
|
"10px -moz-calc(20px)",
|
||||||
|
"-moz-calc(20px) 25%",
|
||||||
|
"25% -moz-calc(20px)",
|
||||||
|
"-moz-calc(20px) -moz-calc(20px)",
|
||||||
|
"-moz-calc(20px + 1em) -moz-calc(20px / 2)",
|
||||||
|
"-moz-calc(20px + 50%) -moz-calc(50% - 10px)",
|
||||||
|
"-moz-calc(-20px) -moz-calc(-50%)",
|
||||||
|
"-moz-calc(-20%) -moz-calc(-50%)" ],
|
||||||
|
invalid_values: [ "red", "auto", "none", "0.5 0.5", "40px #0000ff",
|
||||||
|
"border", "center red", "right diagonal",
|
||||||
|
"#00ffff bottom"]
|
||||||
|
},
|
||||||
|
"-moz-perspective": {
|
||||||
|
domProp: "MozPerspective",
|
||||||
|
inherited: false,
|
||||||
|
type: CSS_TYPE_LONGHAND,
|
||||||
|
initial_values: [ "none", "0" ],
|
||||||
|
other_values: [ "1000px", "500.2px", "-100px", "-27.2em" ],
|
||||||
|
invalid_values: [ "pants", "200" ]
|
||||||
|
},
|
||||||
|
"-moz-backface-visibility": {
|
||||||
|
domProp: "MozBackfaceVisibility",
|
||||||
|
inherited: false,
|
||||||
|
type: CSS_TYPE_LONGHAND,
|
||||||
|
initial_values: [ "visible" ],
|
||||||
|
other_values: [ "hidden" ],
|
||||||
|
invalid_values: [ "collapse" ]
|
||||||
|
},
|
||||||
|
"-moz-transform-style": {
|
||||||
|
domProp: "MozTransformStyle",
|
||||||
|
inherited: false,
|
||||||
|
type: CSS_TYPE_LONGHAND,
|
||||||
|
initial_values: [ "flat" ],
|
||||||
|
other_values: [ "preserve-3d" ],
|
||||||
|
invalid_values: []
|
||||||
|
},
|
||||||
"-moz-user-focus": {
|
"-moz-user-focus": {
|
||||||
domProp: "MozUserFocus",
|
domProp: "MozUserFocus",
|
||||||
inherited: true,
|
inherited: true,
|
||||||
|
@ -80,6 +80,9 @@ var supported_properties = {
|
|||||||
"-moz-transform-origin": [ test_length_pair_transition,
|
"-moz-transform-origin": [ test_length_pair_transition,
|
||||||
test_length_percent_pair_transition,
|
test_length_percent_pair_transition,
|
||||||
test_length_percent_pair_unclamped ],
|
test_length_percent_pair_unclamped ],
|
||||||
|
"-moz-perspective-origin": [ test_length_pair_transition,
|
||||||
|
test_length_percent_pair_transition,
|
||||||
|
test_length_percent_pair_unclamped ],
|
||||||
"background-color": [ test_color_transition ],
|
"background-color": [ test_color_transition ],
|
||||||
"background-position": [ test_background_position_transition,
|
"background-position": [ test_background_position_transition,
|
||||||
// FIXME: We don't currently test clamping,
|
// FIXME: We don't currently test clamping,
|
||||||
@ -190,6 +193,7 @@ var supported_properties = {
|
|||||||
"padding-top": [ test_length_transition, test_percent_transition,
|
"padding-top": [ test_length_transition, test_percent_transition,
|
||||||
test_length_percent_calc_transition,
|
test_length_percent_calc_transition,
|
||||||
test_length_clamped, test_percent_clamped ],
|
test_length_clamped, test_percent_clamped ],
|
||||||
|
"-moz-perspective": [ test_length_transition ],
|
||||||
"right": [ test_length_transition, test_percent_transition,
|
"right": [ test_length_transition, test_percent_transition,
|
||||||
test_length_percent_calc_transition,
|
test_length_percent_calc_transition,
|
||||||
test_length_unclamped, test_percent_unclamped ],
|
test_length_unclamped, test_percent_unclamped ],
|
||||||
@ -1323,11 +1327,11 @@ function test_transform_transition(prop) {
|
|||||||
expected: 'matrix(1, 0, 0, 1, 0px, -30px)' },
|
expected: 'matrix(1, 0, 0, 1, 0px, -30px)' },
|
||||||
{ start: 'translateZ(40px)', end: 'none',
|
{ start: 'translateZ(40px)', end: 'none',
|
||||||
expected_uncomputed: 'translateZ(30px)',
|
expected_uncomputed: 'translateZ(30px)',
|
||||||
expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 30, 1)',
|
expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0px, 0px, 30px, 1)',
|
||||||
requires_3d: true },
|
requires_3d: true },
|
||||||
{ start: 'none', end: 'translate3D(40px, 60px, -40px)',
|
{ start: 'none', end: 'translate3D(40px, 60px, -40px)',
|
||||||
expected_uncomputed: 'translate3D(10px, 15px, -10px)',
|
expected_uncomputed: 'translate3D(10px, 15px, -10px)',
|
||||||
expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 15, -10, 1)',
|
expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10px, 15px, -10px, 1)',
|
||||||
requires_3d: true },
|
requires_3d: true },
|
||||||
// percentages are relative to 300px (width) and 50px (height)
|
// percentages are relative to 300px (width) and 50px (height)
|
||||||
// per the prerequisites in property_database.js
|
// per the prerequisites in property_database.js
|
||||||
@ -1400,11 +1404,11 @@ function test_transform_transition(prop) {
|
|||||||
expected: 'matrix(1, 0, 0, 4, 0px, 0px)' },
|
expected: 'matrix(1, 0, 0, 4, 0px, 0px)' },
|
||||||
{ start: 'scaleZ(5)', end: 'none',
|
{ start: 'scaleZ(5)', end: 'none',
|
||||||
expected_uncomputed: 'scaleZ(4)',
|
expected_uncomputed: 'scaleZ(4)',
|
||||||
expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1)',
|
expected: 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 4, 0, 0px, 0px, 0px, 1)',
|
||||||
requires_3d: true },
|
requires_3d: true },
|
||||||
{ start: 'none', end: 'scale3D(5, 5, 5)',
|
{ start: 'none', end: 'scale3D(5, 5, 5)',
|
||||||
expected_uncomputed: 'scale3D(2, 2, 2)',
|
expected_uncomputed: 'scale3D(2, 2, 2)',
|
||||||
expected: 'matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1)',
|
expected: 'matrix3d(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0px, 0px, 0px, 1)',
|
||||||
requires_3d: true },
|
requires_3d: true },
|
||||||
|
|
||||||
// skew
|
// skew
|
||||||
|
@ -3362,4 +3362,4 @@ pref("full-screen-api.key-input-restricted", true);
|
|||||||
pref("dom.event.handling-user-input-time-limit", 1000);
|
pref("dom.event.handling-user-input-time-limit", 1000);
|
||||||
|
|
||||||
//3D Transforms
|
//3D Transforms
|
||||||
pref("layout.3d-transforms.enabled", false);
|
pref("layout.3d-transforms.enabled", true);
|
||||||
|
@ -53,6 +53,8 @@
|
|||||||
* a11y telemetry
|
* a11y telemetry
|
||||||
*/
|
*/
|
||||||
HISTOGRAM(A11Y_INSTANTIATED, 0, 1, 2, BOOLEAN, "has accessibility support been instantiated")
|
HISTOGRAM(A11Y_INSTANTIATED, 0, 1, 2, BOOLEAN, "has accessibility support been instantiated")
|
||||||
|
HISTOGRAM(ISIMPLE_DOM_USAGE, 0, 1, 2, BOOLEAN, "have the ISimpleDOM* accessibility interfaces been used")
|
||||||
|
HISTOGRAM(IACCESSIBLE_TABLE_USAGE, 0, 1, 2, BOOLEAN, "has the IAccessibleTable accessibility interface been used")
|
||||||
|
|
||||||
HISTOGRAM(CYCLE_COLLECTOR, 1, 10000, 50, EXPONENTIAL, "Time spent on one cycle collection (ms)")
|
HISTOGRAM(CYCLE_COLLECTOR, 1, 10000, 50, EXPONENTIAL, "Time spent on one cycle collection (ms)")
|
||||||
HISTOGRAM(CYCLE_COLLECTOR_VISITED_REF_COUNTED, 1, 300000, 50, EXPONENTIAL, "Number of ref counted objects visited by the cycle collector")
|
HISTOGRAM(CYCLE_COLLECTOR_VISITED_REF_COUNTED, 1, 300000, 50, EXPONENTIAL, "Number of ref counted objects visited by the cycle collector")
|
||||||
|
Loading…
Reference in New Issue
Block a user