Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: modules/include/module_common_types.h

Issue 3014683002: Revert of Remove various IDs (Closed)
Patch Set: Created 3 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « modules/audio_mixer/frame_combiner_unittest.cc ('k') | modules/module_common_types_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // TODO(solenberg): Remove once downstream users of AudioFrame have updated. 333 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
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,
345 size_t samples_per_channel, int sample_rate_hz, 334 size_t samples_per_channel, int sample_rate_hz,
346 SpeechType speech_type, VADActivity vad_activity, 335 SpeechType speech_type, VADActivity vad_activity,
347 size_t num_channels = 1); 336 size_t num_channels = 1);
348 337
349 void CopyFrom(const AudioFrame& src); 338 void CopyFrom(const AudioFrame& src);
350 339
351 // Sets a wall-time clock timestamp in milliseconds to be used for profiling 340 // Sets a wall-time clock timestamp in milliseconds to be used for profiling
352 // of time between two points in the audio chain. 341 // of time between two points in the audio chain.
353 // Example: 342 // Example:
354 // t0: UpdateProfileTimeStamp() 343 // t0: UpdateProfileTimeStamp()
(...skipping 15 matching lines...) Expand all
370 // Frame is muted by default. 359 // Frame is muted by default.
371 bool muted() const; 360 bool muted() const;
372 361
373 // These methods are deprecated. Use the functions in 362 // These methods are deprecated. Use the functions in
374 // webrtc/audio/utility instead. These methods will exists for a 363 // webrtc/audio/utility instead. These methods will exists for a
375 // short period of time until webrtc clients have updated. See 364 // short period of time until webrtc clients have updated. See
376 // webrtc:6548 for details. 365 // webrtc:6548 for details.
377 RTC_DEPRECATED AudioFrame& operator>>=(const int rhs); 366 RTC_DEPRECATED AudioFrame& operator>>=(const int rhs);
378 RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs); 367 RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs);
379 368
369 int id_;
380 // RTP timestamp of the first sample in the AudioFrame. 370 // RTP timestamp of the first sample in the AudioFrame.
381 uint32_t timestamp_ = 0; 371 uint32_t timestamp_ = 0;
382 // Time since the first frame in milliseconds. 372 // Time since the first frame in milliseconds.
383 // -1 represents an uninitialized value. 373 // -1 represents an uninitialized value.
384 int64_t elapsed_time_ms_ = -1; 374 int64_t elapsed_time_ms_ = -1;
385 // NTP time of the estimated capture time in local timebase in milliseconds. 375 // NTP time of the estimated capture time in local timebase in milliseconds.
386 // -1 represents an uninitialized value. 376 // -1 represents an uninitialized value.
387 int64_t ntp_time_ms_ = -1; 377 int64_t ntp_time_ms_ = -1;
388 size_t samples_per_channel_ = 0; 378 size_t samples_per_channel_ = 0;
389 int sample_rate_hz_ = 0; 379 int sample_rate_hz_ = 0;
(...skipping 27 matching lines...) Expand all
417 // Visual Studio doesn't like this in the class definition. 407 // Visual Studio doesn't like this in the class definition.
418 static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes"); 408 static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes");
419 } 409 }
420 410
421 inline void AudioFrame::Reset() { 411 inline void AudioFrame::Reset() {
422 ResetWithoutMuting(); 412 ResetWithoutMuting();
423 muted_ = true; 413 muted_ = true;
424 } 414 }
425 415
426 inline void AudioFrame::ResetWithoutMuting() { 416 inline void AudioFrame::ResetWithoutMuting() {
417 id_ = -1;
427 // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize 418 // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize
428 // to an invalid value, or add a new member to indicate invalidity. 419 // to an invalid value, or add a new member to indicate invalidity.
429 timestamp_ = 0; 420 timestamp_ = 0;
430 elapsed_time_ms_ = -1; 421 elapsed_time_ms_ = -1;
431 ntp_time_ms_ = -1; 422 ntp_time_ms_ = -1;
432 samples_per_channel_ = 0; 423 samples_per_channel_ = 0;
433 sample_rate_hz_ = 0; 424 sample_rate_hz_ = 0;
434 num_channels_ = 0; 425 num_channels_ = 0;
435 speech_type_ = kUndefined; 426 speech_type_ = kUndefined;
436 vad_activity_ = kVadUnknown; 427 vad_activity_ = kVadUnknown;
437 profile_timestamp_ms_ = 0; 428 profile_timestamp_ms_ = 0;
438 } 429 }
439 430
440 inline void AudioFrame::UpdateFrame(uint32_t timestamp, 431 inline void AudioFrame::UpdateFrame(int id,
432 uint32_t timestamp,
441 const int16_t* data, 433 const int16_t* data,
442 size_t samples_per_channel, 434 size_t samples_per_channel,
443 int sample_rate_hz, 435 int sample_rate_hz,
444 SpeechType speech_type, 436 SpeechType speech_type,
445 VADActivity vad_activity, 437 VADActivity vad_activity,
446 size_t num_channels) { 438 size_t num_channels) {
439 id_ = id;
447 timestamp_ = timestamp; 440 timestamp_ = timestamp;
448 samples_per_channel_ = samples_per_channel; 441 samples_per_channel_ = samples_per_channel;
449 sample_rate_hz_ = sample_rate_hz; 442 sample_rate_hz_ = sample_rate_hz;
450 speech_type_ = speech_type; 443 speech_type_ = speech_type;
451 vad_activity_ = vad_activity; 444 vad_activity_ = vad_activity;
452 num_channels_ = num_channels; 445 num_channels_ = num_channels;
453 446
454 const size_t length = samples_per_channel * num_channels; 447 const size_t length = samples_per_channel * num_channels;
455 assert(length <= kMaxDataSizeSamples); 448 assert(length <= kMaxDataSizeSamples);
456 if (data != nullptr) { 449 if (data != nullptr) {
457 memcpy(data_, data, sizeof(int16_t) * length); 450 memcpy(data_, data, sizeof(int16_t) * length);
458 muted_ = false; 451 muted_ = false;
459 } else { 452 } else {
460 muted_ = true; 453 muted_ = true;
461 } 454 }
462 } 455 }
463 456
464 inline void AudioFrame::CopyFrom(const AudioFrame& src) { 457 inline void AudioFrame::CopyFrom(const AudioFrame& src) {
465 if (this == &src) return; 458 if (this == &src) return;
466 459
460 id_ = src.id_;
467 timestamp_ = src.timestamp_; 461 timestamp_ = src.timestamp_;
468 elapsed_time_ms_ = src.elapsed_time_ms_; 462 elapsed_time_ms_ = src.elapsed_time_ms_;
469 ntp_time_ms_ = src.ntp_time_ms_; 463 ntp_time_ms_ = src.ntp_time_ms_;
470 muted_ = src.muted(); 464 muted_ = src.muted();
471 samples_per_channel_ = src.samples_per_channel_; 465 samples_per_channel_ = src.samples_per_channel_;
472 sample_rate_hz_ = src.sample_rate_hz_; 466 sample_rate_hz_ = src.sample_rate_hz_;
473 speech_type_ = src.speech_type_; 467 speech_type_ = src.speech_type_;
474 vad_activity_ = src.vad_activity_; 468 vad_activity_ = src.vad_activity_;
475 num_channels_ = src.num_channels_; 469 num_channels_ = src.num_channels_;
476 470
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 static constexpr int kNotAProbe = -1; 669 static constexpr int kNotAProbe = -1;
676 int send_bitrate_bps = -1; 670 int send_bitrate_bps = -1;
677 int probe_cluster_id = kNotAProbe; 671 int probe_cluster_id = kNotAProbe;
678 int probe_cluster_min_probes = -1; 672 int probe_cluster_min_probes = -1;
679 int probe_cluster_min_bytes = -1; 673 int probe_cluster_min_bytes = -1;
680 }; 674 };
681 675
682 } // namespace webrtc 676 } // namespace webrtc
683 677
684 #endif // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ 678 #endif // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
OLDNEW
« no previous file with comments | « modules/audio_mixer/frame_combiner_unittest.cc ('k') | modules/module_common_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698