Home | History | Annotate | Download | only in renderer
      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.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   MediaStreamTrack* native_track = MediaStreamTrack::GetTrack(track);
     20   // TODO(xians): Support remote audio track.
     21   DCHECK(native_track->is_local_track());
     22   WebRtcLocalAudioTrack* audio_track =
     23       static_cast<WebRtcLocalAudioTrack*>(native_track);
     24   audio_track->AddSink(sink);
     25 }
     26 
     27 void MediaStreamAudioSink::RemoveFromAudioTrack(
     28     MediaStreamAudioSink* sink,
     29     const blink::WebMediaStreamTrack& track) {
     30   MediaStreamTrack* native_track = MediaStreamTrack::GetTrack(track);
     31   // TODO(xians): Support remote audio track.
     32   DCHECK(native_track->is_local_track());
     33   WebRtcLocalAudioTrack* audio_track =
     34       static_cast<WebRtcLocalAudioTrack*>(native_track);
     35   audio_track->RemoveSink(sink);
     36 }
     37 
     38 }  // namespace content
     39