| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_TEST_HELPERS_H_ | 5 #ifndef MEDIA_BASE_TEST_HELPERS_H_ |
| 6 #define MEDIA_BASE_TEST_HELPERS_H_ | 6 #define MEDIA_BASE_TEST_HELPERS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "media/base/pipeline_status.h" | 10 #include "media/base/pipeline_status.h" |
| 11 #include "media/base/sample_format.h" |
| 11 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class MessageLoop; | 17 class MessageLoop; |
| 18 class TimeDelta; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace media { | 21 namespace media { |
| 20 | 22 |
| 23 class AudioBuffer; |
| 24 |
| 21 // Return a callback that expects to be run once. | 25 // Return a callback that expects to be run once. |
| 22 base::Closure NewExpectedClosure(); | 26 base::Closure NewExpectedClosure(); |
| 23 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); | 27 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); |
| 24 | 28 |
| 25 // Helper class for running a message loop until a callback has run. Useful for | 29 // Helper class for running a message loop until a callback has run. Useful for |
| 26 // testing classes that run on more than a single thread. | 30 // testing classes that run on more than a single thread. |
| 27 // | 31 // |
| 28 // Events are intended for single use and cannot be reset. | 32 // Events are intended for single use and cannot be reset. |
| 29 class WaitableMessageLoopEvent { | 33 class WaitableMessageLoopEvent { |
| 30 public: | 34 public: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 static VideoDecoderConfig LargeEncrypted(); | 76 static VideoDecoderConfig LargeEncrypted(); |
| 73 | 77 |
| 74 // Returns coded size for Normal and Large config. | 78 // Returns coded size for Normal and Large config. |
| 75 static gfx::Size NormalCodedSize(); | 79 static gfx::Size NormalCodedSize(); |
| 76 static gfx::Size LargeCodedSize(); | 80 static gfx::Size LargeCodedSize(); |
| 77 | 81 |
| 78 private: | 82 private: |
| 79 DISALLOW_IMPLICIT_CONSTRUCTORS(TestVideoConfig); | 83 DISALLOW_IMPLICIT_CONSTRUCTORS(TestVideoConfig); |
| 80 }; | 84 }; |
| 81 | 85 |
| 86 // Create an AudioBuffer containing |frames| frames of data, where each sample |
| 87 // is of type T. Each frame will have the data from |channels| channels |
| 88 // interleaved. |start| and |increment| are used to specify the values for the |
| 89 // samples. Since this is interleaved data, channel 0 data will be: |
| 90 // |start| |
| 91 // |start| + |channels| * |increment| |
| 92 // |start| + 2 * |channels| * |increment|, and so on. |
| 93 // Data for subsequent channels is similar. No check is done that |format| |
| 94 // requires data to be of type T, but it is verified that |format| is an |
| 95 // interleaved format. |
| 96 // |
| 97 // |start_time| will be used as the start time for the samples. Duration is set |
| 98 // to 1 second per frame, to simplify calculations. |
| 99 template <class T> |
| 100 scoped_refptr<AudioBuffer> MakeInterleavedAudioBuffer( |
| 101 SampleFormat format, |
| 102 int channels, |
| 103 T start, |
| 104 T increment, |
| 105 int frames, |
| 106 base::TimeDelta start_time); |
| 107 |
| 108 // Create an AudioBuffer containing |frames| frames of data, where each sample |
| 109 // is of type T. Since this is planar data, there will be a block for each of |
| 110 // |channel| channels. |start| and |increment| are used to specify the values |
| 111 // for the samples, which are created in channel order. Since this is planar |
| 112 // data, channel 0 data will be: |
| 113 // |start| |
| 114 // |start| + |increment| |
| 115 // |start| + 2 * |increment|, and so on. |
| 116 // Data for channel 1 will follow where channel 0 ends. Subsequent channels are |
| 117 // similar. No check is done that |format| requires data to be of type T, but it |
| 118 // is verified that |format| is a planar format. |
| 119 // |
| 120 // |start_time| will be used as the start time for the samples. Duration is set |
| 121 // to 1 second per frame, to simplify calculations. |
| 122 template <class T> |
| 123 scoped_refptr<AudioBuffer> MakePlanarAudioBuffer( |
| 124 SampleFormat format, |
| 125 int channels, |
| 126 T start, |
| 127 T increment, |
| 128 int frames, |
| 129 base::TimeDelta start_time); |
| 130 |
| 82 } // namespace media | 131 } // namespace media |
| 83 | 132 |
| 84 #endif // MEDIA_BASE_TEST_HELPERS_H_ | 133 #endif // MEDIA_BASE_TEST_HELPERS_H_ |
| OLD | NEW |