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

Side by Side Diff: chrome/renderer/media/cast_transport_sender_ipc.h

Issue 138753004: Cast: IPC glue between cast library transport and encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added rtp statistics callbacks Created 6 years, 10 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 unified diff | Download patch
OLDNEW
(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 #ifndef CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
6 #define CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
7
8 #include "base/callback.h"
9 #include "base/id_map.h"
10 #include "content/common/cast_messages.h"
11 #include "ipc/ipc_channel_proxy.h"
12 #include "media/cast/cast_sender.h"
13 #include "media/cast/transport/cast_transport_sender.h"
14
15 namespace cast {
scherkus (not reviewing) 2014/02/07 00:11:06 IIRC we prefer chrome/ code to be in the global na
hubbe 2014/02/07 00:52:22 Done.
16
17 class CastIPCDispatcher;
18
19 // This implementation of the CastTransportSender interface
20 // communicates with the browser process over IPC and relays
21 // all calls to/from the transport sender to the browser process.
22 // The primary reason for this arrangement is to give the
23 // renderer less direct control over the UDP sockets.
24 class CastTransportSenderIPC
25 : public media::cast::transport::CastTransportSender {
26 public:
27 CastTransportSenderIPC(
28 const media::cast::transport::CastTransportConfig& config,
29 const media::cast::transport::CastTransportStatusCallback& status_cb);
30 virtual ~CastTransportSenderIPC();
31
32 // media::cast::transport::CastTransportSender implementation
scherkus (not reviewing) 2014/02/07 00:11:06 comments end with periods
hubbe 2014/02/07 00:52:22 Done.
33 virtual void SetPacketReceiver(
34 const media::cast::transport::PacketReceiverCallback& packet_callback)
35 OVERRIDE;
36 virtual void InsertCodedAudioFrame(
37 const media::cast::transport::EncodedAudioFrame* audio_frame,
38 const base::TimeTicks& recorded_time) OVERRIDE;
39 virtual void InsertCodedVideoFrame(
40 const media::cast::transport::EncodedVideoFrame* video_frame,
41 const base::TimeTicks& capture_time) OVERRIDE;
42
43 virtual void SendRtcpFromRtpSender(
44 uint32 packet_type_flags,
45 const media::cast::transport::RtcpSenderInfo& sender_info,
46 const media::cast::transport::RtcpDlrrReportBlock& dlrr,
47 const media::cast::transport::RtcpSenderLogMessage& sender_log,
48 uint32 sending_ssrc,
49 const std::string& c_name) OVERRIDE;
50
51 // Retransmission request.
scherkus (not reviewing) 2014/02/07 00:11:06 nit: this looks duplicated from the CastTransportS
hubbe 2014/02/07 00:52:22 Done.
52 virtual void ResendPackets(
53 bool is_audio,
54 const media::cast::MissingFramesAndPacketsMap& missing_packets) OVERRIDE;
55
56 virtual void SubscribeAudioRtpStatsCallback(
57 const media::cast::transport::CastTransportRtpStatistics& callback)
58 OVERRIDE;
59
60 virtual void SubscribeVideoRtpStatsCallback(
61 const media::cast::transport::CastTransportRtpStatistics& callback)
62 OVERRIDE;
63
64 private:
65 bool Send(IPC::Message *message);
66
67 friend class CastIPCDispatcher;
scherkus (not reviewing) 2014/02/07 00:11:06 do these two classes really need to be friends? w
hubbe 2014/02/07 00:52:22 Generally I think of these two classes as one unit
scherkus (not reviewing) 2014/02/07 01:15:29 Not entirely sure what you mean by factory methods
hubbe 2014/02/07 22:27:47 Ok, I started working on (a), but it ended up ugly
68 int32 channel_id_;
69 media::cast::transport::PacketReceiverCallback packet_callback_;
70 media::cast::transport::CastTransportStatusCallback status_callback_;
71 media::cast::transport::CastTransportRtpStatistics audio_rtp_callback_;
72 media::cast::transport::CastTransportRtpStatistics video_rtp_callback_;
73 DISALLOW_COPY_AND_ASSIGN(CastTransportSenderIPC);
74 };
75
76 // This dispatcher listens to incoming IPC messages and sends
77 // the call to the correct CastTransportSenderIPC instance.
78 class CastIPCDispatcher : public IPC::ChannelProxy::MessageFilter {
scherkus (not reviewing) 2014/02/07 00:11:06 any reason this needs to be inside this .h vs its
hubbe 2014/02/07 00:52:22 See comment above (factory methods)
79 public:
80 explicit CastIPCDispatcher(
81 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
82
83 // IPC::ChannelProxy::MessageFilter implementation
84 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
85 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
86 virtual void OnFilterRemoved() OVERRIDE;
87 virtual void OnChannelClosing() OVERRIDE;
88
89 protected:
90 virtual ~CastIPCDispatcher();
91
92 private:
93 void OnReceivedPacket(int32 channel_id, const media::cast::Packet& packet);
94 void OnNotifyStatusChange(
95 int32 channel_id,
96 media::cast::transport::CastTransportStatus status);
97 void OnRtpStatistics(
98 int32 channel_id,
99 bool audio,
100 const media::cast::transport::RtcpSenderInfo& sender_info,
101 base::TimeTicks time_sent,
102 uint32 rtp_timestamp);
103
104 friend CastTransportSenderIPC;
105 static CastIPCDispatcher* global_instance_;
106
107 // IPC channel for Send(); must only be accesed on |io_message_loop_|.
108 IPC::Channel* channel_;
109
110 // Message loop on which IPC calls are driven.
111 const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
112
113 // A map of stream ids to delegates; must only be accessed on
114 // |io_message_loop_|.
115 IDMap<CastTransportSenderIPC> id_map_;
116 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher);
117 };
118
119 } // namespace cast
120
121 #endif // CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698