Chromium Code Reviews| Index: webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc |
| diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc |
| index 6bcd717279b8b5bf4ce8423eaec62b825908997c..c925fe013a9d25c04f515d43350fda0492a33506 100644 |
| --- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc |
| +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc |
| @@ -30,6 +30,7 @@ |
| #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" |
| #include "webrtc/modules/audio_coding/neteq/tools/output_wav_file.h" |
| #include "webrtc/modules/audio_coding/neteq/tools/packet.h" |
| +#include "webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.h" |
| #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
| #include "webrtc/modules/interface/module_common_types.h" |
| #include "webrtc/system_wrappers/interface/trace.h" |
| @@ -137,6 +138,10 @@ DEFINE_string(ssrc, |
| "", |
| "Only use packets with this SSRC (decimal or hex, the latter " |
| "starting with 0x)"); |
| +DEFINE_bool(rtc_event_log, |
| + false, |
| + "Enables using a stored RtcEventLog as input " |
|
hlundin-webrtc
2015/08/28 12:06:24
No need to break this line.
ivoc
2015/09/01 10:03:50
Fixed. The string was longer before and I forgot t
|
| + "file."); |
| const bool hex_ssrc_dummy = |
| google::RegisterFlagValidator(&FLAGS_ssrc, &ValidateSsrcValue); |
| @@ -384,8 +389,15 @@ int main(int argc, char* argv[]) { |
| } |
| printf("Input file: %s\n", argv[1]); |
| - rtc::scoped_ptr<webrtc::test::RtpFileSource> file_source( |
| - webrtc::test::RtpFileSource::Create(argv[1])); |
| + rtc::scoped_ptr<webrtc::test::PacketSource> file_source; |
| + webrtc::test::RtcEventLogSource* event_log_source = nullptr; |
| + if (FLAGS_rtc_event_log) { |
| + event_log_source = webrtc::test::RtcEventLogSource::Create(argv[1]); |
|
minyue-webrtc
2015/08/28 14:50:21
Is there a way to detect the format automatically?
ivoc
2015/09/01 10:03:50
Good idea. I added this feature by checking if the
|
| + file_source.reset(event_log_source); |
| + } else { |
| + file_source.reset(webrtc::test::RtpFileSource::Create(argv[1])); |
| + } |
| + |
| assert(file_source.get()); |
| // Check if an SSRC value was provided. |
| @@ -414,6 +426,7 @@ int main(int argc, char* argv[]) { |
| return 0; |
| } |
| bool packet_available = true; |
| + bool output_event_available = true; |
|
minyue-webrtc
2015/08/28 16:54:17
I think 428 and 429 are too far, move to 500 if po
ivoc
2015/09/01 10:03:50
Done.
|
| // Check the sample rate. |
| int sample_rate_hz = CodecSampleRate(packet->header().payloadType); |
| @@ -485,7 +498,16 @@ int main(int argc, char* argv[]) { |
| next_output_time_ms += |
| kOutputBlockSizeMs - time_now_ms % kOutputBlockSizeMs; |
| } |
| - while (packet_available) { |
| + if (FLAGS_rtc_event_log) { |
| + next_output_time_ms = event_log_source->NextAudioOutputEventMs(); |
|
minyue-webrtc
2015/08/28 16:54:17
why not keeping -1 or let NextAudioOutputEventMs g
ivoc
2015/09/01 10:03:50
Keeping it at -1 would not work because later on t
|
| + if (next_output_time_ms == -1) { |
| + output_event_available = false; |
| + next_output_time_ms = INT_MAX; |
| + } |
| + start_time_ms = time_now_ms = |
| + std::min(next_input_time_ms, next_output_time_ms); |
| + } |
| + while (packet_available || output_event_available) { |
| // Check if it is time to insert packet. |
| while (time_now_ms >= next_input_time_ms && packet_available) { |
| assert(packet->virtual_payload_length_bytes() > 0); |
| @@ -535,7 +557,11 @@ int main(int argc, char* argv[]) { |
| if (temp_packet) { |
| packet.reset(temp_packet); |
| } else { |
| + // Set next input time to INT_MAX to prevent the time_now_ms from |
| + // becoming stuck at the final value. |
| + next_input_time_ms = INT_MAX; |
| packet_available = false; |
| + break; |
|
hlundin-webrtc
2015/08/28 12:06:24
What are you breaking out of, and why do you have
ivoc
2015/09/01 10:03:50
This break is for the while loop on line 512, it i
|
| } |
| if (replace_payload) { |
|
hlundin-webrtc
2015/08/28 12:06:25
Did you try to run with a replacement audio file?
ivoc
2015/09/01 10:03:50
It seems like next_input_time_ms is not used at al
hlundin-webrtc
2015/09/02 08:48:51
Acknowledged.
|
| // At this point |packet| contains the packet *after* |next_packet|. |
| @@ -551,7 +577,7 @@ int main(int argc, char* argv[]) { |
| } |
| // Check if it is time to get output audio. |
| - if (time_now_ms >= next_output_time_ms) { |
| + while (time_now_ms >= next_output_time_ms && output_event_available) { |
| static const int kOutDataLen = |
| kOutputBlockSizeMs * kMaxSamplesPerMs * kMaxChannels; |
| int16_t out_data[kOutDataLen]; |
| @@ -576,11 +602,24 @@ int main(int argc, char* argv[]) { |
| exit(1); |
| } |
| next_output_time_ms += kOutputBlockSizeMs; |
| + if (FLAGS_rtc_event_log) { |
| + next_output_time_ms = event_log_source->NextAudioOutputEventMs(); |
| + if (next_output_time_ms == -1) { |
| + output_event_available = false; |
| + // Set the next output time to INT_MAX to prevent the time_now_ms |
| + // from being set to -1. |
| + next_output_time_ms = INT_MAX; |
| + break; |
|
hlundin-webrtc
2015/08/28 12:06:24
Same as the break above.
ivoc
2015/09/01 10:03:50
Here the break is for the while loop on line 580,
|
| + } |
| + } else { |
| + if (!packet_available) { |
| + output_event_available = false; |
| + } |
| + } |
| } |
| // Advance time to next event. |
| time_now_ms = std::min(next_input_time_ms, next_output_time_ms); |
| } |
| - |
| printf("Simulation done\n"); |
| printf("Produced %i ms of audio\n", time_now_ms - start_time_ms); |