| OLD | NEW | 
|---|
| 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 | 10 | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 67         pcm_out_fid_(fopen(FLAGS_output.c_str(), "wb")), | 67         pcm_out_fid_(fopen(FLAGS_output.c_str(), "wb")), | 
| 68         samples_in_1ms_(48), | 68         samples_in_1ms_(48), | 
| 69         num_10ms_in_codec_frame_(2),  // Typical 20 ms frames. | 69         num_10ms_in_codec_frame_(2),  // Typical 20 ms frames. | 
| 70         time_to_insert_packet_ms_(3),  // An arbitrary offset on pushing packet. | 70         time_to_insert_packet_ms_(3),  // An arbitrary offset on pushing packet. | 
| 71         next_receive_ts_(0), | 71         next_receive_ts_(0), | 
| 72         time_to_playout_audio_ms_(kPlayoutPeriodMs), | 72         time_to_playout_audio_ms_(kPlayoutPeriodMs), | 
| 73         loss_threshold_(0), | 73         loss_threshold_(0), | 
| 74         playout_timing_fid_(fopen("playout_timing.txt", "wt")) {} | 74         playout_timing_fid_(fopen("playout_timing.txt", "wt")) {} | 
| 75 | 75 | 
| 76   void SetUp() { | 76   void SetUp() { | 
| 77     ASSERT_TRUE(sender_clock_ != NULL); | 77     ASSERT_TRUE(sender_clock_ != nullptr); | 
| 78     ASSERT_TRUE(receiver_clock_ != NULL); | 78     ASSERT_TRUE(receiver_clock_ != nullptr); | 
| 79 | 79 | 
| 80     ASSERT_TRUE(send_acm_.get() != NULL); | 80     ASSERT_TRUE(send_acm_.get() != nullptr); | 
| 81     ASSERT_TRUE(receive_acm_.get() != NULL); | 81     ASSERT_TRUE(receive_acm_.get() != nullptr); | 
| 82     ASSERT_TRUE(channel_ != NULL); | 82     ASSERT_TRUE(channel_ != nullptr); | 
| 83 | 83 | 
| 84     ASSERT_TRUE(seq_num_fid_ != NULL); | 84     ASSERT_TRUE(seq_num_fid_ != nullptr); | 
| 85     ASSERT_TRUE(send_ts_fid_ != NULL); | 85     ASSERT_TRUE(send_ts_fid_ != nullptr); | 
| 86     ASSERT_TRUE(receive_ts_fid_ != NULL); | 86     ASSERT_TRUE(receive_ts_fid_ != nullptr); | 
| 87 | 87 | 
| 88     ASSERT_TRUE(playout_timing_fid_ != NULL); | 88     ASSERT_TRUE(playout_timing_fid_ != nullptr); | 
| 89 | 89 | 
| 90     next_receive_ts_ = ReceiveTimestamp(); | 90     next_receive_ts_ = ReceiveTimestamp(); | 
| 91 | 91 | 
| 92     CodecInst codec; | 92     CodecInst codec; | 
| 93     ASSERT_EQ(0, AudioCodingModule::Codec(FLAGS_codec.c_str(), &codec, | 93     ASSERT_EQ(0, AudioCodingModule::Codec(FLAGS_codec.c_str(), &codec, | 
| 94                              FLAGS_codec_sample_rate_hz, | 94                              FLAGS_codec_sample_rate_hz, | 
| 95                              FLAGS_codec_channels)); | 95                              FLAGS_codec_channels)); | 
| 96     ASSERT_EQ(0, receive_acm_->InitializeReceiver()); | 96     ASSERT_EQ(0, receive_acm_->InitializeReceiver()); | 
| 97     ASSERT_EQ(0, send_acm_->RegisterSendCodec(codec)); | 97     ASSERT_EQ(0, send_acm_->RegisterSendCodec(codec)); | 
| 98     ASSERT_EQ(true, receive_acm_->RegisterReceiveCodec(codec.pltype, | 98     ASSERT_EQ(true, receive_acm_->RegisterReceiveCodec(codec.pltype, | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 112       std::cout << "Input file " << file_name << " 32 kHz mono." << std::endl; | 112       std::cout << "Input file " << file_name << " 32 kHz mono." << std::endl; | 
| 113     } else { | 113     } else { | 
| 114       pcm_in_fid_.Open(FLAGS_input, static_cast<uint16_t>(FLAGS_input_fs_hz), | 114       pcm_in_fid_.Open(FLAGS_input, static_cast<uint16_t>(FLAGS_input_fs_hz), | 
| 115                     "r", true);  // auto-rewind | 115                     "r", true);  // auto-rewind | 
| 116       std::cout << "Input file " << FLAGS_input << "at " << FLAGS_input_fs_hz | 116       std::cout << "Input file " << FLAGS_input << "at " << FLAGS_input_fs_hz | 
| 117           << " Hz in " << ((FLAGS_input_stereo) ? "stereo." : "mono.") | 117           << " Hz in " << ((FLAGS_input_stereo) ? "stereo." : "mono.") | 
| 118           << std::endl; | 118           << std::endl; | 
| 119       pcm_in_fid_.ReadStereo(FLAGS_input_stereo); | 119       pcm_in_fid_.ReadStereo(FLAGS_input_stereo); | 
| 120     } | 120     } | 
| 121 | 121 | 
| 122     ASSERT_TRUE(pcm_out_fid_ != NULL); | 122     ASSERT_TRUE(pcm_out_fid_ != nullptr); | 
| 123     std::cout << "Output file " << FLAGS_output << " at " << FLAGS_output_fs_hz | 123     std::cout << "Output file " << FLAGS_output << " at " << FLAGS_output_fs_hz | 
| 124         << " Hz." << std::endl; | 124         << " Hz." << std::endl; | 
| 125 | 125 | 
| 126     // Other setups | 126     // Other setups | 
| 127     if (FLAGS_loss_rate > 0) | 127     if (FLAGS_loss_rate > 0) | 
| 128       loss_threshold_ = RAND_MAX * FLAGS_loss_rate; | 128       loss_threshold_ = RAND_MAX * FLAGS_loss_rate; | 
| 129     else | 129     else | 
| 130       loss_threshold_ = 0; | 130       loss_threshold_ = 0; | 
| 131   } | 131   } | 
| 132 | 132 | 
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 276   FILE* playout_timing_fid_; | 276   FILE* playout_timing_fid_; | 
| 277 }; | 277 }; | 
| 278 | 278 | 
| 279 }  // webrtc | 279 }  // webrtc | 
| 280 | 280 | 
| 281 int main(int argc, char* argv[]) { | 281 int main(int argc, char* argv[]) { | 
| 282   google::ParseCommandLineFlags(&argc, &argv, true); | 282   google::ParseCommandLineFlags(&argc, &argv, true); | 
| 283   webrtc::InsertPacketWithTiming test; | 283   webrtc::InsertPacketWithTiming test; | 
| 284   test.SetUp(); | 284   test.SetUp(); | 
| 285 | 285 | 
| 286   FILE* delay_log = NULL; | 286   FILE* delay_log = nullptr; | 
| 287   if (FLAGS_delay.size() > 0) { | 287   if (FLAGS_delay.size() > 0) { | 
| 288     delay_log = fopen(FLAGS_delay.c_str(), "wt"); | 288     delay_log = fopen(FLAGS_delay.c_str(), "wt"); | 
| 289     if (delay_log == NULL) { | 289     if (delay_log == nullptr) { | 
| 290       std::cout << "Cannot open the file to log delay values." << std::endl; | 290       std::cout << "Cannot open the file to log delay values." << std::endl; | 
| 291       exit(1); | 291       exit(1); | 
| 292     } | 292     } | 
| 293   } | 293   } | 
| 294 | 294 | 
| 295   uint32_t action_taken; | 295   uint32_t action_taken; | 
| 296   int optimal_delay_ms; | 296   int optimal_delay_ms; | 
| 297   int current_delay_ms; | 297   int current_delay_ms; | 
| 298   while (test.HasPackets()) { | 298   while (test.HasPackets()) { | 
| 299     test.TickOneMillisecond(&action_taken); | 299     test.TickOneMillisecond(&action_taken); | 
| 300 | 300 | 
| 301     if (action_taken != 0) { | 301     if (action_taken != 0) { | 
| 302       test.Delay(&optimal_delay_ms, ¤t_delay_ms); | 302       test.Delay(&optimal_delay_ms, ¤t_delay_ms); | 
| 303       if (delay_log != NULL) { | 303       if (delay_log != nullptr) { | 
| 304         fprintf(delay_log, "%3d %3d\n", optimal_delay_ms, current_delay_ms); | 304         fprintf(delay_log, "%3d %3d\n", optimal_delay_ms, current_delay_ms); | 
| 305       } | 305       } | 
| 306     } | 306     } | 
| 307   } | 307   } | 
| 308   std::cout << std::endl; | 308   std::cout << std::endl; | 
| 309   test.TearDown(); | 309   test.TearDown(); | 
| 310   if (delay_log != NULL) | 310   if (delay_log != nullptr) | 
| 311     fclose(delay_log); | 311     fclose(delay_log); | 
| 312 } | 312 } | 
| OLD | NEW | 
|---|