OLD | NEW |
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 #ifndef MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 5 #ifndef MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
6 #define MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 6 #define MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 protected: | 69 protected: |
70 // Protected for testability. | 70 // Protected for testability. |
71 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) | 71 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) |
72 OVERRIDE; | 72 OVERRIDE; |
73 | 73 |
74 private: | 74 private: |
75 // Schedule and execute periodic sending of RTCP report. | 75 // Schedule and execute periodic sending of RTCP report. |
76 void ScheduleNextRtcpReport(); | 76 void ScheduleNextRtcpReport(); |
77 void SendRtcpReport(bool schedule_future_reports); | 77 void SendRtcpReport(bool schedule_future_reports); |
78 | 78 |
79 // Schedule and execute periodic checks for re-sending frames. If no | 79 // Schedule and execute periodic checks for re-sending packets. If no |
80 // acknowledgements have been received for "too long," VideoSender will | 80 // acknowledgements have been received for "too long," VideoSender will |
81 // speculatively re-send the frame just after |latest_acked_frame_id_| (the | 81 // speculatively re-send certain packets of an unacked frame to kick-start |
82 // whole frame). This is a last resort tactic to prevent the session from | 82 // re-transmission. This is a last resort tactic to prevent the session from |
83 // getting stuck after a long outage. | 83 // getting stuck after a long outage. |
84 void ScheduleNextResendCheck(); | 84 void ScheduleNextResendCheck(); |
85 void ResendCheck(); | 85 void ResendCheck(); |
86 | |
87 // Resend certain packets of an unacked frame to kick start re-transmission. | |
88 void ResendForKickstart(); | 86 void ResendForKickstart(); |
89 | 87 |
90 // Returns true if there are too many frames in flight, as defined by the | 88 // Returns true if there are too many frames in flight, as defined by the |
91 // configured target playout delay plus simple logic. When this is true, | 89 // configured target playout delay plus simple logic. When this is true, |
92 // InsertRawVideoFrame() will silenty drop frames instead of sending them to | 90 // InsertRawVideoFrame() will silenty drop frames instead of sending them to |
93 // the video encoder. | 91 // the video encoder. |
94 bool AreTooManyFramesInFlight() const; | 92 bool AreTooManyFramesInFlight() const; |
95 | 93 |
96 // Called by the |video_encoder_| with the next EncodeFrame to send. | 94 // Called by the |video_encoder_| with the next EncodeFrame to send. |
97 void SendEncodedVideoFrame(int requested_bitrate_before_encode, | 95 void SendEncodedVideoFrame(int requested_bitrate_before_encode, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // When we get close to the max number of un-acked frames, we set lower | 160 // When we get close to the max number of un-acked frames, we set lower |
163 // the bitrate drastically to ensure that we catch up. Without this we | 161 // the bitrate drastically to ensure that we catch up. Without this we |
164 // risk getting stuck in a catch-up state forever. | 162 // risk getting stuck in a catch-up state forever. |
165 CongestionControl congestion_control_; | 163 CongestionControl congestion_control_; |
166 | 164 |
167 // If this sender is ready for use, this is STATUS_VIDEO_INITIALIZED. | 165 // If this sender is ready for use, this is STATUS_VIDEO_INITIALIZED. |
168 CastInitializationStatus cast_initialization_status_; | 166 CastInitializationStatus cast_initialization_status_; |
169 | 167 |
170 // This is a "good enough" mapping for finding the RTP timestamp associated | 168 // This is a "good enough" mapping for finding the RTP timestamp associated |
171 // with a video frame. The key is the lowest 8 bits of frame id (which is | 169 // with a video frame. The key is the lowest 8 bits of frame id (which is |
172 // what is sent via RTCP). This map is used for logging purposes. The only | 170 // what is sent via RTCP). This map is used for logging purposes. |
173 // time when this mapping will be incorrect is when it receives an ACK for a | |
174 // old enough frame such that 8-bit wrap around has already occurred, which | |
175 // should be pretty rare. | |
176 RtpTimestamp frame_id_to_rtp_timestamp_[256]; | 171 RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
177 | 172 |
178 // NOTE: Weak pointers must be invalidated before all other member variables. | 173 // NOTE: Weak pointers must be invalidated before all other member variables. |
179 base::WeakPtrFactory<VideoSender> weak_factory_; | 174 base::WeakPtrFactory<VideoSender> weak_factory_; |
180 | 175 |
181 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 176 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
182 }; | 177 }; |
183 | 178 |
184 } // namespace cast | 179 } // namespace cast |
185 } // namespace media | 180 } // namespace media |
186 | 181 |
187 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 182 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
OLD | NEW |