• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)13 MediaStreamTrack* 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)20 MediaStreamTrack::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()26 MediaStreamTrack::~MediaStreamTrack() {
27 }
28 
SetEnabled(bool enabled)29 void MediaStreamTrack::SetEnabled(bool enabled) {
30   DCHECK(thread_checker_.CalledOnValidThread());
31   if (track_.get())
32     track_->set_enabled(enabled);
33 }
34 
Stop()35 void 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()45 webrtc::AudioTrackInterface* MediaStreamTrack::GetAudioAdapter() {
46   DCHECK(thread_checker_.CalledOnValidThread());
47   return static_cast<webrtc::AudioTrackInterface*>(track_.get());
48 }
49 
50 }  // namespace content
51