Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: webrtc/modules/video_coding/receiver_unittest.cc

Issue 1428293003: Add VideoCodec::PreferDecodeLate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
2 * 2 *
3 * Use of this source code is governed by a BSD-style license 3 * Use of this source code is governed by a BSD-style license
4 * that can be found in the LICENSE file in the root of the source 4 * that can be found in the LICENSE file in the root of the source
5 * tree. An additional intellectual property rights grant can be found 5 * tree. An additional intellectual property rights grant can be found
6 * in the file PATENTS. All contributing project authors may 6 * in the file PATENTS. All contributing project authors may
7 * be found in the AUTHORS file in the root of the source tree. 7 * be found in the AUTHORS file in the root of the source tree.
8 */ 8 */
9 9
10 #include <string.h> 10 #include <string.h>
11 11
12 #include <list> 12 #include <list>
13 #include <queue> 13 #include <queue>
14 14
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/modules/video_coding/encoded_frame.h"
17 #include "webrtc/modules/video_coding/packet.h" 18 #include "webrtc/modules/video_coding/packet.h"
18 #include "webrtc/modules/video_coding/receiver.h" 19 #include "webrtc/modules/video_coding/receiver.h"
19 #include "webrtc/modules/video_coding/test/stream_generator.h" 20 #include "webrtc/modules/video_coding/test/stream_generator.h"
20 #include "webrtc/modules/video_coding/timing.h" 21 #include "webrtc/modules/video_coding/timing.h"
21 #include "webrtc/modules/video_coding/test/test_util.h" 22 #include "webrtc/modules/video_coding/test/test_util.h"
22 #include "webrtc/system_wrappers/include/clock.h" 23 #include "webrtc/system_wrappers/include/clock.h"
23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 24 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
24 25
25 namespace webrtc { 26 namespace webrtc {
26 27
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 receiver_.RenderBufferSizeMs()); 135 receiver_.RenderBufferSizeMs());
135 } 136 }
136 137
137 TEST_F(TestVCMReceiver, RenderBufferSize_NoKeyFrame) { 138 TEST_F(TestVCMReceiver, RenderBufferSize_NoKeyFrame) {
138 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); 139 EXPECT_EQ(0, receiver_.RenderBufferSizeMs());
139 int num_of_frames = 10; 140 int num_of_frames = 10;
140 for (int i = 0; i < num_of_frames; ++i) { 141 for (int i = 0; i < num_of_frames; ++i) {
141 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); 142 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError);
142 } 143 }
143 int64_t next_render_time_ms = 0; 144 int64_t next_render_time_ms = 0;
144 VCMEncodedFrame* frame = receiver_.FrameForDecoding(10, next_render_time_ms); 145 VCMEncodedFrame* frame =
146 receiver_.FrameForDecoding(10, next_render_time_ms, false);
145 EXPECT_TRUE(frame == NULL); 147 EXPECT_TRUE(frame == NULL);
146 receiver_.ReleaseFrame(frame); 148 receiver_.ReleaseFrame(frame);
147 EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError); 149 EXPECT_GE(InsertFrame(kVideoFrameDelta, false), kNoError);
148 for (int i = 0; i < num_of_frames; ++i) { 150 for (int i = 0; i < num_of_frames; ++i) {
149 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError); 151 EXPECT_GE(InsertFrame(kVideoFrameDelta, true), kNoError);
150 } 152 }
151 EXPECT_EQ(0, receiver_.RenderBufferSizeMs()); 153 EXPECT_EQ(0, receiver_.RenderBufferSizeMs());
152 } 154 }
153 155
154 TEST_F(TestVCMReceiver, NonDecodableDuration_Empty) { 156 TEST_F(TestVCMReceiver, NonDecodableDuration_Empty) {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 if (frame) { 518 if (frame) {
517 receiver_.ReleaseFrame(frame); 519 receiver_.ReleaseFrame(frame);
518 ++num_frames_return; 520 ++num_frames_return;
519 EXPECT_GE(kMaxWaitTime, end_time - start_time); 521 EXPECT_GE(kMaxWaitTime, end_time - start_time);
520 } else { 522 } else {
521 EXPECT_EQ(kMaxWaitTime, end_time - start_time); 523 EXPECT_EQ(kMaxWaitTime, end_time - start_time);
522 } 524 }
523 } 525 }
524 } 526 }
525 527
528 // Test whether VCMReceiver::FrameForDecoding handles parameter
529 // |prefer_late_decoding| and |max_wait_time_ms| correctly:
530 // 1. The function execution should never take more than |max_wait_time_ms|.
531 // 2. If the function exit before now + |max_wait_time_ms|, a frame must be
532 // returned and the end time must be equal to the render timestamp - delay
533 // for decoding and rendering.
534 TEST_F(VCMReceiverTimingTest, FrameForDecodingPreferLateDecoding) {
535 const size_t kNumFrames = 100;
536 const int kFramePeriod = 40;
537
538 int64_t arrive_timestamps[kNumFrames];
539 int64_t render_timestamps[kNumFrames];
540 int64_t next_render_time;
541
542 int render_delay_ms;
543 int max_decode_ms;
544 int dummy;
545 timing_.GetTimings(&dummy, &max_decode_ms, &dummy, &dummy, &dummy, &dummy,
546 &render_delay_ms);
547
548 // Construct test samples.
549 // render_timestamps are the timestamps stored in the Frame;
550 // arrive_timestamps controls when the Frame packet got received.
551 for (size_t i = 0; i < kNumFrames; i++) {
552 // Preset frame rate to 25Hz.
553 // But we add a reasonable deviation to arrive_timestamps to mimic Internet
554 // fluctuation.
555 arrive_timestamps[i] =
556 (i + 1) * kFramePeriod + (i % 10) * ((i % 2) ? 1 : -1);
557 render_timestamps[i] = (i + 1) * kFramePeriod;
558 }
559
560 clock_.SetFrames(arrive_timestamps, render_timestamps, kNumFrames);
561
562 // Record how many frames we finally get out of the receiver.
563 size_t num_frames_return = 0;
564 const int64_t kMaxWaitTime = 30;
565 bool prefer_late_decoding = true;
566 while (num_frames_return < kNumFrames) {
567 int64_t start_time = clock_.TimeInMilliseconds();
568
569 VCMEncodedFrame* frame =
570 receiver_.FrameForDecoding(kMaxWaitTime, next_render_time,
571 prefer_late_decoding);
572 int64_t end_time = clock_.TimeInMilliseconds();
573 if (frame) {
574 EXPECT_EQ(frame->RenderTimeMs() - max_decode_ms - render_delay_ms,
575 end_time);
576 receiver_.ReleaseFrame(frame);
577 ++num_frames_return;
578 } else {
579 EXPECT_EQ(kMaxWaitTime, end_time - start_time);
580 }
581 }
582 }
583
526 } // namespace webrtc 584 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/receiver.cc ('k') | webrtc/modules/video_coding/video_coding_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698