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"
13 MediaStreamTrack
* MediaStreamTrack::GetTrack(
14 const blink::WebMediaStreamTrack
& track
) {
17 return static_cast<MediaStreamTrack
*>(track
.extraData());
20 MediaStreamTrack::MediaStreamTrack(
21 webrtc::MediaStreamTrackInterface
* track
, bool is_local_track
)
24 is_local_track_(is_local_track
){
27 MediaStreamTrack::~MediaStreamTrack() {
30 void MediaStreamTrack::SetEnabled(bool enabled
) {
31 DCHECK(thread_checker_
.CalledOnValidThread());
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());
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.
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