Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 15c68d2

Browse files
committed
Configured VCMTiming with sender defining delay times.
BUG=webrtc:7590 Review-Url: https://codereview.webrtc.org/2870823003 Cr-Original-Commit-Position: refs/heads/master@{#18086} Review-Url: https://codereview.webrtc.org/2890943002 . Cr-Commit-Position: refs/branch-heads/59@{#10} Cr-Branched-From: 10d095d-refs/heads/master@{#17657}
1 parent 61fe801 commit 15c68d2

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

webrtc/modules/video_coding/encoded_frame.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class VCMEncodedFrame : protected EncodedImage {
4646
_encodedWidth = width;
4747
_encodedHeight = height;
4848
}
49+
50+
void SetPlayoutDelay(PlayoutDelay playout_delay) {
51+
playout_delay_ = playout_delay;
52+
}
53+
4954
/**
5055
* Get the encoded image
5156
*/

webrtc/modules/video_coding/frame_buffer2.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ FrameBuffer::FrameBuffer(Clock* clock,
4343
jitter_estimator_(jitter_estimator),
4444
timing_(timing),
4545
inter_frame_delay_(clock_->TimeInMilliseconds()),
46+
last_decoded_frame_timestamp_(0),
4647
last_decoded_frame_it_(frames_.end()),
4748
last_continuous_frame_it_(frames_.end()),
4849
num_frames_history_(0),
@@ -180,6 +181,16 @@ void FrameBuffer::Stop() {
180181
new_continuous_frame_event_.Set();
181182
}
182183

184+
void FrameBuffer::UpdatePlayoutDelays(const FrameObject& frame) {
185+
TRACE_EVENT0("webrtc", "FrameBuffer::UpdatePlayoutDelays");
186+
PlayoutDelay playout_delay = frame.EncodedImage().playout_delay_;
187+
if (playout_delay.min_ms >= 0)
188+
timing_->set_min_playout_delay(playout_delay.min_ms);
189+
190+
if (playout_delay.max_ms >= 0)
191+
timing_->set_max_playout_delay(playout_delay.max_ms);
192+
}
193+
183194
int FrameBuffer::InsertFrame(std::unique_ptr<FrameObject> frame) {
184195
TRACE_EVENT0("webrtc", "FrameBuffer::InsertFrame");
185196
RTC_DCHECK(frame);
@@ -256,7 +267,7 @@ int FrameBuffer::InsertFrame(std::unique_ptr<FrameObject> frame) {
256267

257268
if (!UpdateFrameInfoWithIncomingFrame(*frame, info))
258269
return last_continuous_picture_id;
259-
270+
UpdatePlayoutDelays(*frame);
260271
info->second.frame = std::move(frame);
261272
++num_frames_buffered_;
262273

webrtc/modules/video_coding/frame_buffer2.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ class FrameBuffer {
120120

121121
using FrameMap = std::map<FrameKey, FrameInfo>;
122122

123+
// Updates the minimal and maximal playout delays
124+
// depending on the frame.
125+
void UpdatePlayoutDelays(const FrameObject& frame)
126+
EXCLUSIVE_LOCKS_REQUIRED(crit_);
127+
123128
// Update all directly dependent and indirectly dependent frames and mark
124129
// them as continuous if all their references has been fulfilled.
125130
void PropagateContinuity(FrameMap::iterator start)

webrtc/modules/video_coding/frame_buffer2_unittest.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ TEST_F(TestFrameBuffer2, OneSuperFrame) {
260260
CheckFrame(1, pid, 1);
261261
}
262262

263+
TEST_F(TestFrameBuffer2, SetPlayoutDelay) {
264+
const PlayoutDelay kPlayoutDelayMs = {123, 321};
265+
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
266+
test_frame->SetPlayoutDelay(kPlayoutDelayMs);
267+
buffer_.InsertFrame(std::move(test_frame));
268+
EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_.min_playout_delay());
269+
EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_.max_playout_delay());
270+
}
271+
263272
// Flaky test, see bugs.webrtc.org/7068.
264273
TEST_F(TestFrameBuffer2, DISABLED_OneUnorderedSuperFrame) {
265274
uint16_t pid = Rand();

webrtc/modules/video_coding/frame_object.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer,
4848
_timeStamp = first_packet->timestamp;
4949
ntp_time_ms_ = first_packet->ntp_time_ms_;
5050

51+
// Setting frame's playout delays to the same values
52+
// as of the first packet's.
53+
SetPlayoutDelay(first_packet->video_header.playout_delay);
54+
5155
// Since FFmpeg use an optimized bitstream reader that reads in chunks of
5256
// 32/64 bits we have to add at least that much padding to the buffer
5357
// to make sure the decoder doesn't read out of bounds.

0 commit comments

Comments
 (0)