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

Side by Side Diff: media/cast/receiver/frame_receiver.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/receiver/frame_receiver.h" 5 #include "media/cast/receiver/frame_receiver.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/big_endian.h" 9 #include "base/big_endian.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 EmitAvailableEncodedFrames(); 74 EmitAvailableEncodedFrames();
75 } 75 }
76 76
77 bool FrameReceiver::ProcessPacket(scoped_ptr<Packet> packet) { 77 bool FrameReceiver::ProcessPacket(scoped_ptr<Packet> packet) {
78 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 78 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
79 79
80 if (Rtcp::IsRtcpPacket(&packet->front(), packet->size())) { 80 if (Rtcp::IsRtcpPacket(&packet->front(), packet->size())) {
81 rtcp_.IncomingRtcpPacket(&packet->front(), packet->size()); 81 rtcp_.IncomingRtcpPacket(&packet->front(), packet->size());
82 } else { 82 } else {
83 RtpCastHeader rtp_header; 83 RtpCastHeader rtp_header;
84 const uint8* payload_data; 84 const uint8_t* payload_data;
85 size_t payload_size; 85 size_t payload_size;
86 if (!packet_parser_.ParsePacket(&packet->front(), 86 if (!packet_parser_.ParsePacket(&packet->front(),
87 packet->size(), 87 packet->size(),
88 &rtp_header, 88 &rtp_header,
89 &payload_data, 89 &payload_data,
90 &payload_size)) { 90 &payload_size)) {
91 return false; 91 return false;
92 } 92 }
93 93
94 ProcessParsedPacket(rtp_header, payload_data, payload_size); 94 ProcessParsedPacket(rtp_header, payload_data, payload_size);
95 stats_.UpdateStatistics(rtp_header); 95 stats_.UpdateStatistics(rtp_header);
96 } 96 }
97 97
98 if (!reports_are_scheduled_) { 98 if (!reports_are_scheduled_) {
99 ScheduleNextRtcpReport(); 99 ScheduleNextRtcpReport();
100 ScheduleNextCastMessage(); 100 ScheduleNextCastMessage();
101 reports_are_scheduled_ = true; 101 reports_are_scheduled_ = true;
102 } 102 }
103 103
104 return true; 104 return true;
105 } 105 }
106 106
107 void FrameReceiver::ProcessParsedPacket(const RtpCastHeader& rtp_header, 107 void FrameReceiver::ProcessParsedPacket(const RtpCastHeader& rtp_header,
108 const uint8* payload_data, 108 const uint8_t* payload_data,
109 size_t payload_size) { 109 size_t payload_size) {
110 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 110 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
111 111
112 const base::TimeTicks now = cast_environment_->Clock()->NowTicks(); 112 const base::TimeTicks now = cast_environment_->Clock()->NowTicks();
113 113
114 frame_id_to_rtp_timestamp_[rtp_header.frame_id & 0xff] = 114 frame_id_to_rtp_timestamp_[rtp_header.frame_id & 0xff] =
115 rtp_header.rtp_timestamp; 115 rtp_header.rtp_timestamp;
116 116
117 scoped_ptr<PacketEvent> receive_event(new PacketEvent()); 117 scoped_ptr<PacketEvent> receive_event(new PacketEvent());
118 receive_event->timestamp = now; 118 receive_event->timestamp = now;
(...skipping 29 matching lines...) Expand all
148 fresh_sync_reference = now; 148 fresh_sync_reference = now;
149 } 149 }
150 // |lip_sync_reference_time_| is always incremented according to the time 150 // |lip_sync_reference_time_| is always incremented according to the time
151 // delta computed from the difference in RTP timestamps. Then, 151 // delta computed from the difference in RTP timestamps. Then,
152 // |lip_sync_drift_| accounts for clock drift and also smoothes-out any 152 // |lip_sync_drift_| accounts for clock drift and also smoothes-out any
153 // sudden/discontinuous shifts in the series of reference time values. 153 // sudden/discontinuous shifts in the series of reference time values.
154 if (lip_sync_reference_time_.is_null()) { 154 if (lip_sync_reference_time_.is_null()) {
155 lip_sync_reference_time_ = fresh_sync_reference; 155 lip_sync_reference_time_ = fresh_sync_reference;
156 } else { 156 } else {
157 lip_sync_reference_time_ += RtpDeltaToTimeDelta( 157 lip_sync_reference_time_ += RtpDeltaToTimeDelta(
158 static_cast<int32>(fresh_sync_rtp - lip_sync_rtp_timestamp_), 158 static_cast<int32_t>(fresh_sync_rtp - lip_sync_rtp_timestamp_),
159 rtp_timebase_); 159 rtp_timebase_);
160 } 160 }
161 lip_sync_rtp_timestamp_ = fresh_sync_rtp; 161 lip_sync_rtp_timestamp_ = fresh_sync_rtp;
162 lip_sync_drift_.Update( 162 lip_sync_drift_.Update(
163 now, fresh_sync_reference - lip_sync_reference_time_); 163 now, fresh_sync_reference - lip_sync_reference_time_);
164 } 164 }
165 165
166 // Another frame is complete from a non-duplicate packet. Attempt to emit 166 // Another frame is complete from a non-duplicate packet. Attempt to emit
167 // more frames to satisfy enqueued requests. 167 // more frames to satisfy enqueued requests.
168 if (complete) 168 if (complete)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (!callback.is_null()) 295 if (!callback.is_null())
296 callback.Run(encoded_frame.Pass()); 296 callback.Run(encoded_frame.Pass());
297 } 297 }
298 298
299 base::TimeTicks FrameReceiver::GetPlayoutTime(const EncodedFrame& frame) const { 299 base::TimeTicks FrameReceiver::GetPlayoutTime(const EncodedFrame& frame) const {
300 base::TimeDelta target_playout_delay = target_playout_delay_; 300 base::TimeDelta target_playout_delay = target_playout_delay_;
301 if (frame.new_playout_delay_ms) { 301 if (frame.new_playout_delay_ms) {
302 target_playout_delay = base::TimeDelta::FromMilliseconds( 302 target_playout_delay = base::TimeDelta::FromMilliseconds(
303 frame.new_playout_delay_ms); 303 frame.new_playout_delay_ms);
304 } 304 }
305 return lip_sync_reference_time_ + 305 return lip_sync_reference_time_ + lip_sync_drift_.Current() +
306 lip_sync_drift_.Current() + 306 RtpDeltaToTimeDelta(static_cast<int32_t>(frame.rtp_timestamp -
307 RtpDeltaToTimeDelta( 307 lip_sync_rtp_timestamp_),
308 static_cast<int32>(frame.rtp_timestamp - lip_sync_rtp_timestamp_), 308 rtp_timebase_) +
309 rtp_timebase_) + 309 target_playout_delay;
310 target_playout_delay;
311 } 310 }
312 311
313 void FrameReceiver::ScheduleNextCastMessage() { 312 void FrameReceiver::ScheduleNextCastMessage() {
314 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 313 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
315 base::TimeTicks send_time; 314 base::TimeTicks send_time;
316 framer_.TimeToSendNextCastMessage(&send_time); 315 framer_.TimeToSendNextCastMessage(&send_time);
317 base::TimeDelta time_to_send = 316 base::TimeDelta time_to_send =
318 send_time - cast_environment_->Clock()->NowTicks(); 317 send_time - cast_environment_->Clock()->NowTicks();
319 time_to_send = std::max( 318 time_to_send = std::max(
320 time_to_send, base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); 319 time_to_send, base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs));
(...skipping 30 matching lines...) Expand all
351 rtcp_.ConvertToNTPAndSave(now), 350 rtcp_.ConvertToNTPAndSave(now),
352 NULL, 351 NULL,
353 base::TimeDelta(), 352 base::TimeDelta(),
354 NULL, 353 NULL,
355 &stats); 354 &stats);
356 ScheduleNextRtcpReport(); 355 ScheduleNextRtcpReport();
357 } 356 }
358 357
359 } // namespace cast 358 } // namespace cast
360 } // namespace media 359 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698