Bug 1100632 - Remove --disable-opus option and MOZ_OPUS #define macros. r=rillian,ted

This commit is contained in:
awake 2014-11-28 01:20:00 -08:00
parent 4e6599adac
commit 153d42d171
14 changed files with 8 additions and 116 deletions

View File

@ -25,9 +25,6 @@ if CONFIG['MOZ_VORBIS']:
if CONFIG['MOZ_TREMOR']: if CONFIG['MOZ_TREMOR']:
external_dirs += ['media/libtremor'] external_dirs += ['media/libtremor']
if CONFIG['MOZ_OPUS']:
external_dirs += ['media/libopus']
if CONFIG['MOZ_WEBM']: if CONFIG['MOZ_WEBM']:
external_dirs += ['media/libnestegg'] external_dirs += ['media/libnestegg']
@ -44,6 +41,7 @@ external_dirs += [
'media/kiss_fft', 'media/kiss_fft',
'media/libcubeb', 'media/libcubeb',
'media/libogg', 'media/libogg',
'media/libopus',
'media/libtheora', 'media/libtheora',
'media/libspeex_resampler', 'media/libspeex_resampler',
'media/libstagefright', 'media/libstagefright',

View File

@ -3852,7 +3852,6 @@ MOZ_TREMOR=
MOZ_WAVE=1 MOZ_WAVE=1
MOZ_SAMPLE_TYPE_FLOAT32= MOZ_SAMPLE_TYPE_FLOAT32=
MOZ_SAMPLE_TYPE_S16= MOZ_SAMPLE_TYPE_S16=
MOZ_OPUS=1
MOZ_WEBM=1 MOZ_WEBM=1
MOZ_GSTREAMER= MOZ_GSTREAMER=
MOZ_DIRECTSHOW= MOZ_DIRECTSHOW=
@ -5224,14 +5223,6 @@ if test "${ac_cv_c_attribute_aligned}" != "0"; then
[${ac_cv_c_attribute_aligned}],[Maximum supported data alignment]) [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
fi fi
dnl ========================================================
dnl = Disable Opus audio codec support
dnl ========================================================
MOZ_ARG_DISABLE_BOOL(opus,
[ --disable-opus Disable support for Opus audio],
MOZ_OPUS=,
MOZ_OPUS=1)
dnl ======================================================== dnl ========================================================
dnl = Disable VP8 decoder support dnl = Disable VP8 decoder support
dnl ======================================================== dnl ========================================================
@ -5567,10 +5558,6 @@ if test -n "$MOZ_VORBIS" -a -n "$MOZ_TREMOR"; then
AC_MSG_ERROR([MOZ_VORBIS and MOZ_TREMOR are mutually exclusive! The build system should not allow them both to be set, but they are. Please file a bug at https://bugzilla.mozilla.org/]) AC_MSG_ERROR([MOZ_VORBIS and MOZ_TREMOR are mutually exclusive! The build system should not allow them both to be set, but they are. Please file a bug at https://bugzilla.mozilla.org/])
fi fi
if test -n "$MOZ_WEBRTC" -a -z "$MOZ_OPUS"; then
AC_MSG_ERROR([MOZ_WEBRTC requires MOZ_OPUS which is disabled.])
fi
if test -n "$MOZ_VORBIS"; then if test -n "$MOZ_VORBIS"; then
AC_DEFINE(MOZ_VORBIS) AC_DEFINE(MOZ_VORBIS)
fi fi
@ -5581,10 +5568,6 @@ if test -n "$MOZ_TREMOR"; then
MOZ_WEBM_ENCODER= MOZ_WEBM_ENCODER=
fi fi
if test -n "$MOZ_OPUS"; then
AC_DEFINE(MOZ_OPUS)
fi
if test -n "$MOZ_WEBM_ENCODER"; then if test -n "$MOZ_WEBM_ENCODER"; then
AC_DEFINE(MOZ_WEBM_ENCODER) AC_DEFINE(MOZ_WEBM_ENCODER)
fi fi
@ -8877,7 +8860,6 @@ AC_SUBST(WIN32_GUI_EXE_LDFLAGS)
AC_SUBST(MOZ_WAVE) AC_SUBST(MOZ_WAVE)
AC_SUBST(MOZ_VORBIS) AC_SUBST(MOZ_VORBIS)
AC_SUBST(MOZ_TREMOR) AC_SUBST(MOZ_TREMOR)
AC_SUBST(MOZ_OPUS)
AC_SUBST(MOZ_WEBM) AC_SUBST(MOZ_WEBM)
AC_SUBST(MOZ_WMF) AC_SUBST(MOZ_WMF)
AC_SUBST(MOZ_FFMPEG) AC_SUBST(MOZ_FFMPEG)

View File

@ -1689,11 +1689,7 @@ MediaDecoder::IsRawEnabled()
bool bool
MediaDecoder::IsOpusEnabled() MediaDecoder::IsOpusEnabled()
{ {
#ifdef MOZ_OPUS
return Preferences::GetBool("media.opus.enabled"); return Preferences::GetBool("media.opus.enabled");
#else
return false;
#endif
} }
bool bool

View File

@ -12,11 +12,8 @@
#include"GeckoProfiler.h" #include"GeckoProfiler.h"
#include "OggWriter.h" #include "OggWriter.h"
#ifdef MOZ_OPUS
#include "OpusTrackEncoder.h" #include "OpusTrackEncoder.h"
#endif
#ifdef MOZ_VORBIS #ifdef MOZ_VORBIS
#include "VorbisTrackEncoder.h" #include "VorbisTrackEncoder.h"
#endif #endif

View File

@ -11,12 +11,14 @@ EXPORTS += [
'ContainerWriter.h', 'ContainerWriter.h',
'EncodedFrameContainer.h', 'EncodedFrameContainer.h',
'MediaEncoder.h', 'MediaEncoder.h',
'OpusTrackEncoder.h',
'TrackEncoder.h', 'TrackEncoder.h',
'TrackMetadataBase.h', 'TrackMetadataBase.h',
] ]
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [
'MediaEncoder.cpp', 'MediaEncoder.cpp',
'OpusTrackEncoder.cpp',
'TrackEncoder.cpp', 'TrackEncoder.cpp',
] ]
@ -24,10 +26,6 @@ if CONFIG['MOZ_OMX_ENCODER']:
EXPORTS += ['OmxTrackEncoder.h'] EXPORTS += ['OmxTrackEncoder.h']
UNIFIED_SOURCES += ['OmxTrackEncoder.cpp'] UNIFIED_SOURCES += ['OmxTrackEncoder.cpp']
if CONFIG['MOZ_OPUS']:
EXPORTS += ['OpusTrackEncoder.h']
UNIFIED_SOURCES += ['OpusTrackEncoder.cpp']
if CONFIG['MOZ_WEBM_ENCODER']: if CONFIG['MOZ_WEBM_ENCODER']:
EXPORTS += ['VorbisTrackEncoder.h', EXPORTS += ['VorbisTrackEncoder.h',
'VP8TrackEncoder.h', 'VP8TrackEncoder.h',

View File

@ -49,10 +49,8 @@ OggCodecState::Create(ogg_page* aPage)
codecState = new TheoraState(aPage); codecState = new TheoraState(aPage);
} else if (aPage->body_len > 6 && memcmp(aPage->body+1, "vorbis", 6) == 0) { } else if (aPage->body_len > 6 && memcmp(aPage->body+1, "vorbis", 6) == 0) {
codecState = new VorbisState(aPage); codecState = new VorbisState(aPage);
#ifdef MOZ_OPUS
} else if (aPage->body_len > 8 && memcmp(aPage->body, "OpusHead", 8) == 0) { } else if (aPage->body_len > 8 && memcmp(aPage->body, "OpusHead", 8) == 0) {
codecState = new OpusState(aPage); codecState = new OpusState(aPage);
#endif
} 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 SkeletonState(aPage); codecState = new SkeletonState(aPage);
} else { } else {
@ -795,7 +793,6 @@ nsresult VorbisState::ReconstructVorbisGranulepos()
return NS_OK; return NS_OK;
} }
#ifdef MOZ_OPUS
OpusState::OpusState(ogg_page* aBosPage) : OpusState::OpusState(ogg_page* aBosPage) :
OggCodecState(aBosPage, true), OggCodecState(aBosPage, true),
mParser(nullptr), mParser(nullptr),
@ -1078,7 +1075,6 @@ bool OpusState::ReconstructOpusGranulepos(void)
mPrevPageGranulepos = last->granulepos; mPrevPageGranulepos = last->granulepos;
return true; return true;
} }
#endif /* MOZ_OPUS */
SkeletonState::SkeletonState(ogg_page* aBosPage) : SkeletonState::SkeletonState(ogg_page* aBosPage) :
OggCodecState(aBosPage, true), OggCodecState(aBosPage, true),

