blob: acdce71705f1a7e9ed65a4bacc03600c5a977c27 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include <memory>
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
namespace media {
class AudioDecoderConfig;
class VideoDecoderConfig;
namespace chromecast {
namespace media {
class CodedFrameProvider;
class DecoderBufferBase;
class FrameGeneratorForTest;
class MockFrameConsumer {
explicit MockFrameConsumer(CodedFrameProvider* coded_frame_provider);
void Configure(const std::vector<bool>& delayed_task_pattern,
bool last_read_aborted_by_flush,
std::unique_ptr<FrameGeneratorForTest> frame_generator);
// Starts consuming frames. Invoke |done_cb| when all the expected frames
// have been received.
void Start(const base::Closure& done_cb);
void ReadFrame();
void OnNewFrame(const scoped_refptr<DecoderBufferBase>& buffer,
const ::media::AudioDecoderConfig& audio_config,
const ::media::VideoDecoderConfig& video_config);
void OnFlushCompleted();
CodedFrameProvider* const coded_frame_provider_;
base::Closure done_cb_;
// Parameterization of the frame consumer:
// |delayed_task_pattern_| indicates the pattern for fetching frames,
// i.e. after receiving a frame, either fetch a frame right away
// or wait some time before fetching another frame.
// |pattern_idx_| is the current index in the pattern.
// |last_read_aborted_by_flush_| indicates whether the last buffer request
// should be aborted by a Flush.
std::vector<bool> delayed_task_pattern_;
size_t pattern_idx_;
bool last_read_aborted_by_flush_;
// Expected results.
std::unique_ptr<FrameGeneratorForTest> frame_generator_;
} // namespace media
} // namespace chromecast