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 3 // found in the LICENSE file. 4 5 #include "content/renderer/media/media_stream_track.h" 6 7 #include "base/logging.h" 8 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 9 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 10 11 namespace content { 12 GetTrack(const blink::WebMediaStreamTrack & track)13MediaStreamTrack* MediaStreamTrack::GetTrack( 14 const blink::WebMediaStreamTrack& track) { 15 if (track.isNull()) 16 return NULL; 17 return static_cast<MediaStreamTrack*>(track.extraData()); 18 } 19 MediaStreamTrack(const scoped_refptr<webrtc::MediaStreamTrackInterface> & track,bool is_local_track)20MediaStreamTrack::MediaStreamTrack( 21 const scoped_refptr<webrtc::MediaStreamTrackInterface>& track, 22 bool is_local_track) 23 : track_(track), is_local_track_(is_local_track) { 24 } 25 ~MediaStreamTrack()26MediaStreamTrack::~MediaStreamTrack() { 27 } 28 SetEnabled(bool enabled)29void MediaStreamTrack::SetEnabled(bool enabled) { 30 DCHECK(thread_checker_.CalledOnValidThread()); 31 if (track_.get()) 32 track_->set_enabled(enabled); 33 } 34 Stop()35void MediaStreamTrack::Stop() { 36 DCHECK(thread_checker_.CalledOnValidThread()); 37 // Stop means that a track should be stopped permanently. But 38 // since there is no proper way of doing that on a remote track, we can 39 // at least disable the track. Blink will not call down to the content layer 40 // after a track has been stopped. 41 if (track_.get()) 42 track_->set_enabled(false); 43 } 44 GetAudioAdapter()45webrtc::AudioTrackInterface* MediaStreamTrack::GetAudioAdapter() { 46 DCHECK(thread_checker_.CalledOnValidThread()); 47 return static_cast<webrtc::AudioTrackInterface*>(track_.get()); 48 } 49 50 } // namespace content 51