This sets up API to release OutputSurface from LTHClient.
[chromium-blink-merge.git] / media / cast / test / utility / generate_timecode_audio.cc
blob219a8e1a1d27676e2ada337f88bee48fb39b2213
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 #include <algorithm>
6 #include <cstdio>
7 #include <cstdlib>
8 #include <vector>
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) {
17 if (argc < 3) {
18 fprintf(stderr, "Usage: %s <fps> <frames> >output.s16le\n", argv[0]);
19 exit(1);
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);