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_
10 #include "base/callback.h"
11 #include "base/macros.h"
14 class AudioDecoderConfig
;
15 class VideoDecoderConfig
;
18 namespace chromecast
{
20 class CodedFrameProvider
;
21 class DecoderBufferBase
;
22 class FrameGeneratorForTest
;
24 class MockFrameConsumer
{
26 explicit MockFrameConsumer(CodedFrameProvider
* coded_frame_provider
);
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
);
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_
;
58 bool last_read_aborted_by_flush_
;
61 scoped_ptr
<FrameGeneratorForTest
> frame_generator_
;
63 DISALLOW_COPY_AND_ASSIGN(MockFrameConsumer
);
67 } // namespace chromecast
69 #endif // CHROMECAST_MEDIA_CMA_TEST_MOCK_FRAME_CONSUMER_H_