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 | #ifndef WEBRTC_API_VIDEOTRACKSOURCE_H_ |
| 12 | #define WEBRTC_API_VIDEOTRACKSOURCE_H_ |
| 13 | |
perkj | 9e083d2 | 2016-03-20 09:38:40 -0700 | [diff] [blame] | 14 | #include "webrtc/api/mediastreaminterface.h" |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 15 | #include "webrtc/api/notifier.h" |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 16 | #include "webrtc/media/base/mediachannel.h" |
| 17 | #include "webrtc/media/base/videosinkinterface.h" |
| 18 | |
| 19 | // VideoTrackSource implements VideoTrackSourceInterface. |
| 20 | namespace webrtc { |
| 21 | |
| 22 | class VideoTrackSource : public Notifier<VideoTrackSourceInterface> { |
| 23 | public: |
| 24 | VideoTrackSource(rtc::VideoSourceInterface<cricket::VideoFrame>* source, |
| 25 | rtc::Thread* worker_thread, |
| 26 | bool remote); |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 27 | void SetState(SourceState new_state); |
perkj | f0dcfe2 | 2016-03-10 18:32:00 +0100 | [diff] [blame] | 28 | // OnSourceDestroyed clears this instance pointer to |source_|. It is useful |
| 29 | // when the underlying rtc::VideoSourceInterface is destroyed before the |
| 30 | // reference counted VideoTrackSource. |
| 31 | void OnSourceDestroyed(); |
| 32 | |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 33 | SourceState state() const override { return state_; } |
| 34 | bool remote() const override { return remote_; } |
| 35 | |
| 36 | void Stop() override{}; |
| 37 | void Restart() override{}; |
| 38 | |
perkj | f0dcfe2 | 2016-03-10 18:32:00 +0100 | [diff] [blame] | 39 | virtual bool is_screencast() const { return false; } |
Per | c0d31e9 | 2016-03-31 17:23:39 +0200 | [diff] [blame] | 40 | virtual rtc::Optional<bool> needs_denoising() const { |
| 41 | return rtc::Optional<bool>(); } |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 42 | |
nisse | fcc640f | 2016-04-01 01:10:42 -0700 | [diff] [blame] | 43 | bool GetStats(Stats* stats) override { return false; } |
| 44 | |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 45 | void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
| 46 | const rtc::VideoSinkWants& wants) override; |
| 47 | void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; |
| 48 | |
perkj | f0dcfe2 | 2016-03-10 18:32:00 +0100 | [diff] [blame] | 49 | cricket::VideoCapturer* GetVideoCapturer() override { return nullptr; } |
| 50 | |
perkj | 0d3eef2 | 2016-03-09 02:39:17 +0100 | [diff] [blame] | 51 | protected: |
| 52 | rtc::Thread* worker_thread() { return worker_thread_; } |
| 53 | |
| 54 | private: |
| 55 | rtc::VideoSourceInterface<cricket::VideoFrame>* source_; |
| 56 | rtc::Thread* worker_thread_; |
| 57 | cricket::VideoOptions options_; |
| 58 | SourceState state_; |
| 59 | const bool remote_; |
| 60 | }; |
| 61 | |
| 62 | } // namespace webrtc |
perkj | 11e1805 | 2016-03-07 22:03:23 +0100 | [diff] [blame] | 63 | |
| 64 | #endif // WEBRTC_API_VIDEOTRACKSOURCE_H_ |