2016-08-17 08:42:18 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "FlacDecoder.h"
|
2017-01-18 03:59:03 +03:00
|
|
|
#include "MediaContainerType.h"
|
2019-07-26 04:10:23 +03:00
|
|
|
#include "mozilla/StaticPrefs_media.h"
|
2016-08-17 08:42:18 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
bool FlacDecoder::IsEnabled() {
|
2016-08-17 08:42:18 +03:00
|
|
|
#ifdef MOZ_FFVPX
|
2019-06-28 07:09:05 +03:00
|
|
|
return StaticPrefs::media_flac_enabled();
|
2016-08-17 08:42:18 +03:00
|
|
|
#else
|
|
|
|
// Until bug 1295886 is fixed.
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
bool FlacDecoder::IsSupportedType(const MediaContainerType& aContainerType) {
|
2017-09-04 12:27:43 +03:00
|
|
|
return IsEnabled() &&
|
|
|
|
(aContainerType.Type() == MEDIAMIMETYPE("audio/flac") ||
|
|
|
|
aContainerType.Type() == MEDIAMIMETYPE("audio/x-flac") ||
|
|
|
|
aContainerType.Type() == MEDIAMIMETYPE("application/x-flac"));
|
2016-08-17 08:42:18 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
nsTArray<UniquePtr<TrackInfo>> FlacDecoder::GetTracksInfo(
|
2018-06-07 17:47:41 +03:00
|
|
|
const MediaContainerType& aType) {
|
|
|
|
nsTArray<UniquePtr<TrackInfo>> tracks;
|
|
|
|
if (!IsSupportedType(aType)) {
|
|
|
|
return tracks;
|
|
|
|
}
|
|
|
|
|
|
|
|
tracks.AppendElement(
|
|
|
|
CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters(
|
|
|
|
NS_LITERAL_CSTRING("audio/flac"), aType));
|
|
|
|
|
|
|
|
return tracks;
|
|
|
|
}
|
|
|
|
|
2016-08-17 08:42:18 +03:00
|
|
|
} // namespace mozilla
|