View File

@ -13,14 +13,12 @@
#else #else
#include <vorbis/codec.h> #include <vorbis/codec.h>
#endif #endif
#ifdef MOZ_OPUS
#include <opus/opus.h> #include <opus/opus.h>
#include "opus/opus_multistream.h" #include "opus/opus_multistream.h"
// For MOZ_SAMPLE_TYPE_* // For MOZ_SAMPLE_TYPE_*
#include "mozilla/dom/HTMLMediaElement.h" #include "mozilla/dom/HTMLMediaElement.h"
#include "MediaDecoderStateMachine.h" #include "MediaDecoderStateMachine.h"
#include "MediaDecoderReader.h" #include "MediaDecoderReader.h"
#endif
#include <nsAutoRef.h> #include <nsAutoRef.h>
#include <nsDeque.h> #include <nsDeque.h>
#include <nsTArray.h> #include <nsTArray.h>
@ -323,7 +321,6 @@ private:
}; };
class OpusState : public OggCodecState { class OpusState : public OggCodecState {
#ifdef MOZ_OPUS
public: public:
explicit OpusState(ogg_page* aBosPage); explicit OpusState(ogg_page* aBosPage);
virtual ~OpusState(); virtual ~OpusState();
@ -375,7 +372,6 @@ private:
// where we may need to trim some samples from the end. // where we may need to trim some samples from the end.
int64_t mPrevPageGranulepos; int64_t mPrevPageGranulepos;
#endif /* MOZ_OPUS */
}; };
// Constructs a 32bit version number out of two 16 bit major,minor // Constructs a 32bit version number out of two 16 bit major,minor

