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 "MediaContainerType.h" 9 #include "PDMFactory.h" 10 11 namespace mozilla { 12 13 /* static */ IsEnabled()14bool ADTSDecoder::IsEnabled() { 15 RefPtr<PDMFactory> platform = new PDMFactory(); 16 return platform->SupportsMimeType(NS_LITERAL_CSTRING("audio/mp4a-latm"), 17 /* DecoderDoctorDiagnostics* */ nullptr); 18 } 19 20 /* static */ IsSupportedType(const MediaContainerType & aContainerType)21bool ADTSDecoder::IsSupportedType(const MediaContainerType& aContainerType) { 22 if (aContainerType.Type() == MEDIAMIMETYPE("audio/aac") || 23 aContainerType.Type() == MEDIAMIMETYPE("audio/aacp") || 24 aContainerType.Type() == MEDIAMIMETYPE("audio/x-aac")) { 25 return IsEnabled() && (aContainerType.ExtendedType().Codecs().IsEmpty() || 26 aContainerType.ExtendedType().Codecs() == "aac"); 27 } 28 29 return false; 30 } 31 32 /* static */ GetTracksInfo(const MediaContainerType & aType)33nsTArray<UniquePtr<TrackInfo>> ADTSDecoder::GetTracksInfo( 34 const MediaContainerType& aType) { 35 nsTArray<UniquePtr<TrackInfo>> tracks; 36 if (!IsSupportedType(aType)) { 37 return tracks; 38 } 39 40 tracks.AppendElement( 41 CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters( 42 NS_LITERAL_CSTRING("audio/mp4a-latm"), aType)); 43 44 return tracks; 45 } 46 47 } // namespace mozilla 48