cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / renderer / media / media_stream_track.cc
blob458748e2f9c24d384c6b165f5da75a6a68c51867
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.
5 #include "content/renderer/media/media_stream_track.h"
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"
11 namespace content {
13 MediaStreamTrack* MediaStreamTrack::GetTrack(
14 const blink::WebMediaStreamTrack& track) {
15 if (track.isNull())
16 return NULL;
17 return static_cast<MediaStreamTrack*>(track.extraData());
20 MediaStreamTrack::MediaStreamTrack(
21 const scoped_refptr<webrtc::MediaStreamTrackInterface>& track,
22 bool is_local_track)
23 : track_(track), is_local_track_(is_local_track) {
26 MediaStreamTrack::~MediaStreamTrack() {
29 void MediaStreamTrack::SetEnabled(bool enabled) {
30 DCHECK(thread_checker_.CalledOnValidThread());
31 if (track_.get())
32 track_->set_enabled(enabled);
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);
45 webrtc::AudioTrackInterface* MediaStreamTrack::GetAudioAdapter() {
46 DCHECK(thread_checker_.CalledOnValidThread());
47 return static_cast<webrtc::AudioTrackInterface*>(track_.get());
50 } // namespace content