OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
11 #ifdef ENABLE_RTC_EVENT_LOG | 11 #ifdef ENABLE_RTC_EVENT_LOG |
12 | 12 |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "webrtc/base/buffer.h" | |
18 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/call.h" | 21 #include "webrtc/call.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" | |
21 #include "webrtc/system_wrappers/interface/clock.h" | 23 #include "webrtc/system_wrappers/interface/clock.h" |
22 #include "webrtc/test/test_suite.h" | 24 #include "webrtc/test/test_suite.h" |
23 #include "webrtc/test/testsupport/fileutils.h" | 25 #include "webrtc/test/testsupport/fileutils.h" |
24 #include "webrtc/test/testsupport/gtest_disable.h" | 26 #include "webrtc/test/testsupport/gtest_disable.h" |
25 #include "webrtc/video/rtc_event_log.h" | 27 #include "webrtc/video/rtc_event_log.h" |
26 | 28 |
27 // Files generated at build-time by the protobuf compiler. | 29 // Files generated at build-time by the protobuf compiler. |
28 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 30 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
29 #include "external/webrtc/webrtc/video/rtc_event_log.pb.h" | 31 #include "external/webrtc/webrtc/video/rtc_event_log.pb.h" |
30 #else | 32 #else |
31 #include "webrtc/video/rtc_event_log.pb.h" | 33 #include "webrtc/video/rtc_event_log.pb.h" |
32 #endif | 34 #endif |
33 | 35 |
34 namespace webrtc { | 36 namespace webrtc { |
35 | 37 |
38 namespace { | |
39 | |
40 const RTPExtensionType kExtensionTypes[] = { | |
41 RTPExtensionType::kRtpExtensionTransmissionTimeOffset, | |
42 RTPExtensionType::kRtpExtensionAudioLevel, | |
43 RTPExtensionType::kRtpExtensionAbsoluteSendTime, | |
44 RTPExtensionType::kRtpExtensionVideoRotation, | |
45 RTPExtensionType::kRtpExtensionTransportSequenceNumber}; | |
46 const char* kExtensionNames[] = {RtpExtension::kTOffset, | |
47 RtpExtension::kAudioLevel, | |
48 RtpExtension::kAbsSendTime, | |
49 RtpExtension::kVideoRotation, | |
50 RtpExtension::kTransportSequenceNumber}; | |
51 const size_t kNumExtensions = 5; | |
52 | |
53 } // namepsace | |
54 | |
36 // TODO(terelius): Place this definition with other parsing functions? | 55 // TODO(terelius): Place this definition with other parsing functions? |
37 MediaType GetRuntimeMediaType(rtclog::MediaType media_type) { | 56 MediaType GetRuntimeMediaType(rtclog::MediaType media_type) { |
38 switch (media_type) { | 57 switch (media_type) { |
39 case rtclog::MediaType::ANY: | 58 case rtclog::MediaType::ANY: |
40 return MediaType::ANY; | 59 return MediaType::ANY; |
41 case rtclog::MediaType::AUDIO: | 60 case rtclog::MediaType::AUDIO: |
42 return MediaType::AUDIO; | 61 return MediaType::AUDIO; |
43 case rtclog::MediaType::VIDEO: | 62 case rtclog::MediaType::VIDEO: |
44 return MediaType::VIDEO; | 63 return MediaType::VIDEO; |
45 case rtclog::MediaType::DATA: | 64 case rtclog::MediaType::DATA: |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 EXPECT_EQ(incoming, rtcp_packet.incoming()); | 258 EXPECT_EQ(incoming, rtcp_packet.incoming()); |
240 ASSERT_TRUE(rtcp_packet.has_type()); | 259 ASSERT_TRUE(rtcp_packet.has_type()); |
241 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type())); | 260 EXPECT_EQ(media_type, GetRuntimeMediaType(rtcp_packet.type())); |
242 ASSERT_TRUE(rtcp_packet.has_packet_data()); | 261 ASSERT_TRUE(rtcp_packet.has_packet_data()); |
243 ASSERT_EQ(total_size, rtcp_packet.packet_data().size()); | 262 ASSERT_EQ(total_size, rtcp_packet.packet_data().size()); |
244 for (size_t i = 0; i < total_size; i++) { | 263 for (size_t i = 0; i < total_size; i++) { |
245 EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.packet_data()[i])); | 264 EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.packet_data()[i])); |
246 } | 265 } |
247 } | 266 } |
248 | 267 |
268 void VerifyPlayoutEvent(const rtclog::Event& event) { | |
269 ASSERT_TRUE(IsValidBasicEvent(event)); | |
270 ASSERT_EQ(rtclog::Event::DEBUG_EVENT, event.type()); | |
271 const rtclog::DebugEvent& debug_event = event.debug_event(); | |
272 ASSERT_TRUE(debug_event.has_type()); | |
273 EXPECT_EQ(rtclog::DebugEvent::AUDIO_PLAYOUT, debug_event.type()); | |
274 } | |
275 | |
249 void VerifyLogStartEvent(const rtclog::Event& event) { | 276 void VerifyLogStartEvent(const rtclog::Event& event) { |
250 ASSERT_TRUE(IsValidBasicEvent(event)); | 277 ASSERT_TRUE(IsValidBasicEvent(event)); |
251 ASSERT_EQ(rtclog::Event::DEBUG_EVENT, event.type()); | 278 ASSERT_EQ(rtclog::Event::DEBUG_EVENT, event.type()); |
252 const rtclog::DebugEvent& debug_event = event.debug_event(); | 279 const rtclog::DebugEvent& debug_event = event.debug_event(); |
253 ASSERT_TRUE(debug_event.has_type()); | 280 ASSERT_TRUE(debug_event.has_type()); |
254 EXPECT_EQ(rtclog::DebugEvent::LOG_START, debug_event.type()); | 281 EXPECT_EQ(rtclog::DebugEvent::LOG_START, debug_event.type()); |
255 } | 282 } |
256 | 283 |
257 void GenerateVideoReceiveConfig(VideoReceiveStream::Config* config) { | 284 /* |
285 * LSB of extension_bitvector indicates presence of TransmissionTimeOffset, | |
286 * next higher bit indicates AudioLevel, then AbsoluteSendTime, then | |
287 * VideoRotation and finally TransportSequenceNumber. | |
288 */ | |
289 size_t GenerateRtpPacket(uint32_t extensions_bitvector, | |
290 uint32_t csrcs_count, | |
291 uint8_t* packet, | |
292 size_t packet_size) { | |
293 // CHECK(packet->size() == packet_size); | |
hlundin-webrtc
2015/08/26 09:42:22
Don't keep code that is commented away.
terelius
2015/09/03 09:20:16
Done.
| |
294 CHECK(packet_size >= 16 + 4 * csrcs_count + 4 * kNumExtensions); | |
hlundin-webrtc
2015/08/26 09:42:22
CHECK_GE; gives better printouts on failure.
terelius
2015/09/03 09:20:16
Done.
| |
295 Clock* clock = Clock::GetRealTimeClock(); | |
296 | |
297 RTPSender rtp_sender(0, // int32_t id | |
298 false, // bool audio | |
299 clock, // Clock* clock | |
300 nullptr, // Transport* | |
301 nullptr, // RtpAudioFeedback* | |
302 nullptr, // PacedSender* | |
303 nullptr, // PacketRouter* | |
304 nullptr, // SendTimeObserver* | |
305 nullptr, // BitrateStatisticsObserver* | |
306 nullptr, // FrameCountObserver* | |
307 nullptr); // SendSideDelayObserver* | |
308 | |
309 std::vector<uint32_t> csrcs; | |
310 for (unsigned i = 0; i < csrcs_count; i++) { | |
311 csrcs.push_back(rand()); | |
312 } | |
313 rtp_sender.SetCsrcs(csrcs); | |
314 rtp_sender.SetSSRC(rand()); | |
315 rtp_sender.SetStartTimestamp(rand(), true); | |
316 rtp_sender.SetSequenceNumber(rand()); | |
317 | |
318 for (unsigned i = 0; i < kNumExtensions; i++) { | |
319 if (extensions_bitvector & (1u << i)) { | |
320 rtp_sender.RegisterRtpHeaderExtension(kExtensionTypes[i], i + 1); | |
321 } | |
322 } | |
323 | |
324 int8_t payload_type = rand() % 128; | |
325 bool marker_bit = rand() & 0x01; | |
326 uint32_t capture_timestamp = rand(); | |
327 int64_t capture_time_ms = rand(); | |
328 bool timestamp_provided = rand() & 0x01; | |
329 bool inc_sequence_number = rand() & 0x01; | |
330 | |
331 size_t header_size = rtp_sender.BuildRTPheader( | |
332 packet, payload_type, marker_bit, capture_timestamp, capture_time_ms, | |
333 timestamp_provided, inc_sequence_number); | |
334 | |
335 for (size_t i = header_size; i < packet_size; i++) { | |
336 packet[i] = rand(); | |
337 } | |
338 | |
339 return header_size; | |
340 } | |
341 | |
342 void GenerateRtcpPacket(uint8_t* packet, size_t packet_size) { | |
343 for (size_t i = 0; i < packet_size; i++) { | |
344 packet[i] = rand(); | |
345 } | |
346 } | |
347 | |
348 void GenerateVideoReceiveConfig(uint32_t extensions_bitvector, | |
349 VideoReceiveStream::Config* config) { | |
258 // Create a map from a payload type to an encoder name. | 350 // Create a map from a payload type to an encoder name. |
259 VideoReceiveStream::Decoder decoder; | 351 VideoReceiveStream::Decoder decoder; |
260 decoder.payload_type = rand(); | 352 decoder.payload_type = rand(); |
261 decoder.payload_name = (rand() % 2 ? "VP8" : "H264"); | 353 decoder.payload_name = (rand() % 2 ? "VP8" : "H264"); |
262 config->decoders.push_back(decoder); | 354 config->decoders.push_back(decoder); |
263 // Add SSRCs for the stream. | 355 // Add SSRCs for the stream. |
264 config->rtp.remote_ssrc = rand(); | 356 config->rtp.remote_ssrc = rand(); |
265 config->rtp.local_ssrc = rand(); | 357 config->rtp.local_ssrc = rand(); |
266 // Add extensions and settings for RTCP. | 358 // Add extensions and settings for RTCP. |
267 config->rtp.rtcp_mode = rand() % 2 ? newapi::kRtcpCompound | 359 config->rtp.rtcp_mode = rand() % 2 ? newapi::kRtcpCompound |
268 : newapi::kRtcpReducedSize; | 360 : newapi::kRtcpReducedSize; |
269 config->rtp.rtcp_xr.receiver_reference_time_report = | 361 config->rtp.rtcp_xr.receiver_reference_time_report = |
270 static_cast<bool>(rand() % 2); | 362 static_cast<bool>(rand() % 2); |
271 config->rtp.remb = static_cast<bool>(rand() % 2); | 363 config->rtp.remb = static_cast<bool>(rand() % 2); |
272 // Add a map from a payload type to a new ssrc and a new payload type for RTX. | 364 // Add a map from a payload type to a new ssrc and a new payload type for RTX. |
273 VideoReceiveStream::Config::Rtp::Rtx rtx_pair; | 365 VideoReceiveStream::Config::Rtp::Rtx rtx_pair; |
274 rtx_pair.ssrc = rand(); | 366 rtx_pair.ssrc = rand(); |
275 rtx_pair.payload_type = rand(); | 367 rtx_pair.payload_type = rand(); |
276 config->rtp.rtx.insert(std::make_pair(rand(), rtx_pair)); | 368 config->rtp.rtx.insert(std::make_pair(rand(), rtx_pair)); |
277 // Add two random header extensions. | 369 // Add header extensions. |
278 const char* extension_name = rand() % 2 ? RtpExtension::kTOffset | 370 for (unsigned i = 0; i < kNumExtensions; i++) { |
279 : RtpExtension::kVideoRotation; | 371 if (extensions_bitvector & (1u << i)) { |
280 config->rtp.extensions.push_back(RtpExtension(extension_name, rand())); | 372 config->rtp.extensions.push_back( |
281 extension_name = rand() % 2 ? RtpExtension::kAudioLevel | 373 RtpExtension(kExtensionNames[i], rand())); |
282 : RtpExtension::kAbsSendTime; | 374 } |
283 config->rtp.extensions.push_back(RtpExtension(extension_name, rand())); | 375 } |
284 } | 376 } |
285 | 377 |
286 void GenerateVideoSendConfig(VideoSendStream::Config* config) { | 378 void GenerateVideoSendConfig(uint32_t extensions_bitvector, |
379 VideoSendStream::Config* config) { | |
287 // Create a map from a payload type to an encoder name. | 380 // Create a map from a payload type to an encoder name. |
288 config->encoder_settings.payload_type = rand(); | 381 config->encoder_settings.payload_type = rand(); |
289 config->encoder_settings.payload_name = (rand() % 2 ? "VP8" : "H264"); | 382 config->encoder_settings.payload_name = (rand() % 2 ? "VP8" : "H264"); |
290 // Add SSRCs for the stream. | 383 // Add SSRCs for the stream. |
291 config->rtp.ssrcs.push_back(rand()); | 384 config->rtp.ssrcs.push_back(rand()); |
292 // Add a map from a payload type to new ssrcs and a new payload type for RTX. | 385 // Add a map from a payload type to new ssrcs and a new payload type for RTX. |
293 config->rtp.rtx.ssrcs.push_back(rand()); | 386 config->rtp.rtx.ssrcs.push_back(rand()); |
294 config->rtp.rtx.payload_type = rand(); | 387 config->rtp.rtx.payload_type = rand(); |
295 // Add a CNAME. | 388 // Add a CNAME. |
296 config->rtp.c_name = "some.user@some.host"; | 389 config->rtp.c_name = "some.user@some.host"; |
297 // Add two random header extensions. | 390 // Add header extensions. |
298 const char* extension_name = rand() % 2 ? RtpExtension::kTOffset | 391 for (unsigned i = 0; i < kNumExtensions; i++) { |
299 : RtpExtension::kVideoRotation; | 392 if (extensions_bitvector & (1u << i)) { |
300 config->rtp.extensions.push_back(RtpExtension(extension_name, rand())); | 393 config->rtp.extensions.push_back( |
301 extension_name = rand() % 2 ? RtpExtension::kAudioLevel | 394 RtpExtension(kExtensionNames[i], rand())); |
302 : RtpExtension::kAbsSendTime; | 395 } |
303 config->rtp.extensions.push_back(RtpExtension(extension_name, rand())); | 396 } |
304 } | 397 } |
305 | 398 |
306 // Test for the RtcEventLog class. Dumps some RTP packets to disk, then reads | 399 // Test for the RtcEventLog class. Dumps some RTP packets to disk, then reads |
307 // them back to see if they match. | 400 // them back to see if they match. |
308 void LogSessionAndReadBack(size_t rtp_count, unsigned random_seed) { | 401 void LogSessionAndReadBack(size_t rtp_count, |
309 std::vector<std::vector<uint8_t>> rtp_packets; | 402 size_t rtcp_count, |
310 std::vector<uint8_t> incoming_rtcp_packet; | 403 size_t debug_count, |
311 std::vector<uint8_t> outgoing_rtcp_packet; | 404 uint32_t extensions_bitvector, |
405 uint32_t csrcs_count, | |
406 unsigned random_seed) { | |
407 ASSERT_LE(rtcp_count, rtp_count); | |
408 ASSERT_LE(debug_count, rtp_count); | |
409 std::vector<rtc::Buffer> rtp_packets; | |
410 std::vector<rtc::Buffer> rtcp_packets; | |
411 std::vector<size_t> rtp_header_sizes; | |
312 | 412 |
313 VideoReceiveStream::Config receiver_config; | 413 VideoReceiveStream::Config receiver_config; |
314 VideoSendStream::Config sender_config; | 414 VideoSendStream::Config sender_config; |
315 | 415 |
316 srand(random_seed); | 416 srand(random_seed); |
317 | 417 |
318 // Create rtp_count RTP packets containing random data. | 418 // Create rtp_count RTP packets containing random data. |
319 const size_t rtp_header_size = 20; | |
320 for (size_t i = 0; i < rtp_count; i++) { | 419 for (size_t i = 0; i < rtp_count; i++) { |
321 size_t packet_size = 1000 + rand() % 30; | 420 size_t packet_size = 1000 + rand() % 64; |
322 rtp_packets.push_back(std::vector<uint8_t>()); | 421 rtp_packets.push_back(rtc::Buffer(packet_size)); |
323 rtp_packets[i].reserve(packet_size); | 422 size_t header_size = GenerateRtpPacket(extensions_bitvector, csrcs_count, |
324 for (size_t j = 0; j < packet_size; j++) { | 423 rtp_packets[i].data(), packet_size); |
325 rtp_packets[i].push_back(rand()); | 424 rtp_header_sizes.push_back(header_size); |
326 } | |
327 } | 425 } |
328 // Create two RTCP packets containing random data. | 426 // Create rtcp_count RTCP packets containing random data. |
329 size_t packet_size = 1000 + rand() % 30; | 427 for (size_t i = 0; i < rtcp_count; i++) { |
330 outgoing_rtcp_packet.reserve(packet_size); | 428 size_t packet_size = 1000 + rand() % 64; |
331 for (size_t j = 0; j < packet_size; j++) { | 429 rtcp_packets.push_back(rtc::Buffer(packet_size)); |
332 outgoing_rtcp_packet.push_back(rand()); | 430 GenerateRtcpPacket(rtcp_packets[i].data(), packet_size); |
333 } | |
334 packet_size = 1000 + rand() % 30; | |
335 incoming_rtcp_packet.reserve(packet_size); | |
336 for (size_t j = 0; j < packet_size; j++) { | |
337 incoming_rtcp_packet.push_back(rand()); | |
338 } | 431 } |
339 // Create configurations for the video streams. | 432 // Create configurations for the video streams. |
340 GenerateVideoReceiveConfig(&receiver_config); | 433 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config); |
341 GenerateVideoSendConfig(&sender_config); | 434 GenerateVideoSendConfig(extensions_bitvector, &sender_config); |
435 const int config_count = 2; | |
342 | 436 |
343 // Find the name of the current test, in order to use it as a temporary | 437 // Find the name of the current test, in order to use it as a temporary |
344 // filename. | 438 // filename. |
345 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | 439 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
346 const std::string temp_filename = | 440 const std::string temp_filename = |
347 test::OutputPath() + test_info->test_case_name() + test_info->name(); | 441 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
348 | 442 |
349 // When log_dumper goes out of scope, it causes the log file to be flushed | 443 // When log_dumper goes out of scope, it causes the log file to be flushed |
350 // to disk. | 444 // to disk. |
351 { | 445 { |
352 rtc::scoped_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | 446 rtc::scoped_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
353 log_dumper->LogVideoReceiveStreamConfig(receiver_config); | 447 log_dumper->LogVideoReceiveStreamConfig(receiver_config); |
354 log_dumper->LogVideoSendStreamConfig(sender_config); | 448 log_dumper->LogVideoSendStreamConfig(sender_config); |
355 size_t i = 0; | 449 size_t rtcp_index = 1, debug_index = 1; |
356 for (; i < rtp_count / 2; i++) { | 450 for (size_t i = 1; i <= rtp_count; i++) { |
357 log_dumper->LogRtpHeader( | 451 log_dumper->LogRtpHeader( |
358 (i % 2 == 0), // Every second packet is incoming. | 452 (i % 2 == 0), // Every second packet is incoming. |
359 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, | 453 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, |
360 rtp_packets[i].data(), rtp_header_size, rtp_packets[i].size()); | 454 rtp_packets[i - 1].data(), rtp_packets[i - 1].size()); |
455 if (i * rtcp_count >= rtcp_index * rtp_count) { | |
456 log_dumper->LogRtcpPacket( | |
457 rtcp_index % 2 == 0, // Every second packet is incoming | |
458 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, | |
459 rtcp_packets[rtcp_index - 1].data(), | |
460 rtcp_packets[rtcp_index - 1].size()); | |
461 rtcp_index++; | |
462 } | |
463 if (i * debug_count >= debug_index * rtp_count) { | |
464 log_dumper->LogDebugEvent(RtcEventLog::DebugEvent::kAudioPlayout); | |
465 debug_index++; | |
466 } | |
467 if (i == rtp_count / 2) { | |
468 log_dumper->StartLogging(temp_filename, 10000000); | |
469 } | |
361 } | 470 } |
362 log_dumper->LogRtcpPacket(false, MediaType::AUDIO, | |
363 outgoing_rtcp_packet.data(), | |
364 outgoing_rtcp_packet.size()); | |
365 log_dumper->StartLogging(temp_filename, 10000000); | |
366 for (; i < rtp_count; i++) { | |
367 log_dumper->LogRtpHeader( | |
368 (i % 2 == 0), // Every second packet is incoming, | |
369 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, | |
370 rtp_packets[i].data(), rtp_header_size, rtp_packets[i].size()); | |
371 } | |
372 log_dumper->LogRtcpPacket(true, MediaType::VIDEO, | |
373 incoming_rtcp_packet.data(), | |
374 incoming_rtcp_packet.size()); | |
375 } | 471 } |
376 | 472 |
377 const int config_count = 2; | |
378 const int rtcp_count = 2; | |
379 const int debug_count = 1; // Only LogStart event, | |
380 const int event_count = config_count + debug_count + rtcp_count + rtp_count; | |
381 | |
382 // Read the generated file from disk. | 473 // Read the generated file from disk. |
383 rtclog::EventStream parsed_stream; | 474 rtclog::EventStream parsed_stream; |
384 | 475 |
385 ASSERT_TRUE(RtcEventLog::ParseRtcEventLog(temp_filename, &parsed_stream)); | 476 ASSERT_TRUE(RtcEventLog::ParseRtcEventLog(temp_filename, &parsed_stream)); |
386 | 477 |
387 // Verify the result. | 478 // Verify the result. |
479 const int event_count = | |
480 config_count + debug_count + rtcp_count + rtp_count + 1; | |
388 EXPECT_EQ(event_count, parsed_stream.stream_size()); | 481 EXPECT_EQ(event_count, parsed_stream.stream_size()); |
389 VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config); | 482 VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config); |
390 VerifySendStreamConfig(parsed_stream.stream(1), sender_config); | 483 VerifySendStreamConfig(parsed_stream.stream(1), sender_config); |
391 size_t i = 0; | 484 size_t event_index = config_count, rtcp_index = 1, debug_index = 1; |
392 for (; i < rtp_count / 2; i++) { | 485 for (size_t i = 1; i <= rtp_count; i++) { |
393 VerifyRtpEvent(parsed_stream.stream(config_count + i), | 486 VerifyRtpEvent(parsed_stream.stream(event_index), |
394 (i % 2 == 0), // Every second packet is incoming. | 487 (i % 2 == 0), // Every second packet is incoming. |
395 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, | 488 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, |
396 rtp_packets[i].data(), rtp_header_size, | 489 rtp_packets[i - 1].data(), rtp_header_sizes[i - 1], |
397 rtp_packets[i].size()); | 490 rtp_packets[i - 1].size()); |
491 event_index++; | |
492 if (i * rtcp_count >= rtcp_index * rtp_count) { | |
493 VerifyRtcpEvent(parsed_stream.stream(event_index), | |
494 rtcp_index % 2 == 0, // Every second packet is incoming. | |
495 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, | |
496 rtcp_packets[rtcp_index - 1].data(), | |
497 rtcp_packets[rtcp_index - 1].size()); | |
498 event_index++; | |
499 rtcp_index++; | |
500 } | |
501 if (i * debug_count >= debug_index * rtp_count) { | |
502 VerifyPlayoutEvent(parsed_stream.stream(event_index)); | |
503 event_index++; | |
504 debug_index++; | |
505 } | |
506 if (i == rtp_count / 2) { | |
507 VerifyLogStartEvent(parsed_stream.stream(event_index)); | |
508 event_index++; | |
509 } | |
398 } | 510 } |
399 VerifyRtcpEvent(parsed_stream.stream(config_count + rtp_count / 2), | |
400 false, // Outgoing RTCP packet. | |
401 MediaType::AUDIO, outgoing_rtcp_packet.data(), | |
402 outgoing_rtcp_packet.size()); | |
403 | |
404 VerifyLogStartEvent(parsed_stream.stream(1 + config_count + rtp_count / 2)); | |
405 for (; i < rtp_count; i++) { | |
406 VerifyRtpEvent(parsed_stream.stream(2 + config_count + i), | |
407 (i % 2 == 0), // Every second packet is incoming. | |
408 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, | |
409 rtp_packets[i].data(), rtp_header_size, | |
410 rtp_packets[i].size()); | |
411 } | |
412 VerifyRtcpEvent(parsed_stream.stream(2 + config_count + rtp_count), | |
413 true, // Incoming RTCP packet. | |
414 MediaType::VIDEO, incoming_rtcp_packet.data(), | |
415 incoming_rtcp_packet.size()); | |
416 | 511 |
417 // Clean up temporary file - can be pretty slow. | 512 // Clean up temporary file - can be pretty slow. |
418 remove(temp_filename.c_str()); | 513 remove(temp_filename.c_str()); |
419 } | 514 } |
420 | 515 |
421 TEST(RtcEventLogTest, LogSessionAndReadBack) { | 516 TEST(RtcEventLogTest, LogSessionAndReadBack) { |
422 LogSessionAndReadBack(5, 321); | 517 // Log 5 RTP, 2 RTCP, and 0 playout events with no header extensions or CSRCS. |
423 LogSessionAndReadBack(8, 3141592653u); | 518 LogSessionAndReadBack(5, 2, 0, 0, 0, 321); |
424 LogSessionAndReadBack(9, 2718281828u); | 519 |
520 // Enable AbsSendTime and TransportSequenceNumbers | |
521 uint32_t extensions = 0; | |
522 for (uint32_t i = 0; i < kNumExtensions; i++) { | |
523 if (kExtensionTypes[i] == RTPExtensionType::kRtpExtensionAbsoluteSendTime || | |
524 kExtensionTypes[i] == | |
525 RTPExtensionType::kRtpExtensionTransportSequenceNumber) { | |
526 extensions |= 1u << i; | |
527 } | |
528 } | |
529 LogSessionAndReadBack(8, 2, 0, extensions, 0, 3141592653u); | |
530 | |
531 extensions = (1u << kNumExtensions) - 1; // Enable all header extensions | |
532 LogSessionAndReadBack(9, 2, 3, extensions, 2, 2718281828u); | |
533 | |
534 // Try all combinations of header extensions and up to 2 CSRCS. | |
535 for (extensions = 0; extensions < (1u << kNumExtensions); extensions++) { | |
536 for (uint32_t csrcs_count = 0; csrcs_count < 3; csrcs_count++) { | |
537 LogSessionAndReadBack(5 + extensions, // Number of RTP packets. | |
538 2 + csrcs_count, // Number of RTCP packets. | |
539 3 + csrcs_count, // Number of playout events | |
540 extensions, // Bit vector choosing extensions | |
541 csrcs_count, // Number of contributing sources | |
542 rand()); | |
543 } | |
544 } | |
425 } | 545 } |
426 | 546 |
427 } // namespace webrtc | 547 } // namespace webrtc |
428 | 548 |
429 #endif // ENABLE_RTC_EVENT_LOG | 549 #endif // ENABLE_RTC_EVENT_LOG |
OLD | NEW |