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

Side by Side Diff: media/cast/net/cast_transport_sender.h

Issue 387933005: Cast: Refactor RTCP handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: smaller diff Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is the main interface for the cast transport sender. It accepts encoded 5 // This is the main interface for the cast transport sender. It accepts encoded
6 // frames (both audio and video), encrypts their encoded data, packetizes them 6 // frames (both audio and video), encrypts their encoded data, packetizes them
7 // and feeds them into a transport (e.g., UDP). 7 // and feeds them into a transport (e.g., UDP).
8 8
9 // Construction of the Cast Sender and the Cast Transport Sender should be done 9 // Construction of the Cast Sender and the Cast Transport Sender should be done
10 // in the following order: 10 // in the following order:
11 // 1. Create CastTransportSender. 11 // 1. Create CastTransportSender.
12 // 2. Create CastSender (accepts CastTransportSender as an input). 12 // 2. Create CastSender (accepts CastTransportSender as an input).
13 // 3. Call CastTransportSender::SetPacketReceiver to ensure that the packets
14 // received by the CastTransportSender will be sent to the CastSender.
15 // Steps 3 can be done interchangeably.
16 13
17 // Destruction: The CastTransportSender is assumed to be valid as long as the 14 // Destruction: The CastTransportSender is assumed to be valid as long as the
18 // CastSender is alive. Therefore the CastSender should be destructed before the 15 // CastSender is alive. Therefore the CastSender should be destructed before the
19 // CastTransportSender. 16 // CastTransportSender.
20 // This also works when the CastSender acts as a receiver for the RTCP packets
21 // due to the weak pointers in the ReceivedPacket method in cast_sender_impl.cc.
22 17
23 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ 18 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_
24 #define MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ 19 #define MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_
25 20
26 #include "base/basictypes.h" 21 #include "base/basictypes.h"
27 #include "base/callback.h" 22 #include "base/callback.h"
28 #include "base/single_thread_task_runner.h" 23 #include "base/single_thread_task_runner.h"
29 #include "base/threading/non_thread_safe.h" 24 #include "base/threading/non_thread_safe.h"
30 #include "base/time/tick_clock.h" 25 #include "base/time/tick_clock.h"
31 #include "media/cast/logging/logging_defines.h" 26 #include "media/cast/logging/logging_defines.h"
32 #include "media/cast/net/cast_transport_config.h" 27 #include "media/cast/net/cast_transport_config.h"
33 #include "media/cast/net/cast_transport_defines.h" 28 #include "media/cast/net/cast_transport_defines.h"
29 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h"
30 #include "media/cast/net/rtcp/rtcp_defines.h"
34 31
35 namespace net { 32 namespace net {
36 class NetLog; 33 class NetLog;
37 } // namespace net 34 } // namespace net
38 35
39 namespace media { 36 namespace media {
40 namespace cast { 37 namespace cast {
41 38
42 // Following the initialization of either audio or video an initialization 39 // Following the initialization of either audio or video an initialization
43 // status will be sent via this callback. 40 // status will be sent via this callback.
44 typedef base::Callback<void(CastTransportStatus status)> 41 typedef base::Callback<void(CastTransportStatus status)>
45 CastTransportStatusCallback; 42 CastTransportStatusCallback;
46 43
47 typedef base::Callback<void(const std::vector<PacketEvent>&)> 44 typedef base::Callback<void(const std::vector<PacketEvent>&,
45 const std::vector<FrameEvent>&)>
48 BulkRawEventsCallback; 46 BulkRawEventsCallback;
49 47
50 // The application should only trigger this class from the transport thread. 48 // The application should only trigger this class from the transport thread.
51 class CastTransportSender : public base::NonThreadSafe { 49 class CastTransportSender : public base::NonThreadSafe {
52 public: 50 public:
53 static scoped_ptr<CastTransportSender> Create( 51 static scoped_ptr<CastTransportSender> Create(
54 net::NetLog* net_log, 52 net::NetLog* net_log,
55 base::TickClock* clock, 53 base::TickClock* clock,
56 const net::IPEndPoint& remote_end_point, 54 const net::IPEndPoint& remote_end_point,
57 const CastTransportStatusCallback& status_callback, 55 const CastTransportStatusCallback& status_callback,
58 const BulkRawEventsCallback& raw_events_callback, 56 const BulkRawEventsCallback& raw_events_callback,
59 base::TimeDelta raw_events_callback_interval, 57 base::TimeDelta raw_events_callback_interval,
60 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner); 58 const scoped_refptr<base::SingleThreadTaskRunner>& transport_task_runner);
61 59
62 virtual ~CastTransportSender() {} 60 virtual ~CastTransportSender() {}
63 61
64 // Audio/Video initialization. 62 // Audio/Video initialization.
65 // Encoded frames cannot be transmitted until the relevant initialize method 63 // Encoded frames cannot be transmitted until the relevant initialize method
66 // is called. Usually called by CastSender. 64 // is called.
67 virtual void InitializeAudio(const CastTransportRtpConfig& config) = 0; 65 virtual void InitializeAudio(const CastTransportRtpConfig& config,
68 virtual void InitializeVideo(const CastTransportRtpConfig& config) = 0; 66 const RtcpCastMessageCallback& cast_message_cb,
69 67 const RtcpRttCallback& rtt_cb) = 0;
70 // Sets the Cast packet receiver. Should be called after creation on the 68 virtual void InitializeVideo(const CastTransportRtpConfig& config,
71 // Cast sender. Packets won't be received until this function is called. 69 const RtcpCastMessageCallback& cast_message_cb,
72 virtual void SetPacketReceiver( 70 const RtcpRttCallback& rtt_cb) = 0;
73 const PacketReceiverCallback& packet_receiver) = 0;
74 71
75 // The following two functions handle the encoded media frames (audio and 72 // The following two functions handle the encoded media frames (audio and
76 // video) to be processed. 73 // video) to be processed.
77 // Frames will be encrypted, packetized and transmitted to the network. 74 // Frames will be encrypted, packetized and transmitted to the network.
78 virtual void InsertCodedAudioFrame(const EncodedFrame& audio_frame) = 0; 75 virtual void InsertCodedAudioFrame(const EncodedFrame& audio_frame) = 0;
79 virtual void InsertCodedVideoFrame(const EncodedFrame& video_frame) = 0; 76 virtual void InsertCodedVideoFrame(const EncodedFrame& video_frame) = 0;
80 77
81 // Builds an RTCP packet and sends it to the network. 78 // Sends a RTCP sender report to the receiver.
82 // |ntp_seconds|, |ntp_fraction| and |rtp_timestamp| are used in the 79 // |audio| is true of this is for audio stream. False otherwise.
83 // RTCP Sender Report. 80 // |current_time| is the current time reported by a tick clock.
84 virtual void SendRtcpFromRtpSender(uint32 packet_type_flags, 81 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp.
85 uint32 ntp_seconds, 82 virtual void SendRtcpFromRtpSender(
miu 2014/07/16 00:09:30 Can we name this SendSenderReport instead? Or, ev
Alpha Left Google 2014/07/17 01:01:43 Let's use the RTCP terminology of "SenderReport".
86 uint32 ntp_fraction, 83 bool audio,
87 uint32 rtp_timestamp, 84 base::TimeTicks current_time,
88 const RtcpDlrrReportBlock& dlrr, 85 uint32 current_time_as_rtp_timestamp) = 0;
89 uint32 sending_ssrc,
90 const std::string& c_name) = 0;
91 86
92 // Retransmission request. 87 // Retransmission request.
93 // |missing_packets| includes the list of frames and packets in each 88 // |missing_packets| includes the list of frames and packets in each
94 // frame to be re-transmitted. 89 // frame to be re-transmitted.
95 // If |cancel_rtx_if_not_in_list| is used as an optimization to cancel 90 // If |cancel_rtx_if_not_in_list| is used as an optimization to cancel
96 // pending re-transmission requests of packets not listed in 91 // pending re-transmission requests of packets not listed in
97 // |missing_packets|. If the requested packet(s) were sent recently 92 // |missing_packets|. If the requested packet(s) were sent recently
98 // (how long is specified by |dedupe_window|) then this re-transmit 93 // (how long is specified by |dedupe_window|) then this re-transmit
99 // will be ignored. 94 // will be ignored.
100 virtual void ResendPackets( 95 virtual void ResendPackets(
101 bool is_audio, 96 bool is_audio,
102 const MissingFramesAndPacketsMap& missing_packets, 97 const MissingFramesAndPacketsMap& missing_packets,
103 bool cancel_rtx_if_not_in_list, 98 bool cancel_rtx_if_not_in_list,
104 base::TimeDelta dedupe_window) = 0; 99 base::TimeDelta dedupe_window) = 0;
100
101 // Returns a callback for receiving packets for testing purposes.
102 virtual PacketReceiverCallback PacketReceiverForTesting() = 0;
105 }; 103 };
106 104
107 } // namespace cast 105 } // namespace cast
108 } // namespace media 106 } // namespace media
109 107
110 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ 108 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698