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 is the base class for an object that send frames to a receiver. | 5 // This is the base class for an object that send frames to a receiver. |
6 // TODO(hclam): Refactor such that there is no separate AudioSender vs. | 6 // TODO(hclam): Refactor such that there is no separate AudioSender vs. |
7 // VideoSender, and the functionality of both is rolled into this class. | 7 // VideoSender, and the functionality of both is rolled into this class. |
8 | 8 |
9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 9 #ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 10 #define MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 base::TimeDelta GetTargetPlayoutDelay() const { | 37 base::TimeDelta GetTargetPlayoutDelay() const { |
38 return target_playout_delay_; | 38 return target_playout_delay_; |
39 } | 39 } |
40 | 40 |
41 protected: | 41 protected: |
42 // Schedule and execute periodic sending of RTCP report. | 42 // Schedule and execute periodic sending of RTCP report. |
43 void ScheduleNextRtcpReport(); | 43 void ScheduleNextRtcpReport(); |
44 void SendRtcpReport(bool schedule_future_reports); | 44 void SendRtcpReport(bool schedule_future_reports); |
45 | 45 |
46 void OnReceivedRtt(base::TimeDelta rtt, | 46 void OnMeasuredRoundTripTime(base::TimeDelta rtt); |
47 base::TimeDelta avg_rtt, | |
48 base::TimeDelta min_rtt, | |
49 base::TimeDelta max_rtt); | |
50 | 47 |
51 bool is_rtt_available() const { return rtt_available_; } | 48 bool is_rtt_available() const { |
| 49 return current_round_trip_time_ > base::TimeDelta(); |
| 50 } |
| 51 |
| 52 base::TimeDelta current_round_trip_time() const { |
| 53 return current_round_trip_time_; |
| 54 } |
52 | 55 |
53 const scoped_refptr<CastEnvironment> cast_environment_; | 56 const scoped_refptr<CastEnvironment> cast_environment_; |
54 | 57 |
55 // Sends encoded frames over the configured transport (e.g., UDP). In | 58 // Sends encoded frames over the configured transport (e.g., UDP). In |
56 // Chromium, this could be a proxy that first sends the frames from a renderer | 59 // Chromium, this could be a proxy that first sends the frames from a renderer |
57 // process to the browser process over IPC, with the browser process being | 60 // process to the browser process over IPC, with the browser process being |
58 // responsible for "packetizing" the frames and pushing packets into the | 61 // responsible for "packetizing" the frames and pushing packets into the |
59 // network layer. | 62 // network layer. |
60 CastTransportSender* const transport_sender_; | 63 CastTransportSender* const transport_sender_; |
61 | 64 |
62 const uint32 ssrc_; | 65 const uint32 ssrc_; |
63 | 66 |
64 // RTT information from RTCP. | |
65 bool rtt_available_; | |
66 base::TimeDelta rtt_; | |
67 base::TimeDelta avg_rtt_; | |
68 base::TimeDelta min_rtt_; | |
69 base::TimeDelta max_rtt_; | |
70 | 67 |
71 protected: | 68 protected: |
72 // Schedule and execute periodic checks for re-sending packets. If no | 69 // Schedule and execute periodic checks for re-sending packets. If no |
73 // acknowledgements have been received for "too long," AudioSender will | 70 // acknowledgements have been received for "too long," AudioSender will |
74 // speculatively re-send certain packets of an unacked frame to kick-start | 71 // speculatively re-send certain packets of an unacked frame to kick-start |
75 // re-transmission. This is a last resort tactic to prevent the session from | 72 // re-transmission. This is a last resort tactic to prevent the session from |
76 // getting stuck after a long outage. | 73 // getting stuck after a long outage. |
77 void ScheduleNextResendCheck(); | 74 void ScheduleNextResendCheck(); |
78 void ResendCheck(); | 75 void ResendCheck(); |
79 void ResendForKickstart(); | 76 void ResendForKickstart(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 private: | 137 private: |
141 // RTP timestamp increment representing one second. | 138 // RTP timestamp increment representing one second. |
142 const int rtp_timebase_; | 139 const int rtp_timebase_; |
143 | 140 |
144 // Ring buffers to keep track of recent frame timestamps (both in terms of | 141 // Ring buffers to keep track of recent frame timestamps (both in terms of |
145 // local reference time and RTP media time). These should only be accessed | 142 // local reference time and RTP media time). These should only be accessed |
146 // through the Record/GetXXX() methods. | 143 // through the Record/GetXXX() methods. |
147 base::TimeTicks frame_reference_times_[256]; | 144 base::TimeTicks frame_reference_times_[256]; |
148 RtpTimestamp frame_rtp_timestamps_[256]; | 145 RtpTimestamp frame_rtp_timestamps_[256]; |
149 | 146 |
| 147 // The most recently measured round trip time. |
| 148 base::TimeDelta current_round_trip_time_; |
| 149 |
150 // NOTE: Weak pointers must be invalidated before all other member variables. | 150 // NOTE: Weak pointers must be invalidated before all other member variables. |
151 base::WeakPtrFactory<FrameSender> weak_factory_; | 151 base::WeakPtrFactory<FrameSender> weak_factory_; |
152 | 152 |
153 DISALLOW_COPY_AND_ASSIGN(FrameSender); | 153 DISALLOW_COPY_AND_ASSIGN(FrameSender); |
154 }; | 154 }; |
155 | 155 |
156 } // namespace cast | 156 } // namespace cast |
157 } // namespace media | 157 } // namespace media |
158 | 158 |
159 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ | 159 #endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_ |
OLD | NEW |