blob: 74ad280343a412285f8468d374c84be130985dcc [file] [log] [blame]
perkj916c76e2016-03-11 22:54:27 +01001/*
2 * Copyright (c) 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MEDIA_BASE_VIDEOSOURCEBASE_H_
12#define MEDIA_BASE_VIDEOSOURCEBASE_H_
perkj916c76e2016-03-11 22:54:27 +010013
perkjd6c39542016-03-17 10:35:23 +010014#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "api/video/video_frame.h"
Niels Möller0327c2d2018-05-21 14:09:31 +020017#include "api/video/video_source_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "rtc_base/thread_checker.h"
perkjd6c39542016-03-17 10:35:23 +010019
20namespace rtc {
21
22// VideoSourceBase is not thread safe.
nisseacd935b2016-11-11 03:55:13 -080023class VideoSourceBase : public VideoSourceInterface<webrtc::VideoFrame> {
perkjd6c39542016-03-17 10:35:23 +010024 public:
25 VideoSourceBase();
Paulina Hensmana680a6a2018-04-05 11:42:24 +020026 ~VideoSourceBase() override;
nisseacd935b2016-11-11 03:55:13 -080027 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
perkjd6c39542016-03-17 10:35:23 +010028 const VideoSinkWants& wants) override;
nisseacd935b2016-11-11 03:55:13 -080029 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override;
perkjd6c39542016-03-17 10:35:23 +010030
31 protected:
32 struct SinkPair {
nisseacd935b2016-11-11 03:55:13 -080033 SinkPair(VideoSinkInterface<webrtc::VideoFrame>* sink, VideoSinkWants wants)
perkjd6c39542016-03-17 10:35:23 +010034 : sink(sink), wants(wants) {}
nisseacd935b2016-11-11 03:55:13 -080035 VideoSinkInterface<webrtc::VideoFrame>* sink;
perkjd6c39542016-03-17 10:35:23 +010036 VideoSinkWants wants;
37 };
nisseacd935b2016-11-11 03:55:13 -080038 SinkPair* FindSinkPair(const VideoSinkInterface<webrtc::VideoFrame>* sink);
perkjd6c39542016-03-17 10:35:23 +010039
40 const std::vector<SinkPair>& sink_pairs() const { return sinks_; }
41 ThreadChecker thread_checker_;
42
43 private:
44 std::vector<SinkPair> sinks_;
45};
46
47} // namespace rtc
perkj916c76e2016-03-11 22:54:27 +010048
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020049#endif // MEDIA_BASE_VIDEOSOURCEBASE_H_