blob: 40d2fb3482f2e55b1998c88150360372bee82ef1 [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"
nisse7341ab82016-11-02 03:39:58 -070017#include "webrtc/media/base/videoframe.h"
perkjd6c39542016-03-17 10:35:23 +010018#include "webrtc/media/base/videosourceinterface.h"
19
20namespace rtc {
21
22// VideoSourceBase is not thread safe.
nisse7341ab82016-11-02 03:39:58 -070023class VideoSourceBase : public VideoSourceInterface<cricket::VideoFrame> {
perkjd6c39542016-03-17 10:35:23 +010024 public:
25 VideoSourceBase();
nisse7341ab82016-11-02 03:39:58 -070026 void AddOrUpdateSink(VideoSinkInterface<cricket::VideoFrame>* sink,
perkjd6c39542016-03-17 10:35:23 +010027 const VideoSinkWants& wants) override;
nisse7341ab82016-11-02 03:39:58 -070028 void RemoveSink(VideoSinkInterface<cricket::VideoFrame>* sink) override;
perkjd6c39542016-03-17 10:35:23 +010029
30 protected:
31 struct SinkPair {
nisse7341ab82016-11-02 03:39:58 -070032 SinkPair(VideoSinkInterface<cricket::VideoFrame>* sink,
33 VideoSinkWants wants)
perkjd6c39542016-03-17 10:35:23 +010034 : sink(sink), wants(wants) {}
nisse7341ab82016-11-02 03:39:58 -070035 VideoSinkInterface<cricket::VideoFrame>* sink;
perkjd6c39542016-03-17 10:35:23 +010036 VideoSinkWants wants;
37 };
nisse7341ab82016-11-02 03:39:58 -070038 SinkPair* FindSinkPair(const VideoSinkInterface<cricket::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
49#endif // WEBRTC_MEDIA_BASE_VIDEOSOURCEBASE_H_