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

Side by Side Diff: chrome/browser/media/cast_remoting_sender.cc

Issue 2861053002: Periodically send RTCP report during Media Remoting. (Closed)
Patch Set: Created 3 years, 7 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 | « chrome/browser/media/cast_remoting_sender.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/media/cast_remoting_sender.h" 5 #include "chrome/browser/media/cast_remoting_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 remoting_event.size = remoting_frame.data.length(); 494 remoting_event.size = remoting_frame.data.length();
495 remoting_event.key_frame = 495 remoting_event.key_frame =
496 remoting_frame.dependency == media::cast::EncodedFrame::KEY; 496 remoting_frame.dependency == media::cast::EncodedFrame::KEY;
497 recent_frame_events_.push_back(remoting_event); 497 recent_frame_events_.push_back(remoting_event);
498 } 498 }
499 499
500 RecordLatestFrameTimestamps(frame_id, remoting_frame.rtp_timestamp); 500 RecordLatestFrameTimestamps(frame_id, remoting_frame.rtp_timestamp);
501 501
502 transport_->InsertFrame(ssrc_, remoting_frame); 502 transport_->InsertFrame(ssrc_, remoting_frame);
503 503
504 // Start periodically sending RTCP report to receiver to prevent keepalive
505 // timeouts on receiver side during media pause.
506 if (is_first_frame_to_be_sent)
507 ScheduleNextRtcpReport();
508
504 return true; 509 return true;
505 } 510 }
506 511
507 void CastRemotingSender::CancelInFlightData() { 512 void CastRemotingSender::CancelInFlightData() {
508 DCHECK_CURRENTLY_ON(BrowserThread::IO); 513 DCHECK_CURRENTLY_ON(BrowserThread::IO);
509 514
510 base::STLClearObject(&next_frame_data_); 515 base::STLClearObject(&next_frame_data_);
511 516
512 // TODO(miu): The following code is something we want to do as an 517 // TODO(miu): The following code is something we want to do as an
513 // optimization. However, as-is, it's not quite correct. We can only cancel 518 // optimization. However, as-is, it's not quite correct. We can only cancel
(...skipping 29 matching lines...) Expand all
543 frame_event_cb_.Run(frame_events); 548 frame_event_cb_.Run(frame_events);
544 } 549 }
545 550
546 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 551 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
547 FROM_HERE, 552 FROM_HERE,
548 base::BindOnce(&CastRemotingSender::SendFrameEvents, 553 base::BindOnce(&CastRemotingSender::SendFrameEvents,
549 weak_factory_.GetWeakPtr()), 554 weak_factory_.GetWeakPtr()),
550 logging_flush_interval_); 555 logging_flush_interval_);
551 } 556 }
552 557
558 void CastRemotingSender::ScheduleNextRtcpReport() {
559 DCHECK_CURRENTLY_ON(BrowserThread::IO);
560
561 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
562 FROM_HERE,
563 base::BindOnce(&CastRemotingSender::SendRtcpReport,
564 weak_factory_.GetWeakPtr()),
565 base::TimeDelta::FromMilliseconds(media::cast::kRtcpReportIntervalMs));
566 }
567
568 void CastRemotingSender::SendRtcpReport() {
569 DCHECK_CURRENTLY_ON(BrowserThread::IO);
570 DCHECK(!last_send_time_.is_null());
571
572 const base::TimeTicks now = clock_->NowTicks();
573 const base::TimeDelta time_delta = now - last_send_time_;
574 const media::cast::RtpTimeDelta rtp_delta =
575 media::cast::RtpTimeDelta::FromTimeDelta(
576 time_delta, media::cast::kRemotingRtpTimebase);
577 const media::cast::RtpTimeTicks now_as_rtp_timestamp =
578 GetRecordedRtpTimestamp(last_sent_frame_id_) + rtp_delta;
579 transport_->SendSenderReport(ssrc_, now, now_as_rtp_timestamp);
580
581 ScheduleNextRtcpReport();
582 }
583
553 } // namespace cast 584 } // namespace cast
OLDNEW
« no previous file with comments | « chrome/browser/media/cast_remoting_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698