Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/renderer/media/cast_ipc_helper.h" | |
| 6 | |
| 7 namespace cast { | |
| 8 | |
| 9 CastIPCDispatcher::CastIPCDispatcher(content::RenderView* render_view) | |
| 10 : content::RenderViewObserver(render_view) { | |
| 11 } | |
| 12 | |
| 13 CastIPCDispatcher::~CastIPCDispatcher() { | |
| 14 IDMap<CastIPCNet>::iterator iter(&id_map_); | |
| 15 while (!iter.IsAtEnd()) { | |
| 16 iter.GetCurrentValue()->dispatcher_ = NULL; | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { | |
| 21 bool handled = true; | |
| 22 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) | |
| 23 IPC_MESSAGE_HANDLER(CastMsg_GotPacket, OnGotPacket) | |
| 24 IPC_END_MESSAGE_MAP(); | |
| 25 return handled; | |
|
mikhal1
2014/01/23 21:04:38
Same comment as above regarding handled.
hubbe
2014/02/03 22:58:59
Done.
| |
| 26 } | |
| 27 | |
| 28 void CastIPCDispatcher::OnGotPacket(int32 channel_id, | |
| 29 const media::cast::Packet& packet) { | |
| 30 CastIPCNet* ptr = id_map_.Lookup(channel_id); | |
| 31 if (ptr && ptr->packet_callback_.is_null()) { | |
| 32 ptr->packet_callback_.Run(packet); | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 void CastIPCDispatcher::OnRtpStatisticsUpdate( | |
| 37 int32 channel_id, | |
| 38 const base::TimeTicks& now, | |
| 39 const media::cast::transport::RtcpSenderInfo& sender_info) { | |
| 40 // TODO(hubbe): Not yet implemented | |
| 41 } | |
| 42 | |
| 43 void CastIPCDispatcher::OnNotifyStatusChange( | |
| 44 int32 channel_id, | |
| 45 media::cast::transport::CastTransportStatus status) { | |
| 46 CastIPCNet* ptr = id_map_.Lookup(channel_id); | |
| 47 if (ptr) { | |
| 48 ptr->status_callback_.Run(status); | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 CastIPCNet::CastIPCNet( | |
| 53 const media::cast::transport::CastTransportConfig& config, | |
| 54 CastIPCDispatcher* dispatcher) | |
| 55 : dispatcher_(dispatcher) { | |
| 56 channel_id_ = dispatcher_->id_map_.Add(this); | |
| 57 Send(new CastHostMsg_New(channel_id_, config)); | |
| 58 } | |
| 59 | |
| 60 CastIPCNet::~CastIPCNet() { | |
| 61 Send(new CastHostMsg_Delete(channel_id_)); | |
| 62 if (dispatcher_) { | |
| 63 dispatcher_->id_map_.Remove(channel_id_); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 bool CastIPCNet::Send(IPC::Message *message) { | |
| 68 if (dispatcher_) { | |
| 69 return dispatcher_->Send(message); | |
| 70 } else { | |
| 71 delete message; | |
| 72 return false; | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 void CastIPCNet::InsertCodedAudioFrame( | |
| 77 const media::cast::transport::EncodedAudioFrame* audio_frame, | |
| 78 const base::TimeTicks& recorded_time) { | |
| 79 Send(new CastHostMsg_InsertCodedAudioFrame(channel_id_, | |
| 80 *audio_frame, | |
| 81 recorded_time)); | |
| 82 } | |
| 83 | |
| 84 void CastIPCNet::InsertCodedVideoFrame( | |
| 85 const media::cast::transport::EncodedVideoFrame* video_frame, | |
| 86 const base::TimeTicks& capture_time) { | |
| 87 Send(new CastHostMsg_InsertCodedVideoFrame(channel_id_, | |
| 88 *video_frame, | |
| 89 capture_time)); | |
| 90 } | |
| 91 | |
| 92 void CastIPCNet::SendRtcpFromRtpSender( | |
| 93 uint32 packet_type_flags, | |
| 94 const media::cast::transport::RtcpSenderInfo& sender_info, | |
| 95 const media::cast::transport::RtcpDlrrReportBlock& dlrr, | |
| 96 const media::cast::transport::RtcpSenderLogMessage& sender_log, | |
| 97 uint32 sending_ssrc, | |
| 98 const std::string& c_name) { | |
| 99 struct cast::SendRtcpFromRtpSenderData data; | |
| 100 data.packet_type_flags = packet_type_flags; | |
| 101 data.sending_ssrc = sending_ssrc; | |
| 102 data.c_name = data.c_name; | |
| 103 Send(new CastHostMsg_SendRtcpFromRtpSender( | |
| 104 channel_id_, | |
| 105 data, | |
| 106 sender_info, | |
| 107 dlrr, | |
| 108 sender_log)); | |
| 109 } | |
| 110 | |
| 111 void CastIPCNet::ResendPackets( | |
| 112 bool is_audio, | |
| 113 const media::cast::MissingFramesAndPacketsMap& missing_packets) { | |
| 114 Send(new CastHostMsg_ResendPackets(channel_id_, | |
| 115 is_audio, | |
| 116 missing_packets)); | |
| 117 } | |
| 118 | |
| 119 } // namespace cast | |
| OLD | NEW |