SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
rtp_capturer_video_source.hpp
1//
2// rtp_capturer_video_source.hpp
3// skyway
4//
5// Created by Naoto Takahashi on 2025/06/30.
6// Copyright © 2025 NTT DOCOMO BUSINESS, Inc. All rights reserved.
7//
8
9#ifndef SKYWAY_MEDIA_RTP_RTP_CAPTURER_VIDEO_SOURCE_HPP_
10#define SKYWAY_MEDIA_RTP_RTP_CAPTURER_VIDEO_SOURCE_HPP_
11
12#include <api/field_trials.h>
13#include <video/rtp_video_stream_receiver2.h>
14
15#include "skyway/global/worker.hpp"
16#include "skyway/media/codec/video_codec.hpp"
17#include "skyway/media/i420_capturer_video_source.hpp"
18#include "skyway/media/rtp/interface/rtp_capturer_video_source.hpp"
19#include "skyway/media/rtp/interface/rtp_capturer_video_source_repository.hpp"
20#include "skyway/network/interface/udp_server.hpp"
21
22namespace skyway {
23namespace media {
24namespace rtp {
26class FakeTransport : public webrtc::Transport {
27public:
28 bool SendRtp(rtc::ArrayView<const uint8_t> packet,
29 const webrtc::PacketOptions& options) override {
30 return true;
31 }
32
33 bool SendRtcp(rtc::ArrayView<const uint8_t> packet) override { return true; }
34};
35// @endcond
36
38 public network::interface::UdpServer::PacketHandler,
39 public webrtc::RtpVideoStreamReceiver2::OnCompleteFrameCallback,
40 public std::enable_shared_from_this<RtpCapturerVideoSource> {
41public:
44 std::shared_ptr<codec::VideoCodec> codec,
45 std::unique_ptr<network::interface::UdpServer> udp_server,
46 std::shared_ptr<interface::RtpCapturerVideoSourceRepository> repository,
47 std::unique_ptr<rtc::Thread> depacketize_th);
50
62 static std::shared_ptr<RtpCapturerVideoSource> Create(
64
65 bool StartReceiving() override;
66 bool StopReceiving() override;
67
69 std::optional<uint8_t> GetFrameId() override;
70 void RegisterCallback(webrtc::EncodedImageCallback* callback) override;
71 std::string Endpoint() const override;
72 void OnEncoderReleased(webrtc::EncodedImageCallback* callback) override;
73 rtc::scoped_refptr<media::interface::InternalCapturerVideoSource> GetSource() override;
74 // Impl network::interface::UdpServer::PacketHandler
75 void OnPacketReceived(const uint8_t* data, size_t size) override;
76 // Impl webrtc::RtpVideoStreamReceiver2::OnCompleteFrameCallback
77 void OnCompleteFrame(std::unique_ptr<webrtc::EncodedFrame> frame) override;
79private:
81 std::unique_ptr<webrtc::RtpVideoStreamReceiver2> CreateReceiver(
82 const webrtc::RtpPacketReceived& packet);
83 void DummyFrameLoop(uint16_t frame_id);
84 uint64_t GenerateSsrc() const;
85 webrtc::VideoReceiveStreamInterface::Config CreateFakeConfig() const;
86
87 std::shared_ptr<codec::VideoCodec> codec_;
88 std::unique_ptr<rtc::Thread> depacketize_th_ = nullptr;
89 FakeTransport transport_;
91 rtc::scoped_refptr<I420CapturerVideoSource::I420InternalCapturerVideoSource> source_;
92 std::unique_ptr<network::interface::UdpServer> udp_server_;
93 std::mutex callbacks_mtx_;
94 std::unordered_set<webrtc::EncodedImageCallback*> callbacks_;
95 std::unique_ptr<webrtc::FieldTrials> trials_ = nullptr;
96 webrtc::VideoReceiveStreamInterface::Config config_;
97 std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter> encoded_image_queue_ = nullptr;
98 std::unique_ptr<webrtc::RtpVideoStreamReceiver2> receiver_ = nullptr;
99 std::atomic<bool> frame_loop_stopped_ = true;
100 global::Worker dummy_frame_worker_;
101 std::optional<uint16_t> frame_id_;
102 std::atomic<bool> is_receiving = false;
103 std::weak_ptr<interface::RtpCapturerVideoSourceRepository> repo_;
104
105public:
107 friend class RtpCapturerVideoSourceTest;
109};
110
111} // namespace rtp
112} // namespace media
113} // namespace skyway
114
115#endif /* SKYWAY_MEDIA_RTP_RTP_CAPTURER_VIDEO_SOURCE_HPP_ */
Definition rtp_capturer_video_source.hpp:40
bool StopReceiving() override
UDPサーバを停止し、RTPパケットの受信を停止します。
bool StartReceiving() override
UDPサーバを起動し、RTPパケットの受信を開始します。
static std::shared_ptr< RtpCapturerVideoSource > Create(const interface::RtpCapturerVideoSourceOptions &options)
RTPキャプチャビデオソースのインスタンスを作成します。
RTPキャプチャビデオソース
Definition rtp_capturer_video_source.hpp:50
virtual ~RtpCapturerVideoSource()=default
デストラクタ
RTPキャプチャビデオソースのオプション
Definition rtp_capturer_video_source.hpp:23