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. 4 5 #ifndef CHROMECAST_MEDIA_CMA_TEST_FRAME_GENERATOR_FOR_TEST_H_ 6 #define CHROMECAST_MEDIA_CMA_TEST_FRAME_GENERATOR_FOR_TEST_H_ 7 8 #include <stddef.h> 9 10 #include <vector> 11 12 #include "base/macros.h" 13 #include "base/memory/ref_counted.h" 14 #include "base/time/time.h" 15 16 namespace chromecast { 17 namespace media { 18 class DecoderBufferBase; 19 20 class FrameGeneratorForTest { 21 public: 22 // Parameters used to generate frames. 23 struct FrameSpec { 24 FrameSpec(); 25 ~FrameSpec(); 26 27 // Indicates whether the frame comes with a new decoder configuration. 28 bool has_config; 29 30 bool is_eos; 31 base::TimeDelta timestamp; 32 bool has_decrypt_config; 33 size_t size; 34 }; 35 36 explicit FrameGeneratorForTest(const std::vector<FrameSpec> frame_specs); 37 ~FrameGeneratorForTest(); 38 39 // Indicates whether the next frame should come with a new decoder config. 40 bool HasDecoderConfig() const; 41 42 // Generates a frame. 43 // Returns NULL is there is no frame left to generate. 44 scoped_refptr<DecoderBufferBase> Generate(); 45 46 // Number of frames not generated yet. 47 size_t RemainingFrameCount() const; 48 49 private: 50 std::vector<FrameSpec> frame_specs_; 51 size_t frame_idx_; 52 53 // Total size of A/V buffers generated so far. 54 size_t total_buffer_size_; 55 56 DISALLOW_COPY_AND_ASSIGN(FrameGeneratorForTest); 57 }; 58 59 } // namespace media 60 } // namespace chromecast 61 62 #endif // CHROMECAST_MEDIA_CMA_TEST_TEST_FRAME_GENERATOR_H_ 63