Files
UnrealEngineUWP/Engine/Source/Programs/PixelStreaming/WebRTCProxy/src/NetworkVideoCapturer.cpp
JeanMichel Dignard fb979d921b Copying //UE4/Dev-Enterprise @ cl 4784880 to Dev-Main (//UE4/Dev-Main)
#rb none
#lockdown Nick.Penwarden

[CL 4784913 by JeanMichel Dignard in Main branch]
2019-01-23 14:28:06 -05:00

36 lines
1.2 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "NetworkVideoCapturer.h"
#include "Logging.h"
#include "UE4Connection.h"
FNetworkVideoCapturer::FNetworkVideoCapturer()
{
set_enable_video_adapter(false);
std::vector<cricket::VideoFormat> Formats;
Formats.push_back(cricket::VideoFormat(1920, 1080, cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_H264));
SetSupportedFormats(Formats);
}
void FNetworkVideoCapturer::ProcessPacket(PixelStreamingProtocol::EToProxyMsg PkType, const void* Data, uint32_t Size)
{
rtc::scoped_refptr<FH264FrameBuffer> buffer = new rtc::RefCountedObject<FH264FrameBuffer>(Width, Height);
webrtc::VideoFrame Frame{buffer, webrtc::VideoRotation::kVideoRotation_0, 0};
// #Andriy: WebRTC doesn't like frames with the same timestamp and will drop one of them
// we don't like our frames to be dropped so let's cheat with setting a unique value but close to be true
int64_t NtpTimeMs = rtc::TimeMillis();
if (NtpTimeMs <= LastNtpTimeMs)
NtpTimeMs = LastNtpTimeMs + 1;
LastNtpTimeMs = NtpTimeMs;
Frame.set_ntp_time_ms(NtpTimeMs);
auto PkData = reinterpret_cast<const uint8_t*>(Data);
buffer->GetBuffer().assign(PkData, PkData + Size);
OnFrame(Frame, Width, Height);
++FrameNo;
}