OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // Reinitializes the data dumping such that new versions | 50 // Reinitializes the data dumping such that new versions |
51 // of all files being dumped to are created. | 51 // of all files being dumped to are created. |
52 void InitiateNewSetOfRecordings() { | 52 void InitiateNewSetOfRecordings() { |
53 #if WEBRTC_APM_DEBUG_DUMP == 1 | 53 #if WEBRTC_APM_DEBUG_DUMP == 1 |
54 ++recording_set_index_; | 54 ++recording_set_index_; |
55 #endif | 55 #endif |
56 } | 56 } |
57 | 57 |
58 // Methods for performing dumping of data of various types into | 58 // Methods for performing dumping of data of various types into |
59 // various formats. | 59 // various formats. |
60 void DumpRaw(const char* name, int v_length, const float* v) { | 60 void DumpRaw(const char* name, double v) { |
| 61 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 62 FILE* file = GetRawFile(name); |
| 63 fwrite(&v, sizeof(v), 1, file); |
| 64 #endif |
| 65 } |
| 66 |
| 67 void DumpRaw(const char* name, size_t v_length, const double* v) { |
61 #if WEBRTC_APM_DEBUG_DUMP == 1 | 68 #if WEBRTC_APM_DEBUG_DUMP == 1 |
62 FILE* file = GetRawFile(name); | 69 FILE* file = GetRawFile(name); |
63 fwrite(v, sizeof(v[0]), v_length, file); | 70 fwrite(v, sizeof(v[0]), v_length, file); |
| 71 #endif |
| 72 } |
| 73 |
| 74 void DumpRaw(const char* name, rtc::ArrayView<const double> v) { |
| 75 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 76 DumpRaw(name, v.size(), v.data()); |
| 77 #endif |
| 78 } |
| 79 |
| 80 void DumpRaw(const char* name, float v) { |
| 81 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 82 FILE* file = GetRawFile(name); |
| 83 fwrite(&v, sizeof(v), 1, file); |
| 84 #endif |
| 85 } |
| 86 |
| 87 void DumpRaw(const char* name, size_t v_length, const float* v) { |
| 88 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 89 FILE* file = GetRawFile(name); |
| 90 fwrite(v, sizeof(v[0]), v_length, file); |
64 #endif | 91 #endif |
65 } | 92 } |
66 | 93 |
67 void DumpRaw(const char* name, rtc::ArrayView<const float> v) { | 94 void DumpRaw(const char* name, rtc::ArrayView<const float> v) { |
68 #if WEBRTC_APM_DEBUG_DUMP == 1 | 95 #if WEBRTC_APM_DEBUG_DUMP == 1 |
69 DumpRaw(name, v.size(), v.data()); | 96 DumpRaw(name, v.size(), v.data()); |
70 #endif | 97 #endif |
71 } | 98 } |
72 | 99 |
73 void DumpRaw(const char* name, int v_length, const bool* v) { | 100 void DumpRaw(const char* name, bool v) { |
| 101 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 102 DumpRaw(name, static_cast<int16_t>(v)); |
| 103 #endif |
| 104 } |
| 105 |
| 106 void DumpRaw(const char* name, size_t v_length, const bool* v) { |
74 #if WEBRTC_APM_DEBUG_DUMP == 1 | 107 #if WEBRTC_APM_DEBUG_DUMP == 1 |
75 FILE* file = GetRawFile(name); | 108 FILE* file = GetRawFile(name); |
76 for (int k = 0; k < v_length; ++k) { | 109 for (size_t k = 0; k < v_length; ++k) { |
77 int16_t value = static_cast<int16_t>(v[k]); | 110 int16_t value = static_cast<int16_t>(v[k]); |
78 fwrite(&value, sizeof(value), 1, file); | 111 fwrite(&value, sizeof(value), 1, file); |
79 } | 112 } |
80 #endif | 113 #endif |
81 } | 114 } |
82 | 115 |
83 void DumpRaw(const char* name, rtc::ArrayView<const bool> v) { | 116 void DumpRaw(const char* name, rtc::ArrayView<const bool> v) { |
84 #if WEBRTC_APM_DEBUG_DUMP == 1 | 117 #if WEBRTC_APM_DEBUG_DUMP == 1 |
85 DumpRaw(name, v.size(), v.data()); | 118 DumpRaw(name, v.size(), v.data()); |
86 #endif | 119 #endif |
87 } | 120 } |
88 | 121 |
89 void DumpRaw(const char* name, int v_length, const int16_t* v) { | 122 void DumpRaw(const char* name, int16_t v) { |
| 123 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 124 FILE* file = GetRawFile(name); |
| 125 fwrite(&v, sizeof(v), 1, file); |
| 126 #endif |
| 127 } |
| 128 |
| 129 void DumpRaw(const char* name, size_t v_length, const int16_t* v) { |
90 #if WEBRTC_APM_DEBUG_DUMP == 1 | 130 #if WEBRTC_APM_DEBUG_DUMP == 1 |
91 FILE* file = GetRawFile(name); | 131 FILE* file = GetRawFile(name); |
92 fwrite(v, sizeof(v[0]), v_length, file); | 132 fwrite(v, sizeof(v[0]), v_length, file); |
93 #endif | 133 #endif |
94 } | 134 } |
95 | 135 |
96 void DumpRaw(const char* name, rtc::ArrayView<const int16_t> v) { | 136 void DumpRaw(const char* name, rtc::ArrayView<const int16_t> v) { |
97 #if WEBRTC_APM_DEBUG_DUMP == 1 | 137 #if WEBRTC_APM_DEBUG_DUMP == 1 |
98 DumpRaw(name, v.size(), v.data()); | 138 DumpRaw(name, v.size(), v.data()); |
99 #endif | 139 #endif |
100 } | 140 } |
101 | 141 |
102 void DumpRaw(const char* name, int v_length, const int32_t* v) { | 142 void DumpRaw(const char* name, int32_t v) { |
| 143 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 144 FILE* file = GetRawFile(name); |
| 145 fwrite(&v, sizeof(v), 1, file); |
| 146 #endif |
| 147 } |
| 148 |
| 149 void DumpRaw(const char* name, size_t v_length, const int32_t* v) { |
103 #if WEBRTC_APM_DEBUG_DUMP == 1 | 150 #if WEBRTC_APM_DEBUG_DUMP == 1 |
104 FILE* file = GetRawFile(name); | 151 FILE* file = GetRawFile(name); |
105 fwrite(v, sizeof(v[0]), v_length, file); | 152 fwrite(v, sizeof(v[0]), v_length, file); |
| 153 #endif |
| 154 } |
| 155 |
| 156 void DumpRaw(const char* name, size_t v) { |
| 157 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 158 FILE* file = GetRawFile(name); |
| 159 fwrite(&v, sizeof(v), 1, file); |
| 160 #endif |
| 161 } |
| 162 |
| 163 void DumpRaw(const char* name, size_t v_length, const size_t* v) { |
| 164 #if WEBRTC_APM_DEBUG_DUMP == 1 |
| 165 FILE* file = GetRawFile(name); |
| 166 fwrite(v, sizeof(v[0]), v_length, file); |
106 #endif | 167 #endif |
107 } | 168 } |
108 | 169 |
109 void DumpRaw(const char* name, rtc::ArrayView<const int32_t> v) { | 170 void DumpRaw(const char* name, rtc::ArrayView<const int32_t> v) { |
110 #if WEBRTC_APM_DEBUG_DUMP == 1 | 171 #if WEBRTC_APM_DEBUG_DUMP == 1 |
111 DumpRaw(name, v.size(), v.data()); | 172 DumpRaw(name, v.size(), v.data()); |
112 #endif | 173 #endif |
113 } | 174 } |
114 | 175 |
115 void DumpWav(const char* name, | 176 void DumpWav(const char* name, |
116 int v_length, | 177 size_t v_length, |
117 const float* v, | 178 const float* v, |
118 int sample_rate_hz, | 179 int sample_rate_hz, |
119 int num_channels) { | 180 int num_channels) { |
120 #if WEBRTC_APM_DEBUG_DUMP == 1 | 181 #if WEBRTC_APM_DEBUG_DUMP == 1 |
121 WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels); | 182 WavWriter* file = GetWavFile(name, sample_rate_hz, num_channels); |
122 file->WriteSamples(v, v_length); | 183 file->WriteSamples(v, v_length); |
123 #endif | 184 #endif |
124 } | 185 } |
125 | 186 |
126 void DumpWav(const char* name, | 187 void DumpWav(const char* name, |
(...skipping 15 matching lines...) Expand all Loading... |
142 | 203 |
143 FILE* GetRawFile(const char* name); | 204 FILE* GetRawFile(const char* name); |
144 WavWriter* GetWavFile(const char* name, int sample_rate_hz, int num_channels); | 205 WavWriter* GetWavFile(const char* name, int sample_rate_hz, int num_channels); |
145 #endif | 206 #endif |
146 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ApmDataDumper); | 207 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(ApmDataDumper); |
147 }; | 208 }; |
148 | 209 |
149 } // namespace webrtc | 210 } // namespace webrtc |
150 | 211 |
151 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LOGGING_APM_DATA_DUMPER_H_ | 212 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LOGGING_APM_DATA_DUMPER_H_ |
OLD | NEW |