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 "ADTSDecoder.h"
8 : #include "ADTSDemuxer.h"
9 : #include "MediaContainerType.h"
10 : #include "MediaDecoderStateMachine.h"
11 : #include "MediaFormatReader.h"
12 : #include "PDMFactory.h"
13 :
14 : namespace mozilla {
15 :
16 : ChannelMediaDecoder*
17 0 : ADTSDecoder::Clone(MediaDecoderInit& aInit)
18 : {
19 0 : if (!IsEnabled())
20 0 : return nullptr;
21 :
22 0 : return new ADTSDecoder(aInit);
23 : }
24 :
25 : MediaDecoderStateMachine*
26 0 : ADTSDecoder::CreateStateMachine()
27 : {
28 0 : MediaDecoderReaderInit init(this);
29 0 : mReader = new MediaFormatReader(init, new ADTSDemuxer(mResource));
30 0 : return new MediaDecoderStateMachine(this, mReader);
31 : }
32 :
33 : /* static */ bool
34 0 : ADTSDecoder::IsEnabled()
35 : {
36 0 : RefPtr<PDMFactory> platform = new PDMFactory();
37 0 : return platform->SupportsMimeType(NS_LITERAL_CSTRING("audio/mp4a-latm"),
38 0 : /* DecoderDoctorDiagnostics* */ nullptr);
39 : }
40 :
41 : /* static */ bool
42 0 : ADTSDecoder::IsSupportedType(const MediaContainerType& aContainerType)
43 : {
44 0 : if (aContainerType.Type() == MEDIAMIMETYPE("audio/aac")
45 0 : || aContainerType.Type() == MEDIAMIMETYPE("audio/aacp")
46 0 : || aContainerType.Type() == MEDIAMIMETYPE("audio/x-aac")) {
47 : return
48 0 : IsEnabled()
49 0 : && (aContainerType.ExtendedType().Codecs().IsEmpty()
50 0 : || aContainerType.ExtendedType().Codecs() == "aac");
51 : }
52 :
53 0 : return false;
54 : }
55 :
56 : } // namespace mozilla
|