Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / renderer / media / media_stream_track.cc
blobf3b728db88d09b6291468c157821453d4c24f665
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 webrtc::MediaStreamTrackInterface* track, bool is_local_track)
22 : track_(track),
23 muted_state_(false),
24 is_local_track_(is_local_track){
27 MediaStreamTrack::~MediaStreamTrack() {
30 void MediaStreamTrack::SetEnabled(bool enabled) {
31 DCHECK(thread_checker_.CalledOnValidThread());
32 if (track_.get())
33 track_->set_enabled(enabled);
36 void MediaStreamTrack::SetMutedState(bool muted_state) {
37 DCHECK(thread_checker_.CalledOnValidThread());
38 muted_state_ = muted_state;
41 bool MediaStreamTrack::GetMutedState(void) const {
42 DCHECK(thread_checker_.CalledOnValidThread());
43 return muted_state_;
46 void MediaStreamTrack::Stop() {
47 DCHECK(thread_checker_.CalledOnValidThread());
48 // Stop means that a track should be stopped permanently. But
49 // since there is no proper way of doing that on a remote track, we can
50 // at least disable the track. Blink will not call down to the content layer
51 // after a track has been stopped.
52 if (track_.get())
53 track_->set_enabled(false);
56 webrtc::AudioTrackInterface* MediaStreamTrack::GetAudioAdapter() {
57 DCHECK(thread_checker_.CalledOnValidThread());
58 return static_cast<webrtc::AudioTrackInterface*>(track_.get());
61 } // namespace content