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

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

Issue 138753004: Cast: IPC glue between cast library transport and encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remote address not needed in new message Created 6 years, 11 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_net_host_filter.cc
diff --git a/chrome/browser/media/cast_net_host_filter.cc b/chrome/browser/media/cast_net_host_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5033721a22679501cab570460b90ca228b9b3b3d
--- /dev/null
+++ b/chrome/browser/media/cast_net_host_filter.cc
@@ -0,0 +1,124 @@
+// 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.
mikhal1 2014/01/23 21:04:38 add new line
hubbe 2014/02/03 22:58:59 Done.
+#include "chrome/browser/media/cast_net_host_filter.h"
+#include "media/cast/transport/cast_transport_sender.h"
+
+namespace cast {
+
+CastNetHostFilter::CastNetHostFilter() {
+}
+
+CastNetHostFilter::~CastNetHostFilter() {
+}
+
+bool CastNetHostFilter::OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(CastNetHostFilter, message)
+ IPC_MESSAGE_HANDLER(CastHostMsg_New, OnNew)
+ IPC_MESSAGE_HANDLER(CastHostMsg_Delete, OnDelete)
+ IPC_MESSAGE_HANDLER(CastHostMsg_InsertCodedAudioFrame,
+ OnInsertCodedAudioFrame)
+ IPC_MESSAGE_HANDLER(CastHostMsg_InsertCodedVideoFrame,
+ OnInsertCodedVideoFrame)
+ IPC_MESSAGE_HANDLER(CastHostMsg_SendRtcpFromRtpSender,
+ OnSendRtcpFromRtpSender);
+ IPC_MESSAGE_HANDLER(CastHostMsg_ResendPackets,
+ OnResendPackets)
+ IPC_END_MESSAGE_MAP();
+ return *message_was_ok = handled;
mikhal1 2014/01/23 21:04:38 This is initially set to true and never modified.
hubbe 2014/02/03 22:58:59 I had seen this in other handlers, but misundersto
+}
+
+CastNetHostFilter::PerSocketData::PerSocketData(
+ int32 channel_id,
+ CastNetHostFilter* filter,
+ const media::cast::transport::CastTransportConfig& config)
+ : channel_id_(channel_id),
+ filter_(filter),
+ sender_(media::cast::transport::CastTransportSender::
+ CreateCastTransportSender(
+ &filter->clock_,
+ config,
+ base::Bind(&CastNetHostFilter::PerSocketData::NotifyStatusChange,
+ base::Unretained(this)),
+ base::MessageLoopProxy::current())) {
+}
+
+CastNetHostFilter::PerSocketData::~PerSocketData() {
+}
+
+void CastNetHostFilter::PerSocketData::NotifyStatusChange(
+ media::cast::transport::CastTransportStatus status) {
+ filter_->Send(new CastMsg_NotifyStatusChange(channel_id_, status));
+}
+
+void CastNetHostFilter::OnNew(
+ int32 channel_id,
+ const media::cast::transport::CastTransportConfig& config) {
+ PerSocketData* ptr = id_map_.Lookup(channel_id);
+ if (ptr) {
+ id_map_.Remove(channel_id);
+ }
+
+ id_map_.AddWithID(
+ new PerSocketData(channel_id, this, config),
+ channel_id);
+}
+
+void CastNetHostFilter::OnDelete(
+ int32 channel_id) {
+ PerSocketData* ptr = id_map_.Lookup(channel_id);
+ if (ptr) {
+ id_map_.Remove(channel_id);
+ }
+}
+
+void CastNetHostFilter::OnInsertCodedAudioFrame(
+ int32 channel_id,
+ const media::cast::transport::EncodedAudioFrame& audio_frame,
+ base::TimeTicks recorded_time) {
+ PerSocketData* ptr = id_map_.Lookup(channel_id);
+ if (ptr) {
+ ptr->sender_->InsertCodedAudioFrame(&audio_frame, recorded_time);
+ }
+}
+
+void CastNetHostFilter::OnInsertCodedVideoFrame(
+ int32 channel_id,
+ const media::cast::transport::EncodedVideoFrame& video_frame,
+ base::TimeTicks capture_time) {
+ PerSocketData* ptr = id_map_.Lookup(channel_id);
+ if (ptr) {
+ ptr->sender_->InsertCodedVideoFrame(&video_frame, capture_time);
+ }
+}
+
+void CastNetHostFilter::OnSendRtcpFromRtpSender(
+ int32 channel_id,
+ const cast::SendRtcpFromRtpSenderData& data,
+ const media::cast::transport::RtcpSenderInfo& sender_info,
+ const media::cast::transport::RtcpDlrrReportBlock& dlrr,
+ const media::cast::transport::RtcpSenderLogMessage& sender_log) {
+ PerSocketData* ptr = id_map_.Lookup(channel_id);
+ if (ptr) {
mikhal1 2014/01/23 21:04:38 Shouldn't there be an error msg in case you didn't
hubbe 2014/02/03 22:58:59 Done.
+ ptr->sender_->SendRtcpFromRtpSender(data.packet_type_flags,
+ sender_info,
+ dlrr,
+ sender_log,
+ data.sending_ssrc,
+ data.c_name);
+ }
+}
+
+void CastNetHostFilter::OnResendPackets(
+ int32 channel_id,
+ bool is_audio,
+ const media::cast::MissingFramesAndPacketsMap& missing_packets) {
+ PerSocketData* ptr = id_map_.Lookup(channel_id);
+ if (ptr) {
+ ptr->sender_->ResendPackets(is_audio, missing_packets);
+ }
+}
+
+} // namespace cast

Powered by Google App Engine
This is Rietveld 408576698