Line data Source code
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 "DummyMediaDataDecoder.h"
8 :
9 : namespace mozilla {
10 :
11 0 : class NullVideoDataCreator : public DummyDataCreator {
12 : public:
13 0 : NullVideoDataCreator() {}
14 :
15 0 : already_AddRefed<MediaData> Create(MediaRawData* aSample) override
16 : {
17 : // Create a dummy VideoData with no image. This gives us something to
18 : // send to media streams if necessary.
19 : RefPtr<VideoData> v(new VideoData(aSample->mOffset,
20 : aSample->mTime,
21 : aSample->mDuration,
22 0 : aSample->mKeyframe,
23 : aSample->mTimecode,
24 0 : gfx::IntSize(),
25 0 : 0));
26 0 : return v.forget();
27 : }
28 : };
29 :
30 0 : class NullDecoderModule : public PlatformDecoderModule {
31 : public:
32 :
33 : // Decode thread.
34 : already_AddRefed<MediaDataDecoder>
35 0 : CreateVideoDecoder(const CreateDecoderParams& aParams) override {
36 0 : UniquePtr<DummyDataCreator> creator = MakeUnique<NullVideoDataCreator>();
37 : RefPtr<MediaDataDecoder> decoder =
38 0 : new DummyMediaDataDecoder(Move(creator), "null media data decoder", aParams);
39 0 : return decoder.forget();
40 : }
41 :
42 : // Decode thread.
43 : already_AddRefed<MediaDataDecoder>
44 0 : CreateAudioDecoder(const CreateDecoderParams& aParams) override {
45 0 : MOZ_ASSERT(false, "Audio decoders are unsupported.");
46 : return nullptr;
47 : }
48 :
49 : bool
50 0 : SupportsMimeType(const nsACString& aMimeType,
51 : DecoderDoctorDiagnostics* aDiagnostics) const override
52 : {
53 0 : return true;
54 : }
55 : };
56 :
57 0 : already_AddRefed<PlatformDecoderModule> CreateNullDecoderModule()
58 : {
59 0 : RefPtr<PlatformDecoderModule> pdm = new NullDecoderModule();
60 0 : return pdm.forget();
61 : }
62 :
63 : } // namespace mozilla
|