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

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

Issue 2996153002: Reland of Add a flags field to video timing extension. (Closed)
Patch Set: Added test Created 3 years, 4 months 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 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 13 matching lines...) Expand all
24 const int& i) { 24 const int& i) {
25 return min_frame_size + (s + 1) * i % (max_frame_size - min_frame_size); 25 return min_frame_size + (s + 1) * i % (max_frame_size - min_frame_size);
26 } 26 }
27 27
28 class FakeEncodedImageCallback : public EncodedImageCallback { 28 class FakeEncodedImageCallback : public EncodedImageCallback {
29 public: 29 public:
30 FakeEncodedImageCallback() : last_frame_was_timing_(false) {} 30 FakeEncodedImageCallback() : last_frame_was_timing_(false) {}
31 Result OnEncodedImage(const EncodedImage& encoded_image, 31 Result OnEncodedImage(const EncodedImage& encoded_image,
32 const CodecSpecificInfo* codec_specific_info, 32 const CodecSpecificInfo* codec_specific_info,
33 const RTPFragmentationHeader* fragmentation) override { 33 const RTPFragmentationHeader* fragmentation) override {
34 last_frame_was_timing_ = encoded_image.timing_.is_timing_frame; 34 last_frame_was_timing_ =
35 encoded_image.timing_.flags != TimingFrameFlags::kInvalid;
35 return Result(Result::OK); 36 return Result(Result::OK);
36 }; 37 };
37 38
38 bool WasTimingFrame() { return last_frame_was_timing_; } 39 bool WasTimingFrame() { return last_frame_was_timing_; }
39 40
40 private: 41 private:
41 bool last_frame_was_timing_; 42 bool last_frame_was_timing_;
42 }; 43 };
43 44
44 enum class FrameType { 45 enum class FrameType {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 for (int s = 0; s < kNumStreams; ++s) { 158 for (int s = 0; s < kNumStreams; ++s) {
158 if (FrameSize(kMinFrameSize, kMaxFrameSize, s, i) >= 159 if (FrameSize(kMinFrameSize, kMaxFrameSize, s, i) >=
159 kAverageSize[s] * kDefaultOutlierFrameSizePercent / 100) { 160 kAverageSize[s] * kDefaultOutlierFrameSizePercent / 100) {
160 // Too big frame. May be dropped or timing, but not normal. 161 // Too big frame. May be dropped or timing, but not normal.
161 EXPECT_NE(frames[s][i], FrameType::kNormal); 162 EXPECT_NE(frames[s][i], FrameType::kNormal);
162 } 163 }
163 } 164 }
164 } 165 }
165 } 166 }
166 167
168 TEST(TestVCMEncodedFrameCallback, NoTimingFrameIfNoEncodeStartTime) {
169 EncodedImage image;
170 CodecSpecificInfo codec_specific;
171 int64_t timestamp = 1;
172 image._length = 500;
173 image.capture_time_ms_ = timestamp;
174 codec_specific.codecType = kVideoCodecGeneric;
175 codec_specific.codecSpecific.generic.simulcast_idx = 0;
176 FakeEncodedImageCallback sink;
177 VCMEncodedFrameCallback callback(&sink, nullptr);
178 VideoCodec::TimingFrameTriggerThresholds thresholds;
179 thresholds.delay_ms = 1; // Make all frames timing frames.
180 callback.SetTimingFramesThresholds(thresholds);
181
182 // Verify a single frame works with encode start time set.
183 callback.OnEncodeStarted(timestamp, 0);
184 callback.OnEncodedImage(image, &codec_specific, nullptr);
185 EXPECT_TRUE(sink.WasTimingFrame());
186
187 // New frame, now skip OnEncodeStarted. Should not result in timing frame.
188 image.capture_time_ms_ = ++timestamp;
189 callback.OnEncodedImage(image, &codec_specific, nullptr);
190 EXPECT_FALSE(sink.WasTimingFrame());
191 }
192
167 } // namespace test 193 } // namespace test
168 } // namespace webrtc 194 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/generic_encoder.cc ('k') | webrtc/sdk/android/src/jni/androidmediaencoder_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698