Home | History | Annotate | Download | only in media
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
      6 #define CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
      7 
      8 #include <map>
      9 
     10 #include "base/message_loop/message_loop_proxy.h"
     11 #include "ipc/ipc_channel_proxy.h"
     12 #include "media/cast/logging/logging_defines.h"
     13 #include "media/cast/net/cast_transport_sender.h"
     14 
     15 // This implementation of the CastTransportSender interface
     16 // communicates with the browser process over IPC and relays
     17 // all calls to/from the transport sender to the browser process.
     18 // The primary reason for this arrangement is to give the
     19 // renderer less direct control over the UDP sockets.
     20 class CastTransportSenderIPC
     21     : public media::cast::CastTransportSender {
     22  public:
     23   CastTransportSenderIPC(
     24       const net::IPEndPoint& remote_end_point,
     25       scoped_ptr<base::DictionaryValue> options,
     26       const media::cast::CastTransportStatusCallback& status_cb,
     27       const media::cast::BulkRawEventsCallback& raw_events_cb);
     28 
     29   virtual ~CastTransportSenderIPC();
     30 
     31   // media::cast::CastTransportSender implementation.
     32   virtual void InitializeAudio(
     33       const media::cast::CastTransportRtpConfig& config,
     34       const media::cast::RtcpCastMessageCallback& cast_message_cb,
     35       const media::cast::RtcpRttCallback& rtt_cb) OVERRIDE;
     36   virtual void InitializeVideo(
     37       const media::cast::CastTransportRtpConfig& config,
     38       const media::cast::RtcpCastMessageCallback& cast_message_cb,
     39       const media::cast::RtcpRttCallback& rtt_cb) OVERRIDE;
     40   virtual void InsertFrame(uint32 ssrc,
     41       const media::cast::EncodedFrame& frame) OVERRIDE;
     42   virtual void SendSenderReport(
     43       uint32 ssrc,
     44       base::TimeTicks current_time,
     45       uint32 current_time_as_rtp_timestamp) OVERRIDE;
     46   virtual void CancelSendingFrames(
     47       uint32 ssrc,
     48       const std::vector<uint32>& frame_ids) OVERRIDE;
     49   virtual void ResendFrameForKickstart(uint32 ssrc, uint32 frame_id) OVERRIDE;
     50 
     51   void OnNotifyStatusChange(
     52       media::cast::CastTransportStatus status);
     53   void OnRawEvents(const std::vector<media::cast::PacketEvent>& packet_events,
     54                    const std::vector<media::cast::FrameEvent>& frame_events);
     55   void OnRtt(uint32 ssrc, base::TimeDelta rtt);
     56   void OnRtcpCastMessage(uint32 ssrc,
     57                          const media::cast::RtcpCastMessage& cast_message);
     58 
     59  private:
     60   struct ClientCallbacks {
     61     ClientCallbacks();
     62     ~ClientCallbacks();
     63 
     64     media::cast::RtcpCastMessageCallback cast_message_cb;
     65     media::cast::RtcpRttCallback rtt_cb;
     66   };
     67 
     68   void Send(IPC::Message* message);
     69 
     70   int32 channel_id_;
     71   media::cast::PacketReceiverCallback packet_callback_;
     72   media::cast::CastTransportStatusCallback status_callback_;
     73   media::cast::BulkRawEventsCallback raw_events_callback_;
     74   typedef std::map<uint32, ClientCallbacks> ClientMap;
     75   ClientMap clients_;
     76 
     77   DISALLOW_COPY_AND_ASSIGN(CastTransportSenderIPC);
     78 };
     79 
     80 #endif  // CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
     81