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

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Fix Mac CE Created 3 years, 8 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include <algorithm> // max 10 #include <algorithm> // max
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 284 }
285 285
286 void PerformTest() override { 286 void PerformTest() override {
287 EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet."; 287 EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet.";
288 } 288 }
289 } test; 289 } test;
290 290
291 RunBaseTest(&test); 291 RunBaseTest(&test);
292 } 292 }
293 293
294 TEST_F(VideoSendStreamTest, SupportsVideoContentType) {
295 class VideoRotationObserver : public test::SendTest {
296 public:
297 VideoRotationObserver() : SendTest(kDefaultTimeoutMs) {
298 EXPECT_TRUE(parser_->RegisterRtpHeaderExtension(
299 kRtpExtensionVideoContentType, test::kVideoContentTypeExtensionId));
300 }
301
302 Action OnSendRtp(const uint8_t* packet, size_t length) override {
303 RTPHeader header;
304 EXPECT_TRUE(parser_->Parse(packet, length, &header));
305 EXPECT_TRUE(header.extension.hasVideoContentType);
306 EXPECT_EQ(VideoContentType::kScreenshare,
307 header.extension.videoContentType);
308 observation_complete_.Set();
309 return SEND_PACKET;
310 }
311
312 void ModifyVideoConfigs(
313 VideoSendStream::Config* send_config,
314 std::vector<VideoReceiveStream::Config>* receive_configs,
315 VideoEncoderConfig* encoder_config) override {
316 send_config->rtp.extensions.clear();
317 send_config->rtp.extensions.push_back(
318 RtpExtension(RtpExtension::kVideoContentTypeUri,
319 test::kVideoContentTypeExtensionId));
320 }
321
322 void OnFrameGeneratorCapturerCreated(
323 test::FrameGeneratorCapturer* frame_generator_capturer) override {
324 frame_generator_capturer->SetFakeContentType(
325 VideoContentType::kScreenshare);
326 }
327
328 void PerformTest() override {
329 EXPECT_TRUE(Wait()) << "Timed out while waiting for single RTP packet.";
330 }
331 } test;
332
333 RunBaseTest(&test);
334 }
335
294 class FakeReceiveStatistics : public NullReceiveStatistics { 336 class FakeReceiveStatistics : public NullReceiveStatistics {
295 public: 337 public:
296 FakeReceiveStatistics(uint32_t send_ssrc, 338 FakeReceiveStatistics(uint32_t send_ssrc,
297 uint32_t last_sequence_number, 339 uint32_t last_sequence_number,
298 uint32_t cumulative_lost, 340 uint32_t cumulative_lost,
299 uint8_t fraction_lost) 341 uint8_t fraction_lost)
300 : lossy_stats_(new LossyStatistician(last_sequence_number, 342 : lossy_stats_(new LossyStatistician(last_sequence_number,
301 cumulative_lost, 343 cumulative_lost,
302 fraction_lost)) { 344 fraction_lost)) {
303 stats_map_[send_ssrc] = lossy_stats_.get(); 345 stats_map_[send_ssrc] = lossy_stats_.get();
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 EXPECT_TRUE(test::FrameBufsEqual(frames1[i].video_frame_buffer(), 2011 EXPECT_TRUE(test::FrameBufsEqual(frames1[i].video_frame_buffer(),
1970 frames2[i].video_frame_buffer())); 2012 frames2[i].video_frame_buffer()));
1971 } 2013 }
1972 2014
1973 VideoFrame CreateVideoFrame(int width, int height, uint8_t data) { 2015 VideoFrame CreateVideoFrame(int width, int height, uint8_t data) {
1974 const int kSizeY = width * height * 2; 2016 const int kSizeY = width * height * 2;
1975 std::unique_ptr<uint8_t[]> buffer(new uint8_t[kSizeY]); 2017 std::unique_ptr<uint8_t[]> buffer(new uint8_t[kSizeY]);
1976 memset(buffer.get(), data, kSizeY); 2018 memset(buffer.get(), data, kSizeY);
1977 VideoFrame frame( 2019 VideoFrame frame(
1978 I420Buffer::Create(width, height, width, width / 2, width / 2), 2020 I420Buffer::Create(width, height, width, width / 2, width / 2),
1979 kVideoRotation_0, data); 2021 kVideoRotation_0, VideoContentType::kDefault, data);
1980 frame.set_timestamp(data); 2022 frame.set_timestamp(data);
1981 // Use data as a ms timestamp. 2023 // Use data as a ms timestamp.
1982 frame.set_timestamp_us(data * rtc::kNumMicrosecsPerMillisec); 2024 frame.set_timestamp_us(data * rtc::kNumMicrosecsPerMillisec);
1983 return frame; 2025 return frame;
1984 } 2026 }
1985 2027
1986 TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) { 2028 TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) {
1987 class EncoderStateObserver : public test::SendTest, public VideoEncoder { 2029 class EncoderStateObserver : public test::SendTest, public VideoEncoder {
1988 public: 2030 public:
1989 EncoderStateObserver() 2031 EncoderStateObserver()
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 rtc::CriticalSection crit_; 3335 rtc::CriticalSection crit_;
3294 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); 3336 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_);
3295 bool first_packet_sent_ GUARDED_BY(&crit_); 3337 bool first_packet_sent_ GUARDED_BY(&crit_);
3296 rtc::Event bitrate_changed_event_; 3338 rtc::Event bitrate_changed_event_;
3297 } test; 3339 } test;
3298 3340
3299 RunBaseTest(&test); 3341 RunBaseTest(&test);
3300 } 3342 }
3301 3343
3302 } // namespace webrtc 3344 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698