Files
palemoon27/dom/media/MP3Decoder.cpp
T
roytam1 0be1a20aba import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1206977: P1. Remove unused PDM function members. r=cpearce (3ff104135b)
- Bug 1193670: P1. Remove use of SharedDecoderManager. r=cpearce (adb5606e3e)
- Bug 1193670: P2. Remove use of SharedDecoderManager from MediaDecoderReader. r=cpearce (61b9170c51)
- Bug 1194612: P1. Dont reject init promise when initialising H264Converter. r=alfredo (d7d9e81361)
- Bug 1194612: P2. Don't drop first sample with SPS/PPS NALs. r=alfredo (ea42652155)
- Bug 1194612: P3. Remove redundant member. r=alfredo (2d30f940c9)
- Bug 1195625 - Use correct TaskQueue in SharedDecoderManager and H264Converter promise. r=jya (87e52cd322)
- Bug 1194518 - Part 1: Passthrough decoder wrapper, useful to spy on MediaFormatReader-decoder calls. r=jya (8e6f7df905)
- Bug 1194518 - Part 2: Using passthrough wrapper if pref 'media.fuzz.vdeo-decode-passthrough' is true. r=jya (2a50be71f0)
- Bug 1194518 - Part 3: Delaying decoder wrapper, ensures a decoder appears consistently slow. r=jya (9d461352e5)
- Bug 1194518 - Part 4: Using delaying wrapper according to pref 'media.fuzz.video-decode-minimum-frame-interval-ms'. r=jya (9ec9684024)
- Bug 1194518 - Part 5: Using std::deque instead of nsTArray to store delayed frames. r=jya (6f3f26578c)
- Bug 1197145 - Added BaseTimeDuration::IsZero(), BaseTimeDuration::operator bool(), TimeStamp::operator bool(). r=nfroyd (1ba008c9fa)
- Bug 1202556 - Detect underflow in TimeStamp addition/subtraction operators; r=froydnj (864a288877)
- Bug 1176731 - Don't mark static inline functions as MFBT_API in TimeStamp.h. r=Waldo (6c94439c61)
- bug 1170586 - Make TimeStamp::FromSystemTime available on iOS. r=froydnj (f9ae7bd8b8)
- Bug 1193670: P3. Remove no longer needed SharedDecoderManager class. r=cpearce (c56ef98e6d)
- Bug 1206977: P2. Wrap PDM creation in a new PDMFactory class. r=cpearce (6425ab58ca)
- Bug 1206977: P3. Allow PDM fallback. r=cpearce (6cce420063)
- Bug 1206977: P4. Add AgnosticDecoderModule object. r=cpearce (1d4581f74c)
- Bug 1206977: P5. Update PlatformDecoderModule documentation. r=cpearce (af14651d29)
- Bug 1206977: P6. Make PlatformDecoderModule::SupportsMimeType pure virtual. r=cpearce (f328eb0a48)
- Bug 1146086: Properly marking overridden member with override keyword. a=bustage (c809b2311c)
- Bug 1204776: P1. Have the PlatformDecoderModules use their own log. r=cpearce (b8565d268b)
- Bug 1204776: P2. Make Apple PDM use PlatformDecoderModule log. r=cpearce (74b9985af8)
- Bug 1204776: P3. Have FFmpeg PDM use PlatformDecoderModule log. r=cpearce (caa498a139)
- Bug 1204776: P4. Have VPX/Opus/Vorbis decoder use PlatformDecoderModule log. r=cpearce (f2fce6c79a)
- fix (215c918930)
- Bug 1206977: [webm] P7. Remove IntelWebMVideoDecoder. r=kinetik (c455347fe1)
- Bug 1206977: P8. Have PDMFactory directly manage the EMEDecoderModule. r=cpearce (d830cbe570)
- Bug 1212164: Prevent use of demuxer before initialization completes. r=cpearce (99c268d31d)
- Bug 1152652: Part1. Use mStandardMozillaStyle for crypto classes. r=edwin (af58e4e822)
- Bug 1206977: P9. Ensure PDMs are only ever created through the PDMFactory. r=cpearce (4d7375ea3d)
- Bug 1206977: P10. Remove redundant code. r=cpearce (8abd18ffe1)
- Bug 1206977: P11. Don't rely on SupportsMimeType to determine if a track can be played. r=cpearce (b569a8f5e1)
- Bug 1212246. Part 1 - remove the aBorrowedTaskQueue parameter from the MediaDecoderReader constructor. r=jya. (0f481aa22b)
- Bug 1212246. Part 2 - remove mTaskQueueIsBorrowed and unnecessary checks for mTaskQueue is never null. r=jya. (27ec74d634)
- Bug 1212723. Part 1 - don't share mBufferedState per bug 1212723 comment 6. r=jya. (59e1b89bee)
- Bug 1212723. Part 2 - remove unused argument aCloneDonor from MediaDecoderReader::Init(). r=jya. (45bc778f41)
2022-10-13 09:51:06 +08:00

83 lines
2.0 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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 "MP3Decoder.h"
#include "MediaDecoderStateMachine.h"
#include "MediaFormatReader.h"
#include "MP3Demuxer.h"
#include "mozilla/Preferences.h"
#include "PDMFactory.h"
namespace mozilla {
MediaDecoder*
MP3Decoder::Clone() {
if (!IsEnabled()) {
return nullptr;
}
return new MP3Decoder();
}
MediaDecoderStateMachine*
MP3Decoder::CreateStateMachine() {
nsRefPtr<MediaDecoderReader> reader =
new MediaFormatReader(this, new mp3::MP3Demuxer(GetResource()));
return new MediaDecoderStateMachine(this, reader);
}
static already_AddRefed<MediaDataDecoder>
CreateTestMP3Decoder(AudioInfo& aConfig)
{
PDMFactory::Init();
nsRefPtr<PDMFactory> platform = new PDMFactory();
nsRefPtr<MediaDataDecoder> decoder(
platform->CreateDecoder(aConfig, nullptr, nullptr));
return decoder.forget();
}
static bool
CanCreateMP3Decoder()
{
static bool haveCachedResult = false;
static bool result = false;
if (haveCachedResult) {
return result;
}
AudioInfo config;
config.mMimeType = "audio/mpeg";
config.mRate = 48000;
config.mChannels = 2;
config.mBitDepth = 16;
nsRefPtr<MediaDataDecoder> decoder(CreateTestMP3Decoder(config));
if (decoder) {
result = true;
}
haveCachedResult = true;
return result;
}
/* static */
bool
MP3Decoder::IsEnabled() {
return CanCreateMP3Decoder();
}
/* static */
bool MP3Decoder::CanHandleMediaType(const nsACString& aType,
const nsAString& aCodecs)
{
if (aType.EqualsASCII("audio/mp3") || aType.EqualsASCII("audio/mpeg")) {
return CanCreateMP3Decoder() &&
(aCodecs.IsEmpty() || aCodecs.EqualsASCII("mp3"));
}
return false;
}
} // namespace mozilla