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

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

Issue 491953003: [Cast] Fix shutdown race between CastReceiverImpl/FrameReceiver and frame emit callback run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « media/cast/receiver/frame_receiver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 // At this point, we have a decrypted EncodedFrame ready to be emitted. 250 // At this point, we have a decrypted EncodedFrame ready to be emitted.
251 encoded_frame->reference_time = playout_time; 251 encoded_frame->reference_time = playout_time;
252 framer_.ReleaseFrame(encoded_frame->frame_id); 252 framer_.ReleaseFrame(encoded_frame->frame_id);
253 if (encoded_frame->new_playout_delay_ms) { 253 if (encoded_frame->new_playout_delay_ms) {
254 target_playout_delay_ = base::TimeDelta::FromMilliseconds( 254 target_playout_delay_ = base::TimeDelta::FromMilliseconds(
255 encoded_frame->new_playout_delay_ms); 255 encoded_frame->new_playout_delay_ms);
256 } 256 }
257 cast_environment_->PostTask(CastEnvironment::MAIN, 257 cast_environment_->PostTask(CastEnvironment::MAIN,
258 FROM_HERE, 258 FROM_HERE,
259 base::Bind(frame_request_queue_.front(), 259 base::Bind(&FrameReceiver::EmitOneFrame,
260 weak_factory_.GetWeakPtr(),
261 frame_request_queue_.front(),
260 base::Passed(&encoded_frame))); 262 base::Passed(&encoded_frame)));
261 frame_request_queue_.pop_front(); 263 frame_request_queue_.pop_front();
262 } 264 }
263 } 265 }
264 266
265 void FrameReceiver::EmitAvailableEncodedFramesAfterWaiting() { 267 void FrameReceiver::EmitAvailableEncodedFramesAfterWaiting() {
266 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 268 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
267 DCHECK(is_waiting_for_consecutive_frame_); 269 DCHECK(is_waiting_for_consecutive_frame_);
268 is_waiting_for_consecutive_frame_ = false; 270 is_waiting_for_consecutive_frame_ = false;
269 EmitAvailableEncodedFrames(); 271 EmitAvailableEncodedFrames();
270 } 272 }
271 273
274 void FrameReceiver::EmitOneFrame(const ReceiveEncodedFrameCallback& callback,
275 scoped_ptr<EncodedFrame> encoded_frame) const {
276 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
277 if (!callback.is_null())
278 callback.Run(encoded_frame.Pass());
279 }
280
272 base::TimeTicks FrameReceiver::GetPlayoutTime(const EncodedFrame& frame) const { 281 base::TimeTicks FrameReceiver::GetPlayoutTime(const EncodedFrame& frame) const {
273 base::TimeDelta target_playout_delay = target_playout_delay_; 282 base::TimeDelta target_playout_delay = target_playout_delay_;
274 if (frame.new_playout_delay_ms) { 283 if (frame.new_playout_delay_ms) {
275 target_playout_delay = base::TimeDelta::FromMilliseconds( 284 target_playout_delay = base::TimeDelta::FromMilliseconds(
276 frame.new_playout_delay_ms); 285 frame.new_playout_delay_ms);
277 } 286 }
278 return lip_sync_reference_time_ + 287 return lip_sync_reference_time_ +
279 lip_sync_drift_.Current() + 288 lip_sync_drift_.Current() +
280 RtpDeltaToTimeDelta( 289 RtpDeltaToTimeDelta(
281 static_cast<int32>(frame.rtp_timestamp - lip_sync_rtp_timestamp_), 290 static_cast<int32>(frame.rtp_timestamp - lip_sync_rtp_timestamp_),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 329 }
321 330
322 void FrameReceiver::SendNextRtcpReport() { 331 void FrameReceiver::SendNextRtcpReport() {
323 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 332 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
324 rtcp_.SendRtcpFromRtpReceiver(NULL, base::TimeDelta(), NULL, &stats_); 333 rtcp_.SendRtcpFromRtpReceiver(NULL, base::TimeDelta(), NULL, &stats_);
325 ScheduleNextRtcpReport(); 334 ScheduleNextRtcpReport();
326 } 335 }
327 336
328 } // namespace cast 337 } // namespace cast
329 } // namespace media 338 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/receiver/frame_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698