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

Unified Diff: webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc

Issue 1230973005: Adds logging of configuration information for VideoReceiveStream (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc b/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc
index 98d0e622a871abe78d74678560d992993003f753..ba93121468120b09169dfc83a6aad900b3c462e8 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_dump_unittest.cc
@@ -31,92 +31,406 @@
namespace webrtc {
-// Test for the acm dump class. Dumps some RTP packets to disk, then reads them
+void VerifyReceiveStreamConfig(const ACMDumpEvent& event,
+ const VideoReceiveStream::Config& config) {
+ EXPECT_TRUE(event.has_timestamp_us());
+ ASSERT_TRUE(event.has_type());
+ EXPECT_EQ(ACMDumpEvent::RECEIVER_CONFIG_EVENT, event.type());
+ EXPECT_FALSE(event.has_rtp_packet());
+ EXPECT_FALSE(event.has_rtcp_packet());
+ EXPECT_FALSE(event.has_debug_event());
+ ASSERT_TRUE(event.has_receiver_config());
+ EXPECT_FALSE(event.has_sender_config());
+ EXPECT_FALSE(event.has_audio_receiver_config());
+ EXPECT_FALSE(event.has_audio_sender_config());
+ const ACMDumpVideoReceiveConfig& receiver_config = event.receiver_config();
+ // Check SSRCs.
+ ASSERT_TRUE(receiver_config.has_remote_ssrc());
+ EXPECT_EQ(config.rtp.remote_ssrc, receiver_config.remote_ssrc());
+ ASSERT_TRUE(receiver_config.has_local_ssrc());
+ EXPECT_EQ(config.rtp.local_ssrc, receiver_config.local_ssrc());
+ // Check RTCP settings.
+ ASSERT_TRUE(receiver_config.has_rtcp_mode());
+ if (config.rtp.rtcp_mode == newapi::kRtcpCompound)
+ EXPECT_EQ(ACMDumpVideoReceiveConfig::RTCP_COMPOUND,
+ receiver_config.rtcp_mode());
+ else
+ EXPECT_EQ(ACMDumpVideoReceiveConfig::RTCP_REDUCEDSIZE,
+ receiver_config.rtcp_mode());
+ ASSERT_TRUE(receiver_config.has_receiver_reference_time_report());
+ EXPECT_EQ(config.rtp.rtcp_xr.receiver_reference_time_report,
+ receiver_config.receiver_reference_time_report());
+ ASSERT_TRUE(receiver_config.has_remb());
+ EXPECT_EQ(config.rtp.remb, receiver_config.remb());
+ // Check RTX map.
+ ASSERT_EQ(static_cast<int>(config.rtp.rtx.size()),
+ receiver_config.rtx_map_size());
+ for (int i = 0; i < receiver_config.rtx_map_size(); i++) {
+ const RtxMap& mapping = receiver_config.rtx_map(i);
+ ASSERT_TRUE(mapping.has_payload_type());
+ ASSERT_TRUE(mapping.has_config());
+ EXPECT_EQ(1,
+ static_cast<int>(config.rtp.rtx.count(mapping.payload_type())));
+ const RtxConfig& rtx_config = mapping.config();
+ const VideoReceiveStream::Config::Rtp::Rtx& rtx =
ivoc 2015/07/14 12:13:14 We could consider making this an auto, since it's
terelius 2015/07/16 12:47:03 While I like using auto to hide obvious boiler-pla
ivoc 2015/07/17 12:14:28 Okay, that makes sense.
+ config.rtp.rtx.at(mapping.payload_type());
+ ASSERT_TRUE(rtx_config.has_rtx_ssrc());
+ ASSERT_TRUE(rtx_config.has_rtx_payload_type());
+ EXPECT_EQ(rtx.ssrc, rtx_config.rtx_ssrc());
+ EXPECT_EQ(rtx.payload_type, rtx_config.rtx_payload_type());
+ }
+ // Check header extensions.
+ ASSERT_EQ(static_cast<int>(config.rtp.extensions.size()),
+ receiver_config.header_extensions_size());
+ for (int i = 0; i < receiver_config.header_extensions_size(); i++) {
+ ASSERT_TRUE(receiver_config.header_extensions(i).has_name());
+ ASSERT_TRUE(receiver_config.header_extensions(i).has_id());
+ const std::string& name = receiver_config.header_extensions(i).name();
+ int id = receiver_config.header_extensions(i).id();
+ EXPECT_EQ(config.rtp.extensions[i].id, id);
+ EXPECT_EQ(config.rtp.extensions[i].name, name);
+ }
+ // Check decoders.
+ ASSERT_EQ(static_cast<int>(config.decoders.size()),
+ receiver_config.decoders_size());
+ for (int i = 0; i < receiver_config.decoders_size(); i++) {
+ ASSERT_TRUE(receiver_config.decoders(i).has_name());
+ ASSERT_TRUE(receiver_config.decoders(i).has_payload_type());
+ const std::string& decoder_name = receiver_config.decoders(i).name();
+ int decoder_type = receiver_config.decoders(i).payload_type();
+ EXPECT_EQ(config.decoders[i].payload_name, decoder_name);
+ EXPECT_EQ(config.decoders[i].payload_type, decoder_type);
+ }
+}
+
+void VerifySendStreamConfig(const ACMDumpEvent& event,
+ const VideoSendStream::Config& config) {
+ EXPECT_TRUE(event.has_timestamp_us());
ivoc 2015/07/14 12:13:14 I think it would be a good idea to refactor the co
stefan-webrtc 2015/07/14 13:28:56 Agree, these functions are very long. If possible
terelius 2015/07/16 12:47:03 The first 10 lines of each function are similar. I
+ ASSERT_TRUE(event.has_type());
+ EXPECT_EQ(ACMDumpEvent::SENDER_CONFIG_EVENT, event.type());
+ EXPECT_FALSE(event.has_rtp_packet());
+ EXPECT_FALSE(event.has_rtcp_packet());
+ EXPECT_FALSE(event.has_debug_event());
+ EXPECT_FALSE(event.has_receiver_config());
+ ASSERT_TRUE(event.has_sender_config());
+ EXPECT_FALSE(event.has_audio_receiver_config());
+ EXPECT_FALSE(event.has_audio_sender_config());
+ const ACMDumpVideoSendConfig& sender_config = event.sender_config();
+ // Check SSRCs.
+ ASSERT_EQ(static_cast<int>(config.rtp.ssrcs.size()),
+ sender_config.ssrcs_size());
+ for (int i = 0; i < sender_config.ssrcs_size(); i++) {
+ EXPECT_EQ(config.rtp.ssrcs[i], sender_config.ssrcs(i));
+ }
+ // Check header extensions.
+ ASSERT_EQ(static_cast<int>(config.rtp.extensions.size()),
+ sender_config.header_extensions_size());
+ for (int i = 0; i < sender_config.header_extensions_size(); i++) {
+ ASSERT_TRUE(sender_config.header_extensions(i).has_name());
+ ASSERT_TRUE(sender_config.header_extensions(i).has_id());
+ const std::string& name = sender_config.header_extensions(i).name();
+ int id = sender_config.header_extensions(i).id();
+ EXPECT_EQ(config.rtp.extensions[i].id, id);
+ EXPECT_EQ(config.rtp.extensions[i].name, name);
+ }
+ // Check RTX settings.
+ ASSERT_EQ(static_cast<int>(config.rtp.rtx.ssrcs.size()),
+ sender_config.rtx_ssrcs_size());
+ for (int i = 0; i < sender_config.rtx_ssrcs_size(); i++) {
+ EXPECT_EQ(config.rtp.rtx.ssrcs[i], sender_config.rtx_ssrcs(i));
+ }
+ if (sender_config.rtx_ssrcs_size() > 0) {
+ ASSERT_TRUE(sender_config.has_rtx_payload_type());
+ EXPECT_EQ(config.rtp.rtx.payload_type, sender_config.rtx_payload_type());
+ }
+ // Check CNAME.
+ ASSERT_TRUE(sender_config.has_c_name());
+ EXPECT_EQ(config.rtp.c_name, sender_config.c_name());
+ // Check encoder.
+ ASSERT_TRUE(sender_config.has_encoder());
+ ASSERT_TRUE(sender_config.encoder().has_name());
+ ASSERT_TRUE(sender_config.encoder().has_payload_type());
+ EXPECT_EQ(config.encoder_settings.payload_name,
+ sender_config.encoder().name());
+ EXPECT_EQ(config.encoder_settings.payload_type,
+ sender_config.encoder().payload_type());
+}
+
+void VerifyRtpEvent(const ACMDumpEvent& event,
+ bool incoming,
+ MediaType media_type,
+ uint8_t* header,
+ size_t header_size,
+ size_t total_size) {
+ EXPECT_TRUE(event.has_timestamp_us());
+ ASSERT_TRUE(event.has_type());
+ EXPECT_EQ(ACMDumpEvent::RTP_EVENT, event.type());
+ ASSERT_TRUE(event.has_rtp_packet());
+ EXPECT_FALSE(event.has_rtcp_packet());
+ EXPECT_FALSE(event.has_debug_event());
+ EXPECT_FALSE(event.has_receiver_config());
+ EXPECT_FALSE(event.has_sender_config());
+ EXPECT_FALSE(event.has_audio_receiver_config());
+ EXPECT_FALSE(event.has_audio_sender_config());
+ const ACMDumpRtpPacket& rtp_packet = event.rtp_packet();
+ ASSERT_TRUE(rtp_packet.has_direction());
+ EXPECT_EQ(incoming ? ACMDumpRtpPacket::INCOMING : ACMDumpRtpPacket::OUTGOING,
+ rtp_packet.direction());
+ ASSERT_TRUE(rtp_packet.has_type());
+ if (media_type == MediaType::VIDEO)
+ EXPECT_EQ(ACMDumpRtpPacket::VIDEO, rtp_packet.type());
+ else if (media_type == MediaType::AUDIO)
+ EXPECT_EQ(ACMDumpRtpPacket::AUDIO, rtp_packet.type());
+ else
+ EXPECT_EQ(ACMDumpRtpPacket::UNKNOWN_TYPE, rtp_packet.type());
+ ASSERT_TRUE(rtp_packet.has_packet_length());
+ EXPECT_EQ(total_size, rtp_packet.packet_length());
+ ASSERT_TRUE(rtp_packet.has_header());
+ ASSERT_EQ(header_size, rtp_packet.header().size());
+ for (size_t i = 0; i < header_size; i++) {
+ EXPECT_EQ(header[i], static_cast<uint8_t>(rtp_packet.header()[i]));
+ }
+}
+
+void VerifyRtcpEvent(const ACMDumpEvent& event,
+ bool incoming,
+ MediaType media_type,
+ uint8_t* packet,
+ size_t total_size) {
+ EXPECT_TRUE(event.has_timestamp_us());
+ ASSERT_TRUE(event.has_type());
+ EXPECT_EQ(ACMDumpEvent::RTCP_EVENT, event.type());
+ EXPECT_FALSE(event.has_rtp_packet());
+ ASSERT_TRUE(event.has_rtcp_packet());
+ EXPECT_FALSE(event.has_debug_event());
+ EXPECT_FALSE(event.has_receiver_config());
+ EXPECT_FALSE(event.has_sender_config());
+ EXPECT_FALSE(event.has_audio_receiver_config());
+ EXPECT_FALSE(event.has_audio_sender_config());
+ const ACMDumpRtcpPacket& rtcp_packet = event.rtcp_packet();
+ ASSERT_TRUE(rtcp_packet.has_direction());
+ EXPECT_EQ(
+ incoming ? ACMDumpRtcpPacket::INCOMING : ACMDumpRtcpPacket::OUTGOING,
+ rtcp_packet.direction());
+ ASSERT_TRUE(rtcp_packet.has_type());
+ if (media_type == MediaType::VIDEO)
+ EXPECT_EQ(ACMDumpRtcpPacket::VIDEO, rtcp_packet.type());
+ else if (media_type == MediaType::AUDIO)
+ EXPECT_EQ(ACMDumpRtcpPacket::AUDIO, rtcp_packet.type());
+ else
+ EXPECT_EQ(ACMDumpRtcpPacket::UNKNOWN_TYPE, rtcp_packet.type());
+ ASSERT_TRUE(rtcp_packet.has_data());
+ ASSERT_EQ(total_size, rtcp_packet.data().size());
+ for (size_t i = 0; i < total_size; i++) {
+ EXPECT_EQ(packet[i], static_cast<uint8_t>(rtcp_packet.data()[i]));
+ }
+}
+
+void VerifyLogStartEvent(const ACMDumpEvent& event) {
+ EXPECT_TRUE(event.has_timestamp_us());
+ ASSERT_TRUE(event.has_type());
+ EXPECT_EQ(ACMDumpEvent::DEBUG_EVENT, event.type());
+ EXPECT_FALSE(event.has_rtp_packet());
+ EXPECT_FALSE(event.has_rtcp_packet());
+ ASSERT_TRUE(event.has_debug_event());
+ EXPECT_FALSE(event.has_receiver_config());
+ EXPECT_FALSE(event.has_sender_config());
+ EXPECT_FALSE(event.has_audio_receiver_config());
+ EXPECT_FALSE(event.has_audio_sender_config());
+ const ACMDumpDebugEvent& debug_event = event.debug_event();
+ ASSERT_TRUE(debug_event.has_type());
+ EXPECT_EQ(ACMDumpDebugEvent::LOG_START, debug_event.type());
+ // TODO(terelius): Deliberately not verifying that there is a message field
+ // since our protobuf file says that the message is optional. Make a decision.
ivoc 2015/07/14 12:13:14 I think that's fine, especially since the message
terelius 2015/07/16 12:47:03 We might want to make LogStart its own event type
ivoc 2015/07/17 12:14:28 Good idea.
+}
+
+void GenerateVideoReceiveConfig(webrtc::VideoReceiveStream::Config* config) {
+ // Create a map from a payload type to an encoder name.
+ VideoReceiveStream::Decoder decoder;
+ decoder.payload_type = rand();
+ decoder.payload_name = (rand() % 2 ? "VP8" : "H264");
+ config->decoders.push_back(decoder);
+ // Add SSRCs for the stream.
+ config->rtp.remote_ssrc = rand();
+ config->rtp.local_ssrc = rand();
+ // Add extensions and settings for RTCP.
+ config->rtp.rtcp_mode = rand() % 2 ? newapi::kRtcpCompound
+ : newapi::kRtcpReducedSize;
+ config->rtp.rtcp_xr.receiver_reference_time_report =
+ static_cast<bool>(rand() % 2);
+ config->rtp.remb = static_cast<bool>(rand() % 2);
+ // Add a map from a payload type to a new ssrc and a new payload type for RTX.
+ webrtc::VideoReceiveStream::Config::Rtp::Rtx rtx_pair;
+ rtx_pair.ssrc = rand();
+ rtx_pair.payload_type = rand();
+ config->rtp.rtx.insert(std::make_pair(rand(), rtx_pair));
+ // Add two random header extensions.
+ const char* extension_name = rand() % 2 ? RtpExtension::kTOffset
+ : RtpExtension::kVideoRotation;
+ config->rtp.extensions.push_back(RtpExtension(extension_name, rand()));
+ extension_name = rand() % 2 ? RtpExtension::kAudioLevel
+ : RtpExtension::kAbsSendTime;
+ config->rtp.extensions.push_back(RtpExtension(extension_name, rand()));
+}
+
+void GenerateVideoSendConfig(webrtc::VideoSendStream::Config* config) {
+ // Create a map from a payload type to an encoder name.
+ config->encoder_settings.payload_type = rand();
+ config->encoder_settings.payload_name = (rand() % 2 ? "VP8" : "H264");
+ // Add SSRCs for the stream.
+ config->rtp.ssrcs.push_back(rand());
+ // Add a map from a payload type to new ssrcs and a new payload type for RTX.
+ config->rtp.rtx.ssrcs.push_back(rand());
+ config->rtp.rtx.payload_type = rand();
+ // Add a CNAME.
+ config->rtp.c_name = "some.user@some.host";
+ // Add two random header extensions.
+ const char* extension_name = rand() % 2 ? RtpExtension::kTOffset
+ : RtpExtension::kVideoRotation;
+ config->rtp.extensions.push_back(RtpExtension(extension_name, rand()));
+ extension_name = rand() % 2 ? RtpExtension::kAudioLevel
+ : RtpExtension::kAbsSendTime;
+ config->rtp.extensions.push_back(RtpExtension(extension_name, rand()));
+}
+
+// Test for the ACMDump class. Dumps some RTP packets to disk, then reads them
// back to see if they match.
-class AcmDumpTest : public ::testing::Test {
- public:
- void VerifyResults(const ACMDumpEventStream& parsed_stream,
- size_t packet_size) {
- // Verify the result.
- EXPECT_EQ(5, parsed_stream.stream_size());
- const ACMDumpEvent& start_event = parsed_stream.stream(2);
- ASSERT_TRUE(start_event.has_type());
- EXPECT_EQ(ACMDumpEvent::DEBUG_EVENT, start_event.type());
- EXPECT_TRUE(start_event.has_timestamp_us());
- EXPECT_FALSE(start_event.has_packet());
- ASSERT_TRUE(start_event.has_debug_event());
- auto start_debug_event = start_event.debug_event();
- ASSERT_TRUE(start_debug_event.has_type());
- EXPECT_EQ(ACMDumpDebugEvent::LOG_START, start_debug_event.type());
- ASSERT_TRUE(start_debug_event.has_message());
-
- for (int i = 0; i < parsed_stream.stream_size(); i++) {
- if (i == 2) {
- // This is the LOG_START packet that was already verified.
- continue;
- }
- const ACMDumpEvent& test_event = parsed_stream.stream(i);
- ASSERT_TRUE(test_event.has_type());
- EXPECT_EQ(ACMDumpEvent::RTP_EVENT, test_event.type());
- EXPECT_TRUE(test_event.has_timestamp_us());
- EXPECT_FALSE(test_event.has_debug_event());
- ASSERT_TRUE(test_event.has_packet());
- const ACMDumpRTPPacket& test_packet = test_event.packet();
- ASSERT_TRUE(test_packet.has_direction());
- if (i <= 1) {
- EXPECT_EQ(ACMDumpRTPPacket::INCOMING, test_packet.direction());
- } else if (i >= 3) {
- EXPECT_EQ(ACMDumpRTPPacket::OUTGOING, test_packet.direction());
- }
- ASSERT_TRUE(test_packet.has_rtp_data());
- ASSERT_EQ(packet_size, test_packet.rtp_data().size());
- for (size_t i = 0; i < packet_size; i++) {
- EXPECT_EQ(rtp_packet_[i],
- static_cast<uint8_t>(test_packet.rtp_data()[i]));
- }
+void LogSessionAndReadBack(size_t rtp_count, unsigned random_seed) {
+ std::vector<uint8_t*> rtp_packets;
+ std::vector<size_t> rtp_packet_sizes;
ivoc 2015/07/14 12:13:14 I would prefer a vector<vector<uint8_t>> here, the
stefan-webrtc 2015/07/14 13:28:56 And you can also avoid the delete[]
terelius 2015/07/16 12:47:03 Done.
+ uint8_t* incoming_rtcp_packet;
+ uint8_t* outgoing_rtcp_packet;
ivoc 2015/07/14 12:13:14 These should be vector<uint8_t>.
terelius 2015/07/16 12:47:03 Done.
+ size_t incoming_rtcp_packet_size;
+ size_t outgoing_rtcp_packet_size;
+ webrtc::VideoReceiveStream::Config receiver_config;
+ webrtc::VideoSendStream::Config sender_config;
+
+ srand(random_seed);
+
+ // Create rtp_count RTP packets containing random data.
+ size_t rtp_header_size = 20;
ivoc 2015/07/14 12:13:14 Should be const.
terelius 2015/07/16 12:47:03 Done.
+ for (size_t i = 0; i < rtp_count; i++) {
+ size_t packet_size = 1000 + rand() % 30;
+ rtp_packets.push_back(new uint8_t[packet_size]);
+ for (size_t j = 0; j < packet_size; j++) {
+ rtp_packets[i][j] = rand();
}
+ rtp_packet_sizes.push_back(packet_size);
+ }
+ // Create two RTCP packets containing random data.
+ outgoing_rtcp_packet_size = 1000 + rand() % 30;
+ outgoing_rtcp_packet = new uint8_t[outgoing_rtcp_packet_size];
+ for (size_t j = 0; j < outgoing_rtcp_packet_size; j++) {
+ outgoing_rtcp_packet[j] = rand();
+ }
+ incoming_rtcp_packet_size = 1000 + rand() % 30;
+ incoming_rtcp_packet = new uint8_t[incoming_rtcp_packet_size];
+ for (size_t j = 0; j < incoming_rtcp_packet_size; j++) {
+ incoming_rtcp_packet[j] = rand();
}
+ // Create configurations for the video streams.
+ GenerateVideoReceiveConfig(&receiver_config);
+ GenerateVideoSendConfig(&sender_config);
- void Run(int packet_size, int random_seed) {
- rtp_packet_.clear();
- rtp_packet_.reserve(packet_size);
- srand(random_seed);
- // Fill the packet vector with random data.
- for (int i = 0; i < packet_size; i++) {
- rtp_packet_.push_back(rand());
+ // Find the name of the current test, in order to use it as a temporary
+ // filename.
+ auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
+ const std::string temp_filename =
+ test::OutputPath() + test_info->test_case_name() + test_info->name();
+
+ // When log_dumper goes out of scope, it causes the log file to be flushed
+ // to disk.
+ {
+ rtc::scoped_ptr<AcmDump> log_dumper(AcmDump::Create());
+ log_dumper->LogVideoReceiveStreamConfig(receiver_config);
+ log_dumper->LogVideoSendStreamConfig(sender_config);
+ size_t i = 0;
+ for (; i < rtp_count / 2; i++) {
+ log_dumper->LogRtpHeader(
+ (i % 2 == 0), // Every second packet is incoming.
+ (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
+ rtp_packets[i],
+ rtp_header_size,
+ rtp_packet_sizes[i]);
}
- // Find the name of the current test, in order to use it as a temporary
- // filename.
- auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
- const std::string temp_filename =
- test::OutputPath() + test_info->test_case_name() + test_info->name();
-
- // When log_dumper goes out of scope, it causes the log file to be flushed
- // to disk.
- {
- rtc::scoped_ptr<AcmDump> log_dumper(AcmDump::Create());
- log_dumper->LogRtpPacket(true, rtp_packet_.data(), rtp_packet_.size());
- log_dumper->LogRtpPacket(true, rtp_packet_.data(), rtp_packet_.size());
- log_dumper->StartLogging(temp_filename, 10000000);
- log_dumper->LogRtpPacket(false, rtp_packet_.data(), rtp_packet_.size());
- log_dumper->LogRtpPacket(false, rtp_packet_.data(), rtp_packet_.size());
+ log_dumper->LogRtcpPacket(false,
+ MediaType::AUDIO,
+ outgoing_rtcp_packet,
+ outgoing_rtcp_packet_size);
+ log_dumper->StartLogging(temp_filename, 10000000);
+ for (; i < rtp_count; i++) {
+ log_dumper->LogRtpHeader(
+ (i % 2 == 0), // Every second packet is incoming,
+ (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
+ rtp_packets[i],
+ rtp_header_size,
+ rtp_packet_sizes[i]);
}
+ log_dumper->LogRtcpPacket(true,
+ MediaType::VIDEO,
+ incoming_rtcp_packet,
+ incoming_rtcp_packet_size);
+ }
+
+ int config_count = 2;
+ int rtcp_count = 2;
+ int debug_count = 1; // Only LogStart event,
ivoc 2015/07/14 12:13:14 These should be const.
terelius 2015/07/16 12:47:03 Done.
+ int event_count = config_count + debug_count + rtcp_count + rtp_count;
ivoc 2015/07/14 12:13:14 This one as well.
terelius 2015/07/16 12:47:03 Done.
+
+ // Read the generated file from disk.
+ ACMDumpEventStream parsed_stream;
- // Read the generated file from disk.
- ACMDumpEventStream parsed_stream;
+ ASSERT_TRUE(AcmDump::ParseAcmDump(temp_filename, &parsed_stream));
- ASSERT_EQ(true, AcmDump::ParseAcmDump(temp_filename, &parsed_stream));
+ // Verify the result.
+ EXPECT_EQ(event_count, parsed_stream.stream_size());
+ VerifyReceiveStreamConfig(parsed_stream.stream(0), receiver_config);
+ VerifySendStreamConfig(parsed_stream.stream(1), sender_config);
+ size_t i = 0;
+ for (; i < rtp_count / 2; i++) {
+ VerifyRtpEvent(parsed_stream.stream(config_count + i),
+ (i % 2 == 0), // Every second packet is incoming.
+ (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
+ rtp_packets[i],
+ rtp_header_size,
+ rtp_packet_sizes[i]);
+ }
+ VerifyRtcpEvent(parsed_stream.stream(config_count + rtp_count / 2),
+ false,
+ MediaType::AUDIO,
+ outgoing_rtcp_packet,
+ outgoing_rtcp_packet_size);
+
+ VerifyLogStartEvent(parsed_stream.stream(1 + config_count + rtp_count / 2));
+ for (; i < rtp_count; i++) {
+ VerifyRtpEvent(parsed_stream.stream(2 + config_count + i),
+ (i % 2 == 0), // Every second packet is incoming.
+ (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO,
+ rtp_packets[i],
+ rtp_header_size,
+ rtp_packet_sizes[i]);
+ }
+ VerifyRtcpEvent(parsed_stream.stream(2 + config_count + rtp_count),
+ true,
+ MediaType::VIDEO,
+ incoming_rtcp_packet,
+ incoming_rtcp_packet_size);
- VerifyResults(parsed_stream, packet_size);
+ // Clean up temporary file - can be pretty slow.
+ remove(temp_filename.c_str());
- // Clean up temporary file - can be pretty slow.
- remove(temp_filename.c_str());
+ // Free allocated memory,
+ for (size_t i = 0; i < rtp_count; i++) {
+ delete[] rtp_packets[i];
}
- std::vector<uint8_t> rtp_packet_;
-};
+ delete[] incoming_rtcp_packet;
+ delete[] outgoing_rtcp_packet;
+}
-TEST_F(AcmDumpTest, DumpAndRead) {
- Run(256, 321);
+TEST(AcmDumpTest, LogSessionAndReadBack) {
+ LogSessionAndReadBack(5, 321);
+ LogSessionAndReadBack(8, 3141592653U);
+ LogSessionAndReadBack(9, 2718281828U);
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698