perkj | 11e1805 | 2016-03-07 22:03:23 +0100 | [diff] [blame] | 1 | /* |
perkj | 11e1805 | 2016-03-07 22:03:23 +0100 | [diff] [blame] | 2 | * 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 | |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame^] | 13 | #include <string> |
| 14 | |
| 15 | #include "webrtc/base/bind.h" |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | VideoTrackSource::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 | |
| 28 | void VideoTrackSource::SetState(SourceState new_state) { |
| 29 | if (state_ != new_state) { |
| 30 | state_ = new_state; |
| 31 | FireOnChanged(); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | void 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 | |
| 43 | void 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 |