18a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org/* 28a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * libjingle 38a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * Copyright 2014, Google Inc. 48a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * 58a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * Redistribution and use in source and binary forms, with or without 68a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * modification, are permitted provided that the following conditions are met: 78a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * 88a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 98a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * this list of conditions and the following disclaimer. 108a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 118a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * this list of conditions and the following disclaimer in the documentation 128a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * and/or other materials provided with the distribution. 138a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * 3. The name of the author may not be used to endorse or promote products 148a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * derived from this software without specific prior written permission. 158a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * 168a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 178a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 188a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 198a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 208a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 218a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 228a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 238a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 248a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 258a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 268a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org */ 278a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 288a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org#include "talk/app/webrtc/remoteaudiosource.h" 298a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 308a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org#include <algorithm> 318a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org#include <functional> 328a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 338a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org#include "talk/base/logging.h" 348a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 358a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgnamespace webrtc { 368a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 378a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgtalk_base::scoped_refptr<RemoteAudioSource> RemoteAudioSource::Create() { 388a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org return new talk_base::RefCountedObject<RemoteAudioSource>(); 398a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 408a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 418a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgRemoteAudioSource::RemoteAudioSource() { 428a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 438a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 448a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgRemoteAudioSource::~RemoteAudioSource() { 458a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org ASSERT(audio_observers_.empty()); 468a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 478a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 488a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgMediaSourceInterface::SourceState RemoteAudioSource::state() const { 498a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org return MediaSourceInterface::kLive; 508a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 518a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 528a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgvoid RemoteAudioSource::SetVolume(double volume) { 538a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org ASSERT(volume >= 0 && volume <= 10); 548a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org for (AudioObserverList::iterator it = audio_observers_.begin(); 558a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org it != audio_observers_.end(); ++it) { 568a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org (*it)->OnSetVolume(volume); 578a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org } 588a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 598a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 608a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgvoid RemoteAudioSource::RegisterAudioObserver(AudioObserver* observer) { 618a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org ASSERT(observer != NULL); 628a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org ASSERT(std::find(audio_observers_.begin(), audio_observers_.end(), 638a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org observer) == audio_observers_.end()); 648a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org audio_observers_.push_back(observer); 658a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 668a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 678a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.orgvoid RemoteAudioSource::UnregisterAudioObserver(AudioObserver* observer) { 688a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org ASSERT(observer != NULL); 698a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org audio_observers_.remove(observer); 708a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} 718a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org 728a77f5bd83ba9386c19ff92f277c7268c1e9ef4awu@webrtc.org} // namespace webrtc 73