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

Side by Side Diff: content/renderer/media/speech_recognition_audio_sink_unittest.cc

Issue 2416123002: Stop media stream source when audio capture error occurs. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
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 "content/renderer/media/speech_recognition_audio_sink.h" 5 #include "content/renderer/media/speech_recognition_audio_sink.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h"
14 #include "content/renderer/media/media_stream_audio_source.h" 15 #include "content/renderer/media/media_stream_audio_source.h"
15 #include "content/renderer/media/media_stream_audio_track.h" 16 #include "content/renderer/media/media_stream_audio_track.h"
16 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h" 17 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h"
17 #include "media/base/audio_bus.h" 18 #include "media/base/audio_bus.h"
18 #include "media/base/audio_parameters.h" 19 #include "media/base/audio_parameters.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 22 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
22 #include "third_party/WebKit/public/platform/WebString.h" 23 #include "third_party/WebKit/public/platform/WebString.h"
23 #include "third_party/WebKit/public/web/WebHeap.h" 24 #include "third_party/WebKit/public/web/WebHeap.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Audio related members. 381 // Audio related members.
381 std::unique_ptr<media::AudioBus> source_bus_; 382 std::unique_ptr<media::AudioBus> source_bus_;
382 media::AudioParameters source_params_; 383 media::AudioParameters source_params_;
383 media::AudioParameters sink_params_; 384 media::AudioParameters sink_params_;
384 blink::WebMediaStreamSource blink_source_; 385 blink::WebMediaStreamSource blink_source_;
385 blink::WebMediaStreamTrack blink_track_; 386 blink::WebMediaStreamTrack blink_track_;
386 387
387 base::TimeTicks first_frame_capture_time_; 388 base::TimeTicks first_frame_capture_time_;
388 int64_t sample_frames_captured_; 389 int64_t sample_frames_captured_;
389 390
391 base::MessageLoop message_loop_;
392
390 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionAudioSinkTest); 393 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionAudioSinkTest);
391 }; 394 };
392 395
393 // Not all types of tracks are supported. This test checks if that policy is 396 // Not all types of tracks are supported. This test checks if that policy is
394 // implemented correctly. 397 // implemented correctly.
395 TEST_F(SpeechRecognitionAudioSinkTest, CheckIsSupportedAudioTrack) { 398 TEST_F(SpeechRecognitionAudioSinkTest, CheckIsSupportedAudioTrack) {
396 typedef std::map<MediaStreamType, bool> SupportedTrackPolicy; 399 typedef std::map<MediaStreamType, bool> SupportedTrackPolicy;
397 400
398 // This test must be aligned with the policy of supported tracks. 401 // This test must be aligned with the policy of supported tracks.
399 SupportedTrackPolicy p; 402 SupportedTrackPolicy p;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600); 540 const uint32_t buffers_per_notification = Initialize(44100, 441, 16000, 1600);
538 AssertConsumedBuffers(0U); 541 AssertConsumedBuffers(0U);
539 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); 542 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U);
540 EXPECT_CALL(*this, StoppedCallback()).Times(1); 543 EXPECT_CALL(*this, StoppedCallback()).Times(1);
541 544
542 native_track()->Stop(); 545 native_track()->Stop();
543 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U); 546 CaptureAudioAndAssertConsumedBuffers(buffers_per_notification, 1U);
544 } 547 }
545 548
546 } // namespace content 549 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_unittest.cc ('k') | content/renderer/media/webrtc/processed_local_audio_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698