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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Returns true if there are too many frames in flight, as defined by the | 90 // 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, | 91 // configured target playout delay plus simple logic. When this is true, |
92 // InsertRawVideoFrame() will silenty drop frames instead of sending them to | 92 // InsertRawVideoFrame() will silenty drop frames instead of sending them to |
93 // the video encoder. | 93 // the video encoder. |
94 bool AreTooManyFramesInFlight() const; | 94 bool AreTooManyFramesInFlight() const; |
95 | 95 |
96 // Called by the |video_encoder_| with the next EncodeFrame to send. | 96 // Called by the |video_encoder_| with the next EncodeFrame to send. |
97 void SendEncodedVideoFrame(int requested_bitrate_before_encode, | 97 void SendEncodedVideoFrame(int requested_bitrate_before_encode, |
98 scoped_ptr<transport::EncodedFrame> encoded_frame); | 98 scoped_ptr<transport::EncodedFrame> encoded_frame); |
99 | 99 |
100 void UpdateBitrate(int32 new_bitrate); | |
101 | |
102 const scoped_refptr<CastEnvironment> cast_environment_; | 100 const scoped_refptr<CastEnvironment> cast_environment_; |
103 | 101 |
104 // The total amount of time between a frame's capture/recording on the sender | 102 // The total amount of time between a frame's capture/recording on the sender |
105 // and its playback on the receiver (i.e., shown to a user). This is fixed as | 103 // and its playback on the receiver (i.e., shown to a user). This is fixed as |
106 // a value large enough to give the system sufficient time to encode, | 104 // a value large enough to give the system sufficient time to encode, |
107 // transmit/retransmit, receive, decode, and render; given its run-time | 105 // transmit/retransmit, receive, decode, and render; given its run-time |
108 // environment (sender/receiver hardware performance, network conditions, | 106 // environment (sender/receiver hardware performance, network conditions, |
109 // etc.). | 107 // etc.). |
110 const base::TimeDelta target_playout_delay_; | 108 const base::TimeDelta target_playout_delay_; |
111 | 109 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // acknowledged. Logic throughout VideoSender assumes this can safely | 152 // acknowledged. Logic throughout VideoSender assumes this can safely |
155 // wrap-around. This member is invalid until |!last_send_time_.is_null()|. | 153 // wrap-around. This member is invalid until |!last_send_time_.is_null()|. |
156 uint32 latest_acked_frame_id_; | 154 uint32 latest_acked_frame_id_; |
157 | 155 |
158 // Counts the number of duplicate ACK that are being received. When this | 156 // Counts the number of duplicate ACK that are being received. When this |
159 // number reaches a threshold, the sender will take this as a sign that the | 157 // number reaches a threshold, the sender will take this as a sign that the |
160 // receiver hasn't yet received the first packet of the next frame. In this | 158 // receiver hasn't yet received the first packet of the next frame. In this |
161 // case, VideoSender will trigger a re-send of the next frame. | 159 // case, VideoSender will trigger a re-send of the next frame. |
162 int duplicate_ack_counter_; | 160 int duplicate_ack_counter_; |
163 | 161 |
164 // Desired encoder bitrate (in bits per second). This is updated by querying | |
165 // |congestion_control_| as each ACK is received. | |
166 int current_requested_bitrate_; | |
167 | |
168 // When we get close to the max number of un-acked frames, we set lower | 162 // When we get close to the max number of un-acked frames, we set lower |
169 // the bitrate drastically to ensure that we catch up. Without this we | 163 // the bitrate drastically to ensure that we catch up. Without this we |
170 // risk getting stuck in a catch-up state forever. | 164 // risk getting stuck in a catch-up state forever. |
171 CongestionControl congestion_control_; | 165 CongestionControl congestion_control_; |
172 | 166 |
173 // If this sender is ready for use, this is STATUS_VIDEO_INITIALIZED. | 167 // If this sender is ready for use, this is STATUS_VIDEO_INITIALIZED. |
174 CastInitializationStatus cast_initialization_status_; | 168 CastInitializationStatus cast_initialization_status_; |
175 | 169 |
176 // This is a "good enough" mapping for finding the RTP timestamp associated | 170 // This is a "good enough" mapping for finding the RTP timestamp associated |
177 // with a video frame. The key is the lowest 8 bits of frame id (which is | 171 // with a video frame. The key is the lowest 8 bits of frame id (which is |
178 // what is sent via RTCP). This map is used for logging purposes. The only | 172 // what is sent via RTCP). This map is used for logging purposes. The only |
179 // time when this mapping will be incorrect is when it receives an ACK for a | 173 // time when this mapping will be incorrect is when it receives an ACK for a |
180 // old enough frame such that 8-bit wrap around has already occurred, which | 174 // old enough frame such that 8-bit wrap around has already occurred, which |
181 // should be pretty rare. | 175 // should be pretty rare. |
182 RtpTimestamp frame_id_to_rtp_timestamp_[256]; | 176 RtpTimestamp frame_id_to_rtp_timestamp_[256]; |
183 | 177 |
184 // NOTE: Weak pointers must be invalidated before all other member variables. | 178 // NOTE: Weak pointers must be invalidated before all other member variables. |
185 base::WeakPtrFactory<VideoSender> weak_factory_; | 179 base::WeakPtrFactory<VideoSender> weak_factory_; |
186 | 180 |
187 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 181 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
188 }; | 182 }; |
189 | 183 |
190 } // namespace cast | 184 } // namespace cast |
191 } // namespace media | 185 } // namespace media |
192 | 186 |
193 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ | 187 #endif // MEDIA_CAST_VIDEO_SENDER_VIDEO_SENDER_H_ |
OLD | NEW |