blob: 56f48e7375cb9d941e0b8e35f790bfe80297300b [file] [log] [blame]
perkj11e18052016-03-07 21:03:231/*
perkj11e18052016-03-07 21:03:232 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 04:47:3111#include "pc/videotracksource.h"
perkj11e18052016-03-07 21:03:2312
perkj0d3eef22016-03-09 01:39:1713#include <string>
14
perkj0d3eef22016-03-09 01:39:1715namespace webrtc {
16
17VideoTrackSource::VideoTrackSource(
nisseacd935b2016-11-11 11:55:1318 rtc::VideoSourceInterface<VideoFrame>* source,
perkj0d3eef22016-03-09 01:39:1719 bool remote)
nisse5b68ab52016-04-07 14:45:5420 : source_(source), state_(kInitializing), remote_(remote) {
21 worker_thread_checker_.DetachFromThread();
22}
perkj0d3eef22016-03-09 01:39:1723
24void VideoTrackSource::SetState(SourceState new_state) {
25 if (state_ != new_state) {
26 state_ = new_state;
27 FireOnChanged();
28 }
29}
30
perkjf0dcfe22016-03-10 17:32:0031void VideoTrackSource::OnSourceDestroyed() {
32 source_ = nullptr;
33}
34
perkj0d3eef22016-03-09 01:39:1735void VideoTrackSource::AddOrUpdateSink(
nisseacd935b2016-11-11 11:55:1336 rtc::VideoSinkInterface<VideoFrame>* sink,
perkj0d3eef22016-03-09 01:39:1737 const rtc::VideoSinkWants& wants) {
nisse5b68ab52016-04-07 14:45:5438 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
perkjf0dcfe22016-03-10 17:32:0039 if (!source_) {
40 return;
41 }
nisse5b68ab52016-04-07 14:45:5442 source_->AddOrUpdateSink(sink, wants);
perkj0d3eef22016-03-09 01:39:1743}
44
nisseacd935b2016-11-11 11:55:1345void VideoTrackSource::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
nisse5b68ab52016-04-07 14:45:5446 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
perkjf0dcfe22016-03-10 17:32:0047 if (!source_) {
48 return;
49 }
nisse5b68ab52016-04-07 14:45:5450 source_->RemoveSink(sink);
perkj0d3eef22016-03-09 01:39:1751}
52
53} // namespace webrtc