2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2011 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
2015-01-20 21:36:13 +00:00
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/videotrack.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-11-25 11:26:01 -08:00
|
|
|
const char MediaStreamTrackInterface::kVideoKind[] = "video";
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
VideoTrack::VideoTrack(const std::string& label,
|
2016-03-08 01:27:48 +01:00
|
|
|
VideoTrackSourceInterface* video_source)
|
2013-07-10 00:45:36 +00:00
|
|
|
: MediaStreamTrack<VideoTrackInterface>(label),
|
|
|
|
|
video_source_(video_source) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VideoTrack::~VideoTrack() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string VideoTrack::kind() const {
|
2015-11-25 11:26:01 -08:00
|
|
|
return kVideoKind;
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-26 01:24:58 -08:00
|
|
|
void VideoTrack::AddOrUpdateSink(
|
|
|
|
|
rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
|
|
|
|
|
const rtc::VideoSinkWants& wants) {
|
2016-03-17 10:35:23 +01:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
VideoSourceBase::AddOrUpdateSink(sink, wants);
|
|
|
|
|
rtc::VideoSinkWants modified_wants = wants;
|
|
|
|
|
modified_wants.black_frames = !enabled();
|
|
|
|
|
video_source_->AddOrUpdateSink(sink, modified_wants);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-26 01:24:58 -08:00
|
|
|
void VideoTrack::RemoveSink(
|
|
|
|
|
rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
|
2016-03-17 10:35:23 +01:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
VideoSourceBase::RemoveSink(sink);
|
|
|
|
|
video_source_->RemoveSink(sink);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool VideoTrack::set_enabled(bool enable) {
|
2016-03-17 10:35:23 +01:00
|
|
|
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
|
|
for (auto& sink_pair : sink_pairs()) {
|
|
|
|
|
rtc::VideoSinkWants modified_wants = sink_pair.wants;
|
|
|
|
|
modified_wants.black_frames = !enable;
|
|
|
|
|
video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
|
2016-02-26 01:24:58 -08:00
|
|
|
const std::string& id,
|
2016-03-08 01:27:48 +01:00
|
|
|
VideoTrackSourceInterface* source) {
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::RefCountedObject<VideoTrack>* track =
|
|
|
|
|
new rtc::RefCountedObject<VideoTrack>(id, source);
|
2013-07-10 00:45:36 +00:00
|
|
|
return track;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|