tor-browser

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

FlacDecoder.cpp (1241B)


      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 "FlacDecoder.h"
      8 
      9 #include "MediaContainerType.h"
     10 #include "mozilla/StaticPrefs_media.h"
     11 
     12 namespace mozilla {
     13 
     14 /* static */
     15 bool FlacDecoder::IsEnabled() { return StaticPrefs::media_flac_enabled(); }
     16 
     17 /* static */
     18 bool FlacDecoder::IsSupportedType(const MediaContainerType& aContainerType) {
     19  return IsEnabled() &&
     20         (aContainerType.Type() == MEDIAMIMETYPE("audio/flac") ||
     21          aContainerType.Type() == MEDIAMIMETYPE("audio/x-flac") ||
     22          aContainerType.Type() == MEDIAMIMETYPE("application/x-flac"));
     23 }
     24 
     25 /* static */
     26 nsTArray<UniquePtr<TrackInfo>> FlacDecoder::GetTracksInfo(
     27    const MediaContainerType& aType) {
     28  nsTArray<UniquePtr<TrackInfo>> tracks;
     29  if (!IsSupportedType(aType)) {
     30    return tracks;
     31  }
     32 
     33  tracks.AppendElement(
     34      CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters(
     35          "audio/flac"_ns, aType));
     36 
     37  return tracks;
     38 }
     39 
     40 }  // namespace mozilla