blob: 507fa106451e7a1021c8aebf3a5fe1fc902bab1b [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
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef MEDIA_BASE_VIDEO_SOURCE_BASE_H_
12#define MEDIA_BASE_VIDEO_SOURCE_BASE_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"
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "api/video/video_sink_interface.h"
Niels Möller0327c2d2018-05-21 14:09:31 +020018#include "api/video/video_source_interface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/thread_checker.h"
perkjd6c39542016-03-17 10:35:23 +010020
21namespace rtc {
22
23// VideoSourceBase is not thread safe.
nisseacd935b2016-11-11 03:55:13 -080024class VideoSourceBase : public VideoSourceInterface<webrtc::VideoFrame> {
perkjd6c39542016-03-17 10:35:23 +010025 public:
26 VideoSourceBase();
Paulina Hensmana680a6a2018-04-05 11:42:24 +020027 ~VideoSourceBase() override;
nisseacd935b2016-11-11 03:55:13 -080028 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
perkjd6c39542016-03-17 10:35:23 +010029 const VideoSinkWants& wants) override;
nisseacd935b2016-11-11 03:55:13 -080030 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override;
perkjd6c39542016-03-17 10:35:23 +010031
32 protected:
33 struct SinkPair {
nisseacd935b2016-11-11 03:55:13 -080034 SinkPair(VideoSinkInterface<webrtc::VideoFrame>* sink, VideoSinkWants wants)
perkjd6c39542016-03-17 10:35:23 +010035 : sink(sink), wants(wants) {}
nisseacd935b2016-11-11 03:55:13 -080036 VideoSinkInterface<webrtc::VideoFrame>* sink;
perkjd6c39542016-03-17 10:35:23 +010037 VideoSinkWants wants;
38 };
nisseacd935b2016-11-11 03:55:13 -080039 SinkPair* FindSinkPair(const VideoSinkInterface<webrtc::VideoFrame>* sink);
perkjd6c39542016-03-17 10:35:23 +010040
41 const std::vector<SinkPair>& sink_pairs() const { return sinks_; }
perkjd6c39542016-03-17 10:35:23 +010042
43 private:
44 std::vector<SinkPair> sinks_;
45};
46
47} // namespace rtc
perkj916c76e2016-03-11 22:54:27 +010048
Steve Anton10542f22019-01-11 09:11:00 -080049#endif // MEDIA_BASE_VIDEO_SOURCE_BASE_H_