Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "FlacDecoder.h"
8 : #include "FlacDemuxer.h"
9 : #include "MediaContainerType.h"
10 : #include "MediaDecoderStateMachine.h"
11 : #include "MediaFormatReader.h"
12 : #include "MediaPrefs.h"
13 :
14 : namespace mozilla {
15 :
16 : ChannelMediaDecoder*
17 0 : FlacDecoder::Clone(MediaDecoderInit& aInit)
18 : {
19 0 : if (!IsEnabled()) {
20 0 : return nullptr;
21 : }
22 :
23 0 : return new FlacDecoder(aInit);
24 : }
25 :
26 : MediaDecoderStateMachine*
27 0 : FlacDecoder::CreateStateMachine()
28 : {
29 0 : MediaDecoderReaderInit init(this);
30 0 : mReader = new MediaFormatReader(init, new FlacDemuxer(mResource));
31 0 : return new MediaDecoderStateMachine(this, mReader);
32 : }
33 :
34 : /* static */ bool
35 0 : FlacDecoder::IsEnabled()
36 : {
37 : #ifdef MOZ_FFVPX
38 0 : return MediaPrefs::FlacEnabled();
39 : #else
40 : // Until bug 1295886 is fixed.
41 : return false;
42 : #endif
43 : }
44 :
45 : /* static */ bool
46 0 : FlacDecoder::IsSupportedType(const MediaContainerType& aContainerType)
47 : {
48 0 : return IsEnabled()
49 0 : && (aContainerType.Type() == MEDIAMIMETYPE("audio/flac")
50 0 : || aContainerType.Type() == MEDIAMIMETYPE("audio/x-flac")
51 0 : || aContainerType.Type() == MEDIAMIMETYPE("application/x-flac"));
52 : }
53 :
54 : } // namespace mozilla
|