View File

@ -13,12 +13,10 @@
#include "VideoUtils.h" #include "VideoUtils.h"
#include "theora/theoradec.h" #include "theora/theoradec.h"
#include <algorithm> #include <algorithm>
#ifdef MOZ_OPUS
#include "opus/opus.h" #include "opus/opus.h"
extern "C" { extern "C" {
#include "opus/opus_multistream.h" #include "opus/opus_multistream.h"
} }
#endif
#include "mozilla/dom/TimeRanges.h" #include "mozilla/dom/TimeRanges.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "VorbisUtils.h" #include "VorbisUtils.h"
@ -62,9 +60,7 @@ static const uint32_t SEEK_FUZZ_USECS = 500000;
// The number of microseconds of "pre-roll" we use for Opus streams. // The number of microseconds of "pre-roll" we use for Opus streams.
// The specification recommends 80 ms. // The specification recommends 80 ms.
#ifdef MOZ_OPUS
static const int64_t SEEK_OPUS_PREROLL = 80 * USECS_PER_MS; static const int64_t SEEK_OPUS_PREROLL = 80 * USECS_PER_MS;
#endif /* MOZ_OPUS */
enum PageSyncResult { enum PageSyncResult {
PAGE_SYNC_ERROR = 1, PAGE_SYNC_ERROR = 1,
@ -136,10 +132,8 @@ OggReader::OggReader(AbstractMediaDecoder* aDecoder)
mMonitor("OggReader"), mMonitor("OggReader"),
mTheoraState(nullptr), mTheoraState(nullptr),
mVorbisState(nullptr), mVorbisState(nullptr),
#ifdef MOZ_OPUS
mOpusState(nullptr), mOpusState(nullptr),
mOpusEnabled(MediaDecoder::IsOpusEnabled()), mOpusEnabled(MediaDecoder::IsOpusEnabled()),
#endif /* MOZ_OPUS */
mSkeletonState(nullptr), mSkeletonState(nullptr),
mVorbisSerial(0), mVorbisSerial(0),
mOpusSerial(0), mOpusSerial(0),
@ -183,11 +177,9 @@ nsresult OggReader::ResetDecode(bool start)
if (mVorbisState && NS_FAILED(mVorbisState->Reset())) { if (mVorbisState && NS_FAILED(mVorbisState->Reset())) {
res = NS_ERROR_FAILURE; res = NS_ERROR_FAILURE;
} }
#ifdef MOZ_OPUS
if (mOpusState && NS_FAILED(mOpusState->Reset(start))) { if (mOpusState && NS_FAILED(mOpusState->Reset(start))) {
res = NS_ERROR_FAILURE; res = NS_ERROR_FAILURE;
} }
#endif /* MOZ_OPUS */
if (mTheoraState && NS_FAILED(mTheoraState->Reset())) { if (mTheoraState && NS_FAILED(mTheoraState->Reset())) {
res = NS_ERROR_FAILURE; res = NS_ERROR_FAILURE;
} }
@ -217,10 +209,8 @@ void OggReader::BuildSerialList(nsTArray<uint32_t>& aTracks)
if (HasAudio()) { if (HasAudio()) {
if (mVorbisState) { if (mVorbisState) {
aTracks.AppendElement(mVorbisState->mSerial); aTracks.AppendElement(mVorbisState->mSerial);
#ifdef MOZ_OPUS
} else if (mOpusState) { } else if (mOpusState) {
aTracks.AppendElement(mOpusState->mSerial); aTracks.AppendElement(mOpusState->mSerial);
#endif /* MOZ_OPUS */
} }
} }
} }
@ -359,7 +349,6 @@ void OggReader::SetupMediaTracksInfo(const nsTArray<uint32_t>& aSerials)
mInfo.mAudio.mHasAudio = true; mInfo.mAudio.mHasAudio = true;
mInfo.mAudio.mRate = vorbisState->mInfo.rate; mInfo.mAudio.mRate = vorbisState->mInfo.rate;
mInfo.mAudio.mChannels = vorbisState->mInfo.channels; mInfo.mAudio.mChannels = vorbisState->mInfo.channels;
#ifdef MOZ_OPUS
} else if (codecState->GetType() == OggCodecState::TYPE_OPUS) { } else if (codecState->GetType() == OggCodecState::TYPE_OPUS) {
OpusState* opusState = static_cast<OpusState*>(codecState); OpusState* opusState = static_cast<OpusState*>(codecState);
if (!(mOpusState && mOpusState->mSerial == opusState->mSerial)) { if (!(mOpusState && mOpusState->mSerial == opusState->mSerial)) {
@ -373,7 +362,6 @@ void OggReader::SetupMediaTracksInfo(const nsTArray<uint32_t>& aSerials)
mInfo.mAudio.mHasAudio = true; mInfo.mAudio.mHasAudio = true;
mInfo.mAudio.mRate = opusState->mRate; mInfo.mAudio.mRate = opusState->mRate;
mInfo.mAudio.mChannels = opusState->mChannels; mInfo.mAudio.mChannels = opusState->mChannels;
#endif
} }
} }
} }
@ -450,7 +438,6 @@ nsresult OggReader::ReadMetadata(MediaInfo* aInfo,
} else { } else {
s->Deactivate(); s->Deactivate();
} }
#ifdef MOZ_OPUS
} else if (s->GetType() == OggCodecState::TYPE_OPUS && ReadHeaders(s)) { } else if (s->GetType() == OggCodecState::TYPE_OPUS && ReadHeaders(s)) {
if (mOpusEnabled) { if (mOpusEnabled) {
if (!mOpusState) { if (!mOpusState) {
@ -464,7 +451,6 @@ nsresult OggReader::ReadMetadata(MediaInfo* aInfo,
NS_WARNING("Opus decoding disabled." NS_WARNING("Opus decoding disabled."
" See media.opus.enabled in about:config"); " See media.opus.enabled in about:config");
} }
#endif // MOZ_OPUS
} else if (s->GetType() == OggCodecState::TYPE_SKELETON && !mSkeletonState) { } else if (s->GetType() == OggCodecState::TYPE_SKELETON && !mSkeletonState) {
mSkeletonState = static_cast<SkeletonState*>(s); mSkeletonState = static_cast<SkeletonState*>(s);
} else { } else {
@ -570,7 +556,7 @@ nsresult OggReader::DecodeVorbis(ogg_packet* aPacket) {
} }
return NS_OK; return NS_OK;
} }
#ifdef MOZ_OPUS
nsresult OggReader::DecodeOpus(ogg_packet* aPacket) { nsresult OggReader::DecodeOpus(ogg_packet* aPacket) {
NS_ASSERTION(aPacket->granulepos != -1, "Must know opus granulepos!"); NS_ASSERTION(aPacket->granulepos != -1, "Must know opus granulepos!");
@ -682,16 +668,12 @@ nsresult OggReader::DecodeOpus(ogg_packet* aPacket) {
return NS_OK; return NS_OK;
} }
#endif /* MOZ_OPUS */
bool OggReader::DecodeAudioData() bool OggReader::DecodeAudioData()
{ {
NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread."); NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
DebugOnly<bool> haveCodecState = mVorbisState != nullptr DebugOnly<bool> haveCodecState = mVorbisState != nullptr ||
#ifdef MOZ_OPUS mOpusState != nullptr;
|| mOpusState != nullptr
#endif /* MOZ_OPUS */
;
NS_ASSERTION(haveCodecState, "Need audio codec state to decode audio"); NS_ASSERTION(haveCodecState, "Need audio codec state to decode audio");
// Read the next data packet. Skip any non-data packets we encounter. // Read the next data packet. Skip any non-data packets we encounter.
@ -699,10 +681,8 @@ bool OggReader::DecodeAudioData()
OggCodecState* codecState; OggCodecState* codecState;
if (mVorbisState) if (mVorbisState)
codecState = static_cast<OggCodecState*>(mVorbisState); codecState = static_cast<OggCodecState*>(mVorbisState);
#ifdef MOZ_OPUS
else else
codecState = static_cast<OggCodecState*>(mOpusState); codecState = static_cast<OggCodecState*>(mOpusState);
#endif /* MOZ_OPUS */
do { do {
if (packet) { if (packet) {
OggCodecState::ReleasePacket(packet); OggCodecState::ReleasePacket(packet);
@ -719,10 +699,8 @@ bool OggReader::DecodeAudioData()
nsAutoRef<ogg_packet> autoRelease(packet); nsAutoRef<ogg_packet> autoRelease(packet);
if (mVorbisState) { if (mVorbisState) {
DecodeVorbis(packet); DecodeVorbis(packet);
#ifdef MOZ_OPUS
} else if (mOpusState) { } else if (mOpusState) {
DecodeOpus(packet); DecodeOpus(packet);
#endif
} }
if ((packet->e_o_s) && (!ReadOggChain())) { if ((packet->e_o_s) && (!ReadOggChain())) {
@ -749,9 +727,7 @@ void OggReader::SetChained(bool aIsChained) {
bool OggReader::ReadOggChain() bool OggReader::ReadOggChain()
{ {
bool chained = false; bool chained = false;
#ifdef MOZ_OPUS
OpusState* newOpusState = nullptr; OpusState* newOpusState = nullptr;
#endif /* MOZ_OPUS */
VorbisState* newVorbisState = nullptr; VorbisState* newVorbisState = nullptr;
nsAutoPtr<MetadataTags> tags; nsAutoPtr<MetadataTags> tags;
@ -778,11 +754,9 @@ bool OggReader::ReadOggChain()
if (mVorbisState && (codecState->GetType() == OggCodecState::TYPE_VORBIS)) { if (mVorbisState && (codecState->GetType() == OggCodecState::TYPE_VORBIS)) {
newVorbisState = static_cast<VorbisState*>(codecState.get()); newVorbisState = static_cast<VorbisState*>(codecState.get());
} }
#ifdef MOZ_OPUS
else if (mOpusState && (codecState->GetType() == OggCodecState::TYPE_OPUS)) { else if (mOpusState && (codecState->GetType() == OggCodecState::TYPE_OPUS)) {
newOpusState = static_cast<OpusState*>(codecState.get()); newOpusState = static_cast<OpusState*>(codecState.get());
} }
#endif
else { else {
return false; return false;
} }
@ -819,7 +793,6 @@ bool OggReader::ReadOggChain()
tags = newVorbisState->GetTags(); tags = newVorbisState->GetTags();
} }
#ifdef MOZ_OPUS
if ((newOpusState && ReadHeaders(newOpusState)) && if ((newOpusState && ReadHeaders(newOpusState)) &&
(mOpusState->mRate == newOpusState->mRate) && (mOpusState->mRate == newOpusState->mRate) &&
(mOpusState->mChannels == newOpusState->mChannels)) { (mOpusState->mChannels == newOpusState->mChannels)) {
@ -835,7 +808,6 @@ bool OggReader::ReadOggChain()
chained = true; chained = true;
tags = newOpusState->GetTags(); tags = newOpusState->GetTags();
} }
#endif
if (chained) { if (chained) {
SetChained(true); SetChained(true);
@ -1441,12 +1413,10 @@ nsresult OggReader::SeekInUnbuffered(int64_t aTarget,
if (HasVideo() && mTheoraState) { if (HasVideo() && mTheoraState) {
keyframeOffsetMs = mTheoraState->MaxKeyframeOffset(); keyframeOffsetMs = mTheoraState->MaxKeyframeOffset();
} }
#ifdef MOZ_OPUS
// Add in the Opus pre-roll if necessary, as well. // Add in the Opus pre-roll if necessary, as well.
if (HasAudio() && mOpusState) { if (HasAudio() && mOpusState) {
keyframeOffsetMs = std::max(keyframeOffsetMs, SEEK_OPUS_PREROLL); keyframeOffsetMs = std::max(keyframeOffsetMs, SEEK_OPUS_PREROLL);
} }
#endif /* MOZ_OPUS */
int64_t seekTarget = std::max(aStartTime, aTarget - keyframeOffsetMs); int64_t seekTarget = std::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.
@ -1476,11 +1446,9 @@ nsresult OggReader::SeekInternal(int64_t aTarget,
MediaResource* resource = mDecoder->GetResource(); MediaResource* resource = mDecoder->GetResource();
NS_ENSURE_TRUE(resource != nullptr, NS_ERROR_FAILURE); NS_ENSURE_TRUE(resource != nullptr, NS_ERROR_FAILURE);
int64_t adjustedTarget = aTarget; int64_t adjustedTarget = aTarget;
#ifdef MOZ_OPUS
if (HasAudio() && mOpusState){ if (HasAudio() && mOpusState){
adjustedTarget = std::max(aStartTime, aTarget - SEEK_OPUS_PREROLL); adjustedTarget = std::max(aStartTime, aTarget - SEEK_OPUS_PREROLL);
} }
#endif /* MOZ_OPUS */
if (adjustedTarget == aStartTime) { if (adjustedTarget == aStartTime) {
// We've seeked to the media start. Just seek to the offset of the first // We've seeked to the media start. Just seek to the offset of the first
@ -1788,10 +1756,8 @@ nsresult OggReader::SeekBisection(int64_t aTarget,
if (HasAudio() && granulepos > 0 && audioTime == -1) { if (HasAudio() && granulepos > 0 && audioTime == -1) {
if (mVorbisState && serial == mVorbisState->mSerial) { if (mVorbisState && serial == mVorbisState->mSerial) {
audioTime = mVorbisState->Time(granulepos); audioTime = mVorbisState->Time(granulepos);
#ifdef MOZ_OPUS
} else if (mOpusState && serial == mOpusState->mSerial) { } else if (mOpusState && serial == mOpusState->mSerial) {
audioTime = mOpusState->Time(granulepos); audioTime = mOpusState->Time(granulepos);
#endif
} }
} }
@ -1966,12 +1932,10 @@ nsresult OggReader::GetBuffered(dom::TimeRanges* aBuffered)
startTime = VorbisState::Time(&mVorbisInfo, granulepos); startTime = VorbisState::Time(&mVorbisInfo, granulepos);
NS_ASSERTION(startTime > 0, "Must have positive start time"); NS_ASSERTION(startTime > 0, "Must have positive start time");
} }
#ifdef MOZ_OPUS
else if (mOpusState && serial == mOpusSerial) { else if (mOpusState && serial == mOpusSerial) {
startTime = OpusState::Time(mOpusPreSkip, granulepos); startTime = OpusState::Time(mOpusPreSkip, granulepos);
NS_ASSERTION(startTime > 0, "Must have positive start time"); NS_ASSERTION(startTime > 0, "Must have positive start time");
} }
#endif /* MOZ_OPUS */
else if (mTheoraState && serial == mTheoraSerial) { else if (mTheoraState && serial == mTheoraSerial) {
startTime = TheoraState::Time(&mTheoraInfo, granulepos); startTime = TheoraState::Time(&mTheoraInfo, granulepos);
NS_ASSERTION(startTime > 0, "Must have positive start time"); NS_ASSERTION(startTime > 0, "Must have positive start time");

View File

@ -65,11 +65,8 @@ public:
int64_t aTimeThreshold); int64_t aTimeThreshold);
virtual bool HasAudio() { virtual bool HasAudio() {
return (mVorbisState != 0 && mVorbisState->mActive) return (mVorbisState != 0 && mVorbisState->mActive) ||
#ifdef MOZ_OPUS (mOpusState != 0 && mOpusState->mActive);
|| (mOpusState != 0 && mOpusState->mActive)
#endif /* MOZ_OPUS */
;
} }
virtual bool HasVideo() { virtual bool HasVideo() {
@ -285,7 +282,6 @@ private:
// Decode state of the Vorbis bitstream we're decoding, if we have audio. // Decode state of the Vorbis bitstream we're decoding, if we have audio.
VorbisState* mVorbisState; VorbisState* mVorbisState;
#ifdef MOZ_OPUS
// Decode state of the Opus bitstream we're decoding, if we have one. // Decode state of the Opus bitstream we're decoding, if we have one.
OpusState *mOpusState; OpusState *mOpusState;
@ -293,7 +289,6 @@ private:
// contructor was called. We can't check it dynamically because // contructor was called. We can't check it dynamically because
// we're not on the main thread; // we're not on the main thread;
bool mOpusEnabled; bool mOpusEnabled;
#endif /* MOZ_OPUS */
// Decode state of the Skeleton bitstream. // Decode state of the Skeleton bitstream.
SkeletonState* mSkeletonState; SkeletonState* mSkeletonState;

View File

@ -169,11 +169,9 @@ WebMReader::WebMReader(AbstractMediaDecoder* aDecoder)
: MediaDecoderReader(aDecoder) : MediaDecoderReader(aDecoder)
, mContext(nullptr) , mContext(nullptr)
, mPacketCount(0) , mPacketCount(0)
#ifdef MOZ_OPUS
, mOpusDecoder(nullptr) , mOpusDecoder(nullptr)
, mSkip(0) , mSkip(0)
, mSeekPreroll(0) , mSeekPreroll(0)
#endif
, mVideoTrack(0) , mVideoTrack(0)
, mAudioTrack(0) , mAudioTrack(0)
, mAudioStartUsec(-1) , mAudioStartUsec(-1)
@ -184,9 +182,7 @@ WebMReader::WebMReader(AbstractMediaDecoder* aDecoder)
, mLayersBackendType(layers::LayersBackend::LAYERS_NONE) , mLayersBackendType(layers::LayersBackend::LAYERS_NONE)
, mHasVideo(false) , mHasVideo(false)
, mHasAudio(false) , mHasAudio(false)
#ifdef MOZ_OPUS
, mPaddingDiscarded(false) , mPaddingDiscarded(false)
#endif
{ {
MOZ_COUNT_CTOR(WebMReader); MOZ_COUNT_CTOR(WebMReader);
#ifdef PR_LOGGING #ifdef PR_LOGGING
@ -304,7 +300,6 @@ nsresult WebMReader::ResetDecode()
// aren't fatal and it fails when ResetDecode is called at a // aren't fatal and it fails when ResetDecode is called at a
// time when no vorbis data has been read. // time when no vorbis data has been read.
vorbis_synthesis_restart(&mVorbisDsp); vorbis_synthesis_restart(&mVorbisDsp);
#ifdef MOZ_OPUS
} else if (mAudioCodec == NESTEGG_CODEC_OPUS) { } else if (mAudioCodec == NESTEGG_CODEC_OPUS) {
if (mOpusDecoder) { if (mOpusDecoder) {
// Reset the decoder. // Reset the decoder.
@ -312,7 +307,6 @@ nsresult WebMReader::ResetDecode()
mSkip = mOpusParser->mPreSkip; mSkip = mOpusParser->mPreSkip;
mPaddingDiscarded = false; mPaddingDiscarded = false;
} }
#endif
} }
mVideoPackets.Reset(); mVideoPackets.Reset();
@ -514,7 +508,6 @@ nsresult WebMReader::ReadMetadata(MediaInfo* aInfo,
mInfo.mAudio.mRate = mVorbisDsp.vi->rate; mInfo.mAudio.mRate = mVorbisDsp.vi->rate;
mInfo.mAudio.mChannels = mVorbisDsp.vi->channels; mInfo.mAudio.mChannels = mVorbisDsp.vi->channels;
#ifdef MOZ_OPUS
} else if (mAudioCodec == NESTEGG_CODEC_OPUS) { } else if (mAudioCodec == NESTEGG_CODEC_OPUS) {
unsigned char* data = 0; unsigned char* data = 0;
size_t length = 0; size_t length = 0;
@ -547,7 +540,6 @@ nsresult WebMReader::ReadMetadata(MediaInfo* aInfo,
mInfo.mAudio.mChannels = mOpusParser->mChannels; mInfo.mAudio.mChannels = mOpusParser->mChannels;
mSeekPreroll = params.seek_preroll; mSeekPreroll = params.seek_preroll;
#endif
} else { } else {
Cleanup(); Cleanup();
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -568,7 +560,6 @@ WebMReader::IsMediaSeekable()
return mContext && nestegg_has_cues(mContext); return mContext && nestegg_has_cues(mContext);
} }
#ifdef MOZ_OPUS
bool WebMReader::InitOpusDecoder() bool WebMReader::InitOpusDecoder()
{ {
int r; int r;
@ -586,7 +577,6 @@ bool WebMReader::InitOpusDecoder()
return r == OPUS_OK; return r == OPUS_OK;
} }
#endif
bool WebMReader::DecodeAudioPacket(nestegg_packet* aPacket, int64_t aOffset) bool WebMReader::DecodeAudioPacket(nestegg_packet* aPacket, int64_t aOffset)
{ {
@ -653,11 +643,9 @@ bool WebMReader::DecodeAudioPacket(nestegg_packet* aPacket, int64_t aOffset)
return false; return false;
} }
} else if (mAudioCodec == NESTEGG_CODEC_OPUS) { } else if (mAudioCodec == NESTEGG_CODEC_OPUS) {
#ifdef MOZ_OPUS
if (!DecodeOpus(data, length, aOffset, tstamp_usecs, aPacket)) { if (!DecodeOpus(data, length, aOffset, tstamp_usecs, aPacket)) {
return false; return false;
} }
#endif
} }
} }
@ -739,7 +727,6 @@ bool WebMReader::DecodeVorbis(const unsigned char* aData, size_t aLength,
return true; return true;
} }
#ifdef MOZ_OPUS
bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength, bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
int64_t aOffset, uint64_t aTstampUsecs, int64_t aOffset, uint64_t aTstampUsecs,
nestegg_packet* aPacket) nestegg_packet* aPacket)
@ -876,7 +863,6 @@ bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
return true; return true;
} }
#endif /* MOZ_OPUS */
nsReturnRef<NesteggPacketHolder> WebMReader::NextPacket(TrackType aTrackType) nsReturnRef<NesteggPacketHolder> WebMReader::NextPacket(TrackType aTrackType)
{ {

View File

@ -24,9 +24,7 @@
#include "vorbis/codec.h" #include "vorbis/codec.h"
#endif #endif
#ifdef MOZ_OPUS
#include "OpusParser.h" #include "OpusParser.h"
#endif
// Holds a nestegg_packet, and its file offset. This is needed so we // Holds a nestegg_packet, and its file offset. This is needed so we
// know the offset in the file we've played up to, in order to calculate // know the offset in the file we've played up to, in order to calculate
@ -190,10 +188,8 @@ public:
MediaTaskQueue* GetTaskQueue() { return mTaskQueue; } MediaTaskQueue* GetTaskQueue() { return mTaskQueue; }
protected: protected:
#ifdef MOZ_OPUS
// Setup opus decoder // Setup opus decoder
bool InitOpusDecoder(); bool InitOpusDecoder();
#endif
// 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 true when there's more audio to decode, // audio queue. Returns true when there's more audio to decode,
@ -205,11 +201,9 @@ protected:
bool DecodeVorbis(const unsigned char* aData, size_t aLength, bool DecodeVorbis(const unsigned char* aData, size_t aLength,
int64_t aOffset, uint64_t aTstampUsecs, int64_t aOffset, uint64_t aTstampUsecs,
int32_t* aTotalFrames); int32_t* aTotalFrames);
#ifdef MOZ_OPUS
bool DecodeOpus(const unsigned char* aData, size_t aLength, bool DecodeOpus(const unsigned char* aData, size_t aLength,
int64_t aOffset, uint64_t aTstampUsecs, int64_t aOffset, uint64_t aTstampUsecs,
nestegg_packet* aPacket); nestegg_packet* aPacket);
#endif
// Release context and set to null. Called when an error occurs during // Release context and set to null. Called when an error occurs during
// reading metadata or destruction of the reader itself. // reading metadata or destruction of the reader itself.
@ -235,13 +229,11 @@ private:
vorbis_block mVorbisBlock; vorbis_block mVorbisBlock;
int64_t mPacketCount; int64_t mPacketCount;
#ifdef MOZ_OPUS
// Opus decoder state // Opus decoder state
nsAutoPtr<OpusParser> mOpusParser; nsAutoPtr<OpusParser> mOpusParser;
OpusMSDecoder *mOpusDecoder; OpusMSDecoder *mOpusDecoder;
uint16_t mSkip; // Samples left to trim before playback. uint16_t mSkip; // Samples left to trim before playback.
uint64_t mSeekPreroll; // Nanoseconds to discard after seeking. uint64_t mSeekPreroll; // Nanoseconds to discard after seeking.
#endif
// Queue of video and audio packets that have been read but not decoded. These // Queue of video and audio packets that have been read but not decoded. These
// must only be accessed from the state machine thread. // must only be accessed from the state machine thread.
@ -288,12 +280,10 @@ private:
bool mHasVideo; bool mHasVideo;
bool mHasAudio; bool mHasAudio;
#ifdef MOZ_OPUS
// Opus padding should only be discarded on the final packet. Once this // Opus padding should only be discarded on the final packet. Once this
// is set to true, if the reader attempts to decode any further packets it // is set to true, if the reader attempts to decode any further packets it
// will raise an error so we can indicate that the file is invalid. // will raise an error so we can indicate that the file is invalid.
bool mPaddingDiscarded; bool mPaddingDiscarded;
#endif
}; };
} // namespace mozilla } // namespace mozilla

View File

@ -153,7 +153,6 @@ th_info_init
th_packet_isheader th_packet_isheader
th_packet_iskeyframe th_packet_iskeyframe
th_setup_free th_setup_free
#ifdef MOZ_OPUS
opus_decoder_create opus_decoder_create
opus_decoder_destroy opus_decoder_destroy
opus_decoder_ctl opus_decoder_ctl
@ -172,7 +171,6 @@ opus_encoder_destroy
opus_encoder_ctl opus_encoder_ctl
opus_encode opus_encode
opus_encode_float opus_encode_float
#endif
#ifndef MOZ_NATIVE_PNG #ifndef MOZ_NATIVE_PNG
MOZ_APNG_get_first_frame_is_hidden MOZ_APNG_get_first_frame_is_hidden
MOZ_APNG_get_next_frame_blend_op MOZ_APNG_get_next_frame_blend_op

View File

@ -276,9 +276,7 @@ pref("media.fragmented-mp4.use-blank-decoder", false);
pref("media.raw.enabled", true); pref("media.raw.enabled", true);
#endif #endif
pref("media.ogg.enabled", true); pref("media.ogg.enabled", true);
#ifdef MOZ_OPUS
pref("media.opus.enabled", true); pref("media.opus.enabled", true);
#endif
#ifdef MOZ_WAVE #ifdef MOZ_WAVE
pref("media.wave.enabled", true); pref("media.wave.enabled", true);
#endif #endif

View File

@ -458,9 +458,7 @@ static nsDefaultMimeTypeEntry defaultMimeEntries [] =
{ VIDEO_OGG, "ogg" }, { VIDEO_OGG, "ogg" },
{ APPLICATION_OGG, "ogg" }, { APPLICATION_OGG, "ogg" },
{ AUDIO_OGG, "oga" }, { AUDIO_OGG, "oga" },
#ifdef MOZ_OPUS
{ AUDIO_OGG, "opus" }, { AUDIO_OGG, "opus" },
#endif
#ifdef MOZ_WEBM #ifdef MOZ_WEBM
{ VIDEO_WEBM, "webm" }, { VIDEO_WEBM, "webm" },
{ AUDIO_WEBM, "webm" }, { AUDIO_WEBM, "webm" },