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

Side by Side Diff: webrtc/api/test/fakeaudiocapturemodule.cc

Issue 1835053002: Change default timestamp to 64 bits in all webrtc directories. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Add TODO for timestamp. Created 4 years, 7 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
« no previous file with comments | « webrtc/api/test/fakeaudiocapturemodule.h ('k') | webrtc/base/asynctcpsocket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 #include "webrtc/api/test/fakeaudiocapturemodule.h" 11 #include "webrtc/api/test/fakeaudiocapturemodule.h"
12 12
13 #include "webrtc/base/common.h" 13 #include "webrtc/base/common.h"
14 #include "webrtc/base/refcount.h" 14 #include "webrtc/base/refcount.h"
15 #include "webrtc/base/thread.h" 15 #include "webrtc/base/thread.h"
16 #include "webrtc/base/timeutils.h" 16 #include "webrtc/base/timeutils.h"
17 17
18 // Audio sample value that is high enough that it doesn't occur naturally when 18 // Audio sample value that is high enough that it doesn't occur naturally when
19 // frames are being faked. E.g. NetEq will not generate this large sample value 19 // frames are being faked. E.g. NetEq will not generate this large sample value
20 // unless it has received an audio frame containing a sample of this value. 20 // unless it has received an audio frame containing a sample of this value.
21 // Even simpler buffers would likely just contain audio sample values of 0. 21 // Even simpler buffers would likely just contain audio sample values of 0.
22 static const int kHighSampleValue = 10000; 22 static const int kHighSampleValue = 10000;
23 23
24 // Same value as src/modules/audio_device/main/source/audio_device_config.h in 24 // Same value as src/modules/audio_device/main/source/audio_device_config.h in
25 // https://code.google.com/p/webrtc/ 25 // https://code.google.com/p/webrtc/
26 static const uint32_t kAdmMaxIdleTimeProcess = 1000; 26 static const int kAdmMaxIdleTimeProcess = 1000;
27 27
28 // Constants here are derived by running VoE using a real ADM. 28 // Constants here are derived by running VoE using a real ADM.
29 // The constants correspond to 10ms of mono audio at 44kHz. 29 // The constants correspond to 10ms of mono audio at 44kHz.
30 static const int kTimePerFrameMs = 10; 30 static const int kTimePerFrameMs = 10;
31 static const uint8_t kNumberOfChannels = 1; 31 static const uint8_t kNumberOfChannels = 1;
32 static const int kSamplesPerSecond = 44000; 32 static const int kSamplesPerSecond = 44000;
33 static const int kTotalDelayMs = 0; 33 static const int kTotalDelayMs = 0;
34 static const int kClockDriftMs = 0; 34 static const int kClockDriftMs = 0;
35 static const uint32_t kMaxVolume = 14392; 35 static const uint32_t kMaxVolume = 14392;
36 36
(...skipping 29 matching lines...) Expand all
66 } 66 }
67 return capture_module; 67 return capture_module;
68 } 68 }
69 69
70 int FakeAudioCaptureModule::frames_received() const { 70 int FakeAudioCaptureModule::frames_received() const {
71 rtc::CritScope cs(&crit_); 71 rtc::CritScope cs(&crit_);
72 return frames_received_; 72 return frames_received_;
73 } 73 }
74 74
75 int64_t FakeAudioCaptureModule::TimeUntilNextProcess() { 75 int64_t FakeAudioCaptureModule::TimeUntilNextProcess() {
76 const uint32_t current_time = rtc::Time(); 76 const int64_t current_time = rtc::TimeMillis();
77 if (current_time < last_process_time_ms_) { 77 if (current_time < last_process_time_ms_) {
78 // TODO: wraparound could be handled more gracefully. 78 // TODO: wraparound could be handled more gracefully.
79 return 0; 79 return 0;
80 } 80 }
81 const uint32_t elapsed_time = current_time - last_process_time_ms_; 81 const int64_t elapsed_time = current_time - last_process_time_ms_;
82 if (kAdmMaxIdleTimeProcess < elapsed_time) { 82 if (kAdmMaxIdleTimeProcess < elapsed_time) {
83 return 0; 83 return 0;
84 } 84 }
85 return kAdmMaxIdleTimeProcess - elapsed_time; 85 return kAdmMaxIdleTimeProcess - elapsed_time;
86 } 86 }
87 87
88 void FakeAudioCaptureModule::Process() { 88 void FakeAudioCaptureModule::Process() {
89 last_process_time_ms_ = rtc::Time(); 89 last_process_time_ms_ = rtc::TimeMillis();
90 } 90 }
91 91
92 int32_t FakeAudioCaptureModule::ActiveAudioLayer( 92 int32_t FakeAudioCaptureModule::ActiveAudioLayer(
93 AudioLayer* /*audio_layer*/) const { 93 AudioLayer* /*audio_layer*/) const {
94 ASSERT(false); 94 ASSERT(false);
95 return 0; 95 return 0;
96 } 96 }
97 97
98 webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const { 98 webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const {
99 ASSERT(false); 99 ASSERT(false);
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 ASSERT(false); 583 ASSERT(false);
584 } 584 }
585 } 585 }
586 586
587 bool FakeAudioCaptureModule::Initialize() { 587 bool FakeAudioCaptureModule::Initialize() {
588 // Set the send buffer samples high enough that it would not occur on the 588 // Set the send buffer samples high enough that it would not occur on the
589 // remote side unless a packet containing a sample of that magnitude has been 589 // remote side unless a packet containing a sample of that magnitude has been
590 // sent to it. Note that the audio processing pipeline will likely distort the 590 // sent to it. Note that the audio processing pipeline will likely distort the
591 // original signal. 591 // original signal.
592 SetSendBuffer(kHighSampleValue); 592 SetSendBuffer(kHighSampleValue);
593 last_process_time_ms_ = rtc::Time(); 593 last_process_time_ms_ = rtc::TimeMillis();
594 return true; 594 return true;
595 } 595 }
596 596
597 void FakeAudioCaptureModule::SetSendBuffer(int value) { 597 void FakeAudioCaptureModule::SetSendBuffer(int value) {
598 Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_); 598 Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_);
599 const size_t buffer_size_in_samples = 599 const size_t buffer_size_in_samples =
600 sizeof(send_buffer_) / kNumberBytesPerSample; 600 sizeof(send_buffer_) / kNumberBytesPerSample;
601 for (size_t i = 0; i < buffer_size_in_samples; ++i) { 601 for (size_t i = 0; i < buffer_size_in_samples; ++i) {
602 buffer_ptr[i] = value; 602 buffer_ptr[i] = value;
603 } 603 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 if (started_) { 642 if (started_) {
643 // Already started. 643 // Already started.
644 return; 644 return;
645 } 645 }
646 ProcessFrameP(); 646 ProcessFrameP();
647 } 647 }
648 648
649 void FakeAudioCaptureModule::ProcessFrameP() { 649 void FakeAudioCaptureModule::ProcessFrameP() {
650 ASSERT(process_thread_->IsCurrent()); 650 ASSERT(process_thread_->IsCurrent());
651 if (!started_) { 651 if (!started_) {
652 next_frame_time_ = rtc::Time(); 652 next_frame_time_ = rtc::TimeMillis();
653 started_ = true; 653 started_ = true;
654 } 654 }
655 655
656 { 656 {
657 rtc::CritScope cs(&crit_); 657 rtc::CritScope cs(&crit_);
658 // Receive and send frames every kTimePerFrameMs. 658 // Receive and send frames every kTimePerFrameMs.
659 if (playing_) { 659 if (playing_) {
660 ReceiveFrameP(); 660 ReceiveFrameP();
661 } 661 }
662 if (recording_) { 662 if (recording_) {
663 SendFrameP(); 663 SendFrameP();
664 } 664 }
665 } 665 }
666 666
667 next_frame_time_ += kTimePerFrameMs; 667 next_frame_time_ += kTimePerFrameMs;
668 const uint32_t current_time = rtc::Time(); 668 const int64_t current_time = rtc::TimeMillis();
669 const uint32_t wait_time = 669 const int64_t wait_time =
670 (next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0; 670 (next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0;
671 process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS); 671 process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS);
672 } 672 }
673 673
674 void FakeAudioCaptureModule::ReceiveFrameP() { 674 void FakeAudioCaptureModule::ReceiveFrameP() {
675 ASSERT(process_thread_->IsCurrent()); 675 ASSERT(process_thread_->IsCurrent());
676 { 676 {
677 rtc::CritScope cs(&crit_callback_); 677 rtc::CritScope cs(&crit_callback_);
678 if (!audio_callback_) { 678 if (!audio_callback_) {
679 return; 679 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 kNumberOfChannels, 716 kNumberOfChannels,
717 kSamplesPerSecond, kTotalDelayMs, 717 kSamplesPerSecond, kTotalDelayMs,
718 kClockDriftMs, current_mic_level, 718 kClockDriftMs, current_mic_level,
719 key_pressed, 719 key_pressed,
720 current_mic_level) != 0) { 720 current_mic_level) != 0) {
721 ASSERT(false); 721 ASSERT(false);
722 } 722 }
723 SetMicrophoneVolume(current_mic_level); 723 SetMicrophoneVolume(current_mic_level);
724 } 724 }
725 725
OLDNEW
« no previous file with comments | « webrtc/api/test/fakeaudiocapturemodule.h ('k') | webrtc/base/asynctcpsocket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698