Open3D (C++ API)  0.19.0
Loading...
Searching...
No Matches
BitmapTrackSource.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2024 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7// ----------------------------------------------------------------------------
8// Modified from: WebRTC src/pc/video_track_source.h
9//
10// Copyright 2016 The WebRTC project authors. All Rights Reserved.
11//
12// Use of this source code is governed by a BSD-style license
13// that can be found in the LICENSE file in the root of the source
14// tree. An additional intellectual property rights grant can be found
15// in the file PATENTS. All contributing project authors may
16// be found in the AUTHORS file in the root of the source tree.
17// ----------------------------------------------------------------------------
18//
19// This is a private header. It shall be hidden from Open3D's public API. Do not
20// put this in Open3D.h.in.
21
22#pragma once
23
24#include <absl/types/optional.h>
25#include <api/notifier.h>
26#include <api/sequence_checker.h>
27#include <api/video/recordable_encoded_frame.h>
28#include <api/video/video_frame.h>
29#include <api/video/video_sink_interface.h>
30#include <api/video/video_source_interface.h>
31#include <media/base/media_channel.h>
32
33#include "open3d/core/Tensor.h"
35
36namespace open3d {
37namespace visualization {
38namespace webrtc_server {
39
56class BitmapTrackSourceInterface : public webrtc::VideoTrackSourceInterface {
57public:
58 virtual void OnFrame(const std::shared_ptr<core::Tensor>& frame) = 0;
59};
60
61class BitmapTrackSource : public webrtc::Notifier<BitmapTrackSourceInterface> {
62public:
63 explicit BitmapTrackSource(bool remote);
64 void SetState(webrtc::MediaSourceInterface::SourceState new_state);
65 webrtc::MediaSourceInterface::SourceState state() const override {
66 return state_;
67 }
68 bool remote() const override { return remote_; }
69 bool is_screencast() const override { return false; }
70 absl::optional<bool> needs_denoising() const override {
71 return absl::nullopt;
72 }
73 bool GetStats(Stats* stats) override { return false; }
74 void AddOrUpdateSink(webrtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
75 const webrtc::VideoSinkWants& wants) override;
76 void RemoveSink(
77 webrtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override;
78 bool SupportsEncodedOutput() const override { return false; }
79 void GenerateKeyFrame() override {}
81 webrtc::VideoSinkInterface<webrtc::RecordableEncodedFrame>* sink)
82 override {}
84 webrtc::VideoSinkInterface<webrtc::RecordableEncodedFrame>* sink)
85 override {}
86
87 virtual void OnFrame(const std::shared_ptr<core::Tensor>& frame) override {
88 // Shall be implemented by child class.
89 utility::LogError("BitmapTrackSource::OnFrame called");
90 }
91
92protected:
93 virtual webrtc::VideoSourceInterface<webrtc::VideoFrame>* source() = 0;
94
95private:
96 webrtc::SequenceChecker worker_thread_checker_;
97 webrtc::MediaSourceInterface::SourceState state_;
98 const bool remote_;
99};
100
101} // namespace webrtc_server
102} // namespace visualization
103} // namespace open3d
Rect frame
Definition BitmapWindowSystem.cpp:31
virtual void OnFrame(const std::shared_ptr< core::Tensor > &frame) override
Definition BitmapTrackSource.h:87
bool SupportsEncodedOutput() const override
Definition BitmapTrackSource.h:78
bool GetStats(Stats *stats) override
Definition BitmapTrackSource.h:73
virtual webrtc::VideoSourceInterface< webrtc::VideoFrame > * source()=0
void AddEncodedSink(webrtc::VideoSinkInterface< webrtc::RecordableEncodedFrame > *sink) override
Definition BitmapTrackSource.h:80
bool remote() const override
Definition BitmapTrackSource.h:68
absl::optional< bool > needs_denoising() const override
Definition BitmapTrackSource.h:70
void RemoveSink(webrtc::VideoSinkInterface< webrtc::VideoFrame > *sink) override
Definition BitmapTrackSource.cpp:48
void RemoveEncodedSink(webrtc::VideoSinkInterface< webrtc::RecordableEncodedFrame > *sink) override
Definition BitmapTrackSource.h:83
void AddOrUpdateSink(webrtc::VideoSinkInterface< webrtc::VideoFrame > *sink, const webrtc::VideoSinkWants &wants) override
Definition BitmapTrackSource.cpp:41
void SetState(webrtc::MediaSourceInterface::SourceState new_state)
Definition BitmapTrackSource.cpp:33
webrtc::MediaSourceInterface::SourceState state() const override
Definition BitmapTrackSource.h:65
bool is_screencast() const override
Definition BitmapTrackSource.h:69
void GenerateKeyFrame() override
Definition BitmapTrackSource.h:79
virtual void OnFrame(const std::shared_ptr< core::Tensor > &frame)=0
Definition PinholeCameraIntrinsic.cpp:16