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

Unified Diff: media/cast/sender/audio_encoder.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/sender/audio_encoder.cc
diff --git a/media/cast/sender/audio_encoder.cc b/media/cast/sender/audio_encoder.cc
index bf1811803f9bfb510c79c5b1510ca8fe2fa14173..d5f5557d5f9211052db331541b8e8214a1a2affb 100644
--- a/media/cast/sender/audio_encoder.cc
+++ b/media/cast/sender/audio_encoder.cc
@@ -15,6 +15,8 @@
#include "base/sys_byteorder.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
+#include "media/cast/common/rtp_time.h"
+#include "media/cast/constants.h"
#if !defined(OS_IOS)
#include "third_party/opus/src/include/opus.h"
@@ -59,8 +61,7 @@ class AudioEncoder::ImplBase
base::Time::kMicrosecondsPerSecond * samples_per_frame_ /
sampling_rate)),
buffer_fill_end_(0),
- frame_id_(0),
- frame_rtp_timestamp_(0),
+ frame_id_(kFirstFrameId),
samples_dropped_from_buffer_(0) {
// Support for max sampling rate of 48KHz, 2 channels, 100 ms duration.
const int kMaxSamplesTimesChannelsPerFrame = 48 * 2 * 100;
@@ -103,7 +104,7 @@ class AudioEncoder::ImplBase
buffer_fill_end_ = 0;
buffer_fill_duration = base::TimeDelta();
frame_rtp_timestamp_ +=
- static_cast<uint32>(num_frames_missed * samples_per_frame_);
+ RtpTimeDelta::FromTicks(num_frames_missed * samples_per_frame_);
DVLOG(1) << "Skipping RTP timestamp ahead to account for "
<< num_frames_missed * samples_per_frame_
<< " samples' worth of underrun.";
@@ -142,9 +143,11 @@ class AudioEncoder::ImplBase
audio_frame->rtp_timestamp = frame_rtp_timestamp_;
audio_frame->reference_time = frame_capture_time_;
- TRACE_EVENT_ASYNC_BEGIN2("cast.stream", "Audio Encode", audio_frame.get(),
- "frame_id", frame_id_,
- "rtp_timestamp", frame_rtp_timestamp_);
+ TRACE_EVENT_ASYNC_BEGIN2(
+ "cast.stream",
+ "Audio Encode", audio_frame.get(),
+ "frame_id", frame_id_,
+ "rtp_timestamp", frame_rtp_timestamp_.lower_32_bits());
if (EncodeFromFilledBuffer(&audio_frame->data)) {
// Compute deadline utilization as the real-world time elapsed divided
// by the signal duration.
@@ -170,7 +173,7 @@ class AudioEncoder::ImplBase
// Reset the internal buffer, frame ID, and timestamps for the next frame.
buffer_fill_end_ = 0;
++frame_id_;
- frame_rtp_timestamp_ += samples_per_frame_;
+ frame_rtp_timestamp_ += RtpTimeDelta::FromTicks(samples_per_frame_);
frame_capture_time_ += frame_duration_;
}
}
@@ -210,9 +213,8 @@ class AudioEncoder::ImplBase
// The RTP timestamp for the next frame of encoded audio. This is defined as
// the number of audio samples encoded so far, plus the estimated number of
// samples that were missed due to data underruns. A receiver uses this value
- // to detect gaps in the audio signal data being provided. Per the spec, RTP
- // timestamp values are allowed to overflow and roll around past zero.
- uint32 frame_rtp_timestamp_;
+ // to detect gaps in the audio signal data being provided.
+ RtpTimeTicks frame_rtp_timestamp_;
// The local system time associated with the start of the next frame of
// encoded audio. This value is passed on to a receiver as a reference clock

Powered by Google App Engine
This is Rietveld 408576698