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

Unified Diff: chrome/browser/media/cast_transport_host_filter.cc

Issue 387933005: Cast: Refactor RTCP handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/cast_transport_host_filter.cc
diff --git a/chrome/browser/media/cast_transport_host_filter.cc b/chrome/browser/media/cast_transport_host_filter.cc
index 0d6e76964830b0643dda1d87ea8c6ea127059a0f..0d8309a268ddcaf2c66f615453e48c0566565d11 100644
--- a/chrome/browser/media/cast_transport_host_filter.cc
+++ b/chrome/browser/media/cast_transport_host_filter.cc
@@ -18,7 +18,8 @@ const int kSendRawEventsIntervalSecs = 1;
namespace cast {
CastTransportHostFilter::CastTransportHostFilter()
- : BrowserMessageFilter(CastMsgStart) {}
+ : BrowserMessageFilter(CastMsgStart),
+ weak_factory_(this) {}
CastTransportHostFilter::~CastTransportHostFilter() {}
@@ -33,8 +34,8 @@ bool CastTransportHostFilter::OnMessageReceived(const IPC::Message& message) {
OnInsertCodedAudioFrame)
IPC_MESSAGE_HANDLER(CastHostMsg_InsertCodedVideoFrame,
OnInsertCodedVideoFrame)
- IPC_MESSAGE_HANDLER(CastHostMsg_SendRtcpFromRtpSender,
- OnSendRtcpFromRtpSender)
+ IPC_MESSAGE_HANDLER(CastHostMsg_SendSenderReport,
+ OnSendSenderReport)
IPC_MESSAGE_HANDLER(CastHostMsg_ResendPackets,
OnResendPackets)
IPC_MESSAGE_UNHANDLED(handled = false);
@@ -48,17 +49,35 @@ void CastTransportHostFilter::NotifyStatusChange(
Send(new CastMsg_NotifyStatusChange(channel_id, status));
}
-void CastTransportHostFilter::ReceivedPacket(
+void CastTransportHostFilter::SendRawEvents(
int32 channel_id,
- scoped_ptr<media::cast::Packet> packet) {
- Send(new CastMsg_ReceivedPacket(channel_id, *packet));
+ const std::vector<media::cast::PacketEvent>& packet_events,
+ const std::vector<media::cast::FrameEvent>& frame_events) {
+ if (!packet_events.empty())
+ Send(new CastMsg_RawEvents(channel_id,
+ packet_events,
+ frame_events));
+}
+
+void CastTransportHostFilter::SendRtt(int32 channel_id,
+ uint32 ssrc,
+ base::TimeDelta rtt,
+ base::TimeDelta avg_rtt,
+ base::TimeDelta min_rtt,
+ base::TimeDelta max_rtt) {
+ media::cast::RtcpRttReport report;
+ report.rtt = rtt;
+ report.avg_rtt = avg_rtt;
+ report.min_rtt = min_rtt;
+ report.max_rtt = max_rtt;
+ Send(new CastMsg_Rtt(channel_id, ssrc, report));
}
-void CastTransportHostFilter::RawEvents(
+void CastTransportHostFilter::SendCastMessage(
int32 channel_id,
- const std::vector<media::cast::PacketEvent>& packet_events) {
- if (!packet_events.empty())
- Send(new CastMsg_RawEvents(channel_id, packet_events));
+ uint32 ssrc,
+ const media::cast::RtcpCastMessage& cast_message) {
+ Send(new CastMsg_RtcpCastMessage(channel_id, ssrc, cast_message));
}
void CastTransportHostFilter::OnNew(
@@ -74,18 +93,13 @@ void CastTransportHostFilter::OnNew(
&clock_,
remote_end_point,
base::Bind(&CastTransportHostFilter::NotifyStatusChange,
- base::Unretained(this),
+ weak_factory_.GetWeakPtr(),
channel_id),
- base::Bind(&CastTransportHostFilter::RawEvents,
- base::Unretained(this),
+ base::Bind(&CastTransportHostFilter::SendRawEvents,
+ weak_factory_.GetWeakPtr(),
channel_id),
base::TimeDelta::FromSeconds(kSendRawEventsIntervalSecs),
base::MessageLoopProxy::current());
-
- sender->SetPacketReceiver(base::Bind(&CastTransportHostFilter::ReceivedPacket,
- base::Unretained(this),
- channel_id));
-
id_map_.AddWithID(sender.release(), channel_id);
}
@@ -106,7 +120,14 @@ void CastTransportHostFilter::OnInitializeAudio(
media::cast::CastTransportSender* sender =
id_map_.Lookup(channel_id);
if (sender) {
- sender->InitializeAudio(config);
+ sender->InitializeAudio(
+ config,
+ base::Bind(&CastTransportHostFilter::SendCastMessage,
+ weak_factory_.GetWeakPtr(),
+ channel_id, config.ssrc),
+ base::Bind(&CastTransportHostFilter::SendRtt,
+ weak_factory_.GetWeakPtr(),
+ channel_id, config.ssrc));
} else {
DVLOG(1)
<< "CastTransportHostFilter::OnInitializeAudio on non-existing channel";
@@ -119,7 +140,14 @@ void CastTransportHostFilter::OnInitializeVideo(
media::cast::CastTransportSender* sender =
id_map_.Lookup(channel_id);
if (sender) {
- sender->InitializeVideo(config);
+ sender->InitializeVideo(
+ config,
+ base::Bind(&CastTransportHostFilter::SendCastMessage,
+ weak_factory_.GetWeakPtr(),
+ channel_id, config.ssrc),
+ base::Bind(&CastTransportHostFilter::SendRtt,
+ weak_factory_.GetWeakPtr(),
+ channel_id, config.ssrc));
} else {
DVLOG(1)
<< "CastTransportHostFilter::OnInitializeVideo on non-existing channel";
@@ -154,23 +182,20 @@ void CastTransportHostFilter::OnInsertCodedVideoFrame(
}
}
-void CastTransportHostFilter::OnSendRtcpFromRtpSender(
+void CastTransportHostFilter::OnSendSenderReport(
int32 channel_id,
- const media::cast::SendRtcpFromRtpSenderData& data,
- const media::cast::RtcpDlrrReportBlock& dlrr) {
+ uint32 ssrc,
+ base::TimeTicks current_time,
+ uint32 current_time_as_rtp_timestamp) {
media::cast::CastTransportSender* sender =
id_map_.Lookup(channel_id);
if (sender) {
- sender->SendRtcpFromRtpSender(data.packet_type_flags,
- data.ntp_seconds,
- data.ntp_fraction,
- data.rtp_timestamp,
- dlrr,
- data.sending_ssrc,
- data.c_name);
+ sender->SendSenderReport(ssrc,
+ current_time,
+ current_time_as_rtp_timestamp);
} else {
DVLOG(1)
- << "CastTransportHostFilter::OnSendRtcpFromRtpSender "
+ << "CastTransportHostFilter::OnSendSenderReport "
<< "on non-existing channel";
}
}
« no previous file with comments | « chrome/browser/media/cast_transport_host_filter.h ('k') | chrome/browser/media/cast_transport_host_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698