blob: 3b5e19a5b733aef9d1cefe9ba40dc49cde9b1fcb [file] [log] [blame]
perkj11e18052016-03-07 22:03:23 +01001/*
perkj11e18052016-03-07 22:03:23 +01002 * 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
11#include "webrtc/api/videotracksource.h"
12
perkj0d3eef22016-03-09 02:39:17 +010013#include <string>
14
15#include "webrtc/base/bind.h"
16
17namespace webrtc {
18
19VideoTrackSource::VideoTrackSource(
20 rtc::VideoSourceInterface<cricket::VideoFrame>* source,
21 rtc::Thread* worker_thread,
22 bool remote)
23 : source_(source),
24 worker_thread_(worker_thread),
25 state_(kInitializing),
26 remote_(remote) {}
27
28void VideoTrackSource::SetState(SourceState new_state) {
29 if (state_ != new_state) {
30 state_ = new_state;
31 FireOnChanged();
32 }
33}
34
35void VideoTrackSource::AddOrUpdateSink(
36 rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
37 const rtc::VideoSinkWants& wants) {
38 worker_thread_->Invoke<void>(rtc::Bind(
39 &rtc::VideoSourceInterface<cricket::VideoFrame>::AddOrUpdateSink, source_,
40 sink, wants));
41}
42
43void VideoTrackSource::RemoveSink(
44 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
45 worker_thread_->Invoke<void>(
46 rtc::Bind(&rtc::VideoSourceInterface<cricket::VideoFrame>::RemoveSink,
47 source_, sink));
48}
49
50} // namespace webrtc