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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 virtual void SetExtraOptions(const Config& config) = 0; | 280 virtual void SetExtraOptions(const Config& config) = 0; |
281 | 281 |
282 // TODO(peah): Remove after voice engine no longer requires it to resample | 282 // TODO(peah): Remove after voice engine no longer requires it to resample |
283 // the reverse stream to the forward rate. | 283 // the reverse stream to the forward rate. |
284 virtual int input_sample_rate_hz() const = 0; | 284 virtual int input_sample_rate_hz() const = 0; |
285 | 285 |
286 // TODO(ajm): Only intended for internal use. Make private and friend the | 286 // TODO(ajm): Only intended for internal use. Make private and friend the |
287 // necessary classes? | 287 // necessary classes? |
288 virtual int proc_sample_rate_hz() const = 0; | 288 virtual int proc_sample_rate_hz() const = 0; |
289 virtual int proc_split_sample_rate_hz() const = 0; | 289 virtual int proc_split_sample_rate_hz() const = 0; |
290 virtual int num_input_channels() const = 0; | 290 virtual size_t num_input_channels() const = 0; |
291 virtual int num_output_channels() const = 0; | 291 virtual size_t num_output_channels() const = 0; |
292 virtual int num_reverse_channels() const = 0; | 292 virtual size_t num_reverse_channels() const = 0; |
293 | 293 |
294 // Set to true when the output of AudioProcessing will be muted or in some | 294 // Set to true when the output of AudioProcessing will be muted or in some |
295 // other way not used. Ideally, the captured audio would still be processed, | 295 // other way not used. Ideally, the captured audio would still be processed, |
296 // but some components may change behavior based on this information. | 296 // but some components may change behavior based on this information. |
297 // Default false. | 297 // Default false. |
298 virtual void set_output_will_be_muted(bool muted) = 0; | 298 virtual void set_output_will_be_muted(bool muted) = 0; |
299 | 299 |
300 // Processes a 10 ms |frame| of the primary audio stream. On the client-side, | 300 // Processes a 10 ms |frame| of the primary audio stream. On the client-side, |
301 // this is the near-end (or captured) audio. | 301 // this is the near-end (or captured) audio. |
302 // | 302 // |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // keyboard channel if it is present. When passing a | 494 // keyboard channel if it is present. When passing a |
495 // StreamConfig with an array of arrays T*[N], | 495 // StreamConfig with an array of arrays T*[N], |
496 // | 496 // |
497 // N == {num_channels + 1 if has_keyboard | 497 // N == {num_channels + 1 if has_keyboard |
498 // {num_channels if !has_keyboard | 498 // {num_channels if !has_keyboard |
499 // | 499 // |
500 // has_keyboard: True if the stream has a keyboard channel. When has_keyboard | 500 // has_keyboard: True if the stream has a keyboard channel. When has_keyboard |
501 // is true, the last channel in any corresponding list of | 501 // is true, the last channel in any corresponding list of |
502 // channels is the keyboard channel. | 502 // channels is the keyboard channel. |
503 StreamConfig(int sample_rate_hz = 0, | 503 StreamConfig(int sample_rate_hz = 0, |
504 int num_channels = 0, | 504 size_t num_channels = 0, |
505 bool has_keyboard = false) | 505 bool has_keyboard = false) |
506 : sample_rate_hz_(sample_rate_hz), | 506 : sample_rate_hz_(sample_rate_hz), |
507 num_channels_(num_channels), | 507 num_channels_(num_channels), |
508 has_keyboard_(has_keyboard), | 508 has_keyboard_(has_keyboard), |
509 num_frames_(calculate_frames(sample_rate_hz)) {} | 509 num_frames_(calculate_frames(sample_rate_hz)) {} |
510 | 510 |
511 void set_sample_rate_hz(int value) { | 511 void set_sample_rate_hz(int value) { |
512 sample_rate_hz_ = value; | 512 sample_rate_hz_ = value; |
513 num_frames_ = calculate_frames(value); | 513 num_frames_ = calculate_frames(value); |
514 } | 514 } |
515 void set_num_channels(int value) { num_channels_ = value; } | 515 void set_num_channels(size_t value) { num_channels_ = value; } |
516 void set_has_keyboard(bool value) { has_keyboard_ = value; } | 516 void set_has_keyboard(bool value) { has_keyboard_ = value; } |
517 | 517 |
518 int sample_rate_hz() const { return sample_rate_hz_; } | 518 int sample_rate_hz() const { return sample_rate_hz_; } |
519 | 519 |
520 // The number of channels in the stream, not including the keyboard channel if | 520 // The number of channels in the stream, not including the keyboard channel if |
521 // present. | 521 // present. |
522 int num_channels() const { return num_channels_; } | 522 size_t num_channels() const { return num_channels_; } |
523 | 523 |
524 bool has_keyboard() const { return has_keyboard_; } | 524 bool has_keyboard() const { return has_keyboard_; } |
525 size_t num_frames() const { return num_frames_; } | 525 size_t num_frames() const { return num_frames_; } |
526 size_t num_samples() const { return num_channels_ * num_frames_; } | 526 size_t num_samples() const { return num_channels_ * num_frames_; } |
527 | 527 |
528 bool operator==(const StreamConfig& other) const { | 528 bool operator==(const StreamConfig& other) const { |
529 return sample_rate_hz_ == other.sample_rate_hz_ && | 529 return sample_rate_hz_ == other.sample_rate_hz_ && |
530 num_channels_ == other.num_channels_ && | 530 num_channels_ == other.num_channels_ && |
531 has_keyboard_ == other.has_keyboard_; | 531 has_keyboard_ == other.has_keyboard_; |
532 } | 532 } |
533 | 533 |
534 bool operator!=(const StreamConfig& other) const { return !(*this == other); } | 534 bool operator!=(const StreamConfig& other) const { return !(*this == other); } |
535 | 535 |
536 private: | 536 private: |
537 static size_t calculate_frames(int sample_rate_hz) { | 537 static size_t calculate_frames(int sample_rate_hz) { |
538 return static_cast<size_t>( | 538 return static_cast<size_t>( |
539 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000); | 539 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000); |
540 } | 540 } |
541 | 541 |
542 int sample_rate_hz_; | 542 int sample_rate_hz_; |
543 int num_channels_; | 543 size_t num_channels_; |
544 bool has_keyboard_; | 544 bool has_keyboard_; |
545 size_t num_frames_; | 545 size_t num_frames_; |
546 }; | 546 }; |
547 | 547 |
548 class ProcessingConfig { | 548 class ProcessingConfig { |
549 public: | 549 public: |
550 enum StreamName { | 550 enum StreamName { |
551 kInputStream, | 551 kInputStream, |
552 kOutputStream, | 552 kOutputStream, |
553 kReverseInputStream, | 553 kReverseInputStream, |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 // This does not impact the size of frames passed to |ProcessStream()|. | 948 // This does not impact the size of frames passed to |ProcessStream()|. |
949 virtual int set_frame_size_ms(int size) = 0; | 949 virtual int set_frame_size_ms(int size) = 0; |
950 virtual int frame_size_ms() const = 0; | 950 virtual int frame_size_ms() const = 0; |
951 | 951 |
952 protected: | 952 protected: |
953 virtual ~VoiceDetection() {} | 953 virtual ~VoiceDetection() {} |
954 }; | 954 }; |
955 } // namespace webrtc | 955 } // namespace webrtc |
956 | 956 |
957 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ | 957 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ |
OLD | NEW |