Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp
Line
Count
Source (jump to first uncovered line)
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 "AgnosticDecoderModule.h"
8
#include "OpusDecoder.h"
9
#include "TheoraDecoder.h"
10
#include "VPXDecoder.h"
11
#include "VorbisDecoder.h"
12
#include "WAVDecoder.h"
13
#include "mozilla/Logging.h"
14
#include "mozilla/StaticPrefs.h"
15
16
#ifdef MOZ_AV1
17
#include "AOMDecoder.h"
18
#endif
19
20
namespace mozilla {
21
22
bool
23
AgnosticDecoderModule::SupportsMimeType(
24
  const nsACString& aMimeType,
25
  DecoderDoctorDiagnostics* aDiagnostics) const
26
0
{
27
0
  bool supports =
28
0
    VPXDecoder::IsVPX(aMimeType) ||
29
0
    OpusDataDecoder::IsOpus(aMimeType) ||
30
0
    VorbisDataDecoder::IsVorbis(aMimeType) ||
31
0
    WaveDataDecoder::IsWave(aMimeType) ||
32
0
    TheoraDecoder::IsTheora(aMimeType);
33
0
#ifdef MOZ_AV1
34
0
  if (StaticPrefs::MediaAv1Enabled()) {
35
0
    supports |= AOMDecoder::IsAV1(aMimeType);
36
0
  }
37
0
#endif
38
0
  MOZ_LOG(sPDMLog, LogLevel::Debug, ("Agnostic decoder %s requested type",
39
0
        supports ? "supports" : "rejects"));
40
0
  return supports;
41
0
}
42
43
already_AddRefed<MediaDataDecoder>
44
AgnosticDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
45
0
{
46
0
  RefPtr<MediaDataDecoder> m;
47
0
48
0
  if (VPXDecoder::IsVPX(aParams.mConfig.mMimeType)) {
49
0
    m = new VPXDecoder(aParams);
50
0
  }
51
0
#ifdef MOZ_AV1
52
0
  else if (AOMDecoder::IsAV1(aParams.mConfig.mMimeType) &&
53
0
           StaticPrefs::MediaAv1Enabled()) {
54
0
    m = new AOMDecoder(aParams);
55
0
  }
56
0
#endif
57
0
  else if (TheoraDecoder::IsTheora(aParams.mConfig.mMimeType)) {
58
0
    m = new TheoraDecoder(aParams);
59
0
  }
60
0
61
0
  return m.forget();
62
0
}
63
64
already_AddRefed<MediaDataDecoder>
65
AgnosticDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
66
0
{
67
0
  RefPtr<MediaDataDecoder> m;
68
0
69
0
  const TrackInfo& config = aParams.mConfig;
70
0
  if (VorbisDataDecoder::IsVorbis(config.mMimeType)) {
71
0
    m = new VorbisDataDecoder(aParams);
72
0
  } else if (OpusDataDecoder::IsOpus(config.mMimeType)) {
73
0
    m = new OpusDataDecoder(aParams);
74
0
  } else if (WaveDataDecoder::IsWave(config.mMimeType)) {
75
0
    m = new WaveDataDecoder(aParams);
76
0
  }
77
0
78
0
  return m.forget();
79
0
}
80
81
} // namespace mozilla