Index: chrome/renderer/media/cast_ipc_helper.cc |
diff --git a/chrome/renderer/media/cast_ipc_helper.cc b/chrome/renderer/media/cast_ipc_helper.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a350a75437bb0300ef1dcccea76e8a1f80e81f6d |
--- /dev/null |
+++ b/chrome/renderer/media/cast_ipc_helper.cc |
@@ -0,0 +1,119 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/renderer/media/cast_ipc_helper.h" |
+ |
+namespace cast { |
+ |
+CastIPCDispatcher::CastIPCDispatcher(content::RenderView* render_view) |
+ : content::RenderViewObserver(render_view) { |
+} |
+ |
+CastIPCDispatcher::~CastIPCDispatcher() { |
+ IDMap<CastIPCNet>::iterator iter(&id_map_); |
+ while (!iter.IsAtEnd()) { |
+ iter.GetCurrentValue()->dispatcher_ = NULL; |
+ } |
+} |
+ |
+bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) |
+ IPC_MESSAGE_HANDLER(CastMsg_GotPacket, OnGotPacket) |
+ IPC_END_MESSAGE_MAP(); |
+ return handled; |
mikhal1
2014/01/23 21:04:38
Same comment as above regarding handled.
hubbe
2014/02/03 22:58:59
Done.
|
+} |
+ |
+void CastIPCDispatcher::OnGotPacket(int32 channel_id, |
+ const media::cast::Packet& packet) { |
+ CastIPCNet* ptr = id_map_.Lookup(channel_id); |
+ if (ptr && ptr->packet_callback_.is_null()) { |
+ ptr->packet_callback_.Run(packet); |
+ } |
+} |
+ |
+void CastIPCDispatcher::OnRtpStatisticsUpdate( |
+ int32 channel_id, |
+ const base::TimeTicks& now, |
+ const media::cast::transport::RtcpSenderInfo& sender_info) { |
+ // TODO(hubbe): Not yet implemented |
+} |
+ |
+void CastIPCDispatcher::OnNotifyStatusChange( |
+ int32 channel_id, |
+ media::cast::transport::CastTransportStatus status) { |
+ CastIPCNet* ptr = id_map_.Lookup(channel_id); |
+ if (ptr) { |
+ ptr->status_callback_.Run(status); |
+ } |
+} |
+ |
+CastIPCNet::CastIPCNet( |
+ const media::cast::transport::CastTransportConfig& config, |
+ CastIPCDispatcher* dispatcher) |
+ : dispatcher_(dispatcher) { |
+ channel_id_ = dispatcher_->id_map_.Add(this); |
+ Send(new CastHostMsg_New(channel_id_, config)); |
+} |
+ |
+CastIPCNet::~CastIPCNet() { |
+ Send(new CastHostMsg_Delete(channel_id_)); |
+ if (dispatcher_) { |
+ dispatcher_->id_map_.Remove(channel_id_); |
+ } |
+} |
+ |
+bool CastIPCNet::Send(IPC::Message *message) { |
+ if (dispatcher_) { |
+ return dispatcher_->Send(message); |
+ } else { |
+ delete message; |
+ return false; |
+ } |
+} |
+ |
+void CastIPCNet::InsertCodedAudioFrame( |
+ const media::cast::transport::EncodedAudioFrame* audio_frame, |
+ const base::TimeTicks& recorded_time) { |
+ Send(new CastHostMsg_InsertCodedAudioFrame(channel_id_, |
+ *audio_frame, |
+ recorded_time)); |
+} |
+ |
+void CastIPCNet::InsertCodedVideoFrame( |
+ const media::cast::transport::EncodedVideoFrame* video_frame, |
+ const base::TimeTicks& capture_time) { |
+ Send(new CastHostMsg_InsertCodedVideoFrame(channel_id_, |
+ *video_frame, |
+ capture_time)); |
+} |
+ |
+void CastIPCNet::SendRtcpFromRtpSender( |
+ uint32 packet_type_flags, |
+ const media::cast::transport::RtcpSenderInfo& sender_info, |
+ const media::cast::transport::RtcpDlrrReportBlock& dlrr, |
+ const media::cast::transport::RtcpSenderLogMessage& sender_log, |
+ uint32 sending_ssrc, |
+ const std::string& c_name) { |
+ struct cast::SendRtcpFromRtpSenderData data; |
+ data.packet_type_flags = packet_type_flags; |
+ data.sending_ssrc = sending_ssrc; |
+ data.c_name = data.c_name; |
+ Send(new CastHostMsg_SendRtcpFromRtpSender( |
+ channel_id_, |
+ data, |
+ sender_info, |
+ dlrr, |
+ sender_log)); |
+} |
+ |
+void CastIPCNet::ResendPackets( |
+ bool is_audio, |
+ const media::cast::MissingFramesAndPacketsMap& missing_packets) { |
+ Send(new CastHostMsg_ResendPackets(channel_id_, |
+ is_audio, |
+ missing_packets)); |
+} |
+ |
+} // namespace cast |