зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1195723: [flac] P8. Add flac MediaDecoder. r=kamidphish
MozReview-Commit-ID: BQ9fERFEFcg --HG-- extra : rebase_source : 04d365967a1caa1104e17b78b5b7c1fa46da27ae
This commit is contained in:
Родитель
51fc514176
Коммит
ee63d6aef9
|
@ -150,7 +150,9 @@ private:
|
|||
// Ogg
|
||||
DECL_MEDIA_PREF("media.ogg.enabled", OggEnabled, bool, true);
|
||||
DECL_MEDIA_PREF("media.format-reader.ogg", OggFormatReader, bool, true);
|
||||
// Flac
|
||||
DECL_MEDIA_PREF("media.ogg.flac.enabled", FlacInOgg, bool, false);
|
||||
DECL_MEDIA_PREF("media.flac.enabled", FlacEnabled, bool, true);
|
||||
|
||||
public:
|
||||
// Manage the singleton:
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "FlacDecoder.h"
|
||||
#include "FlacDemuxer.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaFormatReader.h"
|
||||
#include "MediaPrefs.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
MediaDecoder*
|
||||
FlacDecoder::Clone(MediaDecoderOwner* aOwner)
|
||||
{
|
||||
if (!IsEnabled())
|
||||
return nullptr;
|
||||
|
||||
return new FlacDecoder(aOwner);
|
||||
}
|
||||
|
||||
MediaDecoderStateMachine*
|
||||
FlacDecoder::CreateStateMachine()
|
||||
{
|
||||
RefPtr<MediaDecoderReader> reader =
|
||||
new MediaFormatReader(this, new FlacDemuxer(GetResource()));
|
||||
return new MediaDecoderStateMachine(this, reader);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
FlacDecoder::IsEnabled()
|
||||
{
|
||||
#ifdef MOZ_FFVPX
|
||||
return MediaPrefs::FlacEnabled();
|
||||
#else
|
||||
// Until bug 1295886 is fixed.
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
FlacDecoder::CanHandleMediaType(const nsACString& aType,
|
||||
const nsAString& aCodecs)
|
||||
{
|
||||
return IsEnabled() &&
|
||||
(aType.EqualsASCII("audio/flac") || aType.EqualsASCII("audio/x-flac") ||
|
||||
aType.EqualsASCII("application/x-flac"));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef FLAC_DECODER_H_
|
||||
#define FLAC_DECODER_H_
|
||||
|
||||
#include "MediaDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class FlacDecoder : public MediaDecoder {
|
||||
public:
|
||||
// MediaDecoder interface.
|
||||
explicit FlacDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
|
||||
MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
|
||||
MediaDecoderStateMachine* CreateStateMachine() override;
|
||||
|
||||
// Returns true if the Flac backend is pref'ed on, and we're running on a
|
||||
// platform that is likely to have decoders for the format.
|
||||
static bool IsEnabled();
|
||||
static bool CanHandleMediaType(const nsACString& aType,
|
||||
const nsAString& aCodecs);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // !FLAC_DECODER_H_
|
|
@ -5,11 +5,13 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'FlacDecoder.h',
|
||||
'FlacDemuxer.h',
|
||||
'FlacFrameParser.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'FlacDecoder.cpp',
|
||||
'FlacDemuxer.cpp',
|
||||
'FlacFrameParser.cpp',
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче