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