henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef PC_VIDEOTRACK_H_ |
| 12 | #define PC_VIDEOTRACK_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
| 14 | #include <string> |
perkj | d6c3954 | 2016-03-17 10:35:23 +0100 | [diff] [blame] | 15 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "media/base/videosourcebase.h" |
| 18 | #include "pc/mediastreamtrack.h" |
| 19 | #include "rtc_base/scoped_ref_ptr.h" |
| 20 | #include "rtc_base/thread_checker.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
perkj | d6c3954 | 2016-03-17 10:35:23 +0100 | [diff] [blame] | 24 | class VideoTrack : public MediaStreamTrack<VideoTrackInterface>, |
perkj | c8f952d | 2016-03-23 00:33:56 -0700 | [diff] [blame] | 25 | public rtc::VideoSourceBase, |
| 26 | public ObserverInterface { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 27 | public: |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 28 | static rtc::scoped_refptr<VideoTrack> Create( |
| 29 | const std::string& label, |
perkj | 773be36 | 2017-07-31 23:22:01 -0700 | [diff] [blame] | 30 | VideoTrackSourceInterface* source, |
| 31 | rtc::Thread* worker_thread); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 33 | void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
nisse | db25d2e | 2016-02-26 01:24:58 -0800 | [diff] [blame] | 34 | const rtc::VideoSinkWants& wants) override; |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 35 | void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override; |
nisse | db25d2e | 2016-02-26 01:24:58 -0800 | [diff] [blame] | 36 | |
nisse | ef8b61e | 2016-04-29 06:09:15 -0700 | [diff] [blame] | 37 | VideoTrackSourceInterface* GetSource() const override { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | return video_source_.get(); |
| 39 | } |
pbos | 5214a0a | 2016-12-16 15:39:11 -0800 | [diff] [blame] | 40 | ContentHint content_hint() const override; |
| 41 | void set_content_hint(ContentHint hint) override; |
nisse | ef8b61e | 2016-04-29 06:09:15 -0700 | [diff] [blame] | 42 | bool set_enabled(bool enable) override; |
| 43 | std::string kind() const override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 44 | |
| 45 | protected: |
perkj | 773be36 | 2017-07-31 23:22:01 -0700 | [diff] [blame] | 46 | VideoTrack(const std::string& id, |
| 47 | VideoTrackSourceInterface* video_source, |
| 48 | rtc::Thread* worker_thread); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 49 | ~VideoTrack(); |
| 50 | |
| 51 | private: |
perkj | c8f952d | 2016-03-23 00:33:56 -0700 | [diff] [blame] | 52 | // Implements ObserverInterface. Observes |video_source_| state. |
| 53 | void OnChanged() override; |
| 54 | |
perkj | 773be36 | 2017-07-31 23:22:01 -0700 | [diff] [blame] | 55 | rtc::Thread* const worker_thread_; |
nisse | 5b68ab5 | 2016-04-07 07:45:54 -0700 | [diff] [blame] | 56 | rtc::ThreadChecker signaling_thread_checker_; |
perkj | a3ede6c | 2016-03-08 01:27:48 +0100 | [diff] [blame] | 57 | rtc::scoped_refptr<VideoTrackSourceInterface> video_source_; |
danilchap | a37de39 | 2017-09-09 04:17:22 -0700 | [diff] [blame] | 58 | ContentHint content_hint_ RTC_GUARDED_BY(signaling_thread_checker_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace webrtc |
| 62 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 63 | #endif // PC_VIDEOTRACK_H_ |