| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 AudioFrame(); | 323 AudioFrame(); |
| 324 | 324 |
| 325 // Resets all members to their default state. | 325 // Resets all members to their default state. |
| 326 void Reset(); | 326 void Reset(); |
| 327 // Same as Reset(), but leaves mute state unchanged. Muting a frame requires | 327 // Same as Reset(), but leaves mute state unchanged. Muting a frame requires |
| 328 // the buffer to be zeroed on the next call to mutable_data(). Callers | 328 // the buffer to be zeroed on the next call to mutable_data(). Callers |
| 329 // intending to write to the buffer immediately after Reset() can instead use | 329 // intending to write to the buffer immediately after Reset() can instead use |
| 330 // ResetWithoutMuting() to skip this wasteful zeroing. | 330 // ResetWithoutMuting() to skip this wasteful zeroing. |
| 331 void ResetWithoutMuting(); | 331 void ResetWithoutMuting(); |
| 332 | 332 |
| 333 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data, | 333 // TODO(solenberg): Remove once downstream users of AudioFrame have updated. |
| 334 RTC_DEPRECATED |
| 335 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data, |
| 336 size_t samples_per_channel, int sample_rate_hz, |
| 337 SpeechType speech_type, VADActivity vad_activity, |
| 338 size_t num_channels = 1) { |
| 339 RTC_UNUSED(id); |
| 340 UpdateFrame(timestamp, data, samples_per_channel, sample_rate_hz, |
| 341 speech_type, vad_activity, num_channels); |
| 342 } |
| 343 |
| 344 void UpdateFrame(uint32_t timestamp, const int16_t* data, |
| 334 size_t samples_per_channel, int sample_rate_hz, | 345 size_t samples_per_channel, int sample_rate_hz, |
| 335 SpeechType speech_type, VADActivity vad_activity, | 346 SpeechType speech_type, VADActivity vad_activity, |
| 336 size_t num_channels = 1); | 347 size_t num_channels = 1); |
| 337 | 348 |
| 338 void CopyFrom(const AudioFrame& src); | 349 void CopyFrom(const AudioFrame& src); |
| 339 | 350 |
| 340 // Sets a wall-time clock timestamp in milliseconds to be used for profiling | 351 // Sets a wall-time clock timestamp in milliseconds to be used for profiling |
| 341 // of time between two points in the audio chain. | 352 // of time between two points in the audio chain. |
| 342 // Example: | 353 // Example: |
| 343 // t0: UpdateProfileTimeStamp() | 354 // t0: UpdateProfileTimeStamp() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 359 // Frame is muted by default. | 370 // Frame is muted by default. |
| 360 bool muted() const; | 371 bool muted() const; |
| 361 | 372 |
| 362 // These methods are deprecated. Use the functions in | 373 // These methods are deprecated. Use the functions in |
| 363 // webrtc/audio/utility instead. These methods will exists for a | 374 // webrtc/audio/utility instead. These methods will exists for a |
| 364 // short period of time until webrtc clients have updated. See | 375 // short period of time until webrtc clients have updated. See |
| 365 // webrtc:6548 for details. | 376 // webrtc:6548 for details. |
| 366 RTC_DEPRECATED AudioFrame& operator>>=(const int rhs); | 377 RTC_DEPRECATED AudioFrame& operator>>=(const int rhs); |
| 367 RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs); | 378 RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs); |
| 368 | 379 |
| 369 int id_; | |
| 370 // RTP timestamp of the first sample in the AudioFrame. | 380 // RTP timestamp of the first sample in the AudioFrame. |
| 371 uint32_t timestamp_ = 0; | 381 uint32_t timestamp_ = 0; |
| 372 // Time since the first frame in milliseconds. | 382 // Time since the first frame in milliseconds. |
| 373 // -1 represents an uninitialized value. | 383 // -1 represents an uninitialized value. |
| 374 int64_t elapsed_time_ms_ = -1; | 384 int64_t elapsed_time_ms_ = -1; |
| 375 // NTP time of the estimated capture time in local timebase in milliseconds. | 385 // NTP time of the estimated capture time in local timebase in milliseconds. |
| 376 // -1 represents an uninitialized value. | 386 // -1 represents an uninitialized value. |
| 377 int64_t ntp_time_ms_ = -1; | 387 int64_t ntp_time_ms_ = -1; |
| 378 size_t samples_per_channel_ = 0; | 388 size_t samples_per_channel_ = 0; |
| 379 int sample_rate_hz_ = 0; | 389 int sample_rate_hz_ = 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 407 // Visual Studio doesn't like this in the class definition. | 417 // Visual Studio doesn't like this in the class definition. |
| 408 static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes"); | 418 static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes"); |
| 409 } | 419 } |
| 410 | 420 |
| 411 inline void AudioFrame::Reset() { | 421 inline void AudioFrame::Reset() { |
| 412 ResetWithoutMuting(); | 422 ResetWithoutMuting(); |
| 413 muted_ = true; | 423 muted_ = true; |
| 414 } | 424 } |
| 415 | 425 |
| 416 inline void AudioFrame::ResetWithoutMuting() { | 426 inline void AudioFrame::ResetWithoutMuting() { |
| 417 id_ = -1; | |
| 418 // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize | 427 // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize |
| 419 // to an invalid value, or add a new member to indicate invalidity. | 428 // to an invalid value, or add a new member to indicate invalidity. |
| 420 timestamp_ = 0; | 429 timestamp_ = 0; |
| 421 elapsed_time_ms_ = -1; | 430 elapsed_time_ms_ = -1; |
| 422 ntp_time_ms_ = -1; | 431 ntp_time_ms_ = -1; |
| 423 samples_per_channel_ = 0; | 432 samples_per_channel_ = 0; |
| 424 sample_rate_hz_ = 0; | 433 sample_rate_hz_ = 0; |
| 425 num_channels_ = 0; | 434 num_channels_ = 0; |
| 426 speech_type_ = kUndefined; | 435 speech_type_ = kUndefined; |
| 427 vad_activity_ = kVadUnknown; | 436 vad_activity_ = kVadUnknown; |
| 428 profile_timestamp_ms_ = 0; | 437 profile_timestamp_ms_ = 0; |
| 429 } | 438 } |
| 430 | 439 |
| 431 inline void AudioFrame::UpdateFrame(int id, | 440 inline void AudioFrame::UpdateFrame(uint32_t timestamp, |
| 432 uint32_t timestamp, | |
| 433 const int16_t* data, | 441 const int16_t* data, |
| 434 size_t samples_per_channel, | 442 size_t samples_per_channel, |
| 435 int sample_rate_hz, | 443 int sample_rate_hz, |
| 436 SpeechType speech_type, | 444 SpeechType speech_type, |
| 437 VADActivity vad_activity, | 445 VADActivity vad_activity, |
| 438 size_t num_channels) { | 446 size_t num_channels) { |
| 439 id_ = id; | |
| 440 timestamp_ = timestamp; | 447 timestamp_ = timestamp; |
| 441 samples_per_channel_ = samples_per_channel; | 448 samples_per_channel_ = samples_per_channel; |
| 442 sample_rate_hz_ = sample_rate_hz; | 449 sample_rate_hz_ = sample_rate_hz; |
| 443 speech_type_ = speech_type; | 450 speech_type_ = speech_type; |
| 444 vad_activity_ = vad_activity; | 451 vad_activity_ = vad_activity; |
| 445 num_channels_ = num_channels; | 452 num_channels_ = num_channels; |
| 446 | 453 |
| 447 const size_t length = samples_per_channel * num_channels; | 454 const size_t length = samples_per_channel * num_channels; |
| 448 assert(length <= kMaxDataSizeSamples); | 455 assert(length <= kMaxDataSizeSamples); |
| 449 if (data != nullptr) { | 456 if (data != nullptr) { |
| 450 memcpy(data_, data, sizeof(int16_t) * length); | 457 memcpy(data_, data, sizeof(int16_t) * length); |
| 451 muted_ = false; | 458 muted_ = false; |
| 452 } else { | 459 } else { |
| 453 muted_ = true; | 460 muted_ = true; |
| 454 } | 461 } |
| 455 } | 462 } |
| 456 | 463 |
| 457 inline void AudioFrame::CopyFrom(const AudioFrame& src) { | 464 inline void AudioFrame::CopyFrom(const AudioFrame& src) { |
| 458 if (this == &src) return; | 465 if (this == &src) return; |
| 459 | 466 |
| 460 id_ = src.id_; | |
| 461 timestamp_ = src.timestamp_; | 467 timestamp_ = src.timestamp_; |
| 462 elapsed_time_ms_ = src.elapsed_time_ms_; | 468 elapsed_time_ms_ = src.elapsed_time_ms_; |
| 463 ntp_time_ms_ = src.ntp_time_ms_; | 469 ntp_time_ms_ = src.ntp_time_ms_; |
| 464 muted_ = src.muted(); | 470 muted_ = src.muted(); |
| 465 samples_per_channel_ = src.samples_per_channel_; | 471 samples_per_channel_ = src.samples_per_channel_; |
| 466 sample_rate_hz_ = src.sample_rate_hz_; | 472 sample_rate_hz_ = src.sample_rate_hz_; |
| 467 speech_type_ = src.speech_type_; | 473 speech_type_ = src.speech_type_; |
| 468 vad_activity_ = src.vad_activity_; | 474 vad_activity_ = src.vad_activity_; |
| 469 num_channels_ = src.num_channels_; | 475 num_channels_ = src.num_channels_; |
| 470 | 476 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 static constexpr int kNotAProbe = -1; | 675 static constexpr int kNotAProbe = -1; |
| 670 int send_bitrate_bps = -1; | 676 int send_bitrate_bps = -1; |
| 671 int probe_cluster_id = kNotAProbe; | 677 int probe_cluster_id = kNotAProbe; |
| 672 int probe_cluster_min_probes = -1; | 678 int probe_cluster_min_probes = -1; |
| 673 int probe_cluster_min_bytes = -1; | 679 int probe_cluster_min_bytes = -1; |
| 674 }; | 680 }; |
| 675 | 681 |
| 676 } // namespace webrtc | 682 } // namespace webrtc |
| 677 | 683 |
| 678 #endif // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ | 684 #endif // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ |
| OLD | NEW |