OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <map> | 15 #include <map> |
16 #include <memory> | 16 #include <memory> |
17 #include <set> | 17 #include <set> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "webrtc/base/constructormagic.h" | 20 #include "webrtc/base/constructormagic.h" |
21 #include "webrtc/base/thread_annotations.h" | 21 #include "webrtc/base/thread_annotations.h" |
22 #include "webrtc/modules/include/module_common_types.h" | 22 #include "webrtc/modules/include/module_common_types.h" |
| 23 #include "webrtc/modules/utility/include/process_thread.h" |
23 #include "webrtc/modules/video_coding/include/video_coding.h" | 24 #include "webrtc/modules/video_coding/include/video_coding.h" |
24 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
25 #include "webrtc/modules/video_coding/decoding_state.h" | 26 #include "webrtc/modules/video_coding/decoding_state.h" |
26 #include "webrtc/modules/video_coding/inter_frame_delay.h" | 27 #include "webrtc/modules/video_coding/inter_frame_delay.h" |
27 #include "webrtc/modules/video_coding/jitter_buffer_common.h" | 28 #include "webrtc/modules/video_coding/jitter_buffer_common.h" |
28 #include "webrtc/modules/video_coding/jitter_estimator.h" | 29 #include "webrtc/modules/video_coding/jitter_estimator.h" |
| 30 #include "webrtc/modules/video_coding/nack_module.h" |
29 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 31 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
30 #include "webrtc/typedefs.h" | 32 #include "webrtc/typedefs.h" |
31 | 33 |
32 namespace webrtc { | 34 namespace webrtc { |
33 | 35 |
34 enum VCMNackMode { kNack, kNoNack }; | 36 enum VCMNackMode { kNack, kNoNack }; |
35 | 37 |
36 // forward declarations | 38 // forward declarations |
37 class Clock; | 39 class Clock; |
38 class EventFactory; | 40 class EventFactory; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Advances the oldest SS data to handle timestamp wrap in cases where SS data | 99 // Advances the oldest SS data to handle timestamp wrap in cases where SS data |
98 // are received very seldom (e.g. only once in beginning, second when | 100 // are received very seldom (e.g. only once in beginning, second when |
99 // IsNewerTimestamp is not true). | 101 // IsNewerTimestamp is not true). |
100 void AdvanceFront(uint32_t timestamp); | 102 void AdvanceFront(uint32_t timestamp); |
101 | 103 |
102 SsMap ss_map_; | 104 SsMap ss_map_; |
103 }; | 105 }; |
104 | 106 |
105 class VCMJitterBuffer { | 107 class VCMJitterBuffer { |
106 public: | 108 public: |
107 VCMJitterBuffer(Clock* clock, std::unique_ptr<EventWrapper> event); | 109 VCMJitterBuffer(Clock* clock, |
| 110 std::unique_ptr<EventWrapper> event, |
| 111 NackSender* nack_sender = nullptr, |
| 112 KeyFrameRequestSender* keyframe_request_sender = nullptr); |
108 | 113 |
109 ~VCMJitterBuffer(); | 114 ~VCMJitterBuffer(); |
110 | 115 |
111 // Initializes and starts jitter buffer. | 116 // Initializes and starts jitter buffer. |
112 void Start(); | 117 void Start(); |
113 | 118 |
114 // Signals all internal events and stops the jitter buffer. | 119 // Signals all internal events and stops the jitter buffer. |
115 void Stop(); | 120 void Stop(); |
116 | 121 |
117 // Returns true if the jitter buffer is running. | 122 // Returns true if the jitter buffer is running. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void SetDecodeErrorMode(VCMDecodeErrorMode error_mode); | 211 void SetDecodeErrorMode(VCMDecodeErrorMode error_mode); |
207 int64_t LastDecodedTimestamp() const; | 212 int64_t LastDecodedTimestamp() const; |
208 VCMDecodeErrorMode decode_error_mode() const { return decode_error_mode_; } | 213 VCMDecodeErrorMode decode_error_mode() const { return decode_error_mode_; } |
209 | 214 |
210 // Used to compute time of complete continuous frames. Returns the timestamps | 215 // Used to compute time of complete continuous frames. Returns the timestamps |
211 // corresponding to the start and end of the continuous complete buffer. | 216 // corresponding to the start and end of the continuous complete buffer. |
212 void RenderBufferSize(uint32_t* timestamp_start, uint32_t* timestamp_end); | 217 void RenderBufferSize(uint32_t* timestamp_start, uint32_t* timestamp_end); |
213 | 218 |
214 void RegisterStatsCallback(VCMReceiveStatisticsCallback* callback); | 219 void RegisterStatsCallback(VCMReceiveStatisticsCallback* callback); |
215 | 220 |
| 221 int64_t TimeUntilNextProcess(); |
| 222 void Process(); |
| 223 |
216 private: | 224 private: |
217 class SequenceNumberLessThan { | 225 class SequenceNumberLessThan { |
218 public: | 226 public: |
219 bool operator()(const uint16_t& sequence_number1, | 227 bool operator()(const uint16_t& sequence_number1, |
220 const uint16_t& sequence_number2) const { | 228 const uint16_t& sequence_number2) const { |
221 return IsNewerSequenceNumber(sequence_number2, sequence_number1); | 229 return IsNewerSequenceNumber(sequence_number2, sequence_number1); |
222 } | 230 } |
223 }; | 231 }; |
224 typedef std::set<uint16_t, SequenceNumberLessThan> SequenceNumberSet; | 232 typedef std::set<uint16_t, SequenceNumberLessThan> SequenceNumberSet; |
225 | 233 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 size_t max_nack_list_size_; | 384 size_t max_nack_list_size_; |
377 int max_packet_age_to_nack_; // Measured in sequence numbers. | 385 int max_packet_age_to_nack_; // Measured in sequence numbers. |
378 int max_incomplete_time_ms_; | 386 int max_incomplete_time_ms_; |
379 | 387 |
380 VCMDecodeErrorMode decode_error_mode_; | 388 VCMDecodeErrorMode decode_error_mode_; |
381 // Estimated rolling average of packets per frame | 389 // Estimated rolling average of packets per frame |
382 float average_packets_per_frame_; | 390 float average_packets_per_frame_; |
383 // average_packets_per_frame converges fast if we have fewer than this many | 391 // average_packets_per_frame converges fast if we have fewer than this many |
384 // frames. | 392 // frames. |
385 int frame_counter_; | 393 int frame_counter_; |
| 394 |
| 395 std::unique_ptr<NackModule> nack_module_; |
| 396 |
386 RTC_DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer); | 397 RTC_DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer); |
387 }; | 398 }; |
388 } // namespace webrtc | 399 } // namespace webrtc |
389 | 400 |
390 #endif // WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_ | 401 #endif // WEBRTC_MODULES_VIDEO_CODING_JITTER_BUFFER_H_ |
OLD | NEW |