OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 ProcessingConfig processing_config = api_format_; | 554 ProcessingConfig processing_config = api_format_; |
555 processing_config.input_stream() = input_config; | 555 processing_config.input_stream() = input_config; |
556 processing_config.output_stream() = output_config; | 556 processing_config.output_stream() = output_config; |
557 | 557 |
558 RETURN_ON_ERR(MaybeInitializeLocked(processing_config)); | 558 RETURN_ON_ERR(MaybeInitializeLocked(processing_config)); |
559 assert(processing_config.input_stream().num_frames() == | 559 assert(processing_config.input_stream().num_frames() == |
560 api_format_.input_stream().num_frames()); | 560 api_format_.input_stream().num_frames()); |
561 | 561 |
562 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 562 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
563 if (debug_file_->Open()) { | 563 if (debug_file_->Open()) { |
564 RETURN_ON_ERR(WriteConfigMessage(false)); | |
565 | |
564 event_msg_->set_type(audioproc::Event::STREAM); | 566 event_msg_->set_type(audioproc::Event::STREAM); |
565 audioproc::Stream* msg = event_msg_->mutable_stream(); | 567 audioproc::Stream* msg = event_msg_->mutable_stream(); |
566 const size_t channel_size = | 568 const size_t channel_size = |
567 sizeof(float) * api_format_.input_stream().num_frames(); | 569 sizeof(float) * api_format_.input_stream().num_frames(); |
568 for (int i = 0; i < api_format_.input_stream().num_channels(); ++i) | 570 for (int i = 0; i < api_format_.input_stream().num_channels(); ++i) |
569 msg->add_input_channel(src[i], channel_size); | 571 msg->add_input_channel(src[i], channel_size); |
570 } | 572 } |
571 #endif | 573 #endif |
572 | 574 |
573 capture_audio_->CopyFrom(src, api_format_.input_stream()); | 575 capture_audio_->CopyFrom(src, api_format_.input_stream()); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 if (debug_file_->CloseFile() == -1) { | 941 if (debug_file_->CloseFile() == -1) { |
940 return kFileError; | 942 return kFileError; |
941 } | 943 } |
942 } | 944 } |
943 | 945 |
944 if (debug_file_->OpenFile(filename, false) == -1) { | 946 if (debug_file_->OpenFile(filename, false) == -1) { |
945 debug_file_->CloseFile(); | 947 debug_file_->CloseFile(); |
946 return kFileError; | 948 return kFileError; |
947 } | 949 } |
948 | 950 |
949 int err = WriteInitMessage(); | 951 RETURN_ON_ERR(WriteConfigMessage(true)); |
950 if (err != kNoError) { | 952 RETURN_ON_ERR(WriteInitMessage()); |
951 return err; | |
952 } | |
953 return kNoError; | 953 return kNoError; |
954 #else | 954 #else |
955 return kUnsupportedFunctionError; | 955 return kUnsupportedFunctionError; |
956 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 956 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
957 } | 957 } |
958 | 958 |
959 int AudioProcessingImpl::StartDebugRecording(FILE* handle) { | 959 int AudioProcessingImpl::StartDebugRecording(FILE* handle) { |
960 CriticalSectionScoped crit_scoped(crit_); | 960 CriticalSectionScoped crit_scoped(crit_); |
961 | 961 |
962 if (handle == NULL) { | 962 if (handle == NULL) { |
963 return kNullPointerError; | 963 return kNullPointerError; |
964 } | 964 } |
965 | 965 |
966 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 966 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
967 // Stop any ongoing recording. | 967 // Stop any ongoing recording. |
968 if (debug_file_->Open()) { | 968 if (debug_file_->Open()) { |
969 if (debug_file_->CloseFile() == -1) { | 969 if (debug_file_->CloseFile() == -1) { |
970 return kFileError; | 970 return kFileError; |
971 } | 971 } |
972 } | 972 } |
973 | 973 |
974 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) { | 974 if (debug_file_->OpenFromFileHandle(handle, true, false) == -1) { |
975 return kFileError; | 975 return kFileError; |
976 } | 976 } |
977 | 977 |
978 int err = WriteInitMessage(); | 978 RETURN_ON_ERR(WriteConfigMessage(true)); |
979 if (err != kNoError) { | 979 RETURN_ON_ERR(WriteInitMessage()); |
980 return err; | |
981 } | |
982 return kNoError; | 980 return kNoError; |
983 #else | 981 #else |
984 return kUnsupportedFunctionError; | 982 return kUnsupportedFunctionError; |
985 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 983 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
986 } | 984 } |
987 | 985 |
988 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( | 986 int AudioProcessingImpl::StartDebugRecordingForPlatformFile( |
989 rtc::PlatformFile handle) { | 987 rtc::PlatformFile handle) { |
990 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); | 988 FILE* stream = rtc::FdopenPlatformFileForWriting(handle); |
991 return StartDebugRecording(stream); | 989 return StartDebugRecording(stream); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1241 msg->set_sample_rate(api_format_.input_stream().sample_rate_hz()); | 1239 msg->set_sample_rate(api_format_.input_stream().sample_rate_hz()); |
1242 msg->set_num_input_channels(api_format_.input_stream().num_channels()); | 1240 msg->set_num_input_channels(api_format_.input_stream().num_channels()); |
1243 msg->set_num_output_channels(api_format_.output_stream().num_channels()); | 1241 msg->set_num_output_channels(api_format_.output_stream().num_channels()); |
1244 msg->set_num_reverse_channels( | 1242 msg->set_num_reverse_channels( |
1245 api_format_.reverse_input_stream().num_channels()); | 1243 api_format_.reverse_input_stream().num_channels()); |
1246 msg->set_reverse_sample_rate( | 1244 msg->set_reverse_sample_rate( |
1247 api_format_.reverse_input_stream().sample_rate_hz()); | 1245 api_format_.reverse_input_stream().sample_rate_hz()); |
1248 msg->set_output_sample_rate(api_format_.output_stream().sample_rate_hz()); | 1246 msg->set_output_sample_rate(api_format_.output_stream().sample_rate_hz()); |
1249 // TODO(ekmeyerson): Add reverse output fields to event_msg_. | 1247 // TODO(ekmeyerson): Add reverse output fields to event_msg_. |
1250 | 1248 |
1251 int err = WriteMessageToDebugFile(); | 1249 RETURN_ON_ERR(WriteMessageToDebugFile()); |
1252 if (err != kNoError) { | 1250 return kNoError; |
1253 return err; | 1251 } |
1252 | |
1253 int AudioProcessingImpl::WriteConfigMessage(bool forced) { | |
1254 audioproc::Config config; | |
1255 | |
1256 config.set_aec_enabled(echo_cancellation_->is_enabled()); | |
1257 config.set_aec_delay_agnostic_enabled( | |
1258 echo_cancellation_->is_delay_agnostic_enabled()); | |
1259 config.set_aec_drift_compensation_enabled( | |
1260 echo_cancellation_->is_drift_compensation_enabled()); | |
1261 config.set_aec_extended_filter_enabled( | |
1262 echo_cancellation_->is_extended_filter_enabled()); | |
1263 config.set_aec_suppression_level( | |
1264 static_cast<int>(echo_cancellation_->suppression_level())); | |
1265 | |
1266 config.set_aecm_enabled(echo_control_mobile_->is_enabled()); | |
1267 config.set_aecm_comfort_noise_enabled( | |
1268 echo_control_mobile_->is_comfort_noise_enabled()); | |
1269 config.set_aecm_routing_mode( | |
1270 static_cast<int>(echo_control_mobile_->routing_mode())); | |
1271 | |
1272 config.set_agc_enabled(gain_control_->is_enabled()); | |
1273 config.set_agc_mode(static_cast<int>(gain_control_->mode())); | |
1274 config.set_agc_limiter_enabled(gain_control_->is_limiter_enabled()); | |
1275 config.set_noise_robust_enabled(use_new_agc_); | |
Andrew MacDonald
2015/10/02 22:00:01
Did you build this? This is using the wrong field
minyue-webrtc
2015/10/02 22:01:41
oh, I thought I changed it. sorry, was too hasty.
| |
1276 | |
1277 config.set_hpf_enabled(high_pass_filter_->is_enabled()); | |
1278 | |
1279 config.set_ns_enabled(noise_suppression_->is_enabled()); | |
1280 config.set_ns_level(static_cast<int>(noise_suppression_->level())); | |
1281 | |
1282 config.set_transient_suppression_enabled(transient_suppressor_enabled_); | |
1283 | |
1284 std::string serialized_config = config.SerializeAsString(); | |
1285 if (!forced && last_serialized_config_ == serialized_config) { | |
1286 return kNoError; | |
1254 } | 1287 } |
1255 | 1288 |
1289 last_serialized_config_ = serialized_config; | |
1290 | |
1291 event_msg_->set_type(audioproc::Event::CONFIG); | |
1292 event_msg_->mutable_config()->CopyFrom(config); | |
1293 | |
1294 RETURN_ON_ERR(WriteMessageToDebugFile()); | |
1256 return kNoError; | 1295 return kNoError; |
1257 } | 1296 } |
1258 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1297 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1259 | 1298 |
1260 } // namespace webrtc | 1299 } // namespace webrtc |
OLD | NEW |