OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_LOOP_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_LOOP_H_ |
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_LOOP_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_LOOP_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/single_thread_task_runner.h" | |
15 #include "base/time/tick_clock.h" | 17 #include "base/time/tick_clock.h" |
16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
17 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
18 #include "media/base/android/media_codec_bridge.h" | 20 #include "media/base/android/media_codec_bridge.h" |
19 #include "media/base/decode_status.h" | 21 #include "media/base/decode_status.h" |
20 #include "media/base/encryption_scheme.h" | 22 #include "media/base/encryption_scheme.h" |
21 #include "media/base/media_export.h" | 23 #include "media/base/media_export.h" |
22 #include "media/base/subsample_entry.h" | 24 #include "media/base/subsample_entry.h" |
23 | 25 |
24 // MediaCodecLoop is based on Android's MediaCodec API. | 26 // MediaCodecLoop is based on Android's MediaCodec API. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 // (OnKeyAdded) | 96 // (OnKeyAdded) |
95 // | | 97 // | |
96 // [Ready] | 98 // [Ready] |
97 // | 99 // |
98 // -[Any state]- | 100 // -[Any state]- |
99 // | | | 101 // | | |
100 // (Flush ok) (Flush fails) | 102 // (Flush ok) (Flush fails) |
101 // | | | 103 // | | |
102 // [Ready] [Error] | 104 // [Ready] [Error] |
103 | 105 |
104 namespace base { | |
105 class SingleThreadTaskRunner; | |
106 } | |
107 | |
108 namespace media { | 106 namespace media { |
109 | 107 |
110 class MEDIA_EXPORT MediaCodecLoop { | 108 class MEDIA_EXPORT MediaCodecLoop { |
111 public: | 109 public: |
112 // TODO(liberato): this exists in video_decoder.h and audio_decoder.h too. | 110 // TODO(liberato): this exists in video_decoder.h and audio_decoder.h too. |
113 using InitCB = base::Callback<void(bool success)>; | 111 using InitCB = base::Callback<void(bool success)>; |
114 using DecodeCB = base::Callback<void(DecodeStatus status)>; | 112 using DecodeCB = base::Callback<void(DecodeStatus status)>; |
115 | 113 |
116 // Data that the client wants to put into an input buffer. | 114 // Data that the client wants to put into an input buffer. |
117 struct InputData { | 115 struct InputData { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 virtual ~Client() {} | 195 virtual ~Client() {} |
198 }; | 196 }; |
199 | 197 |
200 // We will take ownership of |media_codec|. We will not destroy it until | 198 // We will take ownership of |media_codec|. We will not destroy it until |
201 // we are destructed. |media_codec| may not be null. | 199 // we are destructed. |media_codec| may not be null. |
202 // |sdk_level| is temporary. It is used only to decouple MediaCodecLoop from | 200 // |sdk_level| is temporary. It is used only to decouple MediaCodecLoop from |
203 // BuildInfo, until we get BuildInfo into a mockable state. | 201 // BuildInfo, until we get BuildInfo into a mockable state. |
204 MediaCodecLoop(int sdk_level, | 202 MediaCodecLoop(int sdk_level, |
205 Client* client, | 203 Client* client, |
206 std::unique_ptr<MediaCodecBridge> media_codec, | 204 std::unique_ptr<MediaCodecBridge> media_codec, |
207 scoped_refptr<base::SingleThreadTaskRunner> = | 205 scoped_refptr<base::SingleThreadTaskRunner> = nullptr); |
DaleCurtis
2017/01/25 22:33:25
Is the = nullptr even necessary? I didn't think th
gab
2017/02/13 19:57:00
Guess not, made mandatory.
| |
208 scoped_refptr<base::SingleThreadTaskRunner>()); | |
209 ~MediaCodecLoop(); | 206 ~MediaCodecLoop(); |
210 | 207 |
211 // Optionally set the tick clock used for testing. It is our caller's | 208 // Optionally set the tick clock used for testing. It is our caller's |
212 // responsibility to maintain ownership of this, since | 209 // responsibility to maintain ownership of this, since |
213 // FakeSingleThreadTaskRunner maintains a raw ptr to it also. | 210 // FakeSingleThreadTaskRunner maintains a raw ptr to it also. |
214 void SetTestTickClock(base::TickClock* test_tick_clock); | 211 void SetTestTickClock(base::TickClock* test_tick_clock); |
215 | 212 |
216 // Does the MediaCodec processing cycle: enqueues an input buffer, then | 213 // Does the MediaCodec processing cycle: enqueues an input buffer, then |
217 // dequeues output buffers. This should be called by the client when more | 214 // dequeues output buffers. This should be called by the client when more |
218 // work becomes available, such as when new input data arrives. If codec | 215 // work becomes available, such as when new input data arrives. If codec |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 | 319 |
323 // NOTE: Weak pointers must be invalidated before all other member variables. | 320 // NOTE: Weak pointers must be invalidated before all other member variables. |
324 base::WeakPtrFactory<MediaCodecLoop> weak_factory_; | 321 base::WeakPtrFactory<MediaCodecLoop> weak_factory_; |
325 | 322 |
326 DISALLOW_COPY_AND_ASSIGN(MediaCodecLoop); | 323 DISALLOW_COPY_AND_ASSIGN(MediaCodecLoop); |
327 }; | 324 }; |
328 | 325 |
329 } // namespace media | 326 } // namespace media |
330 | 327 |
331 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_LOOP_H_ | 328 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_LOOP_H_ |
OLD | NEW |