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

Side by Side Diff: chrome/renderer/media/cast_transport_sender_ipc.cc

Issue 1709863002: Add Cast PLI support on sender side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate Pli message from Cast message. Created 4 years, 10 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
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 "chrome/renderer/media/cast_transport_sender_ipc.h" 5 #include "chrome/renderer/media/cast_transport_sender_ipc.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/id_map.h" 10 #include "base/id_map.h"
(...skipping 27 matching lines...) Expand all
38 CastTransportSenderIPC::~CastTransportSenderIPC() { 38 CastTransportSenderIPC::~CastTransportSenderIPC() {
39 Send(new CastHostMsg_Delete(channel_id_)); 39 Send(new CastHostMsg_Delete(channel_id_));
40 if (CastIPCDispatcher::Get()) { 40 if (CastIPCDispatcher::Get()) {
41 CastIPCDispatcher::Get()->RemoveSender(channel_id_); 41 CastIPCDispatcher::Get()->RemoveSender(channel_id_);
42 } 42 }
43 } 43 }
44 44
45 void CastTransportSenderIPC::InitializeAudio( 45 void CastTransportSenderIPC::InitializeAudio(
46 const media::cast::CastTransportRtpConfig& config, 46 const media::cast::CastTransportRtpConfig& config,
47 const media::cast::RtcpCastMessageCallback& cast_message_cb, 47 const media::cast::RtcpCastMessageCallback& cast_message_cb,
48 const media::cast::RtcpRttCallback& rtt_cb) { 48 const media::cast::RtcpRttCallback& rtt_cb,
49 const media::cast::RtcpPliCallback& pli_cb) {
49 clients_[config.ssrc].cast_message_cb = cast_message_cb; 50 clients_[config.ssrc].cast_message_cb = cast_message_cb;
50 clients_[config.ssrc].rtt_cb = rtt_cb; 51 clients_[config.ssrc].rtt_cb = rtt_cb;
52 clients_[config.ssrc].pli_cb = pli_cb;
51 Send(new CastHostMsg_InitializeAudio(channel_id_, config)); 53 Send(new CastHostMsg_InitializeAudio(channel_id_, config));
52 } 54 }
53 55
54 void CastTransportSenderIPC::InitializeVideo( 56 void CastTransportSenderIPC::InitializeVideo(
55 const media::cast::CastTransportRtpConfig& config, 57 const media::cast::CastTransportRtpConfig& config,
56 const media::cast::RtcpCastMessageCallback& cast_message_cb, 58 const media::cast::RtcpCastMessageCallback& cast_message_cb,
57 const media::cast::RtcpRttCallback& rtt_cb) { 59 const media::cast::RtcpRttCallback& rtt_cb,
60 const media::cast::RtcpPliCallback& pli_cb) {
58 clients_[config.ssrc].cast_message_cb = cast_message_cb; 61 clients_[config.ssrc].cast_message_cb = cast_message_cb;
59 clients_[config.ssrc].rtt_cb = rtt_cb; 62 clients_[config.ssrc].rtt_cb = rtt_cb;
63 clients_[config.ssrc].pli_cb = pli_cb;
60 Send(new CastHostMsg_InitializeVideo(channel_id_, config)); 64 Send(new CastHostMsg_InitializeVideo(channel_id_, config));
61 } 65 }
62 66
63 void CastTransportSenderIPC::InsertFrame( 67 void CastTransportSenderIPC::InsertFrame(
64 uint32_t ssrc, 68 uint32_t ssrc,
65 const media::cast::EncodedFrame& frame) { 69 const media::cast::EncodedFrame& frame) {
66 Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame)); 70 Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame));
67 } 71 }
68 72
69 void CastTransportSenderIPC::SendSenderReport( 73 void CastTransportSenderIPC::SendSenderReport(
(...skipping 23 matching lines...) Expand all
93 97
94 void CastTransportSenderIPC::AddValidSsrc(uint32_t ssrc) { 98 void CastTransportSenderIPC::AddValidSsrc(uint32_t ssrc) {
95 Send(new CastHostMsg_AddValidSsrc(channel_id_, ssrc)); 99 Send(new CastHostMsg_AddValidSsrc(channel_id_, ssrc));
96 } 100 }
97 101
98 void CastTransportSenderIPC::SendRtcpFromRtpReceiver( 102 void CastTransportSenderIPC::SendRtcpFromRtpReceiver(
99 uint32_t ssrc, 103 uint32_t ssrc,
100 uint32_t sender_ssrc, 104 uint32_t sender_ssrc,
101 const media::cast::RtcpTimeData& time_data, 105 const media::cast::RtcpTimeData& time_data,
102 const media::cast::RtcpCastMessage* cast_message, 106 const media::cast::RtcpCastMessage* cast_message,
107 const media::cast::RtcpPliMessage* pli_message,
103 base::TimeDelta target_delay, 108 base::TimeDelta target_delay,
104 const media::cast::ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, 109 const media::cast::ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events,
105 const media::cast::RtpReceiverStatistics* rtp_receiver_statistics) { 110 const media::cast::RtpReceiverStatistics* rtp_receiver_statistics) {
106 // To avoid copies, we put pointers to objects we don't really 111 // To avoid copies, we put pointers to objects we don't really
107 // own into scoped pointers and then very carefully extract them again 112 // own into scoped pointers and then very carefully extract them again
108 // before the scoped pointers go out of scope. 113 // before the scoped pointers go out of scope.
109 media::cast::SendRtcpFromRtpReceiver_Params params; 114 media::cast::SendRtcpFromRtpReceiver_Params params;
110 params.ssrc = ssrc; 115 params.ssrc = ssrc;
111 params.sender_ssrc = sender_ssrc; 116 params.sender_ssrc = sender_ssrc;
112 params.time_data = time_data; 117 params.time_data = time_data;
113 if (cast_message) { 118 if (cast_message) {
114 params.cast_message.reset( 119 params.cast_message.reset(
115 const_cast<media::cast::RtcpCastMessage*>(cast_message)); 120 const_cast<media::cast::RtcpCastMessage*>(cast_message));
116 } 121 }
122 if (pli_message) {
123 params.pli_message.reset(
124 const_cast<media::cast::RtcpPliMessage*>(pli_message));
125 }
117 params.target_delay = target_delay; 126 params.target_delay = target_delay;
118 if (rtcp_events) { 127 if (rtcp_events) {
119 params.rtcp_events.reset( 128 params.rtcp_events.reset(
120 const_cast<media::cast::ReceiverRtcpEventSubscriber::RtcpEvents*>( 129 const_cast<media::cast::ReceiverRtcpEventSubscriber::RtcpEvents*>(
121 rtcp_events)); 130 rtcp_events));
122 } 131 }
123 if (rtp_receiver_statistics) { 132 if (rtp_receiver_statistics) {
124 params.rtp_receiver_statistics.reset( 133 params.rtp_receiver_statistics.reset(
125 const_cast<media::cast::RtpReceiverStatistics*>( 134 const_cast<media::cast::RtpReceiverStatistics*>(
126 rtp_receiver_statistics)); 135 rtp_receiver_statistics));
127 } 136 }
128 // Note, params contains scoped_ptr<>, but this still works because 137 // Note, params contains scoped_ptr<>, but this still works because
129 // CastHostMsg_SendRtcpFromRtpReceiver doesn't take ownership, it 138 // CastHostMsg_SendRtcpFromRtpReceiver doesn't take ownership, it
130 // serializes it and remember the serialized form instead. 139 // serializes it and remember the serialized form instead.
131 Send(new CastHostMsg_SendRtcpFromRtpReceiver(channel_id_, params)); 140 Send(new CastHostMsg_SendRtcpFromRtpReceiver(channel_id_, params));
132 141
133 ignore_result(params.rtp_receiver_statistics.release()); 142 ignore_result(params.rtp_receiver_statistics.release());
134 ignore_result(params.cast_message.release()); 143 ignore_result(params.cast_message.release());
144 ignore_result(params.pli_message.release());
135 ignore_result(params.rtcp_events.release()); 145 ignore_result(params.rtcp_events.release());
136 } 146 }
137 147
138 148
139 void CastTransportSenderIPC::OnNotifyStatusChange( 149 void CastTransportSenderIPC::OnNotifyStatusChange(
140 media::cast::CastTransportStatus status) { 150 media::cast::CastTransportStatus status) {
141 status_callback_.Run(status); 151 status_callback_.Run(status);
142 } 152 }
143 153
144 void CastTransportSenderIPC::OnRawEvents( 154 void CastTransportSenderIPC::OnRawEvents(
(...skipping 30 matching lines...) Expand all
175 ClientMap::iterator it = clients_.find(ssrc); 185 ClientMap::iterator it = clients_.find(ssrc);
176 if (it == clients_.end()) { 186 if (it == clients_.end()) {
177 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc; 187 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc;
178 return; 188 return;
179 } 189 }
180 if (it->second.cast_message_cb.is_null()) 190 if (it->second.cast_message_cb.is_null())
181 return; 191 return;
182 it->second.cast_message_cb.Run(cast_message); 192 it->second.cast_message_cb.Run(cast_message);
183 } 193 }
184 194
195 void CastTransportSenderIPC::OnReceivedPli(uint32_t ssrc) {
196 ClientMap::iterator it = clients_.find(ssrc);
197 if (it == clients_.end()) {
198 LOG(ERROR) << "Received picture loss indicator from for unknown SSRC: "
199 << ssrc;
200 return;
201 }
202 if (!it->second.pli_cb.is_null())
203 it->second.pli_cb.Run();
204 }
205
185 void CastTransportSenderIPC::OnReceivedPacket( 206 void CastTransportSenderIPC::OnReceivedPacket(
186 const media::cast::Packet& packet) { 207 const media::cast::Packet& packet) {
187 if (!packet_callback_.is_null()) { 208 if (!packet_callback_.is_null()) {
188 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? 209 // TODO(hubbe): Perhaps an non-ownership-transferring cb here?
189 scoped_ptr<media::cast::Packet> packet_copy( 210 scoped_ptr<media::cast::Packet> packet_copy(
190 new media::cast::Packet(packet)); 211 new media::cast::Packet(packet));
191 packet_callback_.Run(std::move(packet_copy)); 212 packet_callback_.Run(std::move(packet_copy));
192 } else { 213 } else {
193 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; 214 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet.";
194 } 215 }
195 } 216 }
196 217
197 void CastTransportSenderIPC::Send(IPC::Message* message) { 218 void CastTransportSenderIPC::Send(IPC::Message* message) {
198 if (CastIPCDispatcher::Get()) { 219 if (CastIPCDispatcher::Get()) {
199 CastIPCDispatcher::Get()->Send(message); 220 CastIPCDispatcher::Get()->Send(message);
200 } else { 221 } else {
201 delete message; 222 delete message;
202 } 223 }
203 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698