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 "AppleATDecoder.h"
8 #include "AppleDecoderModule.h"
9 #include "AppleVTDecoder.h"
10 #include "mozilla/DebugOnly.h"
11 #include "mozilla/Logging.h"
12 #include "mozilla/gfx/gfxVars.h"
13 
14 namespace mozilla {
15 
16 bool AppleDecoderModule::sInitialized = false;
17 bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true;
18 
AppleDecoderModule()19 AppleDecoderModule::AppleDecoderModule() {}
20 
~AppleDecoderModule()21 AppleDecoderModule::~AppleDecoderModule() {}
22 
23 /* static */
Init()24 void AppleDecoderModule::Init() {
25   if (sInitialized) {
26     return;
27   }
28 
29   sCanUseHardwareVideoDecoder = gfx::gfxVars::CanUseHardwareVideoDecoding();
30 
31   sInitialized = true;
32 }
33 
Startup()34 nsresult AppleDecoderModule::Startup() {
35   if (!sInitialized) {
36     return NS_ERROR_FAILURE;
37   }
38   return NS_OK;
39 }
40 
CreateVideoDecoder(const CreateDecoderParams & aParams)41 already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateVideoDecoder(
42     const CreateDecoderParams& aParams) {
43   RefPtr<MediaDataDecoder> decoder =
44       new AppleVTDecoder(aParams.VideoConfig(), aParams.mTaskQueue,
45                          aParams.mImageContainer, aParams.mOptions);
46   return decoder.forget();
47 }
48 
CreateAudioDecoder(const CreateDecoderParams & aParams)49 already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateAudioDecoder(
50     const CreateDecoderParams& aParams) {
51   RefPtr<MediaDataDecoder> decoder =
52       new AppleATDecoder(aParams.AudioConfig(), aParams.mTaskQueue);
53   return decoder.forget();
54 }
55 
SupportsMimeType(const nsACString & aMimeType,DecoderDoctorDiagnostics * aDiagnostics) const56 bool AppleDecoderModule::SupportsMimeType(
57     const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
58   return aMimeType.EqualsLiteral("audio/mpeg") ||
59          aMimeType.EqualsLiteral("audio/mp4a-latm") ||
60          aMimeType.EqualsLiteral("video/mp4") ||
61          aMimeType.EqualsLiteral("video/avc");
62 }
63 
64 }  // namespace mozilla
65