Chromium Code Reviews| Index: chrome/renderer/media/cast_transport_sender_ipc.h |
| diff --git a/chrome/renderer/media/cast_transport_sender_ipc.h b/chrome/renderer/media/cast_transport_sender_ipc.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b3f3351d3a3265ea309e33c051c4d079daec8f88 |
| --- /dev/null |
| +++ b/chrome/renderer/media/cast_transport_sender_ipc.h |
| @@ -0,0 +1,115 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_ |
| +#define CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/id_map.h" |
| +#include "content/common/cast_messages.h" |
| +#include "ipc/ipc_channel_proxy.h" |
| +#include "media/cast/cast_sender.h" |
| +#include "media/cast/transport/cast_transport_sender.h" |
| + |
| +namespace cast { |
| + |
| +class CastIPCDispatcher; |
| + |
| +// This implementation of the CastTransportSender interface |
| +// communicates with the browser process over IPC and relays |
| +// all calls to/from the transport sender to the browser process. |
| +// The primary reason for this arrangement is to give the |
| +// renderer less direct control over the UDP sockets. |
| +class CastTransportSenderIPC |
| + : public media::cast::transport::CastTransportSender { |
| + public: |
| + explicit CastTransportSenderIPC( |
|
mikhal1
2014/02/05 00:53:05
remove explicit
hubbe
2014/02/05 01:11:44
Done.
|
| + const media::cast::transport::CastTransportConfig& config, |
| + const media::cast::transport::CastTransportStatusCallback& status_cb); |
| + virtual ~CastTransportSenderIPC(); |
| + |
| + // media::cast::transport::CastNetSender implementation |
|
mikhal1
2014/02/05 00:53:05
CastNetSender->CastTransportSender
hubbe
2014/02/05 01:11:44
Done.
|
| + virtual void SetPacketReceiver( |
| + const media::cast::transport::PacketReceiverCallback& packet_callback) |
| + OVERRIDE; |
| + virtual void InsertCodedAudioFrame( |
| + const media::cast::transport::EncodedAudioFrame* audio_frame, |
| + const base::TimeTicks& recorded_time) OVERRIDE; |
| + virtual void InsertCodedVideoFrame( |
| + const media::cast::transport::EncodedVideoFrame* video_frame, |
| + const base::TimeTicks& capture_time) OVERRIDE; |
| + |
| + virtual void 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) OVERRIDE; |
| + |
| + // Retransmission request. |
| + virtual void ResendPackets( |
| + bool is_audio, |
| + const media::cast::MissingFramesAndPacketsMap& missing_packets) OVERRIDE; |
| + |
| + // Retrieves audio RTP statistics. |
| + virtual void RtpAudioStatistics( |
| + const base::TimeTicks& now, |
| + media::cast::transport::RtcpSenderInfo* sender_info) OVERRIDE; |
| + |
| + // Retrieves video RTP statistics. |
| + virtual void RtpVideoStatistics( |
| + const base::TimeTicks& now, |
| + media::cast::transport::RtcpSenderInfo* sender_info) OVERRIDE; |
| + |
| + private: |
| + bool Send(IPC::Message *message); |
| + |
| + friend class CastIPCDispatcher; |
| + int32 channel_id_; |
| + media::cast::transport::PacketReceiverCallback packet_callback_; |
| + media::cast::transport::CastTransportStatusCallback status_callback_; |
| + DISALLOW_COPY_AND_ASSIGN(CastTransportSenderIPC); |
| +}; |
| + |
| +// This dispatcher listens to incoming IPC messages and sends |
| +// the call to the correct CastTransportSenderIPC instance. |
| +class CastIPCDispatcher : public IPC::ChannelProxy::MessageFilter { |
| + public: |
| + explicit CastIPCDispatcher( |
| + const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
| + |
| + // IPC::ChannelProxy::MessageFilter implementation |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
| + virtual void OnFilterRemoved() OVERRIDE; |
| + virtual void OnChannelClosing() OVERRIDE; |
| + |
| + protected: |
| + virtual ~CastIPCDispatcher(); |
| + |
| + private: |
| + void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet); |
| + void OnNotifyStatusChange( |
| + int32 channel_id, |
| + media::cast::transport::CastTransportStatus status); |
| + |
| + friend CastTransportSenderIPC; |
| + static CastIPCDispatcher* global_instance_; |
| + |
| + // IPC channel for Send(); must only be accesed on |io_message_loop_|. |
| + IPC::Channel* channel_; |
| + |
| + // Message loop on which IPC calls are driven. |
| + const scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| + |
| + // A map of stream ids to delegates; must only be accessed on |
| + // |io_message_loop_|. |
| + IDMap<CastTransportSenderIPC> id_map_; |
| + DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher); |
| +}; |
| + |
| +} // namespace cast |
| + |
| +#endif // CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_ |