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.
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "media/cast/test/utility/audio_utility.h"
14 const size_t kSamplingFrequency
= 48000;
16 int main(int argc
, char **argv
) {
18 fprintf(stderr
, "Usage: %s <fps> <frames> >output.s16le\n", argv
[0]);
21 int fps
= atoi(argv
[1]);
22 const uint32 frames
= static_cast<uint32
>(std::max(0, atoi(argv
[2])));
23 std::vector
<float> samples(kSamplingFrequency
/ fps
);
24 size_t num_samples
= 0;
25 for (uint32 frame_id
= 1; frame_id
<= frames
; frame_id
++) {
26 CHECK(media::cast::EncodeTimestamp(
27 frame_id
, num_samples
, samples
.size(), &samples
.front()));
28 num_samples
+= samples
.size();
29 for (size_t i
= 0; i
< samples
.size(); ++i
) {
30 const int16 sample_s16
= static_cast<int16
>(samples
[i
] * kint16max
);
31 putchar(sample_s16
& 0xff);
32 putchar(sample_s16
>> 8);
33 putchar(sample_s16
& 0xff);
34 putchar(sample_s16
>> 8);