1 /* 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_SINK_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_SINK_H_ 13 14 #include "webrtc/base/constructormagic.h" 15 #include "webrtc/modules/interface/module_common_types.h" 16 #include "webrtc/typedefs.h" 17 18 namespace webrtc { 19 namespace test { 20 21 // Interface class for an object receiving raw output audio from test 22 // applications. 23 class AudioSink { 24 public: 25 AudioSink() {} 26 virtual ~AudioSink() {} 27 28 // Writes |num_samples| from |audio| to the AudioSink. Returns true if 29 // successful, otherwise false. 30 virtual bool WriteArray(const int16_t* audio, size_t num_samples) = 0; 31 32 // Writes |audio_frame| to the AudioSink. Returns true if successful, 33 // otherwise false. 34 bool WriteAudioFrame(const AudioFrame& audio_frame) { 35 return WriteArray( 36 audio_frame.data_, 37 audio_frame.samples_per_channel_ * audio_frame.num_channels_); 38 } 39 40 private: 41 DISALLOW_COPY_AND_ASSIGN(AudioSink); 42 }; 43 44 } // namespace test 45 } // namespace webrtc 46 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_AUDIO_SINK_H_ 47