blob: 5ddef093b46ca51b8a95f848168113f58c36e66c [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
11#ifndef WEBRTC_MEDIA_BASE_VIDEOSOURCEBASE_H_
12#define WEBRTC_MEDIA_BASE_VIDEOSOURCEBASE_H_
13
perkjd6c39542016-03-17 10:35:23 +010014#include <vector>
15
16#include "webrtc/base/thread_checker.h"
perkjd6c39542016-03-17 10:35:23 +010017#include "webrtc/media/base/videosourceinterface.h"
nisseacd935b2016-11-11 03:55:13 -080018#include "webrtc/video_frame.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();
nisseacd935b2016-11-11 03:55:13 -080026 void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
perkjd6c39542016-03-17 10:35:23 +010027 const VideoSinkWants& wants) override;
nisseacd935b2016-11-11 03:55:13 -080028 void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override;
perkjd6c39542016-03-17 10:35:23 +010029
30 protected:
31 struct SinkPair {
nisseacd935b2016-11-11 03:55:13 -080032 SinkPair(VideoSinkInterface<webrtc::VideoFrame>* sink, VideoSinkWants wants)
perkjd6c39542016-03-17 10:35:23 +010033 : sink(sink), wants(wants) {}
nisseacd935b2016-11-11 03:55:13 -080034 VideoSinkInterface<webrtc::VideoFrame>* sink;
perkjd6c39542016-03-17 10:35:23 +010035 VideoSinkWants wants;
36 };
nisseacd935b2016-11-11 03:55:13 -080037 SinkPair* FindSinkPair(const VideoSinkInterface<webrtc::VideoFrame>* sink);
perkjd6c39542016-03-17 10:35:23 +010038
39 const std::vector<SinkPair>& sink_pairs() const { return sinks_; }
40 ThreadChecker thread_checker_;
41
42 private:
43 std::vector<SinkPair> sinks_;
44};
45
46} // namespace rtc
perkj916c76e2016-03-11 22:54:27 +010047
48#endif // WEBRTC_MEDIA_BASE_VIDEOSOURCEBASE_H_