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

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: more tests 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 {
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
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.
52 virtual void ResendPackets(
53 bool is_audio,
54 const media::cast::MissingFramesAndPacketsMap& missing_packets) OVERRIDE;
55
56 // Retrieves audio RTP statistics.
57 virtual void RtpAudioStatistics(
58 const base::TimeTicks& now,
59 media::cast::transport::RtcpSenderInfo* sender_info) OVERRIDE;
60
61 // Retrieves video RTP statistics.
62 virtual void RtpVideoStatistics(
63 const base::TimeTicks& now,
64 media::cast::transport::RtcpSenderInfo* sender_info) OVERRIDE;
65
66 private:
67 bool Send(IPC::Message *message);
68
69 friend class CastIPCDispatcher;
70 int32 channel_id_;
71 media::cast::transport::PacketReceiverCallback packet_callback_;
72 media::cast::transport::CastTransportStatusCallback status_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 {
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
98 friend CastTransportSenderIPC;
99 static CastIPCDispatcher* global_instance_;
100
101 // IPC channel for Send(); must only be accesed on |io_message_loop_|.
102 IPC::Channel* channel_;
103
104 // Message loop on which IPC calls are driven.
105 const scoped_refptr<base::MessageLoopProxy> io_message_loop_;
106
107 // A map of stream ids to delegates; must only be accessed on
108 // |io_message_loop_|.
109 IDMap<CastTransportSenderIPC> id_map_;
110 DISALLOW_COPY_AND_ASSIGN(CastIPCDispatcher);
111 };
112
113 } // namespace cast
114
115 #endif // CHROME_RENDERER_MEDIA_CAST_TRANSPORT_SENDER_IPC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698