tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MP3Decoder.cpp (1364B)


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