Index: media/base/android/media_codec_loop.h |
diff --git a/media/base/android/media_codec_loop.h b/media/base/android/media_codec_loop.h |
index 6889f8e0c407c5661e41fe983fc4fdfabf9a7b21..6201414fa1310ccfca7014778d3aee0136f33e77 100644 |
--- a/media/base/android/media_codec_loop.h |
+++ b/media/base/android/media_codec_loop.h |
@@ -12,6 +12,7 @@ |
#include "base/macros.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/time/tick_clock.h" |
#include "base/time/time.h" |
#include "base/timer/timer.h" |
#include "media/base/android/media_codec_bridge.h" |
@@ -192,9 +193,17 @@ class MEDIA_EXPORT MediaCodecLoop { |
// We will take ownership of |media_codec|. We will not destroy it until |
// we are destructed. |media_codec| may not be null. |
- MediaCodecLoop(Client* client, std::unique_ptr<MediaCodecBridge> media_codec); |
+ MediaCodecLoop(Client* client, |
+ std::unique_ptr<MediaCodecBridge> media_codec, |
+ scoped_refptr<base::SingleThreadTaskRunner> = |
+ scoped_refptr<base::SingleThreadTaskRunner>()); |
~MediaCodecLoop(); |
+ // Optionally set the tick clock used for testing. It is our caller's |
+ // responsibility to maintain ownership of this, since |
+ // FakeSingleThreadTaskRunner maintains a raw ptr to it also. |
+ void SetTestTickClock(base::TickClock* test_tick_clock); |
+ |
// Does the MediaCodec processing cycle: enqueues an input buffer, then |
// dequeues output buffers. This should be called by the client when more |
// work becomes available, such as when new input data arrives. If codec |
@@ -266,10 +275,6 @@ class MEDIA_EXPORT MediaCodecLoop { |
// A helper function for logging. |
static const char* AsString(State state); |
- // Used to post tasks. This class is single threaded and every method should |
- // run on this task runner. |
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
- |
State state_; |
// The client that we notify about MediaCodec events. |
@@ -297,6 +302,10 @@ class MEDIA_EXPORT MediaCodecLoop { |
// arrives at the output queue. This is valid when we're in STATE_DRAINING. |
DecodeCB pending_eos_completion_cb_; |
+ // Optional clock for use during testing. It may be null. We do not maintain |
+ // ownership of it. |
+ base::TickClock* test_tick_clock_ = nullptr; |
+ |
// NOTE: Weak pointers must be invalidated before all other member variables. |
base::WeakPtrFactory<MediaCodecLoop> weak_factory_; |