| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // TODO(ajm): Remove after voice engine no longer requires it to resample | 259 // TODO(ajm): Remove after voice engine no longer requires it to resample |
| 260 // the reverse stream to the forward rate. | 260 // the reverse stream to the forward rate. |
| 261 virtual int input_sample_rate_hz() const = 0; | 261 virtual int input_sample_rate_hz() const = 0; |
| 262 // TODO(ajm): Remove after Chromium no longer depends on it. | 262 // TODO(ajm): Remove after Chromium no longer depends on it. |
| 263 virtual int sample_rate_hz() const = 0; | 263 virtual int sample_rate_hz() const = 0; |
| 264 | 264 |
| 265 // TODO(ajm): Only intended for internal use. Make private and friend the | 265 // TODO(ajm): Only intended for internal use. Make private and friend the |
| 266 // necessary classes? | 266 // necessary classes? |
| 267 virtual int proc_sample_rate_hz() const = 0; | 267 virtual int proc_sample_rate_hz() const = 0; |
| 268 virtual int proc_split_sample_rate_hz() const = 0; | 268 virtual int proc_split_sample_rate_hz() const = 0; |
| 269 virtual int num_input_channels() const = 0; | 269 virtual size_t num_input_channels() const = 0; |
| 270 virtual int num_output_channels() const = 0; | 270 virtual size_t num_output_channels() const = 0; |
| 271 virtual int num_reverse_channels() const = 0; | 271 virtual size_t num_reverse_channels() const = 0; |
| 272 | 272 |
| 273 // Set to true when the output of AudioProcessing will be muted or in some | 273 // Set to true when the output of AudioProcessing will be muted or in some |
| 274 // other way not used. Ideally, the captured audio would still be processed, | 274 // other way not used. Ideally, the captured audio would still be processed, |
| 275 // but some components may change behavior based on this information. | 275 // but some components may change behavior based on this information. |
| 276 // Default false. | 276 // Default false. |
| 277 virtual void set_output_will_be_muted(bool muted) = 0; | 277 virtual void set_output_will_be_muted(bool muted) = 0; |
| 278 virtual bool output_will_be_muted() const = 0; | 278 virtual bool output_will_be_muted() const = 0; |
| 279 | 279 |
| 280 // Processes a 10 ms |frame| of the primary audio stream. On the client-side, | 280 // Processes a 10 ms |frame| of the primary audio stream. On the client-side, |
| 281 // this is the near-end (or captured) audio. | 281 // this is the near-end (or captured) audio. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 // keyboard channel if it is present. When passing a | 463 // keyboard channel if it is present. When passing a |
| 464 // StreamConfig with an array of arrays T*[N], | 464 // StreamConfig with an array of arrays T*[N], |
| 465 // | 465 // |
| 466 // N == {num_channels + 1 if has_keyboard | 466 // N == {num_channels + 1 if has_keyboard |
| 467 // {num_channels if !has_keyboard | 467 // {num_channels if !has_keyboard |
| 468 // | 468 // |
| 469 // has_keyboard: True if the stream has a keyboard channel. When has_keyboard | 469 // has_keyboard: True if the stream has a keyboard channel. When has_keyboard |
| 470 // is true, the last channel in any corresponding list of | 470 // is true, the last channel in any corresponding list of |
| 471 // channels is the keyboard channel. | 471 // channels is the keyboard channel. |
| 472 StreamConfig(int sample_rate_hz = 0, | 472 StreamConfig(int sample_rate_hz = 0, |
| 473 int num_channels = 0, | 473 size_t num_channels = 0, |
| 474 bool has_keyboard = false) | 474 bool has_keyboard = false) |
| 475 : sample_rate_hz_(sample_rate_hz), | 475 : sample_rate_hz_(sample_rate_hz), |
| 476 num_channels_(num_channels), | 476 num_channels_(num_channels), |
| 477 has_keyboard_(has_keyboard), | 477 has_keyboard_(has_keyboard), |
| 478 num_frames_(calculate_frames(sample_rate_hz)) {} | 478 num_frames_(calculate_frames(sample_rate_hz)) {} |
| 479 | 479 |
| 480 void set_sample_rate_hz(int value) { | 480 void set_sample_rate_hz(int value) { |
| 481 sample_rate_hz_ = value; | 481 sample_rate_hz_ = value; |
| 482 num_frames_ = calculate_frames(value); | 482 num_frames_ = calculate_frames(value); |
| 483 } | 483 } |
| 484 void set_num_channels(int value) { num_channels_ = value; } | 484 void set_num_channels(size_t value) { num_channels_ = value; } |
| 485 void set_has_keyboard(bool value) { has_keyboard_ = value; } | 485 void set_has_keyboard(bool value) { has_keyboard_ = value; } |
| 486 | 486 |
| 487 int sample_rate_hz() const { return sample_rate_hz_; } | 487 int sample_rate_hz() const { return sample_rate_hz_; } |
| 488 | 488 |
| 489 // The number of channels in the stream, not including the keyboard channel if | 489 // The number of channels in the stream, not including the keyboard channel if |
| 490 // present. | 490 // present. |
| 491 int num_channels() const { return num_channels_; } | 491 size_t num_channels() const { return num_channels_; } |
| 492 | 492 |
| 493 bool has_keyboard() const { return has_keyboard_; } | 493 bool has_keyboard() const { return has_keyboard_; } |
| 494 size_t num_frames() const { return num_frames_; } | 494 size_t num_frames() const { return num_frames_; } |
| 495 | 495 |
| 496 bool operator==(const StreamConfig& other) const { | 496 bool operator==(const StreamConfig& other) const { |
| 497 return sample_rate_hz_ == other.sample_rate_hz_ && | 497 return sample_rate_hz_ == other.sample_rate_hz_ && |
| 498 num_channels_ == other.num_channels_ && | 498 num_channels_ == other.num_channels_ && |
| 499 has_keyboard_ == other.has_keyboard_; | 499 has_keyboard_ == other.has_keyboard_; |
| 500 } | 500 } |
| 501 | 501 |
| 502 bool operator!=(const StreamConfig& other) const { return !(*this == other); } | 502 bool operator!=(const StreamConfig& other) const { return !(*this == other); } |
| 503 | 503 |
| 504 private: | 504 private: |
| 505 static size_t calculate_frames(int sample_rate_hz) { | 505 static size_t calculate_frames(int sample_rate_hz) { |
| 506 return static_cast<size_t>( | 506 return static_cast<size_t>( |
| 507 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000); | 507 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000); |
| 508 } | 508 } |
| 509 | 509 |
| 510 int sample_rate_hz_; | 510 int sample_rate_hz_; |
| 511 int num_channels_; | 511 size_t num_channels_; |
| 512 bool has_keyboard_; | 512 bool has_keyboard_; |
| 513 size_t num_frames_; | 513 size_t num_frames_; |
| 514 }; | 514 }; |
| 515 | 515 |
| 516 class ProcessingConfig { | 516 class ProcessingConfig { |
| 517 public: | 517 public: |
| 518 enum StreamName { | 518 enum StreamName { |
| 519 kInputStream, | 519 kInputStream, |
| 520 kOutputStream, | 520 kOutputStream, |
| 521 kReverseStream, | 521 kReverseStream, |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 // This does not impact the size of frames passed to |ProcessStream()|. | 907 // This does not impact the size of frames passed to |ProcessStream()|. |
| 908 virtual int set_frame_size_ms(int size) = 0; | 908 virtual int set_frame_size_ms(int size) = 0; |
| 909 virtual int frame_size_ms() const = 0; | 909 virtual int frame_size_ms() const = 0; |
| 910 | 910 |
| 911 protected: | 911 protected: |
| 912 virtual ~VoiceDetection() {} | 912 virtual ~VoiceDetection() {} |
| 913 }; | 913 }; |
| 914 } // namespace webrtc | 914 } // namespace webrtc |
| 915 | 915 |
| 916 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ | 916 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ |
| OLD | NEW |