blob: e669e0814c7253e0a873774f8933a34216bb550d [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"
20#include "rtc_base/thread_checker.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000021
22namespace webrtc {
23
perkjd6c39542016-03-17 10:35:23 +010024class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
perkjc8f952d2016-03-23 00:33:56 -070025 public rtc::VideoSourceBase,
26 public ObserverInterface {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000027 public:
perkja3ede6c2016-03-08 01:27:48 +010028 static rtc::scoped_refptr<VideoTrack> Create(
29 const std::string& label,
perkj773be362017-07-31 23:22:01 -070030 VideoTrackSourceInterface* source,
31 rtc::Thread* worker_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000032
nisseacd935b2016-11-11 03:55:13 -080033 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
nissedb25d2e2016-02-26 01:24:58 -080034 const rtc::VideoSinkWants& wants) override;
nisseacd935b2016-11-11 03:55:13 -080035 void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
nissedb25d2e2016-02-26 01:24:58 -080036
nisseef8b61e2016-04-29 06:09:15 -070037 VideoTrackSourceInterface* GetSource() const override {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038 return video_source_.get();
39 }
pbos5214a0a2016-12-16 15:39:11 -080040 ContentHint content_hint() const override;
41 void set_content_hint(ContentHint hint) override;
nisseef8b61e2016-04-29 06:09:15 -070042 bool set_enabled(bool enable) override;
43 std::string kind() const override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000044
45 protected:
perkj773be362017-07-31 23:22:01 -070046 VideoTrack(const std::string& id,
47 VideoTrackSourceInterface* video_source,
48 rtc::Thread* worker_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000049 ~VideoTrack();
50
51 private:
perkjc8f952d2016-03-23 00:33:56 -070052 // Implements ObserverInterface. Observes |video_source_| state.
53 void OnChanged() override;
54
perkj773be362017-07-31 23:22:01 -070055 rtc::Thread* const worker_thread_;
nisse5b68ab52016-04-07 07:45:54 -070056 rtc::ThreadChecker signaling_thread_checker_;
perkja3ede6c2016-03-08 01:27:48 +010057 rtc::scoped_refptr<VideoTrackSourceInterface> video_source_;
danilchapa37de392017-09-09 04:17:22 -070058 ContentHint content_hint_ RTC_GUARDED_BY(signaling_thread_checker_);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000059};
60
61} // namespace webrtc
62
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020063#endif // PC_VIDEOTRACK_H_