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

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

Issue 765643006: Cast: Make receiver use cast_transport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix end2end test Created 6 years 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/renderer/media/cast_transport_sender_ipc.h ('k') | media/cast/BUILD.gn » ('j') | 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 "chrome/renderer/media/cast_transport_sender_ipc.h" 5 #include "chrome/renderer/media/cast_transport_sender_ipc.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/id_map.h" 8 #include "base/id_map.h"
9 #include "chrome/common/cast_messages.h" 9 #include "chrome/common/cast_messages.h"
10 #include "chrome/renderer/media/cast_ipc_dispatcher.h" 10 #include "chrome/renderer/media/cast_ipc_dispatcher.h"
11 #include "ipc/ipc_channel_proxy.h" 11 #include "ipc/ipc_channel_proxy.h"
12 #include "media/cast/cast_sender.h" 12 #include "media/cast/cast_sender.h"
13 13
14 CastTransportSenderIPC::ClientCallbacks::ClientCallbacks() {} 14 CastTransportSenderIPC::ClientCallbacks::ClientCallbacks() {}
15 CastTransportSenderIPC::ClientCallbacks::~ClientCallbacks() {} 15 CastTransportSenderIPC::ClientCallbacks::~ClientCallbacks() {}
16 16
17 CastTransportSenderIPC::CastTransportSenderIPC( 17 CastTransportSenderIPC::CastTransportSenderIPC(
18 const net::IPEndPoint& local_end_point,
18 const net::IPEndPoint& remote_end_point, 19 const net::IPEndPoint& remote_end_point,
19 scoped_ptr<base::DictionaryValue> options, 20 scoped_ptr<base::DictionaryValue> options,
21 const media::cast::PacketReceiverCallback& packet_callback,
20 const media::cast::CastTransportStatusCallback& status_cb, 22 const media::cast::CastTransportStatusCallback& status_cb,
21 const media::cast::BulkRawEventsCallback& raw_events_cb) 23 const media::cast::BulkRawEventsCallback& raw_events_cb)
22 : status_callback_(status_cb), raw_events_callback_(raw_events_cb) { 24 : packet_callback_(packet_callback) ,
25 status_callback_(status_cb),
26 raw_events_callback_(raw_events_cb) {
23 if (CastIPCDispatcher::Get()) { 27 if (CastIPCDispatcher::Get()) {
24 channel_id_ = CastIPCDispatcher::Get()->AddSender(this); 28 channel_id_ = CastIPCDispatcher::Get()->AddSender(this);
25 } 29 }
26 Send(new CastHostMsg_New(channel_id_, remote_end_point, *options)); 30 Send(new CastHostMsg_New(channel_id_,
31 local_end_point,
32 remote_end_point,
33 *options));
27 } 34 }
28 35
29 CastTransportSenderIPC::~CastTransportSenderIPC() { 36 CastTransportSenderIPC::~CastTransportSenderIPC() {
30 Send(new CastHostMsg_Delete(channel_id_)); 37 Send(new CastHostMsg_Delete(channel_id_));
31 if (CastIPCDispatcher::Get()) { 38 if (CastIPCDispatcher::Get()) {
32 CastIPCDispatcher::Get()->RemoveSender(channel_id_); 39 CastIPCDispatcher::Get()->RemoveSender(channel_id_);
33 } 40 }
34 } 41 }
35 42
36 void CastTransportSenderIPC::InitializeAudio( 43 void CastTransportSenderIPC::InitializeAudio(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 frame_ids)); 80 frame_ids));
74 } 81 }
75 82
76 void CastTransportSenderIPC::ResendFrameForKickstart( 83 void CastTransportSenderIPC::ResendFrameForKickstart(
77 uint32 ssrc, uint32 frame_id) { 84 uint32 ssrc, uint32 frame_id) {
78 Send(new CastHostMsg_ResendFrameForKickstart(channel_id_, 85 Send(new CastHostMsg_ResendFrameForKickstart(channel_id_,
79 ssrc, 86 ssrc,
80 frame_id)); 87 frame_id));
81 } 88 }
82 89
90 void CastTransportSenderIPC::AddValidSsrc(uint32 ssrc) {
91 Send(new CastHostMsg_AddValidSsrc(channel_id_, ssrc));
92 }
93
94
Tom Sepez 2014/12/10 23:52:57 nit: extra blank line.
hubbe 2014/12/11 00:10:32 Done.
95 void CastTransportSenderIPC::SendRtcpFromRtpReceiver(
96 uint32 ssrc,
97 uint32 sender_ssrc,
98 const media::cast::RtcpTimeData& time_data,
99 const media::cast::RtcpCastMessage* cast_message,
100 base::TimeDelta target_delay,
101 const media::cast::ReceiverRtcpEventSubscriber::RtcpEvents*
102 rtcp_events,
103 const media::cast::RtpReceiverStatistics* rtp_receiver_statistics) {
104 // To avoid copies, we put pointers to objects we don't really
Tom Sepez 2014/12/10 23:52:57 Sounds dangerous, can we avoid this?
hubbe 2014/12/11 00:10:32 The only way I see to avoid it is to actually copy
105 // own into scoped pointers and then very carefully extract them again
106 // before the scoped pointers go out of scope.
107 media::cast::SendRtcpFromRtpReceiver_Params params;
108 params.ssrc = ssrc;
109 params.sender_ssrc = sender_ssrc;
110 params.time_data = time_data;
111 if (cast_message) {
112 params.cast_message.reset(
113 const_cast<media::cast::RtcpCastMessage*>(cast_message));
114 }
115 params.target_delay = target_delay;
116 if (rtcp_events) {
117 params.rtcp_events.reset(
118 const_cast<media::cast::ReceiverRtcpEventSubscriber::RtcpEvents*>(
119 rtcp_events));
120 }
121 if (rtp_receiver_statistics) {
122 params.rtp_receiver_statistics.reset(
123 const_cast<media::cast::RtpReceiverStatistics*>(
124 rtp_receiver_statistics));
125 }
126 // Note, params contains scoped_ptr<>, but this still works because
127 // CastHostMsg_SendRtcpFromRtpReceiver doesn't take ownership, it
128 // serializes it and remember the serialized form instead.
129 Send(new CastHostMsg_SendRtcpFromRtpReceiver(channel_id_, params));
130
131 ignore_result(params.rtp_receiver_statistics.release());
132 ignore_result(params.cast_message.release());
133 ignore_result(params.rtcp_events.release());
134 }
135
136
83 void CastTransportSenderIPC::OnNotifyStatusChange( 137 void CastTransportSenderIPC::OnNotifyStatusChange(
84 media::cast::CastTransportStatus status) { 138 media::cast::CastTransportStatus status) {
85 status_callback_.Run(status); 139 status_callback_.Run(status);
86 } 140 }
87 141
88 void CastTransportSenderIPC::OnRawEvents( 142 void CastTransportSenderIPC::OnRawEvents(
89 const std::vector<media::cast::PacketEvent>& packet_events, 143 const std::vector<media::cast::PacketEvent>& packet_events,
90 const std::vector<media::cast::FrameEvent>& frame_events) { 144 const std::vector<media::cast::FrameEvent>& frame_events) {
91 raw_events_callback_.Run(packet_events, frame_events); 145 raw_events_callback_.Run(packet_events, frame_events);
92 } 146 }
(...skipping 14 matching lines...) Expand all
107 ClientMap::iterator it = clients_.find(ssrc); 161 ClientMap::iterator it = clients_.find(ssrc);
108 if (it == clients_.end()) { 162 if (it == clients_.end()) {
109 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc; 163 LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc;
110 return; 164 return;
111 } 165 }
112 if (it->second.cast_message_cb.is_null()) 166 if (it->second.cast_message_cb.is_null())
113 return; 167 return;
114 it->second.cast_message_cb.Run(cast_message); 168 it->second.cast_message_cb.Run(cast_message);
115 } 169 }
116 170
171 void CastTransportSenderIPC::OnReceivedPacket(
172 const media::cast::Packet& packet) {
173 if (!packet_callback_.is_null()) {
174 // TODO(hubbe): Perhaps an non-ownership-transferring cb here?
175 scoped_ptr<media::cast::Packet> packet_copy(
176 new media::cast::Packet(packet));
177 packet_callback_.Run(packet_copy.Pass());
178 } else {
179 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet.";
180 }
181 }
182
117 void CastTransportSenderIPC::Send(IPC::Message* message) { 183 void CastTransportSenderIPC::Send(IPC::Message* message) {
118 if (CastIPCDispatcher::Get()) { 184 if (CastIPCDispatcher::Get()) {
119 CastIPCDispatcher::Get()->Send(message); 185 CastIPCDispatcher::Get()->Send(message);
120 } else { 186 } else {
121 delete message; 187 delete message;
122 } 188 }
123 } 189 }
OLDNEW
« no previous file with comments | « chrome/renderer/media/cast_transport_sender_ipc.h ('k') | media/cast/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698