15#include <nlohmann/json.hpp>
16#include <opencv2/opencv.hpp>
18#include <shared_mutex>
22#include <libavcodec/avcodec.h>
23#include <libavformat/avformat.h>
24#include <libavutil/avutil.h>
25#include <libavutil/error.h>
26#include <libavutil/frame.h>
27#include <libavutil/imgutils.h>
28#include <libavutil/mem.h>
29#include <libavutil/opt.h>
30#include <libswscale/swscale.h>
49 WebRTC(
const std::string& szSignallingServerURL,
const std::string& szStreamerID);
71 std::string m_szSignallingServerURL;
72 std::string m_szStreamerID;
75 std::shared_ptr<rtc::WebSocket> m_pWebSocket;
76 std::shared_ptr<rtc::PeerConnection> m_pPeerConnection;
77 std::shared_ptr<rtc::DataChannel> m_pDataChannel;
78 std::shared_ptr<rtc::Track> m_pVideoTrack1;
79 std::shared_ptr<rtc::H264RtpDepacketizer> m_pTrack1H264DepacketizationHandler;
80 std::shared_ptr<rtc::RtcpReceivingSession> m_pTrack1RtcpReceivingSession;
81 std::chrono::system_clock::time_point m_tmLastKeyFrameRequestTime;
84 AVCodecContext* m_pAVCodecContext;
87 SwsContext* m_pSWSContext;
88 AVPixelFormat m_eOutputPixelFormat;
89 std::shared_mutex m_muDecoderMutex;
95 std::function<void(
cv::Mat&)> m_fnOnFrameReceivedCallback;
This class is used to establish a connection with the RoveSoSimulator and retrieve video streams from...
Definition WebRTC.h:44
bool RequestKeyFrame()
Requests a key frame from the given video track. This is useful for when the video track is out of sy...
Definition WebRTC.cpp:772
~WebRTC()
Destroy the Web RTC::WebRTC object.
Definition WebRTC.cpp:61
bool InitializeH264Decoder()
Initialize the H264 decoder. Creates the AVCodecContext, AVFrame, and AVPacket.
Definition WebRTC.cpp:563
bool ConnectToSignallingServer(const std::string &szSignallingServerURL)
Connected to the Unreal Engine 5 hosted Signalling Server for WebRTC negotiation.
Definition WebRTC.cpp:167
void SetOnFrameReceivedCallback(std::function< void(cv::Mat &)> fnOnFrameReceivedCallback, const AVPixelFormat eOutputPixelFormat=AV_PIX_FMT_BGR24)
Set the callback function for when a new frame is received.
Definition WebRTC.cpp:127
bool SendCommandToStreamer(const std::string &szCommand)
This method sends a command to the streamer via the data channel. The command is a JSON string that i...
Definition WebRTC.cpp:805
bool DecodeH264BytesToCVMat(const std::vector< uint8_t > &vH264EncodedBytes, cv::Mat &cvDecodedFrame, const AVPixelFormat eOutputPixelFormat)
Decodes H264 encoded bytes to a cv::Mat using FFmpeg.
Definition WebRTC.cpp:625
bool GetIsConnected() const
Get the connection status of the WebRTC object.
Definition WebRTC.cpp:144