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

Side by Side Diff: content/renderer/media/webrtc/webrtc_local_audio_track_adapter_unittest.cc

Issue 671793004: Clean up the media stream audio track code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h"
6 #include "content/public/common/content_switches.h"
7 #include "content/renderer/media/mock_media_constraint_factory.h" 5 #include "content/renderer/media/mock_media_constraint_factory.h"
8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 6 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
7 #include "content/renderer/media/webrtc_audio_capturer.h"
9 #include "content/renderer/media/webrtc_local_audio_track.h" 8 #include "content/renderer/media/webrtc_local_audio_track.h"
10 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
13 12
14 using ::testing::_; 13 using ::testing::_;
15 using ::testing::AnyNumber; 14 using ::testing::AnyNumber;
16 15
17 namespace content { 16 namespace content {
18 17
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Send a packet via |track_| and it data should reach the sink of the 66 // Send a packet via |track_| and it data should reach the sink of the
68 // |adapter_|. 67 // |adapter_|.
69 const int length = params_.frames_per_buffer() * params_.channels(); 68 const int length = params_.frames_per_buffer() * params_.channels();
70 scoped_ptr<int16[]> data(new int16[length]); 69 scoped_ptr<int16[]> data(new int16[length]);
71 // Initialize the data to 0 to avoid Memcheck:Uninitialized warning. 70 // Initialize the data to 0 to avoid Memcheck:Uninitialized warning.
72 memset(data.get(), 0, length * sizeof(data[0])); 71 memset(data.get(), 0, length * sizeof(data[0]));
73 72
74 EXPECT_CALL(*sink, 73 EXPECT_CALL(*sink,
75 OnData(_, 16, params_.sample_rate(), params_.channels(), 74 OnData(_, 16, params_.sample_rate(), params_.channels(),
76 params_.frames_per_buffer())); 75 params_.frames_per_buffer()));
77 track_->Capture(data.get(), base::TimeDelta(), 255, false, false, false); 76 track_->Capture(data.get(), false);
78 77
79 // Remove the sink from the webrtc track. 78 // Remove the sink from the webrtc track.
80 webrtc_track->RemoveSink(sink.get()); 79 webrtc_track->RemoveSink(sink.get());
81 sink.reset(); 80 sink.reset();
82 81
83 // Verify that no more callback gets into the sink. 82 // Verify that no more callback gets into the sink.
84 track_->Capture(data.get(), base::TimeDelta(), 255, false, false, false); 83 track_->Capture(data.get(), false);
85 } 84 }
86 85
87 TEST_F(WebRtcLocalAudioTrackAdapterTest, GetSignalLevel) { 86 TEST_F(WebRtcLocalAudioTrackAdapterTest, GetSignalLevel) {
88 webrtc::AudioTrackInterface* webrtc_track = 87 webrtc::AudioTrackInterface* webrtc_track =
89 static_cast<webrtc::AudioTrackInterface*>(adapter_.get()); 88 static_cast<webrtc::AudioTrackInterface*>(adapter_.get());
90 int signal_level = 0; 89 int signal_level = 0;
91 EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level)); 90 EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level));
92
93 // Disable the audio processing in the audio track.
94 CommandLine::ForCurrentProcess()->AppendSwitch(
95 switches::kDisableAudioTrackProcessing);
96 EXPECT_FALSE(webrtc_track->GetSignalLevel(&signal_level));
97 } 91 }
98 92
99 } // namespace content 93 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/webrtc_local_audio_track_adapter.cc ('k') | content/renderer/media/webrtc_audio_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698