/src/mozilla-central/dom/media/mp3/MP3Decoder.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
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 "MP3Decoder.h" |
8 | | #include "MediaContainerType.h" |
9 | | #include "PDMFactory.h" |
10 | | |
11 | | namespace mozilla { |
12 | | |
13 | | /* static */ |
14 | | bool |
15 | 0 | MP3Decoder::IsEnabled() { |
16 | 0 | RefPtr<PDMFactory> platform = new PDMFactory(); |
17 | 0 | return platform->SupportsMimeType(NS_LITERAL_CSTRING("audio/mpeg"), |
18 | 0 | /* DecoderDoctorDiagnostics* */ nullptr); |
19 | 0 | } |
20 | | |
21 | | /* static */ |
22 | | bool MP3Decoder::IsSupportedType(const MediaContainerType& aContainerType) |
23 | 0 | { |
24 | 0 | if (aContainerType.Type() == MEDIAMIMETYPE("audio/mp3") || |
25 | 0 | aContainerType.Type() == MEDIAMIMETYPE("audio/mpeg")) { |
26 | 0 | return IsEnabled() && (aContainerType.ExtendedType().Codecs().IsEmpty() || |
27 | 0 | aContainerType.ExtendedType().Codecs() == "mp3"); |
28 | 0 | } |
29 | 0 | return false; |
30 | 0 | } |
31 | | |
32 | | /* static */ nsTArray<UniquePtr<TrackInfo>> |
33 | | MP3Decoder::GetTracksInfo(const MediaContainerType& aType) |
34 | 0 | { |
35 | 0 | nsTArray<UniquePtr<TrackInfo>> tracks; |
36 | 0 | if (!IsSupportedType(aType)) { |
37 | 0 | return tracks; |
38 | 0 | } |
39 | 0 | |
40 | 0 | tracks.AppendElement( |
41 | 0 | CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters( |
42 | 0 | NS_LITERAL_CSTRING("audio/mpeg"), aType)); |
43 | 0 |
|
44 | 0 | return tracks; |
45 | 0 | } |
46 | | |
47 | | } // namespace mozilla |