blob: f119dd86d83de6806d63d072a7ea3e29882647b6 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.org28e20752013-07-10 00:45:36 +00009 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_VIDEOTRACK_H_
12#define PC_VIDEOTRACK_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
14#include <string>
perkjd6c39542016-03-17 10:35:23 +010015#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000016
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "media/base/videosourcebase.h"
18#include "pc/mediastreamtrack.h"
19#include "rtc_base/scoped_ref_ptr.h"
Yves Gerey2e00abc2018-10-05 15:39:24 +020020#include "rtc_base/thread.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "rtc_base/thread_checker.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022
23namespace webrtc {
24
perkjd6c39542016-03-17 10:35:23 +010025class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
perkjc8f952d2016-03-23 00:33:56 -070026 public rtc::VideoSourceBase,
27 public ObserverInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000028 public:
perkja3ede6c2016-03-08 01:27:48 +010029 static rtc::scoped_refptr<VideoTrack> Create(
30 const std::string& label,
perkj773be362017-07-31 23:22:01 -070031 VideoTrackSourceInterface* source,
32 rtc::Thread* worker_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033
nisseacd935b2016-11-11 03:55:13 -080034 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
nissedb25d2e2016-02-26 01:24:58 -080035 const rtc::VideoSinkWants& wants) override;
nisseacd935b2016-11-11 03:55:13 -080036 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
nissedb25d2e2016-02-26 01:24:58 -080037
nisseef8b61e2016-04-29 06:09:15 -070038 VideoTrackSourceInterface* GetSource() const override {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039 return video_source_.get();
40 }
pbos5214a0a2016-12-16 15:39:11 -080041 ContentHint content_hint() const override;
42 void set_content_hint(ContentHint hint) override;
nisseef8b61e2016-04-29 06:09:15 -070043 bool set_enabled(bool enable) override;
44 std::string kind() const override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000045
46 protected:
perkj773be362017-07-31 23:22:01 -070047 VideoTrack(const std::string& id,
48 VideoTrackSourceInterface* video_source,
49 rtc::Thread* worker_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000050 ~VideoTrack();
51
52 private:
perkjc8f952d2016-03-23 00:33:56 -070053 // Implements ObserverInterface. Observes |video_source_| state.
54 void OnChanged() override;
55
perkj773be362017-07-31 23:22:01 -070056 rtc::Thread* const worker_thread_;
nisse5b68ab52016-04-07 07:45:54 -070057 rtc::ThreadChecker signaling_thread_checker_;
perkja3ede6c2016-03-08 01:27:48 +010058 rtc::scoped_refptr<VideoTrackSourceInterface> video_source_;
danilchapa37de392017-09-09 04:17:22 -070059 ContentHint content_hint_ RTC_GUARDED_BY(signaling_thread_checker_);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000060};
61
62} // namespace webrtc
63
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020064#endif // PC_VIDEOTRACK_H_