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

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

Issue 1878883003: Refactor: simplify interface of SenderRtcpSession and CastTransport. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 273d6ffaffc212a32957d9e2977206eecc66f736..4363e388247443df059068d69227afc251f13709 100644
--- a/chrome/browser/media/cast_transport_host_filter.cc
+++ b/chrome/browser/media/cast_transport_host_filter.cc
@@ -58,6 +58,39 @@ void TransportClient::ProcessRtpPacket(
new CastMsg_ReceivedPacket(channel_id_, *packet));
}
+class RtcpClient : public media::cast::RtpSenderRtcpClient {
+ public:
+ RtcpClient(int32_t channel_id,
+ uint32_t rtp_sender_ssrc,
+ cast::CastTransportHostFilter* cast_transport_host_filter)
miu 2016/04/15 23:14:39 Should the third arg be of type base::WeakPtr<cast
xjz 2016/04/20 01:09:02 Done. Use weak ptr.
+ : channel_id_(channel_id),
+ rtp_sender_ssrc_(rtp_sender_ssrc),
+ cast_transport_host_filter_(cast_transport_host_filter) {}
+
+ void OnCastMessageReceived(
+ const media::cast::RtcpCastMessage& cast_message) override {
+ cast_transport_host_filter_->Send(new CastMsg_RtcpCastMessage(
+ channel_id_, rtp_sender_ssrc_, cast_message));
+ }
+
+ void OnRttReceived(base::TimeDelta round_trip_time) override {
+ cast_transport_host_filter_->Send(
+ new CastMsg_Rtt(channel_id_, rtp_sender_ssrc_, round_trip_time));
+ }
+
+ void OnPliReceived() override {
+ cast_transport_host_filter_->Send(
+ new CastMsg_Pli(channel_id_, rtp_sender_ssrc_));
+ }
+
+ private:
+ int32_t channel_id_;
miu 2016/04/15 23:14:39 Please make these three members const.
xjz 2016/04/20 01:09:02 Done.
+ uint32_t rtp_sender_ssrc_;
+ cast::CastTransportHostFilter* cast_transport_host_filter_;
+
+ DISALLOW_COPY_AND_ASSIGN(RtcpClient);
+};
+
} // namespace
namespace cast {
@@ -103,24 +136,6 @@ bool CastTransportHostFilter::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void CastTransportHostFilter::SendRtt(int32_t channel_id,
- uint32_t rtp_sender_ssrc,
- base::TimeDelta rtt) {
- Send(new CastMsg_Rtt(channel_id, rtp_sender_ssrc, rtt));
-}
-
-void CastTransportHostFilter::SendCastMessage(
- int32_t channel_id,
- uint32_t rtp_sender_ssrc,
- const media::cast::RtcpCastMessage& cast_message) {
- Send(new CastMsg_RtcpCastMessage(channel_id, rtp_sender_ssrc, cast_message));
-}
-
-void CastTransportHostFilter::SendReceivedPli(int32_t channel_id,
- uint32_t rtp_sender_ssrc) {
- Send(new CastMsg_Pli(channel_id, rtp_sender_ssrc));
-}
-
void CastTransportHostFilter::OnNew(int32_t channel_id,
const net::IPEndPoint& local_end_point,
const net::IPEndPoint& remote_end_point,
@@ -176,13 +191,8 @@ void CastTransportHostFilter::OnInitializeAudio(
const media::cast::CastTransportRtpConfig& config) {
media::cast::CastTransport* sender = id_map_.Lookup(channel_id);
if (sender) {
- 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),
- base::Bind(&CastTransportHostFilter::SendReceivedPli,
- weak_factory_.GetWeakPtr(), channel_id, config.ssrc));
+ sender->InitializeAudio(config, base::WrapUnique(new RtcpClient(
+ channel_id, config.ssrc, this)));
} else {
DVLOG(1)
<< "CastTransportHostFilter::OnInitializeAudio on non-existing channel";
@@ -194,13 +204,8 @@ void CastTransportHostFilter::OnInitializeVideo(
const media::cast::CastTransportRtpConfig& config) {
media::cast::CastTransport* sender = id_map_.Lookup(channel_id);
if (sender) {
- 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),
- base::Bind(&CastTransportHostFilter::SendReceivedPli,
- weak_factory_.GetWeakPtr(), channel_id, config.ssrc));
+ sender->InitializeVideo(config, base::WrapUnique(new RtcpClient(
+ channel_id, config.ssrc, this)));
} else {
DVLOG(1)
<< "CastTransportHostFilter::OnInitializeVideo on non-existing channel";

Powered by Google App Engine
This is Rietveld 408576698