Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: webrtc/modules/audio_processing/test/audio_file_processor.h

Issue 1409943002: Add aecdump support to audioproc_f. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_FILE_PROCESSOR_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_FILE_PROCESSOR_H_
13
14 #include <vector>
15
16 #include "webrtc/base/scoped_ptr.h"
17 #include "webrtc/common_audio/channel_buffer.h"
18 #include "webrtc/common_audio/wav_file.h"
19 #include "webrtc/modules/audio_processing/include/audio_processing.h"
20 #include "webrtc/modules/audio_processing/test/test_utils.h"
21 #include "webrtc/system_wrappers/interface/tick_util.h"
22
23 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
24 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h"
25 #else
26 #include "webrtc/audio_processing/debug.pb.h"
27 #endif
28
29 namespace webrtc {
30
31 // Interface for processing an input file with an AudioProcessing instance and
32 // dumping the results to an output file.
33 class AudioFileProcessor {
34 public:
35 static const int kChunksPerSecond = 1000 / AudioProcessing::kChunkSizeMs;
36
37 virtual ~AudioFileProcessor() {}
38
39 // Process one AuioProcessing::kChunkSizeMs of data from the input file.
peah-webrtc 2015/10/20 21:17:25 Typo: Should be AudioProcessing
Andrew MacDonald 2015/10/21 00:29:28 Done.
40 virtual bool ProcessChunk() = 0;
peah-webrtc 2015/10/20 21:17:25 I think another name is needed for this method. Wh
Andrew MacDonald 2015/10/21 00:29:28 The name is intentionally ambiguous in order for i
peah-webrtc 2015/10/21 08:10:04 I think ProcessChunk was better than ProcessAndWri
Andrew MacDonald 2015/10/22 00:12:09 Except that it might not process a capture chunk a
peah-webrtc 2015/10/22 04:50:40 Then the loop does not make sense at all. As it is
Andrew MacDonald 2015/10/22 05:11:55 And update the trace time overrider. My point is t
Andrew MacDonald 2015/10/22 16:38:20 I'd like to settle on a name you're happy with (or
peah-webrtc 2015/10/23 07:42:40 From the link I definitely see the risk of confusi
Andrew MacDonald 2015/10/23 23:58:35 We've been using block to refer to the underlying
41
42 // Returns the total execution time of all AudioProcessing calls.
43 int64_t processing_time_ms() const { return processing_time_.Milliseconds(); }
44
45 protected:
46 // RAII class for execution time measurement. Updates the provided
47 // TickInterval with the time between object creation and leaving the
48 // enclosing scope.
49 class ScopedTimer {
50 public:
51 explicit ScopedTimer(TickInterval* interval)
52 : interval_(interval), start_time_(TickTime::Now()) {}
53
54 ~ScopedTimer() { *interval_ += TickTime::Now() - start_time_; }
aluebs-webrtc 2015/10/24 00:53:34 Don't you think it is more intuitive to have a met
Andrew MacDonald 2015/10/29 00:44:50 I find scoped objects quite intuitive (in webrtc,
aluebs-webrtc 2015/10/29 01:03:19 But you can forget to scope it right. But if you f
Andrew MacDonald 2015/10/29 01:14:33 That's true, but I think that's harder (given the
55
56 private:
57 TickInterval* const interval_;
aluebs-webrtc 2015/10/24 00:53:34 What does this const mean?
Andrew MacDonald 2015/10/29 00:44:50 It means the pointer can't be reseated (its value
aluebs-webrtc 2015/10/29 01:03:19 Ok, thanks for clarifying.
58 TickTime start_time_;
59 };
60
61 TickInterval* processing_time() { return &processing_time_; }
62
63 private:
64 TickInterval processing_time_;
65 };
66
67 // Used to read from and write to WavFile objects.
68 class WavFileProcessor final : public AudioFileProcessor {
69 public:
70 // Takes ownership of all parameters.
71 WavFileProcessor(rtc::scoped_ptr<AudioProcessing> ap,
72 rtc::scoped_ptr<WavReader> in_file,
73 rtc::scoped_ptr<WavWriter> out_file);
74 virtual ~WavFileProcessor() {}
75
76 bool ProcessChunk() override;
77
78 private:
79 rtc::scoped_ptr<AudioProcessing> ap_;
80 rtc::scoped_ptr<WavReader> in_file_;
81
82 ChannelBuffer<float> in_buf_;
83 ChannelBuffer<float> out_buf_;
84 std::vector<float> in_interleaved_;
85 const StreamConfig input_config_;
86 const StreamConfig output_config_;
87 ChannelBufferWavWriter buffer_writer_;
88 };
89
90 // Used to read from an aecdump file and write to a WavWriter.
91 class AecDumpFileProcessor final : public AudioFileProcessor {
92 public:
93 // Takes ownership of all parameters.
94 AecDumpFileProcessor(rtc::scoped_ptr<AudioProcessing> ap,
95 FILE* dump_file,
aluebs-webrtc 2015/10/24 00:53:34 Shouldn't this be a scoped_ptr? Else, you could pa
Andrew MacDonald 2015/10/29 00:44:50 It can't be a scoped_ptr unless I specialize the d
aluebs-webrtc 2015/10/29 01:03:19 Oh, I see. Agreed.
96 rtc::scoped_ptr<WavWriter> out_file);
97
98 virtual ~AecDumpFileProcessor();
99
100 // Processes messages from the aecdump file until the first Stream message is
101 // completed.
aluebs-webrtc 2015/10/24 00:53:34 Doesn't this mess with the chunk number in process
Andrew MacDonald 2015/10/29 00:44:50 No, because the chunk counter is indeed for the nu
aluebs-webrtc 2015/10/29 01:03:19 Good point.
102 bool ProcessChunk() override;
103
104 private:
105 void HandleMessage(const webrtc::audioproc::Init& msg);
106 void HandleMessage(const webrtc::audioproc::Stream& msg);
107 void HandleMessage(const webrtc::audioproc::ReverseStream& msg);
108
109 rtc::scoped_ptr<AudioProcessing> ap_;
110 FILE* dump_file_;
111
112 rtc::scoped_ptr<ChannelBuffer<float>> in_buf_;
113 rtc::scoped_ptr<ChannelBuffer<float>> reverse_buf_;
114 ChannelBuffer<float> out_buf_;
115 StreamConfig input_config_;
116 StreamConfig reverse_config_;
117 const StreamConfig output_config_;
118 ChannelBufferWavWriter buffer_writer_;
119 };
120
121 } // namespace webrtc
122
123 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_AUDIO_FILE_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698