OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 // The primary timing component should be passed | 28 // The primary timing component should be passed |
29 // if this is the dual timing component. | 29 // if this is the dual timing component. |
30 explicit VCMTiming(Clock* clock, VCMTiming* master_timing = NULL); | 30 explicit VCMTiming(Clock* clock, VCMTiming* master_timing = NULL); |
31 virtual ~VCMTiming(); | 31 virtual ~VCMTiming(); |
32 | 32 |
33 // Resets the timing to the initial state. | 33 // Resets the timing to the initial state. |
34 void Reset(); | 34 void Reset(); |
35 void ResetDecodeTime(); | 35 void ResetDecodeTime(); |
36 | 36 |
37 // Set the amount of time needed to render an image. Defaults to 10 ms. | 37 // Set the amount of time needed to render an image. Defaults to 10 ms. |
38 void set_render_delay(uint32_t render_delay_ms); | 38 void set_render_delay(int render_delay_ms); |
39 | 39 |
40 // Set the minimum time the video must be delayed on the receiver to | 40 // Set the minimum time the video must be delayed on the receiver to |
41 // get the desired jitter buffer level. | 41 // get the desired jitter buffer level. |
42 void SetJitterDelay(uint32_t required_delay_ms); | 42 void SetJitterDelay(int required_delay_ms); |
43 | 43 |
44 // Set the minimum playout delay required to sync video with audio. | 44 // Set the minimum playout delay from capture to render in ms. |
45 void set_min_playout_delay(uint32_t min_playout_delay); | 45 void set_min_playout_delay(int min_playout_delay_ms); |
| 46 |
| 47 // Returns the minimum playout delay from capture to render in ms. |
| 48 int min_playout_delay(); |
| 49 |
| 50 // Set the maximum playout delay from capture to render in ms. |
| 51 void set_max_playout_delay(int max_playout_delay_ms); |
| 52 |
| 53 // Returns the maximum playout delay from capture to render in ms. |
| 54 int max_playout_delay(); |
46 | 55 |
47 // Increases or decreases the current delay to get closer to the target delay. | 56 // Increases or decreases the current delay to get closer to the target delay. |
48 // Calculates how long it has been since the previous call to this function, | 57 // Calculates how long it has been since the previous call to this function, |
49 // and increases/decreases the delay in proportion to the time difference. | 58 // and increases/decreases the delay in proportion to the time difference. |
50 void UpdateCurrentDelay(uint32_t frame_timestamp); | 59 void UpdateCurrentDelay(uint32_t frame_timestamp); |
51 | 60 |
52 // Increases or decreases the current delay to get closer to the target delay. | 61 // Increases or decreases the current delay to get closer to the target delay. |
53 // Given the actual decode time in ms and the render time in ms for a frame, | 62 // Given the actual decode time in ms and the render time in ms for a frame, |
54 // this function calculates how late the frame is and increases the delay | 63 // this function calculates how late the frame is and increases the delay |
55 // accordingly. | 64 // accordingly. |
(...skipping 14 matching lines...) Expand all Loading... |
70 // frame_timestamp should be rendered, assuming that the system time currently | 79 // frame_timestamp should be rendered, assuming that the system time currently |
71 // is now_ms. | 80 // is now_ms. |
72 virtual int64_t RenderTimeMs(uint32_t frame_timestamp, int64_t now_ms) const; | 81 virtual int64_t RenderTimeMs(uint32_t frame_timestamp, int64_t now_ms) const; |
73 | 82 |
74 // Returns the maximum time in ms that we can wait for a frame to become | 83 // Returns the maximum time in ms that we can wait for a frame to become |
75 // complete before we must pass it to the decoder. | 84 // complete before we must pass it to the decoder. |
76 virtual uint32_t MaxWaitingTime(int64_t render_time_ms, int64_t now_ms) const; | 85 virtual uint32_t MaxWaitingTime(int64_t render_time_ms, int64_t now_ms) const; |
77 | 86 |
78 // Returns the current target delay which is required delay + decode time + | 87 // Returns the current target delay which is required delay + decode time + |
79 // render delay. | 88 // render delay. |
80 uint32_t TargetVideoDelay() const; | 89 int TargetVideoDelay() const; |
81 | 90 |
82 // Calculates whether or not there is enough time to decode a frame given a | 91 // Calculates whether or not there is enough time to decode a frame given a |
83 // certain amount of processing time. | 92 // certain amount of processing time. |
84 bool EnoughTimeToDecode(uint32_t available_processing_time_ms) const; | 93 bool EnoughTimeToDecode(uint32_t available_processing_time_ms) const; |
85 | 94 |
86 // Return current timing information. | 95 // Return current timing information. |
87 void GetTimings(int* decode_ms, | 96 void GetTimings(int* decode_ms, |
88 int* max_decode_ms, | 97 int* max_decode_ms, |
89 int* current_delay_ms, | 98 int* current_delay_ms, |
90 int* target_delay_ms, | 99 int* target_delay_ms, |
91 int* jitter_buffer_ms, | 100 int* jitter_buffer_ms, |
92 int* min_playout_delay_ms, | 101 int* min_playout_delay_ms, |
93 int* render_delay_ms) const; | 102 int* render_delay_ms) const; |
94 | 103 |
95 enum { kDefaultRenderDelayMs = 10 }; | 104 enum { kDefaultRenderDelayMs = 10 }; |
96 enum { kDelayMaxChangeMsPerS = 100 }; | 105 enum { kDelayMaxChangeMsPerS = 100 }; |
97 | 106 |
98 protected: | 107 protected: |
99 int64_t RequiredDecodeTimeMs() const | 108 int RequiredDecodeTimeMs() const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
100 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | |
101 int64_t RenderTimeMsInternal(uint32_t frame_timestamp, int64_t now_ms) const | 109 int64_t RenderTimeMsInternal(uint32_t frame_timestamp, int64_t now_ms) const |
102 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 110 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
103 uint32_t TargetDelayInternal() const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 111 int TargetDelayInternal() const EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
104 | 112 |
105 private: | 113 private: |
106 void UpdateHistograms() const; | 114 void UpdateHistograms() const; |
107 | 115 |
108 CriticalSectionWrapper* crit_sect_; | 116 CriticalSectionWrapper* crit_sect_; |
109 Clock* const clock_; | 117 Clock* const clock_; |
110 bool master_ GUARDED_BY(crit_sect_); | 118 bool master_ GUARDED_BY(crit_sect_); |
111 TimestampExtrapolator* ts_extrapolator_ GUARDED_BY(crit_sect_); | 119 TimestampExtrapolator* ts_extrapolator_ GUARDED_BY(crit_sect_); |
112 std::unique_ptr<VCMCodecTimer> codec_timer_ GUARDED_BY(crit_sect_); | 120 std::unique_ptr<VCMCodecTimer> codec_timer_ GUARDED_BY(crit_sect_); |
113 uint32_t render_delay_ms_ GUARDED_BY(crit_sect_); | 121 int render_delay_ms_ GUARDED_BY(crit_sect_); |
114 uint32_t min_playout_delay_ms_ GUARDED_BY(crit_sect_); | 122 // Best-effort playout delay range for frames from capture to render. |
115 uint32_t jitter_delay_ms_ GUARDED_BY(crit_sect_); | 123 // The receiver tries to keep the delay between |min_playout_delay_ms_| |
116 uint32_t current_delay_ms_ GUARDED_BY(crit_sect_); | 124 // and |max_playout_delay_ms_| taking the network jitter into account. |
| 125 // A special case is where min_playout_delay_ms_ = max_playout_delay_ms_ = 0, |
| 126 // in which case the receiver tries to play the frames as they arrive. |
| 127 int min_playout_delay_ms_ GUARDED_BY(crit_sect_); |
| 128 int max_playout_delay_ms_ GUARDED_BY(crit_sect_); |
| 129 int jitter_delay_ms_ GUARDED_BY(crit_sect_); |
| 130 int current_delay_ms_ GUARDED_BY(crit_sect_); |
117 int last_decode_ms_ GUARDED_BY(crit_sect_); | 131 int last_decode_ms_ GUARDED_BY(crit_sect_); |
118 uint32_t prev_frame_timestamp_ GUARDED_BY(crit_sect_); | 132 uint32_t prev_frame_timestamp_ GUARDED_BY(crit_sect_); |
119 | 133 |
120 // Statistics. | 134 // Statistics. |
121 size_t num_decoded_frames_ GUARDED_BY(crit_sect_); | 135 size_t num_decoded_frames_ GUARDED_BY(crit_sect_); |
122 size_t num_delayed_decoded_frames_ GUARDED_BY(crit_sect_); | 136 size_t num_delayed_decoded_frames_ GUARDED_BY(crit_sect_); |
123 int64_t first_decoded_frame_ms_ GUARDED_BY(crit_sect_); | 137 int64_t first_decoded_frame_ms_ GUARDED_BY(crit_sect_); |
124 uint64_t sum_missed_render_deadline_ms_ GUARDED_BY(crit_sect_); | 138 uint64_t sum_missed_render_deadline_ms_ GUARDED_BY(crit_sect_); |
125 }; | 139 }; |
126 } // namespace webrtc | 140 } // namespace webrtc |
127 | 141 |
128 #endif // WEBRTC_MODULES_VIDEO_CODING_TIMING_H_ | 142 #endif // WEBRTC_MODULES_VIDEO_CODING_TIMING_H_ |
OLD | NEW |