Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromecast / media / cma / test / mock_frame_consumer.h
blob582cb7c71aabbd9c5daad28ef3b0d8a4b2af2669
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_MEDIA_CMA_TEST_MOCK_FRAME_CONSUMER_H_
6 #define CHROMECAST_MEDIA_CMA_TEST_MOCK_FRAME_CONSUMER_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/macros.h"
13 namespace media {
14 class AudioDecoderConfig;
15 class VideoDecoderConfig;
18 namespace chromecast {
19 namespace media {
20 class CodedFrameProvider;
21 class DecoderBufferBase;
22 class FrameGeneratorForTest;
24 class MockFrameConsumer {
25 public:
26 explicit MockFrameConsumer(CodedFrameProvider* coded_frame_provider);
27 ~MockFrameConsumer();
29 void Configure(const std::vector<bool>& delayed_task_pattern,
30 bool last_read_aborted_by_flush,
31 scoped_ptr<FrameGeneratorForTest> frame_generator);
33 // Starts consuming frames. Invoke |done_cb| when all the expected frames
34 // have been received.
35 void Start(const base::Closure& done_cb);
37 private:
38 void ReadFrame();
39 void OnNewFrame(const scoped_refptr<DecoderBufferBase>& buffer,
40 const ::media::AudioDecoderConfig& audio_config,
41 const ::media::VideoDecoderConfig& video_config);
43 void OnFlushCompleted();
45 CodedFrameProvider* const coded_frame_provider_;
47 base::Closure done_cb_;
49 // Parameterization of the frame consumer:
50 // |delayed_task_pattern_| indicates the pattern for fetching frames,
51 // i.e. after receiving a frame, either fetch a frame right away
52 // or wait some time before fetching another frame.
53 // |pattern_idx_| is the current index in the pattern.
54 // |last_read_aborted_by_flush_| indicates whether the last buffer request
55 // should be aborted by a Flush.
56 std::vector<bool> delayed_task_pattern_;
57 size_t pattern_idx_;
58 bool last_read_aborted_by_flush_;
60 // Expected results.
61 scoped_ptr<FrameGeneratorForTest> frame_generator_;
63 DISALLOW_COPY_AND_ASSIGN(MockFrameConsumer);
66 } // namespace media
67 } // namespace chromecast
69 #endif // CHROMECAST_MEDIA_CMA_TEST_MOCK_FRAME_CONSUMER_H_