Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/PlatformDecoderModule.h
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
#if !defined(PlatformDecoderModule_h_)
8
#define PlatformDecoderModule_h_
9
10
#include "DecoderDoctorLogger.h"
11
#include "GMPCrashHelper.h"
12
#include "MediaEventSource.h"
13
#include "MediaInfo.h"
14
#include "MediaResult.h"
15
#include "mozilla/EnumSet.h"
16
#include "mozilla/MozPromise.h"
17
#include "mozilla/RefPtr.h"
18
#include "mozilla/TaskQueue.h"
19
#include "mozilla/layers/KnowsCompositor.h"
20
#include "mozilla/layers/LayersTypes.h"
21
#include "nsTArray.h"
22
#include <queue>
23
24
namespace mozilla {
25
class TrackInfo;
26
class AudioInfo;
27
class VideoInfo;
28
class MediaRawData;
29
class DecoderDoctorDiagnostics;
30
31
namespace layers {
32
class ImageContainer;
33
} // namespace layers
34
35
namespace dom {
36
class RemoteDecoderModule;
37
}
38
39
class MediaDataDecoder;
40
class TaskQueue;
41
class CDMProxy;
42
43
static LazyLogModule sPDMLog("PlatformDecoderModule");
44
45
struct MOZ_STACK_CLASS CreateDecoderParams final
46
{
47
0
  explicit CreateDecoderParams(const TrackInfo& aConfig) : mConfig(aConfig) { }
48
49
  enum class Option
50
  {
51
    Default,
52
    LowLatency,
53
  };
54
  using OptionSet = EnumSet<Option>;
55
56
  struct UseNullDecoder
57
  {
58
0
    UseNullDecoder() = default;
59
0
    explicit UseNullDecoder(bool aUseNullDecoder) : mUse(aUseNullDecoder) { }
60
    bool mUse = false;
61
  };
62
63
  // Do not wrap H264 decoder in a H264Converter.
64
  struct NoWrapper
65
  {
66
0
    NoWrapper() = default;
67
    explicit NoWrapper(bool aDontUseWrapper)
68
      : mDontUseWrapper(aDontUseWrapper)
69
0
    {
70
0
    }
71
    bool mDontUseWrapper = false;
72
  };
73
74
  struct VideoFrameRate
75
  {
76
0
    VideoFrameRate() = default;
77
0
    explicit VideoFrameRate(float aFramerate) : mValue(aFramerate) { }
78
    float mValue = 0.0f;
79
  };
80
81
  template <typename T1, typename... Ts>
82
  CreateDecoderParams(const TrackInfo& aConfig, T1&& a1, Ts&&... args)
83
    : mConfig(aConfig)
84
0
  {
85
0
    Set(std::forward<T1>(a1), std::forward<Ts>(args)...);
86
0
  }
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue> const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int>, mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue> const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int>&&, mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&)
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue>&>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue>&)
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&)
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::layers::ImageContainer*, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::layers::ImageContainer*&&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::CreateDecoderParams::VideoFrameRate, mozilla::TrackInfo::TrackType>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::CreateDecoderParams::VideoFrameRate&&, mozilla::TrackInfo::TrackType&&)
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics* const&, RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics* const&, RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*&&, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: mozilla::CreateDecoderParams::CreateDecoderParams<RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics*&, RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(mozilla::TrackInfo const&, RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics*&, RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
87
88
  const VideoInfo& VideoConfig() const
89
0
  {
90
0
    MOZ_ASSERT(mConfig.IsVideo());
91
0
    return *mConfig.GetAsVideoInfo();
92
0
  }
93
94
  const AudioInfo& AudioConfig() const
95
0
  {
96
0
    MOZ_ASSERT(mConfig.IsAudio());
97
0
    return *mConfig.GetAsAudioInfo();
98
0
  }
99
100
  layers::LayersBackend GetLayersBackend() const
101
0
  {
102
0
    if (mKnowsCompositor) {
103
0
      return mKnowsCompositor->GetCompositorBackendType();
104
0
    }
105
0
    return layers::LayersBackend::LAYERS_NONE;
106
0
  }
107
108
  const TrackInfo& mConfig;
109
  TaskQueue* mTaskQueue = nullptr;
110
  DecoderDoctorDiagnostics* mDiagnostics = nullptr;
111
  layers::ImageContainer* mImageContainer = nullptr;
112
  MediaResult* mError = nullptr;
113
  RefPtr<layers::KnowsCompositor> mKnowsCompositor;
114
  RefPtr<GMPCrashHelper> mCrashHelper;
115
  UseNullDecoder mUseNullDecoder;
116
  NoWrapper mNoWrapper;
117
  TrackInfo::TrackType mType = TrackInfo::kUndefinedTrack;
118
  MediaEventProducer<TrackInfo::TrackType>* mOnWaitingForKeyEvent = nullptr;
119
  OptionSet mOptions = OptionSet(Option::Default);
120
  VideoFrameRate mRate;
121
122
private:
123
0
  void Set(TaskQueue* aTaskQueue) { mTaskQueue = aTaskQueue; }
124
  void Set(DecoderDoctorDiagnostics* aDiagnostics)
125
0
  {
126
0
    mDiagnostics = aDiagnostics;
127
0
  }
128
  void Set(layers::ImageContainer* aImageContainer)
129
0
  {
130
0
    mImageContainer = aImageContainer;
131
0
  }
132
0
  void Set(MediaResult* aError) { mError = aError; }
133
0
  void Set(GMPCrashHelper* aCrashHelper) { mCrashHelper = aCrashHelper; }
134
0
  void Set(UseNullDecoder aUseNullDecoder) { mUseNullDecoder = aUseNullDecoder; }
135
0
  void Set(NoWrapper aNoWrapper) { mNoWrapper = aNoWrapper; }
136
0
  void Set(OptionSet aOptions) { mOptions = aOptions; }
137
0
  void Set(VideoFrameRate aRate) { mRate = aRate; }
138
  void Set(layers::KnowsCompositor* aKnowsCompositor)
139
0
  {
140
0
    if (aKnowsCompositor) {
141
0
      mKnowsCompositor = aKnowsCompositor;
142
0
      MOZ_ASSERT(aKnowsCompositor->IsThreadSafe());
143
0
    }
144
0
  }
145
  void Set(TrackInfo::TrackType aType)
146
0
  {
147
0
    mType = aType;
148
0
  }
149
  void Set(MediaEventProducer<TrackInfo::TrackType>* aOnWaitingForKey)
150
0
  {
151
0
    mOnWaitingForKeyEvent = aOnWaitingForKey;
152
0
  }
153
  template <typename T1, typename T2, typename... Ts>
154
  void Set(T1&& a1, T2&& a2, Ts&&... args)
155
0
  {
156
0
    Set(std::forward<T1>(a1));
157
0
    Set(std::forward<T2>(a2), std::forward<Ts>(args)...);
158
0
  }
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::TaskQueue> const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int>, mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&>(RefPtr<mozilla::TaskQueue> const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int>&&, mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int>, mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&>(mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int>&&, mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&>(mozilla::TrackInfo::TrackType&, RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&>(RefPtr<mozilla::layers::ImageContainer> const&, RefPtr<mozilla::layers::KnowsCompositor>&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*>(RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*>(RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*>(mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*>(mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*>(mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::layers::ImageContainer*, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::layers::ImageContainer*&&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::layers::ImageContainer*, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::layers::ImageContainer*&&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::layers::ImageContainer*, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(mozilla::layers::ImageContainer*&&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(RefPtr<mozilla::GMPCrashHelper>&, mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::CreateDecoderParams::UseNullDecoder, mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(mozilla::CreateDecoderParams::UseNullDecoder&&, mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::MediaResult*, mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(mozilla::MediaResult*&&, mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::TrackInfo::TrackType, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(mozilla::TrackInfo::TrackType&&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*, mozilla::CreateDecoderParams::VideoFrameRate>(mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>*&&, mozilla::CreateDecoderParams::VideoFrameRate&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::CreateDecoderParams::VideoFrameRate, mozilla::TrackInfo::TrackType>(RefPtr<mozilla::TaskQueue>&, RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::CreateDecoderParams::VideoFrameRate&&, mozilla::TrackInfo::TrackType&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::CreateDecoderParams::VideoFrameRate, mozilla::TrackInfo::TrackType>(RefPtr<mozilla::layers::KnowsCompositor>&, mozilla::CreateDecoderParams::VideoFrameRate&&, mozilla::TrackInfo::TrackType&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::CreateDecoderParams::VideoFrameRate, mozilla::TrackInfo::TrackType>(mozilla::CreateDecoderParams::VideoFrameRate&&, mozilla::TrackInfo::TrackType&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics* const&, RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics* const&, RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*&&, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::DecoderDoctorDiagnostics* const&, RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::DecoderDoctorDiagnostics* const&, RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*&&, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(RefPtr<mozilla::layers::ImageContainer> const&, mozilla::MediaResult*&&, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::MediaResult*, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::MediaResult*&&, RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(RefPtr<mozilla::layers::KnowsCompositor> const&, RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(RefPtr<mozilla::GMPCrashHelper> const&, mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::CreateDecoderParams::UseNullDecoder const&, mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::CreateDecoderParams::NoWrapper const&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&>(mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics*&, RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(RefPtr<mozilla::TaskQueue> const&, mozilla::DecoderDoctorDiagnostics*&, RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::DecoderDoctorDiagnostics*&, RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(mozilla::DecoderDoctorDiagnostics*&, RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(RefPtr<mozilla::layers::ImageContainer>&, RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(RefPtr<mozilla::layers::KnowsCompositor>&, RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(RefPtr<mozilla::GMPCrashHelper>&, mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(mozilla::TrackInfo::TrackType const&, mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(mozilla::MediaEventProducer<mozilla::TrackInfo::TrackType>* const&, mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(mozilla::EnumSet<mozilla::CreateDecoderParams::Option, unsigned int> const&, mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
Unexecuted instantiation: void mozilla::CreateDecoderParams::Set<mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*>(mozilla::CreateDecoderParams::VideoFrameRate const&, mozilla::MediaResult*&&)
159
};
160
161
// The PlatformDecoderModule interface is used by the MediaFormatReader to
162
// abstract access to decoders provided by various
163
// platforms.
164
// Each platform (Windows, MacOSX, Linux, B2G etc) must implement a
165
// PlatformDecoderModule to provide access to its decoders in order to get
166
// decompressed H.264/AAC from the MediaFormatReader.
167
//
168
// Decoding is asynchronous, and should be performed on the task queue
169
// provided if the underlying platform isn't already exposing an async API.
170
//
171
// A cross-platform decoder module that discards input and produces "blank"
172
// output samples exists for testing, and is created when the pref
173
// "media.use-blank-decoder" is true.
174
175
class PlatformDecoderModule
176
{
177
public:
178
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PlatformDecoderModule)
179
180
  // Perform any per-instance initialization.
181
  // This is called on the decode task queue.
182
0
  virtual nsresult Startup() { return NS_OK; }
183
184
  // Indicates if the PlatformDecoderModule supports decoding of aMimeType.
185
  virtual bool
186
  SupportsMimeType(const nsACString& aMimeType,
187
                   DecoderDoctorDiagnostics* aDiagnostics) const = 0;
188
189
  virtual bool
190
  Supports(const TrackInfo& aTrackInfo,
191
           DecoderDoctorDiagnostics* aDiagnostics) const
192
0
  {
193
0
    if (!SupportsMimeType(aTrackInfo.mMimeType, aDiagnostics)) {
194
0
      return false;
195
0
    }
196
0
    const auto videoInfo = aTrackInfo.GetAsVideoInfo();
197
0
    return !videoInfo || SupportsBitDepth(videoInfo->mBitDepth, aDiagnostics);
198
0
  }
199
200
protected:
201
0
  PlatformDecoderModule() { }
202
0
  virtual ~PlatformDecoderModule() { }
203
204
  friend class H264Converter;
205
  friend class PDMFactory;
206
  friend class dom::RemoteDecoderModule;
207
  friend class EMEDecoderModule;
208
209
  // Indicates if the PlatformDecoderModule supports decoding of aBitDepth.
210
  // Should override this method when the platform can support bitDepth != 8.
211
  virtual bool SupportsBitDepth(const uint8_t aBitDepth,
212
                                DecoderDoctorDiagnostics* aDiagnostics) const
213
0
  {
214
0
    return aBitDepth == 8;
215
0
  }
216
217
  // Creates a Video decoder. The layers backend is passed in so that
218
  // decoders can determine whether hardware accelerated decoding can be used.
219
  // Asynchronous decoding of video should be done in runnables dispatched
220
  // to aVideoTaskQueue. If the task queue isn't needed, the decoder should
221
  // not hold a reference to it.
222
  // On Windows the task queue's threads in have MSCOM initialized with
223
  // COINIT_MULTITHREADED.
224
  // Returns nullptr if the decoder can't be created.
225
  // It is safe to store a reference to aConfig.
226
  // This is called on the decode task queue.
227
  virtual already_AddRefed<MediaDataDecoder>
228
  CreateVideoDecoder(const CreateDecoderParams& aParams) = 0;
229
230
  // Creates an Audio decoder with the specified properties.
231
  // Asynchronous decoding of audio should be done in runnables dispatched to
232
  // aAudioTaskQueue. If the task queue isn't needed, the decoder should
233
  // not hold a reference to it.
234
  // Returns nullptr if the decoder can't be created.
235
  // On Windows the task queue's threads in have MSCOM initialized with
236
  // COINIT_MULTITHREADED.
237
  // It is safe to store a reference to aConfig.
238
  // This is called on the decode task queue.
239
  virtual already_AddRefed<MediaDataDecoder>
240
  CreateAudioDecoder(const CreateDecoderParams& aParams) = 0;
241
};
242
243
DDLoggedTypeDeclName(MediaDataDecoder);
244
245
// MediaDataDecoder is the interface exposed by decoders created by the
246
// PlatformDecoderModule's Create*Decoder() functions. The type of
247
// media data that the decoder accepts as valid input and produces as
248
// output is determined when the MediaDataDecoder is created.
249
//
250
// Unless otherwise noted, all functions are only called on the decode task
251
// queue.  An exception is the MediaDataDecoder in
252
// MediaFormatReader::IsVideoAccelerated() for which all calls (Init(),
253
// IsHardwareAccelerated(), and Shutdown()) are from the main thread.
254
//
255
// Don't block inside these functions, unless it's explicitly noted that you
256
// should (like in Flush()).
257
//
258
// Decoding is done asynchronously. Any async work can be done on the
259
// TaskQueue passed into the PlatformDecoderModules's Create*Decoder()
260
// function. This may not be necessary for platforms with async APIs
261
// for decoding.
262
class MediaDataDecoder : public DecoderDoctorLifeLogger<MediaDataDecoder>
263
{
264
protected:
265
0
  virtual ~MediaDataDecoder() { }
266
267
public:
268
  typedef TrackInfo::TrackType TrackType;
269
  typedef nsTArray<RefPtr<MediaData>> DecodedData;
270
  typedef MozPromise<TrackType, MediaResult, /* IsExclusive = */ true>
271
    InitPromise;
272
  typedef MozPromise<DecodedData, MediaResult, /* IsExclusive = */ true>
273
    DecodePromise;
274
  typedef MozPromise<bool, MediaResult, /* IsExclusive = */ true> FlushPromise;
275
276
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDecoder)
277
278
  // Initialize the decoder. The decoder should be ready to decode once
279
  // promise resolves. The decoder should do any initialization here, rather
280
  // than in its constructor or PlatformDecoderModule::Create*Decoder(),
281
  // so that if the MediaFormatReader needs to shutdown during initialization,
282
  // it can call Shutdown() to cancel this operation. Any initialization
283
  // that requires blocking the calling thread in this function *must*
284
  // be done here so that it can be canceled by calling Shutdown()!
285
  virtual RefPtr<InitPromise> Init() = 0;
286
287
  // Inserts a sample into the decoder's decode pipeline. The DecodePromise will
288
  // be resolved with the decoded MediaData. In case the decoder needs more
289
  // input, the DecodePromise may be resolved with an empty array of samples to
290
  // indicate that Decode should be called again before a MediaData is returned.
291
  virtual RefPtr<DecodePromise> Decode(MediaRawData* aSample) = 0;
292
293
  // Causes all complete samples in the pipeline that can be decoded to be
294
  // output. If the decoder can't produce samples from the current output,
295
  // it drops the input samples. The decoder may be holding onto samples
296
  // that are required to decode samples that it expects to get in future.
297
  // This is called when the demuxer reaches end of stream.
298
  // This function is asynchronous.
299
  // The MediaDataDecoder shall resolve the pending DecodePromise with drained
300
  // samples. Drain will be called multiple times until the resolved
301
  // DecodePromise is empty which indicates that there are no more samples to
302
  // drain.
303
  virtual RefPtr<DecodePromise> Drain() = 0;
304
305
  // Causes all samples in the decoding pipeline to be discarded. When this
306
  // promise resolves, the decoder must be ready to accept new data for
307
  // decoding. This function is called when the demuxer seeks, before decoding
308
  // resumes after the seek. The current DecodePromise if any shall be rejected
309
  // with NS_ERROR_DOM_MEDIA_CANCELED
310
  virtual RefPtr<FlushPromise> Flush() = 0;
311
312
  // Cancels all init/decode/drain operations, and shuts down the decoder. The
313
  // platform decoder should clean up any resources it's using and release
314
  // memory etc. The shutdown promise will be resolved once the decoder has
315
  // completed shutdown. The reader calls Flush() before calling Shutdown(). The
316
  // reader will delete the decoder once the promise is resolved.
317
  // The ShutdownPromise must only ever be resolved.
318
  virtual RefPtr<ShutdownPromise> Shutdown() = 0;
319
320
  // Called from the state machine task queue or main thread. Decoder needs to
321
  // decide whether or not hardware acceleration is supported after creating.
322
  // It doesn't need to call Init() before calling this function.
323
  virtual bool IsHardwareAccelerated(nsACString& aFailureReason) const
324
0
  {
325
0
    return false;
326
0
  }
327
328
  // Return the name of the MediaDataDecoder, only used for decoding.
329
  // May be accessed in a non thread-safe fashion.
330
  virtual nsCString GetDescriptionName() const = 0;
331
332
  // Set a hint of seek target time to decoder. Decoder will drop any decoded
333
  // data which pts is smaller than this value. This threshold needs to be clear
334
  // after reset decoder.
335
  // Decoder may not honor this value. However, it'd be better that
336
  // video decoder implements this API to improve seek performance.
337
  // Note: it should be called before Input() or after Flush().
338
0
  virtual void SetSeekThreshold(const media::TimeUnit& aTime) { }
339
340
  // When playing adaptive playback, recreating an Android video decoder will
341
  // cause the transition not smooth during resolution change.
342
  // Reuse the decoder if the decoder support recycling.
343
  // Currently, only Android video decoder will return true.
344
0
  virtual bool SupportDecoderRecycling() const { return false; }
345
346
  enum class ConversionRequired
347
  {
348
    kNeedNone = 0,
349
    kNeedAVCC = 1,
350
    kNeedAnnexB = 2,
351
  };
352
353
  // Indicates that the decoder requires a specific format.
354
  // The demuxed data will be converted accordingly before feeding it to
355
  // Decode().
356
  virtual ConversionRequired NeedsConversion() const
357
0
  {
358
0
    return ConversionRequired::kNeedNone;
359
0
  }
360
};
361
362
} // namespace mozilla
363
364
#endif