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

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

Issue 3019543002: Remove various IDs (Closed)
Patch Set: compatibility version of UpdateFrame Created 3 years, 3 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
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 AudioFrame(); 322 AudioFrame();
323 323
324 // Resets all members to their default state. 324 // Resets all members to their default state.
325 void Reset(); 325 void Reset();
326 // Same as Reset(), but leaves mute state unchanged. Muting a frame requires 326 // Same as Reset(), but leaves mute state unchanged. Muting a frame requires
327 // the buffer to be zeroed on the next call to mutable_data(). Callers 327 // the buffer to be zeroed on the next call to mutable_data(). Callers
328 // intending to write to the buffer immediately after Reset() can instead use 328 // intending to write to the buffer immediately after Reset() can instead use
329 // ResetWithoutMuting() to skip this wasteful zeroing. 329 // ResetWithoutMuting() to skip this wasteful zeroing.
330 void ResetWithoutMuting(); 330 void ResetWithoutMuting();
331 331
332 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data, 332 // TODO(solenberg): Remove once downstream users of AudioFrame have updated.
333 RTC_DEPRECATED
334 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
335 size_t samples_per_channel, int sample_rate_hz,
336 SpeechType speech_type, VADActivity vad_activity,
337 size_t num_channels = 1) {
338 RTC_UNUSED(id);
339 UpdateFrame(timestamp, data, samples_per_channel, sample_rate_hz,
340 speech_type, vad_activity, num_channels);
341 }
342
343 void UpdateFrame(uint32_t timestamp, const int16_t* data,
333 size_t samples_per_channel, int sample_rate_hz, 344 size_t samples_per_channel, int sample_rate_hz,
334 SpeechType speech_type, VADActivity vad_activity, 345 SpeechType speech_type, VADActivity vad_activity,
335 size_t num_channels = 1); 346 size_t num_channels = 1);
336 347
337 void CopyFrom(const AudioFrame& src); 348 void CopyFrom(const AudioFrame& src);
338 349
339 // data() returns a zeroed static buffer if the frame is muted. 350 // data() returns a zeroed static buffer if the frame is muted.
340 // mutable_frame() always returns a non-static buffer; the first call to 351 // mutable_frame() always returns a non-static buffer; the first call to
341 // mutable_frame() zeros the non-static buffer and marks the frame unmuted. 352 // mutable_frame() zeros the non-static buffer and marks the frame unmuted.
342 const int16_t* data() const; 353 const int16_t* data() const;
343 int16_t* mutable_data(); 354 int16_t* mutable_data();
344 355
345 // Prefer to mute frames using AudioFrameOperations::Mute. 356 // Prefer to mute frames using AudioFrameOperations::Mute.
346 void Mute(); 357 void Mute();
347 // Frame is muted by default. 358 // Frame is muted by default.
348 bool muted() const; 359 bool muted() const;
349 360
350 // These methods are deprecated. Use the functions in 361 // These methods are deprecated. Use the functions in
351 // webrtc/audio/utility instead. These methods will exists for a 362 // webrtc/audio/utility instead. These methods will exists for a
352 // short period of time until webrtc clients have updated. See 363 // short period of time until webrtc clients have updated. See
353 // webrtc:6548 for details. 364 // webrtc:6548 for details.
354 RTC_DEPRECATED AudioFrame& operator>>=(const int rhs); 365 RTC_DEPRECATED AudioFrame& operator>>=(const int rhs);
355 RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs); 366 RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs);
356 367
357 int id_;
358 // RTP timestamp of the first sample in the AudioFrame. 368 // RTP timestamp of the first sample in the AudioFrame.
359 uint32_t timestamp_ = 0; 369 uint32_t timestamp_ = 0;
360 // Time since the first frame in milliseconds. 370 // Time since the first frame in milliseconds.
361 // -1 represents an uninitialized value. 371 // -1 represents an uninitialized value.
362 int64_t elapsed_time_ms_ = -1; 372 int64_t elapsed_time_ms_ = -1;
363 // NTP time of the estimated capture time in local timebase in milliseconds. 373 // NTP time of the estimated capture time in local timebase in milliseconds.
364 // -1 represents an uninitialized value. 374 // -1 represents an uninitialized value.
365 int64_t ntp_time_ms_ = -1; 375 int64_t ntp_time_ms_ = -1;
366 size_t samples_per_channel_ = 0; 376 size_t samples_per_channel_ = 0;
367 int sample_rate_hz_ = 0; 377 int sample_rate_hz_ = 0;
(...skipping 21 matching lines...) Expand all
389 // Visual Studio doesn't like this in the class definition. 399 // Visual Studio doesn't like this in the class definition.
390 static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes"); 400 static_assert(sizeof(data_) == kMaxDataSizeBytes, "kMaxDataSizeBytes");
391 } 401 }
392 402
393 inline void AudioFrame::Reset() { 403 inline void AudioFrame::Reset() {
394 ResetWithoutMuting(); 404 ResetWithoutMuting();
395 muted_ = true; 405 muted_ = true;
396 } 406 }
397 407
398 inline void AudioFrame::ResetWithoutMuting() { 408 inline void AudioFrame::ResetWithoutMuting() {
399 id_ = -1;
400 // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize 409 // TODO(wu): Zero is a valid value for |timestamp_|. We should initialize
401 // to an invalid value, or add a new member to indicate invalidity. 410 // to an invalid value, or add a new member to indicate invalidity.
402 timestamp_ = 0; 411 timestamp_ = 0;
403 elapsed_time_ms_ = -1; 412 elapsed_time_ms_ = -1;
404 ntp_time_ms_ = -1; 413 ntp_time_ms_ = -1;
405 samples_per_channel_ = 0; 414 samples_per_channel_ = 0;
406 sample_rate_hz_ = 0; 415 sample_rate_hz_ = 0;
407 num_channels_ = 0; 416 num_channels_ = 0;
408 speech_type_ = kUndefined; 417 speech_type_ = kUndefined;
409 vad_activity_ = kVadUnknown; 418 vad_activity_ = kVadUnknown;
410 } 419 }
411 420
412 inline void AudioFrame::UpdateFrame(int id, 421 inline void AudioFrame::UpdateFrame(uint32_t timestamp,
413 uint32_t timestamp,
414 const int16_t* data, 422 const int16_t* data,
415 size_t samples_per_channel, 423 size_t samples_per_channel,
416 int sample_rate_hz, 424 int sample_rate_hz,
417 SpeechType speech_type, 425 SpeechType speech_type,
418 VADActivity vad_activity, 426 VADActivity vad_activity,
419 size_t num_channels) { 427 size_t num_channels) {
420 id_ = id;
421 timestamp_ = timestamp; 428 timestamp_ = timestamp;
422 samples_per_channel_ = samples_per_channel; 429 samples_per_channel_ = samples_per_channel;
423 sample_rate_hz_ = sample_rate_hz; 430 sample_rate_hz_ = sample_rate_hz;
424 speech_type_ = speech_type; 431 speech_type_ = speech_type;
425 vad_activity_ = vad_activity; 432 vad_activity_ = vad_activity;
426 num_channels_ = num_channels; 433 num_channels_ = num_channels;
427 434
428 const size_t length = samples_per_channel * num_channels; 435 const size_t length = samples_per_channel * num_channels;
429 assert(length <= kMaxDataSizeSamples); 436 assert(length <= kMaxDataSizeSamples);
430 if (data != nullptr) { 437 if (data != nullptr) {
431 memcpy(data_, data, sizeof(int16_t) * length); 438 memcpy(data_, data, sizeof(int16_t) * length);
432 muted_ = false; 439 muted_ = false;
433 } else { 440 } else {
434 muted_ = true; 441 muted_ = true;
435 } 442 }
436 } 443 }
437 444
438 inline void AudioFrame::CopyFrom(const AudioFrame& src) { 445 inline void AudioFrame::CopyFrom(const AudioFrame& src) {
439 if (this == &src) return; 446 if (this == &src) return;
440 447
441 id_ = src.id_;
442 timestamp_ = src.timestamp_; 448 timestamp_ = src.timestamp_;
443 elapsed_time_ms_ = src.elapsed_time_ms_; 449 elapsed_time_ms_ = src.elapsed_time_ms_;
444 ntp_time_ms_ = src.ntp_time_ms_; 450 ntp_time_ms_ = src.ntp_time_ms_;
445 muted_ = src.muted(); 451 muted_ = src.muted();
446 samples_per_channel_ = src.samples_per_channel_; 452 samples_per_channel_ = src.samples_per_channel_;
447 sample_rate_hz_ = src.sample_rate_hz_; 453 sample_rate_hz_ = src.sample_rate_hz_;
448 speech_type_ = src.speech_type_; 454 speech_type_ = src.speech_type_;
449 vad_activity_ = src.vad_activity_; 455 vad_activity_ = src.vad_activity_;
450 num_channels_ = src.num_channels_; 456 num_channels_ = src.num_channels_;
451 457
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 static constexpr int kNotAProbe = -1; 644 static constexpr int kNotAProbe = -1;
639 int send_bitrate_bps = -1; 645 int send_bitrate_bps = -1;
640 int probe_cluster_id = kNotAProbe; 646 int probe_cluster_id = kNotAProbe;
641 int probe_cluster_min_probes = -1; 647 int probe_cluster_min_probes = -1;
642 int probe_cluster_min_bytes = -1; 648 int probe_cluster_min_bytes = -1;
643 }; 649 };
644 650
645 } // namespace webrtc 651 } // namespace webrtc
646 652
647 #endif // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ 653 #endif // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698