ADTSDecoder.cpp (1441B)
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 9 #include "MediaContainerType.h" 10 #include "PDMFactory.h" 11 12 namespace mozilla { 13 14 /* static */ 15 bool ADTSDecoder::IsEnabled() { 16 RefPtr<PDMFactory> platform = new PDMFactory(); 17 return !platform->SupportsMimeType("audio/mp4a-latm"_ns).isEmpty(); 18 } 19 20 /* static */ 21 bool 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 */ 33 nsTArray<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 "audio/mp4a-latm"_ns, aType)); 43 44 return tracks; 45 } 46 47 } // namespace mozilla