1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/public/renderer/media_stream_audio_sink.h" 6 7 #include "base/logging.h" 8 #include "content/renderer/media/media_stream_track_extra_data.h" 9 #include "content/renderer/media/webrtc_local_audio_track.h" 10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 12 13 namespace content { 14 15 void MediaStreamAudioSink::AddToAudioTrack( 16 MediaStreamAudioSink* sink, 17 const blink::WebMediaStreamTrack& track) { 18 DCHECK(track.source().type() == blink::WebMediaStreamSource::TypeAudio); 19 MediaStreamTrackExtraData* extra_data = 20 static_cast<MediaStreamTrackExtraData*>(track.extraData()); 21 // TODO(xians): Support remote audio track. 22 DCHECK(extra_data->is_local_track()); 23 WebRtcLocalAudioTrack* audio_track = 24 static_cast<WebRtcLocalAudioTrack*>(extra_data->track().get()); 25 audio_track->AddSink(sink); 26 } 27 28 void MediaStreamAudioSink::RemoveFromAudioTrack( 29 MediaStreamAudioSink* sink, 30 const blink::WebMediaStreamTrack& track) { 31 MediaStreamTrackExtraData* extra_data = 32 static_cast<MediaStreamTrackExtraData*>(track.extraData()); 33 // TODO(xians): Support remote audio track. 34 DCHECK(extra_data->is_local_track()); 35 WebRtcLocalAudioTrack* audio_track = 36 static_cast<WebRtcLocalAudioTrack*>(extra_data->track().get()); 37 audio_track->RemoveSink(sink); 38 } 39 40 } // namespace content 41