/src/mozilla-central/dom/media/platforms/wrappers/MediaDataDecoderProxy.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 "MediaDataDecoderProxy.h" |
8 | | |
9 | | namespace mozilla { |
10 | | |
11 | | RefPtr<MediaDataDecoder::InitPromise> |
12 | | MediaDataDecoderProxy::Init() |
13 | 0 | { |
14 | 0 | MOZ_ASSERT(!mIsShutdown); |
15 | 0 |
|
16 | 0 | if (!mProxyThread) { |
17 | 0 | return mProxyDecoder->Init(); |
18 | 0 | } |
19 | 0 | RefPtr<MediaDataDecoderProxy> self = this; |
20 | 0 | return InvokeAsync(mProxyThread, __func__, |
21 | 0 | [self]() { return self->mProxyDecoder->Init(); }); |
22 | 0 | } |
23 | | |
24 | | RefPtr<MediaDataDecoder::DecodePromise> |
25 | | MediaDataDecoderProxy::Decode(MediaRawData* aSample) |
26 | 0 | { |
27 | 0 | MOZ_ASSERT(!mIsShutdown); |
28 | 0 |
|
29 | 0 | if (!mProxyThread) { |
30 | 0 | return mProxyDecoder->Decode(aSample); |
31 | 0 | } |
32 | 0 | RefPtr<MediaDataDecoderProxy> self = this; |
33 | 0 | RefPtr<MediaRawData> sample = aSample; |
34 | 0 | return InvokeAsync(mProxyThread, __func__, [self, sample]() { |
35 | 0 | return self->mProxyDecoder->Decode(sample); |
36 | 0 | }); |
37 | 0 | } |
38 | | |
39 | | RefPtr<MediaDataDecoder::FlushPromise> |
40 | | MediaDataDecoderProxy::Flush() |
41 | 0 | { |
42 | 0 | MOZ_ASSERT(!mIsShutdown); |
43 | 0 |
|
44 | 0 | if (!mProxyThread) { |
45 | 0 | return mProxyDecoder->Flush(); |
46 | 0 | } |
47 | 0 | RefPtr<MediaDataDecoderProxy> self = this; |
48 | 0 | return InvokeAsync(mProxyThread, __func__, |
49 | 0 | [self]() { return self->mProxyDecoder->Flush(); }); |
50 | 0 | } |
51 | | |
52 | | RefPtr<MediaDataDecoder::DecodePromise> |
53 | | MediaDataDecoderProxy::Drain() |
54 | 0 | { |
55 | 0 | MOZ_ASSERT(!mIsShutdown); |
56 | 0 |
|
57 | 0 | if (!mProxyThread) { |
58 | 0 | return mProxyDecoder->Drain(); |
59 | 0 | } |
60 | 0 | RefPtr<MediaDataDecoderProxy> self = this; |
61 | 0 | return InvokeAsync(mProxyThread, __func__, |
62 | 0 | [self]() { return self->mProxyDecoder->Drain(); }); |
63 | 0 | } |
64 | | |
65 | | RefPtr<ShutdownPromise> |
66 | | MediaDataDecoderProxy::Shutdown() |
67 | 0 | { |
68 | 0 | MOZ_ASSERT(!mIsShutdown); |
69 | 0 |
|
70 | | #if defined(DEBUG) |
71 | | mIsShutdown = true; |
72 | | #endif |
73 | |
|
74 | 0 | if (!mProxyThread) { |
75 | 0 | return mProxyDecoder->Shutdown(); |
76 | 0 | } |
77 | 0 | RefPtr<MediaDataDecoderProxy> self = this; |
78 | 0 | return InvokeAsync(mProxyThread, __func__, |
79 | 0 | [self]() { return self->mProxyDecoder->Shutdown(); }); |
80 | 0 | } |
81 | | |
82 | | nsCString |
83 | | MediaDataDecoderProxy::GetDescriptionName() const |
84 | 0 | { |
85 | 0 | MOZ_ASSERT(!mIsShutdown); |
86 | 0 |
|
87 | 0 | return mProxyDecoder->GetDescriptionName(); |
88 | 0 | } |
89 | | |
90 | | bool |
91 | | MediaDataDecoderProxy::IsHardwareAccelerated(nsACString& aFailureReason) const |
92 | 0 | { |
93 | 0 | MOZ_ASSERT(!mIsShutdown); |
94 | 0 |
|
95 | 0 | return mProxyDecoder->IsHardwareAccelerated(aFailureReason); |
96 | 0 | } |
97 | | |
98 | | void |
99 | | MediaDataDecoderProxy::SetSeekThreshold(const media::TimeUnit& aTime) |
100 | 0 | { |
101 | 0 | MOZ_ASSERT(!mIsShutdown); |
102 | 0 |
|
103 | 0 | if (!mProxyThread) { |
104 | 0 | mProxyDecoder->SetSeekThreshold(aTime); |
105 | 0 | return; |
106 | 0 | } |
107 | 0 | RefPtr<MediaDataDecoderProxy> self = this; |
108 | 0 | media::TimeUnit time = aTime; |
109 | 0 | mProxyThread->Dispatch(NS_NewRunnableFunction( |
110 | 0 | "MediaDataDecoderProxy::SetSeekThreshold", |
111 | 0 | [self, time] { self->mProxyDecoder->SetSeekThreshold(time); })); |
112 | 0 | } |
113 | | |
114 | | bool |
115 | | MediaDataDecoderProxy::SupportDecoderRecycling() const |
116 | 0 | { |
117 | 0 | MOZ_ASSERT(!mIsShutdown); |
118 | 0 |
|
119 | 0 | return mProxyDecoder->SupportDecoderRecycling(); |
120 | 0 | } |
121 | | |
122 | | MediaDataDecoder::ConversionRequired |
123 | | MediaDataDecoderProxy::NeedsConversion() const |
124 | 0 | { |
125 | 0 | MOZ_ASSERT(!mIsShutdown); |
126 | 0 |
|
127 | 0 | return mProxyDecoder->NeedsConversion(); |
128 | 0 | } |
129 | | |
130 | | } // namespace mozilla |