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

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: Speculative workaround fix for win8_chromium_ng compile error. 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
« no previous file with comments | « media/cast/receiver/frame_receiver_unittest.cc ('k') | media/cast/sender/audio_encoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/sender/audio_encoder.cc
diff --git a/media/cast/sender/audio_encoder.cc b/media/cast/sender/audio_encoder.cc
index 3c5740c74c4ed4bfadf93c81d9c41e7587aa9260..bacb793fddbb6b9fd1cfc23de5fca3fcc36fcb66 100644
--- a/media/cast/sender/audio_encoder.cc
+++ b/media/cast/sender/audio_encoder.cc
@@ -19,6 +19,8 @@
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.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"
@@ -63,8 +65,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;
@@ -107,7 +108,7 @@ class AudioEncoder::ImplBase
buffer_fill_end_ = 0;
buffer_fill_duration = base::TimeDelta();
frame_rtp_timestamp_ +=
- static_cast<uint32_t>(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.";
@@ -146,9 +147,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.
@@ -174,7 +177,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_;
}
}
@@ -214,9 +217,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_t 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
« no previous file with comments | « media/cast/receiver/frame_receiver_unittest.cc ('k') | media/cast/sender/audio_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698