Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 class maintains a send transport for audio and video in a Cast | 5 // This class maintains a send transport for audio and video in a Cast |
| 6 // Streaming session. | 6 // Streaming session. |
| 7 // Audio, video frames and RTCP messages are submitted to this object | 7 // Audio, video frames and RTCP messages are submitted to this object |
| 8 // and then packetized and paced to the underlying UDP socket. | 8 // and then packetized and paced to the underlying UDP socket. |
| 9 // | 9 // |
| 10 // The hierarchy of send transport in a Cast Streaming session: | 10 // The hierarchy of send transport in a Cast Streaming session: |
| 11 // | 11 // |
| 12 // CastTransportSender RTP RTCP | 12 // CastTransportSender RTP RTCP |
| 13 // ------------------------------------------------------------------ | 13 // ------------------------------------------------------------------ |
| 14 // TransportEncryptionHandler (A/V) | 14 // TransportEncryptionHandler (A/V) |
| 15 // RtpSender (A/V) Rtcp (A/V) | 15 // RtpSender (A/V) Rtcp (A/V) |
| 16 // PacedSender (Shared) | 16 // PacedSender (Shared) |
| 17 // UdpTransport (Shared) | 17 // UdpTransport (Shared) |
| 18 // | 18 // |
| 19 // There are objects of TransportEncryptionHandler, RtpSender and Rtcp | 19 // There are objects of TransportEncryptionHandler, RtpSender and Rtcp |
| 20 // for each audio and video stream. | 20 // for each audio and video stream. |
| 21 // PacedSender and UdpTransport are shared between all RTP and RTCP | 21 // PacedSender and UdpTransport are shared between all RTP and RTCP |
| 22 // streams. | 22 // streams. |
| 23 | 23 |
| 24 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ | 24 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ |
| 25 #define MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ | 25 #define MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ |
| 26 | 26 |
| 27 #include "base/callback.h" | 27 #include "base/callback.h" |
| 28 #include "base/gtest_prod_util.h" | |
| 28 #include "base/memory/ref_counted.h" | 29 #include "base/memory/ref_counted.h" |
| 29 #include "base/memory/scoped_ptr.h" | 30 #include "base/memory/scoped_ptr.h" |
| 30 #include "base/memory/weak_ptr.h" | 31 #include "base/memory/weak_ptr.h" |
| 31 #include "base/time/tick_clock.h" | 32 #include "base/time/tick_clock.h" |
| 32 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 33 #include "base/timer/timer.h" | 34 #include "base/timer/timer.h" |
| 34 #include "media/cast/common/transport_encryption_handler.h" | 35 #include "media/cast/common/transport_encryption_handler.h" |
| 35 #include "media/cast/logging/logging_defines.h" | 36 #include "media/cast/logging/logging_defines.h" |
| 36 #include "media/cast/logging/simple_event_subscriber.h" | 37 #include "media/cast/logging/simple_event_subscriber.h" |
| 37 #include "media/cast/net/cast_transport_config.h" | 38 #include "media/cast/net/cast_transport_config.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 const RtcpCastMessageCallback& cast_message_cb, | 73 const RtcpCastMessageCallback& cast_message_cb, |
| 73 const RtcpRttCallback& rtt_cb) OVERRIDE; | 74 const RtcpRttCallback& rtt_cb) OVERRIDE; |
| 74 virtual void InsertCodedAudioFrame(const EncodedFrame& audio_frame) OVERRIDE; | 75 virtual void InsertCodedAudioFrame(const EncodedFrame& audio_frame) OVERRIDE; |
| 75 virtual void InsertCodedVideoFrame(const EncodedFrame& video_frame) OVERRIDE; | 76 virtual void InsertCodedVideoFrame(const EncodedFrame& video_frame) OVERRIDE; |
| 76 | 77 |
| 77 virtual void SendSenderReport( | 78 virtual void SendSenderReport( |
| 78 uint32 ssrc, | 79 uint32 ssrc, |
| 79 base::TimeTicks current_time, | 80 base::TimeTicks current_time, |
| 80 uint32 current_time_as_rtp_timestamp) OVERRIDE; | 81 uint32 current_time_as_rtp_timestamp) OVERRIDE; |
| 81 | 82 |
| 82 virtual void ResendPackets(bool is_audio, | 83 virtual void CancelSendingFrames(uint32 ssrc, |
| 83 const MissingFramesAndPacketsMap& missing_packets, | 84 const std::set<uint32>& frame_ids) OVERRIDE; |
| 84 bool cancel_rtx_if_not_in_list, | 85 |
| 85 base::TimeDelta dedupe_window) | 86 virtual void ResendFrameForKickstart(uint32 ssrc, uint32 frame_id) OVERRIDE; |
| 86 OVERRIDE; | |
| 87 | 87 |
| 88 virtual PacketReceiverCallback PacketReceiverForTesting() OVERRIDE; | 88 virtual PacketReceiverCallback PacketReceiverForTesting() OVERRIDE; |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 FRIEND_TEST_ALL_PREFIXES(CastTransportSenderImplTest, NacksCancelRetransmits); | |
| 92 FRIEND_TEST_ALL_PREFIXES(CastTransportSenderImplTest, CancelRetransmits); | |
| 93 FRIEND_TEST_ALL_PREFIXES(CastTransportSenderImplTest, Kickstart); | |
| 94 | |
| 95 // Resend packets for the stream identified by |ssrc|. | |
| 96 // If |cancel_rtx_if_not_in_list| is true then transmission of packets for the | |
| 97 // frames but not in the list will be dropped. | |
| 98 // If packet was sent after |now - dedupe_window| then it will not be sent. | |
| 99 void ResendPackets(uint32 ssrc, | |
| 100 const MissingFramesAndPacketsMap& missing_packets, | |
| 101 bool cancel_rtx_if_not_in_list, | |
| 102 base::TimeDelta dedupe_window); | |
| 103 | |
| 91 // If |raw_events_callback_| is non-null, calls it with events collected | 104 // If |raw_events_callback_| is non-null, calls it with events collected |
| 92 // by |event_subscriber_| since last call. | 105 // by |event_subscriber_| since last call. |
| 93 void SendRawEvents(); | 106 void SendRawEvents(); |
| 94 | 107 |
| 95 // Called when a packet is received. | 108 // Called when a packet is received. |
| 96 void OnReceivedPacket(scoped_ptr<Packet> packet); | 109 void OnReceivedPacket(scoped_ptr<Packet> packet); |
| 97 | 110 |
| 98 // Called when a log message is received. | 111 // Called when a log message is received. |
| 99 void OnReceivedLogMessage(EventMediaType media_type, | 112 void OnReceivedLogMessage(EventMediaType media_type, |
| 100 const RtcpReceiverLogMessage& log); | 113 const RtcpReceiverLogMessage& log); |
| 101 | 114 |
| 115 // Called when RTT information is updated. | |
| 116 void OnReceivedRtt(const RtcpRttCallback& rtt_cb, | |
| 117 base::TimeDelta rtt, | |
| 118 base::TimeDelta avg_rtt, | |
| 119 base::TimeDelta min_rtt, | |
| 120 base::TimeDelta max_rtt); | |
| 121 | |
| 122 // Called when a RTCP Cast message is received. | |
| 123 void OnReceivedCastMessage(uint32 ssrc, | |
| 124 const RtcpCastMessageCallback& cast_message_cb, | |
| 125 const RtcpCastMessage& cast_message); | |
| 126 | |
| 102 base::TickClock* clock_; // Not owned by this class. | 127 base::TickClock* clock_; // Not owned by this class. |
| 103 CastTransportStatusCallback status_callback_; | 128 CastTransportStatusCallback status_callback_; |
| 104 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; | 129 scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; |
| 105 | 130 |
| 106 LoggingImpl logging_; | 131 LoggingImpl logging_; |
| 107 | 132 |
| 108 // Interface to a UDP socket. | 133 // Interface to a UDP socket. |
| 109 scoped_ptr<UdpTransport> transport_; | 134 scoped_ptr<UdpTransport> transport_; |
| 110 | 135 |
| 111 // Packet sender that performs pacing. | 136 // Packet sender that performs pacing. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 125 // the damage that could be caused by a compromised renderer process. | 150 // the damage that could be caused by a compromised renderer process. |
| 126 TransportEncryptionHandler audio_encryptor_; | 151 TransportEncryptionHandler audio_encryptor_; |
| 127 TransportEncryptionHandler video_encryptor_; | 152 TransportEncryptionHandler video_encryptor_; |
| 128 | 153 |
| 129 // This is non-null iff |raw_events_callback_| is non-null. | 154 // This is non-null iff |raw_events_callback_| is non-null. |
| 130 scoped_ptr<SimpleEventSubscriber> event_subscriber_; | 155 scoped_ptr<SimpleEventSubscriber> event_subscriber_; |
| 131 | 156 |
| 132 BulkRawEventsCallback raw_events_callback_; | 157 BulkRawEventsCallback raw_events_callback_; |
| 133 base::TimeDelta raw_events_callback_interval_; | 158 base::TimeDelta raw_events_callback_interval_; |
| 134 | 159 |
| 160 // The most up-to-date RTT information from either audio of video RTCP | |
| 161 // stream. | |
| 162 base::TimeDelta most_recent_rtt_; | |
|
hubbe
2014/08/11 19:11:50
Given that audio packets are usually smaller than
Alpha Left Google
2014/08/11 21:03:18
RTT is gathered by RTCP packets so it doesn't matt
| |
| 163 | |
| 135 base::WeakPtrFactory<CastTransportSenderImpl> weak_factory_; | 164 base::WeakPtrFactory<CastTransportSenderImpl> weak_factory_; |
| 136 | 165 |
| 137 DISALLOW_COPY_AND_ASSIGN(CastTransportSenderImpl); | 166 DISALLOW_COPY_AND_ASSIGN(CastTransportSenderImpl); |
| 138 }; | 167 }; |
| 139 | 168 |
| 140 } // namespace cast | 169 } // namespace cast |
| 141 } // namespace media | 170 } // namespace media |
| 142 | 171 |
| 143 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ | 172 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_IMPL_H_ |
| OLD | NEW |