First drop of the WebRTC wrappers (#22)

Co-authored-by: Augusto Cesar Righetto <augustorighetto@outlook.com>
This commit is contained in:
Augusto Righetto 2020-04-30 14:05:12 -07:00 коммит произвёл GitHub
Родитель 106fc90bff
Коммит 2a8669760a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
80 изменённых файлов: 4897 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
Language: Cpp
BasedOnStyle: Microsoft
IndentWidth: 2
AlwaysBreakAfterReturnType: AllDefinitions

Просмотреть файл

@ -0,0 +1,422 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
namespace Microsoft.WinRTC.WebRtcWrapper.cricket
{
runtimeclass AudioOptions
{
AudioOptions();
String ToString();
};
} // namespace Microsoft.WinRTC.WebRtcWrapper.cricket
namespace Microsoft.WinRTC.WebRtcWrapper.rtc
{
static runtimeclass RTC
{
static void InitializeSSL();
static void CleanupSSL();
};
runtimeclass VideoSinkWants
{
VideoSinkWants();
Boolean BlackFrames;
Int32 MaxFramerateFps;
Int32 MaxPixelCount;
Boolean RotationApplied;
Int32 TargetPixelCount;
};
runtimeclass Thread
{
static Thread Create();
static Thread CreateWithSocketServer();
String Name;
Boolean Start();
};
} // namespace Microsoft.WinRTC.WebRtcWrapper.rtc
namespace Microsoft.WinRTC.WebRtcWrapper.webrtc
{
enum PeerConnectionSignalingState
{
Stable,
HaveLocalOffer,
HaveLocalPrAnswer,
HaveRemoteOffer,
HaveRemotePrAnswer,
Closed,
};
enum SdpType
{
Offer,
PrAnswer,
Answer,
Rollback,
};
[default_interface]
runtimeclass AudioDecoderFactory
{
};
[default_interface]
runtimeclass AudioEncoderFactory
{
};
runtimeclass AudioSource
{
Single Volume;
Microsoft.WinRTC.WebRtcWrapper.cricket.AudioOptions Options{ get; };
void AddSink(AudioTrackSink sink);
void RemoveSink(AudioTrackSink sink);
event Microsoft.WinRTC.WebRtcWrapper.webrtc.AudioSourceOnSetVolumeDelegate OnSetVolume;
};
[default_interface]
runtimeclass AudioTrack : MediaStreamTrack
{
};
runtimeclass AudioTrackSink
{
event Microsoft.WinRTC.WebRtcWrapper.webrtc.AudioTrackSinkOnData OnData;
};
runtimeclass CreateSessionDescriptionObserver
{
CreateSessionDescriptionObserver();
event Microsoft.WinRTC.WebRtcWrapper.webrtc.CreateSessionDescriptionObserverOnSuccessDelegate OnSuccess;
event Microsoft.WinRTC.WebRtcWrapper.webrtc.CreateSessionDescriptionObserverOnFailureDelegate OnFailure;
};
runtimeclass IceCandidate
{
String SdpMid { get; };
Int32 SdpMlineIndex{ get; };
String ServerUrl{ get; };
String ToString{ get; };
};
unsealed runtimeclass MediaStreamTrack
{
static String AudioKind{ get; };
static String VideoKind{ get; };
String Kind { get; };
String Id{ get; };
Boolean Enabled;
// FIXME(aurighet): AddOrUpdateSink belongs to VideoTrack
void AddOrUpdateSink(VideoSink_VideoFrame sink, Microsoft.WinRTC.WebRtcWrapper.rtc.VideoSinkWants wants);
event Microsoft.WinRTC.WebRtcWrapper.webrtc.NotifierOnChangedDelegate OnChanged;
};
[default_interface]
runtimeclass PeerConnectionDependencies
{
PeerConnectionDependencies(PeerConnectionObserver observer);
};
runtimeclass PeerConnectionFactory
{
PeerConnectionFactory(Microsoft.WinRTC.WebRtcWrapper.rtc.Thread network_thread, Microsoft.WinRTC.WebRtcWrapper.rtc.Thread worker_thread, Microsoft.WinRTC.WebRtcWrapper.rtc.Thread signaling_thread, AudioEncoderFactory audio_encoder_factory, AudioDecoderFactory audio_decoder_factory, VideoEncoderFactory video_encoder_factory, VideoDecoderFactory video_decoder_factory);
AudioSource CreateAudioSource(Microsoft.WinRTC.WebRtcWrapper.cricket.AudioOptions options);
AudioTrack CreateAudioTrack(String label, AudioSource audio_source);
Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection.PeerConnection CreatePeerConnection(Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection.RTCConfiguration configuration, PeerConnectionDependencies dependencies);
VideoTrack CreateVideoTrack(String label, VideoTrackSource video_source);
};
runtimeclass PeerConnectionObserver
{
PeerConnectionObserver();
event Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionObserverOnIceCandidateDelegate OnIceCandidate;
event Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionObserverOnIceGatheringChangeDelegate OnIceGatheringChange;
event Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionObserverOnRenegotiationNeededDelegate OnRenegotiationNeeded;
event Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionObserverOnSignalingChangeDelegate OnSignalingChange;
event Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionObserverOnTrackDelegate OnTrack;
};
runtimeclass RtpReceiver
{
MediaStreamTrack Track { get; };
};
[default_interface]
runtimeclass RtpSender
{
};
runtimeclass RtpTransceiver
{
RtpReceiver Receiver{ get; };
};
runtimeclass SessionDescription
{
static String Offer{ get; };
static String PrAnswer{ get; };
static String Answer{ get; };
static String Rollback{ get; };
SdpType Type{ get; };
String ToString();
};
runtimeclass SetSessionDescriptionObserver
{
SetSessionDescriptionObserver();
event Microsoft.WinRTC.WebRtcWrapper.webrtc.SetSessionDescriptionObserverOnSuccessDelegate OnSuccess;
event Microsoft.WinRTC.WebRtcWrapper.webrtc.SetSessionDescriptionObserverOnFailureDelegate OnFailure;
};
[default_interface]
runtimeclass VideoDecoderFactory
{
};
[default_interface]
runtimeclass VideoEncoderFactory
{
};
[default_interface]
runtimeclass VideoSink_VideoFrame {
VideoSink_VideoFrame(Windows.UI.Composition.VisualCollection visual_collection);
};
[default_interface]
runtimeclass VideoTrack : MediaStreamTrack
{
};
// VideoTrackSource is not a wrapper of a WebRTC object.
// It is a simplification encompassing the concept of a
// video capture as a video track source.
// FIXME(aurighet): VideoTrackSource has to be refactored.
[default_interface]
runtimeclass VideoTrackSource
{
VideoTrackSource();
};
static runtimeclass WebRTC
{
static AudioDecoderFactory CreateBuiltinAudioDecoderFactory();
static AudioEncoderFactory CreateBuiltinAudioEncoderFactory();
static VideoDecoderFactory CreateBuiltinVideoDecoderFactory();
static VideoEncoderFactory CreateBuiltinVideoEncoderFactory();
// FIXME(aurighet): SessionDescription should play under C++ move semantics rules.
static Microsoft.WinRTC.WebRtcWrapper.webrtc.SessionDescription CreateSessionDescription(SdpType type, String sdp);
static Microsoft.WinRTC.WebRtcWrapper.webrtc.IceCandidate CreateIceCandidate(String sdp_mid, Int32 sdp_mline_index, String sdp);
static SdpType SdpTypeFromString(String type_str);
static String SdpTypeToString(SdpType sdp_type);
};
delegate void AudioSourceOnSetVolumeDelegate(Double volume);
delegate void AudioTrackSinkOnData(Windows.Storage.Streams.IBuffer audio_data, Int32 bits_per_sample, Int32 sample_rate, UInt32 number_of_channels, UInt32 number_of_frames);
delegate void CreateSessionDescriptionObserverOnFailureDelegate(String error);
delegate void CreateSessionDescriptionObserverOnSuccessDelegate(Microsoft.WinRTC.WebRtcWrapper.webrtc.SessionDescription value);
delegate void NotifierOnChangedDelegate();
delegate void PeerConnectionObserverOnIceCandidateDelegate(Microsoft.WinRTC.WebRtcWrapper.webrtc.IceCandidate value);
delegate void PeerConnectionObserverOnIceGatheringChangeDelegate(Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection.IceGatheringState value);
delegate void PeerConnectionObserverOnRenegotiationNeededDelegate();
delegate void PeerConnectionObserverOnSignalingChangeDelegate(Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionSignalingState value);
delegate void PeerConnectionObserverOnTrackDelegate(Microsoft.WinRTC.WebRtcWrapper.webrtc.RtpTransceiver value);
delegate void SetSessionDescriptionObserverOnSuccessDelegate();
delegate void SetSessionDescriptionObserverOnFailureDelegate(String error_message);
} // Microsoft.WinRTC.WebRtcWrapper.webrtc
namespace Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection
{
enum BundlePolicy
{
Balanced,
MaxBundle,
MaxCompat,
};
enum IceGatheringState
{
New,
Gathering,
Complete,
};
enum IceTransportType
{
None,
Relay,
NoHost,
All,
};
enum RtcpMuxPolicy
{
Negotiate,
Require,
};
enum SdpSemantics
{
PlanB,
UnifiedPlan,
};
enum TlsCertPolicy
{
Secure,
InsecureNoCheck,
};
runtimeclass IceServer
{
IceServer();
IVector<String> Urls;
String Username;
String Password;
TlsCertPolicy TlsCertPolicy;
String Hostname;
IVector<String> TlsAlpnProtocols;
IVector<String> TlsEllipticCurves;
};
runtimeclass PeerConnection
{
Boolean AddIceCandidate(Microsoft.WinRTC.WebRtcWrapper.webrtc.IceCandidate value);
void SetLocalDescription(Microsoft.WinRTC.WebRtcWrapper.webrtc.SetSessionDescriptionObserver observer, Microsoft.WinRTC.WebRtcWrapper.webrtc.SessionDescription desc);
void SetRemoteDescription(Microsoft.WinRTC.WebRtcWrapper.webrtc.SetSessionDescriptionObserver observer, Microsoft.WinRTC.WebRtcWrapper.webrtc.SessionDescription desc);
Microsoft.WinRTC.WebRtcWrapper.webrtc.RtpSender AddAudioTrack(Microsoft.WinRTC.WebRtcWrapper.webrtc.AudioTrack /*FIXME*/ track, IVector<String> stream_ids);
Microsoft.WinRTC.WebRtcWrapper.webrtc.RtpSender AddVideoTrack(Microsoft.WinRTC.WebRtcWrapper.webrtc.VideoTrack /*FIXME*/ track, IVector<String> stream_ids);
void CreateOffer(Microsoft.WinRTC.WebRtcWrapper.webrtc.CreateSessionDescriptionObserver observer, Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection.RTCOfferAnswerOptions options);
void CreateAnswer(Microsoft.WinRTC.WebRtcWrapper.webrtc.CreateSessionDescriptionObserver observer, Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection.RTCOfferAnswerOptions options);
};
runtimeclass RTCConfiguration
{
RTCConfiguration();
IVector<IceServer> IceServers;
IceTransportType IceTransportType;
BundlePolicy BundlePolicy;
RtcpMuxPolicy RtcpMuxPolicy;
Int32 IceCandidatePoolSize;
SdpSemantics SdpSemantics;
};
runtimeclass RTCOfferAnswerOptions
{
RTCOfferAnswerOptions();
Boolean VoiceActivityDetection;
Boolean IceRestart;
Boolean UseRtpMux;
Boolean RawPacketizationForVideo;
Int32 NumSimulcastLayers;
Boolean UseObsoleteSctpSdp;
};
} // Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection
namespace Microsoft.WinRTC.WebRtcWrapper.webrtc
{
// The following APIs are in the works.
enum VideoType
{
Unknown,
I420,
IYUV,
RGB24,
ABGR,
ARGB,
ARGB4444,
RGB565,
ARGB1555,
YUY2,
YV12,
UYVY,
MJPEG,
NV21,
NV12,
BGRA,
};
// The following APIs are in the works.
enum VideoRotation
{
VideoRotation_0 = 0,
VideoRotation_90 = 90,
VideoRotation_180 = 180,
VideoRotation_270 = 270,
};
// The following APIs are in the works.
struct DeviceIdentification
{
String DeviceName;
String DeviceUniqueId;
String ProductUniqueId;
};
// The following APIs are in the works.
runtimeclass VideoCaptureCapability
{
VideoCaptureCapability();
Int32 Width;
Int32 Height;
Int32 MaxFPS;
VideoType VideoType;
Boolean Interlaced;
};
// The following APIs are in the works.
runtimeclass VideoCaptureModule_DeviceInfo
{
IVector<DeviceIdentification> GetDeviceName{get;};
IVector<VideoCaptureCapability> GetCapability(String device_unique_id);
VideoCaptureCapability GetBestMatchedCapability(String device_unique_id, VideoCaptureCapability requested);
VideoRotation GetOrientation(String device_unique_id);
};
// The following APIs are in the works.
runtimeclass VideoCaptureModule
{
void StartCapture(VideoCaptureCapability capability);
void StopCapture();
};
// The following APIs are in the works.
static runtimeclass VideoCaptureFactory
{
static VideoCaptureModule Create(String device_unique_id);
static VideoCaptureModule_DeviceInfo CreateDeviceInfo();
};
}
namespace Microsoft.WinRTC.WebRtcWrapper.webrtc.VideoFrame
{
// The following APIs are in the works.
runtimeclass Builder
{
Builder();
VideoFrame Build();
Builder SetTimestampMs(Int64 timestamp_ms);
Builder SetTimestampUs(Int64 timestamp_us);
Builder SetTimestampRtp(UInt32 timestamp_rtp);
Builder SetNtpTimeMs(Int64 ntp_time_ms);
Builder SetId(UInt16 id);
};
// The following APIs are in the works.
unsealed runtimeclass VideoFrame
{
Int32 Width{ get; };
Int32 Height{ get; };
UInt32 Size{ get; };
};
} // namespace Microsoft.WinRTC.WebRtcWrapper.webrtc.VideoFrame

Просмотреть файл

@ -0,0 +1,3 @@
EXPORTS
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE

Просмотреть файл

@ -0,0 +1,233 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.WinRTC.libwebrtc.80.0.11-alpha\build\native\Microsoft.WinRTC.libwebrtc.props" Condition="Exists('..\packages\Microsoft.WinRTC.libwebrtc.80.0.11-alpha\build\native\Microsoft.WinRTC.libwebrtc.props')" />
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
<MinimalCoreWin>true</MinimalCoreWin>
<ProjectGuid>{7ee6e284-7878-4c68-bfa0-2d4728572906}</ProjectGuid>
<ProjectName>WebRtcWrapper</ProjectName>
<RootNamespace>Microsoft.WinRTC.WebRtcWrapper</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
<CppWinRTProjectLanguage>C++/WinRT</CppWinRTProjectLanguage>
<CppWinRTModernIDL>true</CppWinRTModernIDL>
<CppWinRTUsePrefixes>true</CppWinRTUsePrefixes>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<!-- Import Project="PropertySheet.props" / -->
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level4</WarningLevel>
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
<!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
<AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<PreprocessorDefinitions>_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<ModuleDefinitionFile>WebRtcWrapper.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">ole32.lib;oleaut32.lib;Kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">ole32.lib;oleaut32.lib;Kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ole32.lib;oleaut32.lib;Kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">ole32.lib;oleaut32.lib;Kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">ole32.lib;oleaut32.lib;Kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ole32.lib;oleaut32.lib;Kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="webrtc.AudioDecoderFactory.h" />
<ClInclude Include="webrtc.AudioEncoderFactory.h" />
<ClInclude Include="cricket.AudioOptions.h" />
<ClInclude Include="webrtc.IceCandidate.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="rtc.RTC.h" />
<ClInclude Include="rtc.VideoSinkWants.h" />
<ClInclude Include="webrtc.AudioTrackSink.h" />
<ClInclude Include="webrtc.RtpTransceiver.h" />
<ClInclude Include="rtc.Thread.h" />
<ClInclude Include="webrtc.VideoDecoderFactory.h" />
<ClInclude Include="webrtc.VideoEncoderFactory.h" />
<ClInclude Include="webrtc.AudioSource.h" />
<ClInclude Include="webrtc.AudioTrack.h" />
<ClInclude Include="webrtc.CreateSessionDescriptionObserver.h" />
<ClInclude Include="webrtc.VideoCaptureCapability.h" />
<ClInclude Include="webrtc.VideoCaptureFactory.h" />
<ClInclude Include="webrtc.VideoCaptureModule.h" />
<ClInclude Include="webrtc.VideoCaptureModule_DeviceInfo.h" />
<ClInclude Include="webrtc.WebRTC.h" />
<ClInclude Include="webrtc.MediaStreamTrack.h" />
<ClInclude Include="webrtc.PeerConnection.IceServer.h" />
<ClInclude Include="webrtc.PeerConnection.PeerConnection.h" />
<ClInclude Include="webrtc.PeerConnection.RTCConfiguration.h" />
<ClInclude Include="webrtc.PeerConnection.RTCOfferAnswerOptions.h" />
<ClInclude Include="webrtc.PeerConnectionDependencies.h" />
<ClInclude Include="webrtc.PeerConnectionFactory.h" />
<ClInclude Include="webrtc.PeerConnectionObserver.h" />
<ClInclude Include="webrtc.RtpReceiver.h" />
<ClInclude Include="webrtc.RtpSender.h" />
<ClInclude Include="webrtc.SessionDescription.h" />
<ClInclude Include="webrtc.SetSessionDescriptionObserver.h" />
<ClInclude Include="webrtc.VideoFrame.Builder.h" />
<ClInclude Include="webrtc.VideoFrame.VideoFrame.h" />
<ClInclude Include="webrtc.VideoTrack.h" />
<ClInclude Include="webrtc.VideoTrackSource.h" />
<ClInclude Include="webrtc.VideoSink_VideoFrame.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="webrtc.AudioDecoderFactory.cpp" />
<ClCompile Include="webrtc.AudioEncoderFactory.cpp" />
<ClCompile Include="cricket.AudioOptions.cpp" />
<ClCompile Include="webrtc.IceCandidate.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="rtc.RTC.cpp" />
<ClCompile Include="rtc.VideoSinkWants.cpp" />
<ClCompile Include="webrtc.AudioTrackSink.cpp" />
<ClCompile Include="webrtc.RtpTransceiver.cpp" />
<ClCompile Include="rtc.Thread.cpp" />
<ClCompile Include="webrtc.VideoDecoderFactory.cpp" />
<ClCompile Include="webrtc.VideoEncoderFactory.cpp" />
<ClCompile Include="webrtc.AudioSource.cpp" />
<ClCompile Include="webrtc.AudioTrack.cpp" />
<ClCompile Include="webrtc.VideoCaptureCapability.cpp" />
<ClCompile Include="webrtc.VideoCaptureFactory.cpp" />
<ClCompile Include="webrtc.VideoCaptureModule.cpp" />
<ClCompile Include="webrtc.VideoCaptureModule_DeviceInfo.cpp" />
<ClCompile Include="webrtc.WebRTC.cpp" />
<ClCompile Include="webrtc.CreateSessionDescriptionObserver.cpp" />
<ClCompile Include="webrtc.MediaStreamTrack.cpp" />
<ClCompile Include="webrtc.PeerConnection.IceServer.cpp" />
<ClCompile Include="webrtc.PeerConnection.PeerConnection.cpp" />
<ClCompile Include="webrtc.PeerConnection.RTCConfiguration.cpp" />
<ClCompile Include="webrtc.PeerConnection.RTCOfferAnswerOptions.cpp" />
<ClCompile Include="webrtc.PeerConnectionDependencies.cpp" />
<ClCompile Include="webrtc.PeerConnectionFactory.cpp" />
<ClCompile Include="webrtc.PeerConnectionObserver.cpp" />
<ClCompile Include="webrtc.RtpReceiver.cpp" />
<ClCompile Include="webrtc.RtpSender.cpp" />
<ClCompile Include="webrtc.SessionDescription.cpp" />
<ClCompile Include="webrtc.SetSessionDescriptionObserver.cpp" />
<ClCompile Include="webrtc.VideoFrame.Builder.cpp" />
<ClCompile Include="webrtc.VideoFrame.VideoFrame.cpp" />
<ClCompile Include="webrtc.VideoTrack.cpp" />
<ClCompile Include="webrtc.VideoTrackSource.cpp" />
<ClCompile Include="webrtc.VideoSink_VideoFrame.cpp" />
</ItemGroup>
<ItemGroup>
<None Include=".clang-format" />
<None Include="packages.config" />
<None Include="WebRtcWrapper.def" />
</ItemGroup>
<ItemGroup>
<Midl Include="Microsoft.WinRTC.WebRtcWrapper.idl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\packages\Win2D.uwp.1.25.0\build\native\Win2D.uwp.targets" Condition="Exists('..\packages\Win2D.uwp.1.25.0\build\native\Win2D.uwp.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.200316.3\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\packages\Win2D.uwp.1.25.0\build\native\Win2D.uwp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Win2D.uwp.1.25.0\build\native\Win2D.uwp.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.WinRTC.libwebrtc.80.0.11-alpha\build\native\Microsoft.WinRTC.libwebrtc.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WinRTC.libwebrtc.80.0.11-alpha\build\native\Microsoft.WinRTC.libwebrtc.props'))" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,251 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Resources">
<UniqueIdentifier>accd3aa8-1ba0-4223-9bbe-0c431709210b</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Generated Files">
<UniqueIdentifier>{926ab91d-31b4-48c3-b9a4-e681349f27f0}</UniqueIdentifier>
</Filter>
<Filter Include="InTheWorks">
<UniqueIdentifier>{0bffb185-24b0-4cd0-b8f8-ef7f36840110}</UniqueIdentifier>
</Filter>
<Filter Include="Wrappers">
<UniqueIdentifier>{b6da9a87-6e65-49c7-ba05-796166a0502a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="rtc.RTC.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="rtc.Thread.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoCaptureCapability.cpp">
<Filter>InTheWorks</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoCaptureFactory.cpp">
<Filter>InTheWorks</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoCaptureModule.cpp">
<Filter>InTheWorks</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoCaptureModule_DeviceInfo.cpp">
<Filter>InTheWorks</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoFrame.Builder.cpp">
<Filter>InTheWorks</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoFrame.VideoFrame.cpp">
<Filter>InTheWorks</Filter>
</ClCompile>
<ClCompile Include="webrtc.AudioDecoderFactory.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.AudioEncoderFactory.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoDecoderFactory.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoEncoderFactory.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnectionFactory.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnection.RTCConfiguration.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnection.IceServer.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnectionObserver.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.IceCandidate.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.RtpTransceiver.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.RtpReceiver.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.MediaStreamTrack.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoSink_VideoFrame.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnectionDependencies.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.SetSessionDescriptionObserver.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="cricket.AudioOptions.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="rtc.VideoSinkWants.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoTrackSource.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.CreateSessionDescriptionObserver.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnection.RTCOfferAnswerOptions.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.SessionDescription.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.AudioSource.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.AudioTrackSink.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.AudioTrack.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.RtpSender.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.PeerConnection.PeerConnection.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.WebRTC.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
<ClCompile Include="webrtc.VideoTrack.cpp">
<Filter>Wrappers</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="rtc.RTC.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="rtc.Thread.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoCaptureCapability.h">
<Filter>InTheWorks</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoCaptureFactory.h">
<Filter>InTheWorks</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoCaptureModule.h">
<Filter>InTheWorks</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoCaptureModule_DeviceInfo.h">
<Filter>InTheWorks</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoFrame.Builder.h">
<Filter>InTheWorks</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoFrame.VideoFrame.h">
<Filter>InTheWorks</Filter>
</ClInclude>
<ClInclude Include="webrtc.AudioDecoderFactory.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.AudioEncoderFactory.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoDecoderFactory.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoEncoderFactory.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnectionFactory.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnection.RTCConfiguration.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnection.IceServer.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnectionObserver.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.IceCandidate.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.RtpTransceiver.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.RtpReceiver.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.MediaStreamTrack.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoSink_VideoFrame.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnectionDependencies.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.SetSessionDescriptionObserver.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="cricket.AudioOptions.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="rtc.VideoSinkWants.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoTrackSource.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.CreateSessionDescriptionObserver.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnection.RTCOfferAnswerOptions.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.SessionDescription.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.AudioSource.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.AudioTrackSink.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.AudioTrack.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.RtpSender.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.PeerConnection.PeerConnection.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.WebRTC.h">
<Filter>Wrappers</Filter>
</ClInclude>
<ClInclude Include="webrtc.VideoTrack.h">
<Filter>Wrappers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="WebRtcWrapper.def" />
<None Include="packages.config" />
<None Include=".clang-format" />
</ItemGroup>
<ItemGroup>
<Midl Include="Microsoft.WinRTC.WebRtcWrapper.idl">
<Filter>Wrappers</Filter>
</Midl>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "cricket.AudioOptions.h"
#include "cricket.AudioOptions.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::cricket::implementation
{
AudioOptions::AudioOptions(::cricket::AudioOptions cricket_audio_options)
: cricket_audio_options_(cricket_audio_options)
{
}
hstring
AudioOptions::ToString()
{
return to_hstring(cricket_audio_options_.ToString());
}
const ::cricket::AudioOptions &
AudioOptions::get_cricket_audio_options() const
{
return cricket_audio_options_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::cricket::implementation

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "cricket.AudioOptions.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::cricket::implementation
{
struct AudioOptions : AudioOptionsT<AudioOptions>
{
AudioOptions() = default;
explicit AudioOptions(::cricket::AudioOptions cricket_audio_options);
hstring ToString();
const ::cricket::AudioOptions &get_cricket_audio_options() const;
private:
::cricket::AudioOptions cricket_audio_options_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::cricket::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::cricket::factory_implementation
{
struct AudioOptions : AudioOptionsT<AudioOptions, implementation::AudioOptions>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::cricket::factory_implementation

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.200316.3" targetFramework="native" />
<package id="Microsoft.WinRTC.libwebrtc" version="80.0.11-alpha" targetFramework="native" />
<package id="Win2D.uwp" version="1.25.0" targetFramework="native" />
</packages>

2
WebRtcWrapper/pch.cpp Normal file
Просмотреть файл

@ -0,0 +1,2 @@
#include "pch.h"

74
WebRtcWrapper/pch.h Normal file
Просмотреть файл

@ -0,0 +1,74 @@
#pragma once
#include <unknwn.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.UI.Composition.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.Xaml.h>
#include <winrt/Windows.UI.Xaml.Hosting.h>
#include <winrt/Windows.UI.Xaml.Markup.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
#include <winrt/Microsoft.Graphics.Canvas.h>
#include <winrt/Microsoft.Graphics.Canvas.UI.Composition.h>
#include <winrt/Microsoft.Graphics.Canvas.UI.Xaml.h>
#pragma warning(push)
#pragma warning(disable : 4100 4127)
#include "rtc_base/ref_count.h"
#include "rtc_base/ref_counted_object.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/thread.h"
#include "api/audio_options.h"
#include "api/jsep.h"
#include "api/peer_connection_interface.h"
#include "api/scoped_refptr.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/audio_codecs/audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
#include "api/peer_connection_interface.h"
#include "api/video_codecs/builtin_video_decoder_factory.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "api/video_codecs/builtin_video_encoder_factory.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "api/video/video_source_interface.h"
#include "api/video/video_frame.h"
#include "api/rtp_transceiver_interface.h"
#include "modules/video_capture/video_capture.h"
#include "modules/video_capture/video_capture_factory.h"
#include "pc/video_track_source.h"
#include "media/base/video_adapter.h"
#include "media/base/video_broadcaster.h"
#include "rtc_base/critical_section.h"
#include "api/scoped_refptr.h"
#include "api/video/i420_buffer.h"
#include "api/video/video_frame_buffer.h"
#include "api/video/video_rotation.h"
#include "libyuv/libyuv.h"
// mkdir include
// copy common_types.h include
// robocopy /mir api include\api *.h
// robocopy /mir rtc_base include\rtc_base *.h
// robocopy /mir pc include\pc *.h
// robocopy /mir media include\media *.h
// robocopy /mir system_wrappers\include include\system_wrappers\include *.h
// robocopy /mir call include\call *.h
// robocopy /mir modules include\modules *.h
// robocopy /mir common_video include\common_video *.h
// robocopy /mir p2p include\p2p *.h
// robocopy /mir logging include\logging *.h
// xcopy /S /Y third_party\abseil-cpp\absl\*.h include\absl\
// xcopy /S /Y third_party\libyuv\include\*.h include\libyuv\
// xcopy /s /y common_video\*.h \WinRTC_Build\WinRTC\packages\Microsoft.WinRTC.libwebrtc.80.0.7-alpha\build\native\include\common_video\
#pragma warning(pop)

25
WebRtcWrapper/rtc.RTC.cpp Normal file
Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "rtc.RTC.h"
#include "rtc.RTC.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
{
void
RTC::InitializeSSL()
{
::rtc::InitializeSSL();
}
void
RTC::CleanupSSL()
{
::rtc::CleanupSSL();
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation

23
WebRtcWrapper/rtc.RTC.h Normal file
Просмотреть файл

@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "rtc.RTC.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
{
struct RTC
{
RTC() = default;
static void InitializeSSL();
static void CleanupSSL();
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::factory_implementation
{
struct RTC : RTCT<RTC, implementation::RTC>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::factory_implementation

Просмотреть файл

@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "rtc.Thread.h"
#include "rtc.Thread.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
{
Thread::Thread(std::unique_ptr<::rtc::Thread> webrtc_thread) : webrtc_thread_(move(webrtc_thread))
{
}
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread
Thread::CreateWithSocketServer()
{
return make<Thread>(::rtc::Thread::CreateWithSocketServer());
}
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread
Thread::Create()
{
return make<Thread>(::rtc::Thread::Create());
}
bool
Thread::Start()
{
return webrtc_thread_->Start();
}
hstring
Thread::Name()
{
return to_hstring(webrtc_thread_->name());
}
void
Thread::Name(hstring const &value)
{
webrtc_thread_->SetName(to_string(value), nullptr);
}
::rtc::Thread *
Thread::get_webrtc_thread_no_ref() const noexcept
{
return webrtc_thread_.get();
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "rtc.Thread.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
{
struct Thread : ThreadT<Thread>
{
Thread(std::unique_ptr<::rtc::Thread> webrtc_thread);
static Microsoft::WinRTC::WebRtcWrapper::rtc::Thread CreateWithSocketServer();
static Microsoft::WinRTC::WebRtcWrapper::rtc::Thread Create();
bool Start();
hstring Name();
void Name(hstring const &value);
::rtc::Thread *get_webrtc_thread_no_ref() const noexcept;
private:
std::unique_ptr<::rtc::Thread> webrtc_thread_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::factory_implementation
{
struct Thread : ThreadT<Thread, implementation::Thread>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::factory_implementation

Просмотреть файл

@ -0,0 +1,72 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "rtc.VideoSinkWants.h"
#include "rtc.VideoSinkWants.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
{
bool
VideoSinkWants::RotationApplied()
{
return rotation_applied;
}
void
VideoSinkWants::RotationApplied(bool value)
{
rotation_applied = value;
}
bool
VideoSinkWants::BlackFrames()
{
return black_frames;
}
void
VideoSinkWants::BlackFrames(bool value)
{
black_frames = value;
}
int32_t
VideoSinkWants::MaxPixelCount()
{
return max_pixel_count;
}
void
VideoSinkWants::MaxPixelCount(int32_t value)
{
max_pixel_count = value;
}
int32_t
VideoSinkWants::TargetPixelCount()
{
return target_pixel_count.value_or(max_pixel_count);
}
void
VideoSinkWants::TargetPixelCount(int32_t value)
{
target_pixel_count = value;
}
int32_t
VideoSinkWants::MaxFramerateFps()
{
return max_framerate_fps;
}
void
VideoSinkWants::MaxFramerateFps(int32_t value)
{
max_framerate_fps = value;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "rtc.VideoSinkWants.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
{
struct VideoSinkWants : VideoSinkWantsT<VideoSinkWants>, ::rtc::VideoSinkWants
{
VideoSinkWants() = default;
bool RotationApplied();
void RotationApplied(bool value);
bool BlackFrames();
void BlackFrames(bool value);
int32_t MaxPixelCount();
void MaxPixelCount(int32_t value);
int32_t TargetPixelCount();
void TargetPixelCount(int32_t value);
int32_t MaxFramerateFps();
void MaxFramerateFps(int32_t value);
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::factory_implementation
{
struct VideoSinkWants : VideoSinkWantsT<VideoSinkWants, implementation::VideoSinkWants>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::rtc::factory_implementation

Просмотреть файл

@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.AudioDecoderFactory.h"
#include "webrtc.AudioDecoderFactory.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
AudioDecoderFactory::AudioDecoderFactory(::rtc::scoped_refptr<::webrtc::AudioDecoderFactory> audio_decoder_factory)
: webrtc_audio_decoder_factory_(audio_decoder_factory)
{
}
::webrtc::AudioDecoderFactory *
AudioDecoderFactory::get_webrtc_audio_decoder_factory_no_ref() const
{
return webrtc_audio_decoder_factory_.get();
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.AudioDecoderFactory.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct AudioDecoderFactory : AudioDecoderFactoryT<AudioDecoderFactory>
{
AudioDecoderFactory(::rtc::scoped_refptr<::webrtc::AudioDecoderFactory> audio_decoder_factory);
::webrtc::AudioDecoderFactory *get_webrtc_audio_decoder_factory_no_ref() const;
private:
::rtc::scoped_refptr<::webrtc::AudioDecoderFactory> webrtc_audio_decoder_factory_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.AudioEncoderFactory.h"
#include "webrtc.AudioEncoderFactory.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
AudioEncoderFactory::AudioEncoderFactory(
::rtc::scoped_refptr<::webrtc::AudioEncoderFactory> webrtc_audio_encoder_factory)
: webrtc_audio_encoder_factory_(webrtc_audio_encoder_factory)
{
}
::webrtc::AudioEncoderFactory *
AudioEncoderFactory::get_webrtc_audio_encoder_factory_no_ref() const
{
return webrtc_audio_encoder_factory_.get();
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.AudioEncoderFactory.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct AudioEncoderFactory : AudioEncoderFactoryT<AudioEncoderFactory>
{
AudioEncoderFactory(::rtc::scoped_refptr<::webrtc::AudioEncoderFactory> webrtc_audio_encoder_factory);
::webrtc::AudioEncoderFactory *get_webrtc_audio_encoder_factory_no_ref() const;
private:
::rtc::scoped_refptr<::webrtc::AudioEncoderFactory> webrtc_audio_encoder_factory_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,85 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.AudioSource.h"
#include "webrtc.AudioSource.g.cpp"
// clang-format on
#include "cricket.AudioOptions.h"
#include "webrtc.AudioTrackSink.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
AudioSource::AudioSource(::rtc::scoped_refptr<::webrtc::AudioSourceInterface> webrtc_audio_source)
: webrtc_audio_source_(webrtc_audio_source)
{
webrtc_audio_source_->RegisterAudioObserver(this);
}
AudioSource::~AudioSource()
{
webrtc_audio_source_->UnregisterAudioObserver(this);
}
void
AudioSource::OnSetVolume(double volume)
{
on_set_volume_event_(volume);
}
float
AudioSource::Volume()
{
// ::webrtc::AudioSourceInterface doesn't define a getter for Volume,
// but WinRT doesn't allow set only props.
throw hresult_not_implemented();
}
void
AudioSource::Volume(float value)
{
webrtc_audio_source_->SetVolume(value);
}
Microsoft::WinRTC::WebRtcWrapper::cricket::AudioOptions
AudioSource::Options()
{
return make<Microsoft::WinRTC::WebRtcWrapper::cricket::implementation::AudioOptions>(webrtc_audio_source_->options());
}
void
AudioSource::AddSink(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSink const &sink)
{
webrtc_audio_source_->AddSink(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::AudioTrackSink>(sink));
}
void
AudioSource::RemoveSink(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSink const &sink)
{
webrtc_audio_source_->RemoveSink(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::AudioTrackSink>(sink));
}
winrt::event_token
AudioSource::OnSetVolume(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSourceOnSetVolumeDelegate const &handler)
{
return on_set_volume_event_.add(handler);
}
void
AudioSource::OnSetVolume(winrt::event_token const &token) noexcept
{
on_set_volume_event_.remove(token);
}
::rtc::scoped_refptr<::webrtc::AudioSourceInterface>
AudioSource::get_webrtc_audio_source()
{
return webrtc_audio_source_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.AudioSource.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct AudioSource : AudioSourceT<AudioSource>, ::webrtc::AudioSourceInterface::AudioObserver
{
explicit AudioSource(::rtc::scoped_refptr<::webrtc::AudioSourceInterface> webrtc_audio_source);
~AudioSource();
float Volume();
void Volume(float value);
Microsoft::WinRTC::WebRtcWrapper::cricket::AudioOptions Options();
void AddSink(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSink const &sink);
void RemoveSink(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSink const &sink);
winrt::event_token OnSetVolume(
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSourceOnSetVolumeDelegate const &handler);
void OnSetVolume(winrt::event_token const &token) noexcept;
void OnSetVolume(double volume) override;
::rtc::scoped_refptr<::webrtc::AudioSourceInterface> get_webrtc_audio_source();
private:
::rtc::scoped_refptr<::webrtc::AudioSourceInterface> webrtc_audio_source_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSourceOnSetVolumeDelegate> on_set_volume_event_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.AudioTrack.h"
#include "webrtc.AudioTrack.g.cpp"
// clang-format on
#include "webrtc.MediaStreamTrack.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
AudioTrack::AudioTrack(::rtc::scoped_refptr<::webrtc::AudioTrackInterface> webrtc_audio_track)
: AudioTrackT<AudioTrack, Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::MediaStreamTrack>(
webrtc_audio_track),
webrtc_audio_track_(webrtc_audio_track)
{
}
::rtc::scoped_refptr<::webrtc::AudioTrackInterface>
AudioTrack::get_webrtc_audio_track()
{
return webrtc_audio_track_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.AudioTrack.g.h"
#include "webrtc.MediaStreamTrack.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct AudioTrack : AudioTrackT<AudioTrack, Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::MediaStreamTrack>
{
AudioTrack(::rtc::scoped_refptr<::webrtc::AudioTrackInterface> webrtc_audio_track);
::rtc::scoped_refptr<::webrtc::AudioTrackInterface> get_webrtc_audio_track();
private:
::rtc::scoped_refptr<::webrtc::AudioTrackInterface> webrtc_audio_track_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,95 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.AudioTrackSink.h"
#include "webrtc.AudioTrackSink.g.cpp"
// clang-format on
#include "winrt/Windows.Storage.Streams.h"
using namespace winrt;
using namespace Windows::Foundation;
using namespace Windows::Storage::Streams;
struct __declspec(uuid("5b0d3235-4dba-4d44-865e-8f1d0e4fd04d")) __declspec(novtable) IMemoryBufferByteAccess
: ::IUnknown
{
virtual HRESULT __stdcall GetBuffer(uint8_t **value, uint32_t *capacity) = 0;
};
struct __declspec(uuid("905a0fef-bc53-11df-8c49-001e4fc686da")) IBufferByteAccess : ::IUnknown
{
virtual HRESULT __stdcall Buffer(uint8_t **value) noexcept = 0;
};
struct BufferView : implements<BufferView, IBuffer, IBufferByteAccess, IClosable>
{
const uint8_t *data_;
size_t capacity_;
BufferView(const uint8_t *data, size_t capacity) : data_(data), capacity_(capacity)
{
}
~BufferView() noexcept
{
}
void
Close() noexcept
{
}
uint32_t
Capacity() const noexcept
{
return static_cast<uint32_t>(capacity_);
}
uint32_t
Length() const noexcept
{
return static_cast<uint32_t>(capacity_);
}
void
Length(uint32_t value)
{
UNREFERENCED_PARAMETER(value);
}
HRESULT __stdcall Buffer(uint8_t **value) noexcept final
{
*value = const_cast<uint8_t *>(data_);
return S_OK;
}
};
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
winrt::event_token
AudioTrackSink::OnData(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSinkOnData const &handler)
{
return on_audio_track_sink_on_data_event_.add(handler);
}
void
AudioTrackSink::OnData(winrt::event_token const &token) noexcept
{
on_audio_track_sink_on_data_event_.remove(token);
}
void
AudioTrackSink::OnData(const void *audio_data, int bits_per_sample, int sample_rate, size_t number_of_channels,
size_t number_of_frames)
{
// FIXME(auright): Check if this method works.
size_t capacity = (bits_per_sample >> 3) * sample_rate * number_of_channels * number_of_frames;
on_audio_track_sink_on_data_event_(make<BufferView>(static_cast<const uint8_t *>(audio_data), capacity),
bits_per_sample, sample_rate, static_cast<uint32_t>(number_of_channels),
static_cast<uint32_t>(number_of_frames));
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.AudioTrackSink.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct AudioTrackSink : AudioTrackSinkT<AudioTrackSink>, ::webrtc::AudioTrackSinkInterface
{
AudioTrackSink() = default;
winrt::event_token OnData(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSinkOnData const &handler);
void OnData(winrt::event_token const &token) noexcept;
void OnData(const void *audio_data, int bits_per_sample, int sample_rate, size_t number_of_channels,
size_t number_of_frames) override;
private:
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrackSinkOnData> on_audio_track_sink_on_data_event_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,91 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.CreateSessionDescriptionObserver.h"
#include "webrtc.CreateSessionDescriptionObserver.g.cpp"
// clang-format on
#include "webrtc.SessionDescription.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
// The implementation::CreateSessionDescriptionObserver class doesn't
// inherits from ::webrtc::CreateSessionDescriptionObserver because the
// latter inherits from rtc::RefCountInterface.
// rtc::RefCountInterface has two methods named AddRef and Release.
// CreateSessionDescriptionObserverT<CreateSessionDescriptionObserver> also
// have two methods named AddRef and Release.
struct CreateSessionDescriptionObserver_Helper : public ::webrtc::CreateSessionDescriptionObserver
{
CreateSessionDescriptionObserver_Helper(
Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::CreateSessionDescriptionObserver
*create_session_description_observer)
: create_session_description_observer_(create_session_description_observer)
{
}
void
OnSuccess(::webrtc::SessionDescriptionInterface *desc) override
{
create_session_description_observer_->on_success_event_(make<SessionDescription>(desc));
}
void
OnFailure(::webrtc::RTCError error) override
{
create_session_description_observer_->on_failure_event_(to_hstring(error.message()));
}
private:
Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::CreateSessionDescriptionObserver
*create_session_description_observer_;
};
// Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserver
CreateSessionDescriptionObserver::CreateSessionDescriptionObserver()
: webrtc_create_session_description_observer_helper_(
new ::rtc::RefCountedObject<CreateSessionDescriptionObserver_Helper>(this))
{
}
CreateSessionDescriptionObserver::~CreateSessionDescriptionObserver()
{
}
winrt::event_token
CreateSessionDescriptionObserver::OnSuccess(
Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserverOnSuccessDelegate const &handler)
{
return on_success_event_.add(handler);
}
void
CreateSessionDescriptionObserver::OnSuccess(winrt::event_token const &token) noexcept
{
on_success_event_.remove(token);
}
winrt::event_token
CreateSessionDescriptionObserver::OnFailure(
Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserverOnFailureDelegate const &handler)
{
return on_failure_event_.add(handler);
}
void
CreateSessionDescriptionObserver::OnFailure(winrt::event_token const &token) noexcept
{
on_failure_event_.remove(token);
}
::rtc::scoped_refptr<::webrtc::CreateSessionDescriptionObserver>
CreateSessionDescriptionObserver::get_webrtc_create_session_description_observer()
{
return webrtc_create_session_description_observer_helper_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.CreateSessionDescriptionObserver.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct CreateSessionDescriptionObserver : CreateSessionDescriptionObserverT<CreateSessionDescriptionObserver>
{
CreateSessionDescriptionObserver();
~CreateSessionDescriptionObserver();
winrt::event_token OnSuccess(
Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserverOnSuccessDelegate const &handler);
void OnSuccess(winrt::event_token const &token) noexcept;
winrt::event_token OnFailure(
Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserverOnFailureDelegate const &handler);
void OnFailure(winrt::event_token const &token) noexcept;
::rtc::scoped_refptr<::webrtc::CreateSessionDescriptionObserver> get_webrtc_create_session_description_observer();
// FIXME(aurighet): Improve encapsulation
::rtc::scoped_refptr<::webrtc::CreateSessionDescriptionObserver> webrtc_create_session_description_observer_helper_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserverOnSuccessDelegate>
on_success_event_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserverOnFailureDelegate>
on_failure_event_;
private:
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct CreateSessionDescriptionObserver
: CreateSessionDescriptionObserverT<CreateSessionDescriptionObserver,
implementation::CreateSessionDescriptionObserver>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,66 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.IceCandidate.h"
#include "webrtc.IceCandidate.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
IceCandidate::IceCandidate(const ::webrtc::IceCandidateInterface *webrtc_ice_candidate)
: webrtc_ice_candidate_(webrtc_ice_candidate)
{
if (!webrtc_ice_candidate_)
{
throw hresult_invalid_argument();
}
}
IceCandidate::~IceCandidate()
{
// This class doesn't own the object
// Do not delete webrtc_ice_candidate_
}
hstring
IceCandidate::SdpMid()
{
return to_hstring(webrtc_ice_candidate_->sdp_mid());
}
int32_t
IceCandidate::SdpMlineIndex()
{
return webrtc_ice_candidate_->sdp_mline_index();
}
hstring
IceCandidate::ServerUrl()
{
return to_hstring(webrtc_ice_candidate_->server_url());
}
hstring
IceCandidate::ToString()
{
std::string sdp;
if (webrtc_ice_candidate_->ToString(&sdp))
{
return to_hstring(sdp);
}
else
{
throw hresult_illegal_method_call();
}
}
const ::webrtc::IceCandidateInterface *
IceCandidate::get_webrtc_ice_candidate() const
{
return webrtc_ice_candidate_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.IceCandidate.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct IceCandidate : IceCandidateT<IceCandidate>
{
IceCandidate(const ::webrtc::IceCandidateInterface *webrtc_ice_candidate);
~IceCandidate();
hstring SdpMid();
int32_t SdpMlineIndex();
hstring ServerUrl();
hstring ToString();
const ::webrtc::IceCandidateInterface *get_webrtc_ice_candidate() const;
private:
const ::webrtc::IceCandidateInterface *webrtc_ice_candidate_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,97 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.MediaStreamTrack.h"
#include "webrtc.MediaStreamTrack.g.cpp"
// clang-format on
#include "webrtc.VideoSink_VideoFrame.h"
#include "rtc.VideoSinkWants.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
MediaStreamTrack::MediaStreamTrack(::rtc::scoped_refptr<::webrtc::MediaStreamTrackInterface> webrtc_media_stream_track)
: webrtc_media_stream_track_(webrtc_media_stream_track)
{
webrtc_media_stream_track_->RegisterObserver(this);
}
MediaStreamTrack::~MediaStreamTrack()
{
webrtc_media_stream_track_->UnregisterObserver(this);
}
void
MediaStreamTrack::OnChanged()
{
on_changed_event_();
}
hstring
MediaStreamTrack::AudioKind()
{
return to_hstring(::webrtc::MediaStreamTrackInterface::kAudioKind);
}
hstring
MediaStreamTrack::VideoKind()
{
return to_hstring(::webrtc::MediaStreamTrackInterface::kVideoKind);
}
hstring
MediaStreamTrack::Kind()
{
return to_hstring(webrtc_media_stream_track_->kind());
}
hstring
MediaStreamTrack::Id()
{
return to_hstring(webrtc_media_stream_track_->id());
}
bool
MediaStreamTrack::Enabled()
{
return webrtc_media_stream_track_->enabled();
}
void
MediaStreamTrack::Enabled(bool value)
{
webrtc_media_stream_track_->set_enabled(value);
}
::rtc::scoped_refptr<::webrtc::MediaStreamTrackInterface>
MediaStreamTrack::get_webrtc_media_stream_track()
{
return webrtc_media_stream_track_;
}
winrt::event_token
MediaStreamTrack::OnChanged(Microsoft::WinRTC::WebRtcWrapper::webrtc::NotifierOnChangedDelegate const &handler)
{
return on_changed_event_.add(handler);
}
void
MediaStreamTrack::OnChanged(winrt::event_token const &token) noexcept
{
on_changed_event_.remove(token);
}
// FIXME(aurighet): AddOrUpdateSink belongs to VideoTrack
void
MediaStreamTrack::AddOrUpdateSink(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoSink_VideoFrame const &sink,
Microsoft::WinRTC::WebRtcWrapper::rtc::VideoSinkWants const &wants)
{
static_cast<::webrtc::VideoTrackInterface *>(webrtc_media_stream_track_.get())
->AddOrUpdateSink(get_self<implementation::VideoSink_VideoFrame>(sink)->get_webrtc_video_sink_video_frame(),
*get_self<Microsoft::WinRTC::WebRtcWrapper::rtc::implementation::VideoSinkWants>(wants));
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.MediaStreamTrack.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct MediaStreamTrack : MediaStreamTrackT<MediaStreamTrack>, ::webrtc::ObserverInterface
{
explicit MediaStreamTrack(::rtc::scoped_refptr<::webrtc::MediaStreamTrackInterface> webrtc_media_stream_track);
~MediaStreamTrack();
static hstring AudioKind();
static hstring VideoKind();
hstring Kind();
hstring Id();
bool Enabled();
void Enabled(bool value);
winrt::event_token OnChanged(Microsoft::WinRTC::WebRtcWrapper::webrtc::NotifierOnChangedDelegate const &handler);
void OnChanged(winrt::event_token const &token) noexcept;
void AddOrUpdateSink(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoSink_VideoFrame const &sink,
Microsoft::WinRTC::WebRtcWrapper::rtc::VideoSinkWants const &wants);
::rtc::scoped_refptr<::webrtc::MediaStreamTrackInterface> get_webrtc_media_stream_track();
void OnChanged() override;
private:
::rtc::scoped_refptr<::webrtc::MediaStreamTrackInterface> webrtc_media_stream_track_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::NotifierOnChangedDelegate> on_changed_event_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct MediaStreamTrack : MediaStreamTrackT<MediaStreamTrack, implementation::MediaStreamTrack>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,152 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnection.IceServer.h"
#include "webrtc.PeerConnection.IceServer.g.cpp"
// clang-format off
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
IceServer::IceServer(const ::webrtc::PeerConnectionInterface::IceServer& webrtc_ice_server) :
webrtc_ice_server_(webrtc_ice_server)
{ }
Windows::Foundation::Collections::IVector<hstring> IceServer::Urls()
{
std::vector<hstring> urls_with_hstrings;
for (auto const& url : webrtc_ice_server_.urls)
{
urls_with_hstrings.push_back(to_hstring(url));
}
return single_threaded_vector<hstring>(std::move(urls_with_hstrings));
}
void IceServer::Urls(Windows::Foundation::Collections::IVector<hstring> const& value)
{
webrtc_ice_server_.urls.clear();
for (auto const& url : value.GetView())
{
webrtc_ice_server_.urls.push_back(to_string(url));
}
}
hstring IceServer::Username()
{
return to_hstring(webrtc_ice_server_.username);
}
void IceServer::Username(hstring const& value)
{
webrtc_ice_server_.username = to_string(value);
}
hstring IceServer::Password()
{
return to_hstring(webrtc_ice_server_.password);
}
void IceServer::Password(hstring const& value)
{
webrtc_ice_server_.password = to_string(value);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::TlsCertPolicy IceServer::TlsCertPolicy()
{
switch (webrtc_ice_server_.tls_cert_policy)
{
case ::webrtc::PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicyInsecureNoCheck:
{
return TlsCertPolicy::InsecureNoCheck;
}
case ::webrtc::PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicySecure:
{
return TlsCertPolicy::Secure;
}
default:
{
throw hresult_illegal_state_change();
}
}
}
void IceServer::TlsCertPolicy(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::TlsCertPolicy const& value)
{
switch (value)
{
case TlsCertPolicy::InsecureNoCheck:
{
webrtc_ice_server_.tls_cert_policy = ::webrtc::PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicyInsecureNoCheck;
break;
}
case TlsCertPolicy::Secure:
{
webrtc_ice_server_.tls_cert_policy = ::webrtc::PeerConnectionInterface::TlsCertPolicy::kTlsCertPolicySecure;
break;
}
default:
{
throw hresult_illegal_state_change();
}
}
}
hstring IceServer::Hostname()
{
return to_hstring(webrtc_ice_server_.hostname);
}
void IceServer::Hostname(hstring const& value)
{
webrtc_ice_server_.hostname = to_string(value);
}
Windows::Foundation::Collections::IVector<hstring> IceServer::TlsAlpnProtocols()
{
std::vector<hstring> protocols_with_hstrings;
for (auto const& protocol : webrtc_ice_server_.tls_alpn_protocols)
{
protocols_with_hstrings.push_back(to_hstring(protocol));
}
return single_threaded_vector<hstring>(std::move(protocols_with_hstrings));
}
void IceServer::TlsAlpnProtocols(Windows::Foundation::Collections::IVector<hstring> const& value)
{
webrtc_ice_server_.tls_alpn_protocols.clear();
for (auto const& protocol : value.GetView())
{
webrtc_ice_server_.tls_alpn_protocols.push_back(to_string(protocol));
}
}
Windows::Foundation::Collections::IVector<hstring> IceServer::TlsEllipticCurves()
{
std::vector<hstring> curves_with_hstrings;
for (auto const& curve : webrtc_ice_server_.tls_elliptic_curves)
{
curves_with_hstrings.push_back(to_hstring(curve));
}
return single_threaded_vector<hstring>(std::move(curves_with_hstrings));
}
void IceServer::TlsEllipticCurves(Windows::Foundation::Collections::IVector<hstring> const& value)
{
webrtc_ice_server_.tls_elliptic_curves.clear();
for (auto const& curve : value.GetView())
{
webrtc_ice_server_.tls_elliptic_curves.push_back(to_string(curve));
}
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation

Просмотреть файл

@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnection.IceServer.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
struct IceServer : IceServerT<IceServer>
{
friend struct RTCConfiguration;
IceServer() = default;
explicit IceServer(const ::webrtc::PeerConnectionInterface::IceServer &webrtc_ice_server);
Windows::Foundation::Collections::IVector<hstring> Urls();
void Urls(Windows::Foundation::Collections::IVector<hstring> const &value);
hstring Username();
void Username(hstring const &value);
hstring Password();
void Password(hstring const &value);
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::TlsCertPolicy TlsCertPolicy();
void TlsCertPolicy(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::TlsCertPolicy const &value);
hstring Hostname();
void Hostname(hstring const &value);
Windows::Foundation::Collections::IVector<hstring> TlsAlpnProtocols();
void TlsAlpnProtocols(Windows::Foundation::Collections::IVector<hstring> const &value);
Windows::Foundation::Collections::IVector<hstring> TlsEllipticCurves();
void TlsEllipticCurves(Windows::Foundation::Collections::IVector<hstring> const &value);
private:
::webrtc::PeerConnectionInterface::IceServer webrtc_ice_server_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::factory_implementation
{
struct IceServer : IceServerT<IceServer, implementation::IceServer>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::factory_implementation

Просмотреть файл

@ -0,0 +1,138 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnection.PeerConnection.h"
#include "webrtc.PeerConnection.PeerConnection.g.cpp"
// clang-format on
#include "webrtc.IceCandidate.h"
#include "webrtc.SetSessionDescriptionObserver.h"
#include "webrtc.SessionDescription.h"
#include "webrtc.AudioTrack.h"
#include "webrtc.VideoTrack.h"
#include "webrtc.RtpSender.h"
#include "webrtc.CreateSessionDescriptionObserver.h"
#include "webrtc.PeerConnection.RTCOfferAnswerOptions.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
PeerConnection::PeerConnection(::rtc::scoped_refptr<::webrtc::PeerConnectionInterface> webrtc_peer_connection)
: webrtc_peer_connection_(webrtc_peer_connection)
{
}
bool
PeerConnection::AddIceCandidate(Microsoft::WinRTC::WebRtcWrapper::webrtc::IceCandidate const &value)
{
return webrtc_peer_connection_->AddIceCandidate(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::IceCandidate>(value)
->get_webrtc_ice_candidate());
}
void
PeerConnection::SetLocalDescription(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::SessionDescription const &desc)
{
// FIXME: observer and desc don't have clear ownership. SetLocalDescription
// is transfering the underlying objects.
webrtc_peer_connection_->SetLocalDescription(
static_cast<::webrtc::SetSessionDescriptionObserver *>(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::SetSessionDescriptionObserver>(observer)
->webrtc_set_session_description_observer_helper_),
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::SessionDescription>(desc)
->get_webrtc_session_description());
}
void
PeerConnection::SetRemoteDescription(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::SessionDescription const &desc)
{
// FIXME: observer and desc don't have clear ownership. SetRemoteDescription
// is transfering the underlying objects.
webrtc_peer_connection_->SetRemoteDescription(
static_cast<::webrtc::SetSessionDescriptionObserver *>(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::SetSessionDescriptionObserver>(observer)
->webrtc_set_session_description_observer_helper_),
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::SessionDescription>(desc)
->get_webrtc_session_description());
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::RtpSender
PeerConnection::AddAudioTrack(Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrack const &track,
Windows::Foundation::Collections::IVector<hstring> const &stream_ids)
{
std::vector<std::string> stream_ids_string;
for (auto const &stream_id : stream_ids)
{
stream_ids_string.push_back(to_string(stream_id));
}
auto rtc_sender_error = webrtc_peer_connection_->AddTrack(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::AudioTrack>(track)->get_webrtc_audio_track(),
stream_ids_string);
if (rtc_sender_error.ok())
{
return make<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::RtpSender>(rtc_sender_error.MoveValue());
}
else
{
throw hresult_illegal_state_change();
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::RtpSender
PeerConnection::AddVideoTrack(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoTrack const &track,
Windows::Foundation::Collections::IVector<hstring> const &stream_ids)
{
std::vector<std::string> stream_ids_string;
for (auto const &stream_id : stream_ids)
{
stream_ids_string.push_back(to_string(stream_id));
}
auto rtc_sender_error = webrtc_peer_connection_->AddTrack(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::VideoTrack>(track)->get_webrtc_video_track(),
stream_ids_string);
if (rtc_sender_error.ok())
{
return make<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::RtpSender>(rtc_sender_error.MoveValue());
}
else
{
throw hresult_illegal_state_change();
}
}
void
PeerConnection::CreateOffer(
Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RTCOfferAnswerOptions const &options)
{
webrtc_peer_connection_->CreateOffer(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::CreateSessionDescriptionObserver>(observer)
->get_webrtc_create_session_description_observer()
.get(),
*get_self<RTCOfferAnswerOptions>(options));
}
void
PeerConnection::CreateAnswer(
Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RTCOfferAnswerOptions const &options)
{
webrtc_peer_connection_->CreateAnswer(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::CreateSessionDescriptionObserver>(observer)
->get_webrtc_create_session_description_observer()
.get(),
*get_self<RTCOfferAnswerOptions>(options));
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation

Просмотреть файл

@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnection.PeerConnection.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
struct PeerConnection : PeerConnectionT<PeerConnection>
{
PeerConnection(::rtc::scoped_refptr<::webrtc::PeerConnectionInterface> webrtc_peer_connection);
bool AddIceCandidate(Microsoft::WinRTC::WebRtcWrapper::webrtc::IceCandidate const &value);
void SetLocalDescription(Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::SessionDescription const &desc);
void SetRemoteDescription(Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::SessionDescription const &desc);
Microsoft::WinRTC::WebRtcWrapper::webrtc::RtpSender AddAudioTrack(
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrack const &track,
Windows::Foundation::Collections::IVector<hstring> const &stream_ids);
Microsoft::WinRTC::WebRtcWrapper::webrtc::RtpSender AddVideoTrack(
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoTrack const &track,
Windows::Foundation::Collections::IVector<hstring> const &stream_ids);
void CreateOffer(Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RTCOfferAnswerOptions const &options);
void CreateAnswer(Microsoft::WinRTC::WebRtcWrapper::webrtc::CreateSessionDescriptionObserver const &observer,
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RTCOfferAnswerOptions const &options);
private:
::rtc::scoped_refptr<::webrtc::PeerConnectionInterface> webrtc_peer_connection_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation

Просмотреть файл

@ -0,0 +1,229 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnection.RTCConfiguration.h"
#include "webrtc.PeerConnection.RTCConfiguration.g.cpp"
// clang-format on
#include "webrtc.PeerConnection.IceServer.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
::webrtc::PeerConnectionInterface::RTCConfiguration
RTCConfiguration::get_webrtc_rtc_configuration() const
{
return webrtc_rtc_configuration_;
}
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceServer>
RTCConfiguration::IceServers()
{
std::vector<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceServer> ice_servers;
for (auto const &webrtc_ice_server : webrtc_rtc_configuration_.servers)
{
IceServer ice_server(webrtc_ice_server);
ice_servers.push_back(ice_server);
}
return single_threaded_vector<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceServer>(
std::move(ice_servers));
}
void
RTCConfiguration::IceServers(
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceServer> const
&value)
{
webrtc_rtc_configuration_.servers.clear();
for (auto const &server : value.GetView())
{
webrtc_rtc_configuration_.servers.push_back(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation::IceServer>(server)
->webrtc_ice_server_);
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceTransportType
RTCConfiguration::IceTransportType()
{
switch (webrtc_rtc_configuration_.type)
{
case ::webrtc::PeerConnectionInterface::IceTransportsType::kAll: {
return IceTransportType::All;
}
case ::webrtc::PeerConnectionInterface::IceTransportsType::kNoHost: {
return IceTransportType::NoHost;
}
case ::webrtc::PeerConnectionInterface::IceTransportsType::kNone: {
return IceTransportType::None;
}
case ::webrtc::PeerConnectionInterface::IceTransportsType::kRelay: {
return IceTransportType::Relay;
}
default: {
throw hresult_illegal_state_change();
}
}
}
void
RTCConfiguration::IceTransportType(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceTransportType const &value)
{
switch (value)
{
case IceTransportType::All: {
webrtc_rtc_configuration_.type = ::webrtc::PeerConnectionInterface::IceTransportsType::kAll;
break;
}
case IceTransportType::NoHost: {
webrtc_rtc_configuration_.type = ::webrtc::PeerConnectionInterface::IceTransportsType::kNoHost;
break;
}
case IceTransportType::None: {
webrtc_rtc_configuration_.type = ::webrtc::PeerConnectionInterface::IceTransportsType::kNone;
break;
}
case IceTransportType::Relay: {
webrtc_rtc_configuration_.type = ::webrtc::PeerConnectionInterface::IceTransportsType::kRelay;
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::BundlePolicy
RTCConfiguration::BundlePolicy()
{
switch (webrtc_rtc_configuration_.bundle_policy)
{
case ::webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyBalanced: {
return BundlePolicy::Balanced;
}
case ::webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxBundle: {
return BundlePolicy::MaxBundle;
}
case ::webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxCompat: {
return BundlePolicy::MaxCompat;
}
default: {
throw hresult_illegal_state_change();
}
}
}
void
RTCConfiguration::BundlePolicy(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::BundlePolicy const &value)
{
switch (value)
{
case BundlePolicy::Balanced: {
webrtc_rtc_configuration_.bundle_policy = ::webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyBalanced;
break;
}
case BundlePolicy::MaxBundle: {
webrtc_rtc_configuration_.bundle_policy = ::webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxBundle;
break;
}
case BundlePolicy::MaxCompat: {
webrtc_rtc_configuration_.bundle_policy = ::webrtc::PeerConnectionInterface::BundlePolicy::kBundlePolicyMaxCompat;
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RtcpMuxPolicy
RTCConfiguration::RtcpMuxPolicy()
{
switch (webrtc_rtc_configuration_.rtcp_mux_policy)
{
case ::webrtc::PeerConnectionInterface::RtcpMuxPolicy::kRtcpMuxPolicyNegotiate: {
return RtcpMuxPolicy::Negotiate;
}
case ::webrtc::PeerConnectionInterface::RtcpMuxPolicy::kRtcpMuxPolicyRequire: {
return RtcpMuxPolicy::Require;
}
default: {
throw hresult_illegal_state_change();
}
}
}
void
RTCConfiguration::RtcpMuxPolicy(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RtcpMuxPolicy const &value)
{
switch (value)
{
case RtcpMuxPolicy::Negotiate: {
webrtc_rtc_configuration_.rtcp_mux_policy =
::webrtc::PeerConnectionInterface::RtcpMuxPolicy::kRtcpMuxPolicyNegotiate;
break;
}
case RtcpMuxPolicy::Require: {
webrtc_rtc_configuration_.rtcp_mux_policy = ::webrtc::PeerConnectionInterface::RtcpMuxPolicy::kRtcpMuxPolicyRequire;
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
int32_t
RTCConfiguration::IceCandidatePoolSize()
{
return webrtc_rtc_configuration_.ice_candidate_pool_size;
}
void
RTCConfiguration::IceCandidatePoolSize(int32_t value)
{
webrtc_rtc_configuration_.ice_candidate_pool_size = value;
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::SdpSemantics
RTCConfiguration::SdpSemantics()
{
switch (webrtc_rtc_configuration_.sdp_semantics)
{
case ::webrtc::SdpSemantics::kPlanB: {
return SdpSemantics::PlanB;
}
case ::webrtc::SdpSemantics::kUnifiedPlan: {
return SdpSemantics::UnifiedPlan;
}
default: {
throw hresult_illegal_state_change();
}
}
}
void
RTCConfiguration::SdpSemantics(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::SdpSemantics const &value)
{
switch (value)
{
case SdpSemantics::PlanB: {
webrtc_rtc_configuration_.sdp_semantics = ::webrtc::SdpSemantics::kPlanB;
break;
}
case SdpSemantics::UnifiedPlan: {
webrtc_rtc_configuration_.sdp_semantics = ::webrtc::SdpSemantics::kUnifiedPlan;
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnection.RTCConfiguration.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
struct RTCConfiguration : RTCConfigurationT<RTCConfiguration>
{
RTCConfiguration() = default;
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceServer>
IceServers();
void IceServers(Windows::Foundation::Collections::IVector<
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceServer> const &value);
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceTransportType IceTransportType();
void IceTransportType(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceTransportType const &value);
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::BundlePolicy BundlePolicy();
void BundlePolicy(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::BundlePolicy const &value);
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RtcpMuxPolicy RtcpMuxPolicy();
void RtcpMuxPolicy(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RtcpMuxPolicy const &value);
int32_t IceCandidatePoolSize();
void IceCandidatePoolSize(int32_t value);
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::SdpSemantics SdpSemantics();
void SdpSemantics(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::SdpSemantics const &value);
::webrtc::PeerConnectionInterface::RTCConfiguration get_webrtc_rtc_configuration() const;
private:
::webrtc::PeerConnectionInterface::RTCConfiguration webrtc_rtc_configuration_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::factory_implementation
{
struct RTCConfiguration : RTCConfigurationT<RTCConfiguration, implementation::RTCConfiguration>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::factory_implementation

Просмотреть файл

@ -0,0 +1,84 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnection.RTCOfferAnswerOptions.h"
#include "webrtc.PeerConnection.RTCOfferAnswerOptions.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
bool
RTCOfferAnswerOptions::VoiceActivityDetection()
{
return voice_activity_detection;
}
void
RTCOfferAnswerOptions::VoiceActivityDetection(bool value)
{
voice_activity_detection = value;
}
bool
RTCOfferAnswerOptions::IceRestart()
{
return ice_restart;
}
void
RTCOfferAnswerOptions::IceRestart(bool value)
{
ice_restart = value;
}
bool
RTCOfferAnswerOptions::UseRtpMux()
{
return use_rtp_mux;
}
void
RTCOfferAnswerOptions::UseRtpMux(bool value)
{
use_rtp_mux = value;
}
bool
RTCOfferAnswerOptions::RawPacketizationForVideo()
{
return raw_packetization_for_video;
}
void
RTCOfferAnswerOptions::RawPacketizationForVideo(bool value)
{
raw_packetization_for_video = value;
}
int32_t
RTCOfferAnswerOptions::NumSimulcastLayers()
{
return num_simulcast_layers;
}
void
RTCOfferAnswerOptions::NumSimulcastLayers(int32_t value)
{
num_simulcast_layers = value;
}
bool
RTCOfferAnswerOptions::UseObsoleteSctpSdp()
{
return use_obsolete_sctp_sdp;
}
void
RTCOfferAnswerOptions::UseObsoleteSctpSdp(bool value)
{
use_obsolete_sctp_sdp = value;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation

Просмотреть файл

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnection.RTCOfferAnswerOptions.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
{
struct RTCOfferAnswerOptions : RTCOfferAnswerOptionsT<RTCOfferAnswerOptions>,
::webrtc::PeerConnectionInterface::RTCOfferAnswerOptions
{
RTCOfferAnswerOptions() = default;
bool VoiceActivityDetection();
void VoiceActivityDetection(bool value);
bool IceRestart();
void IceRestart(bool value);
bool UseRtpMux();
void UseRtpMux(bool value);
bool RawPacketizationForVideo();
void RawPacketizationForVideo(bool value);
int32_t NumSimulcastLayers();
void NumSimulcastLayers(int32_t value);
bool UseObsoleteSctpSdp();
void UseObsoleteSctpSdp(bool value);
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::factory_implementation
{
struct RTCOfferAnswerOptions : RTCOfferAnswerOptionsT<RTCOfferAnswerOptions, implementation::RTCOfferAnswerOptions>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::factory_implementation

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnectionDependencies.h"
#include "webrtc.PeerConnectionDependencies.g.cpp"
// clang-format on
#include "webrtc.PeerConnectionObserver.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
PeerConnectionDependencies::PeerConnectionDependencies(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserver const &observer)
: peer_connection_observer_(observer)
{
}
::webrtc::PeerConnectionDependencies
PeerConnectionDependencies::build_webrtc_peer_connection_dependencies()
{
return ::webrtc::PeerConnectionDependencies(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::PeerConnectionObserver>(
peer_connection_observer_));
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnectionDependencies.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct PeerConnectionDependencies : PeerConnectionDependenciesT<PeerConnectionDependencies>
{
explicit PeerConnectionDependencies(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserver const &observer);
::webrtc::PeerConnectionDependencies build_webrtc_peer_connection_dependencies();
private:
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserver peer_connection_observer_{nullptr};
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct PeerConnectionDependencies
: PeerConnectionDependenciesT<PeerConnectionDependencies, implementation::PeerConnectionDependencies>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,87 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnectionFactory.h"
#include "webrtc.PeerConnectionFactory.g.cpp"
// clang-format on
#include "cricket.AudioOptions.h"
#include "webrtc.AudioDecoderFactory.h"
#include "webrtc.AudioEncoderFactory.h"
#include "webrtc.AudioSource.h"
#include "webrtc.AudioTrack.h"
#include "webrtc.PeerConnection.PeerConnection.h"
#include "webrtc.PeerConnection.RTCConfiguration.h"
#include "webrtc.PeerConnectionDependencies.h"
#include "webrtc.VideoEncoderFactory.h"
#include "webrtc.VideoDecoderFactory.h"
#include "webrtc.VideoTrack.h"
#include "webrtc.VideoTrackSource.h"
#include "rtc.Thread.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
PeerConnectionFactory::PeerConnectionFactory(
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread const &network_thread,
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread const &worker_thread,
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread const &signaling_thread,
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioEncoderFactory const &audio_encoder_factory,
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioDecoderFactory const &audio_decoder_factory,
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoEncoderFactory const &video_encoder_factory,
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoDecoderFactory const &video_decoder_factory)
: webrtc_peer_connection_factory_(::webrtc::CreatePeerConnectionFactory(
get_self<Microsoft::WinRTC::WebRtcWrapper::rtc::implementation::Thread>(network_thread)
->get_webrtc_thread_no_ref(),
get_self<Microsoft::WinRTC::WebRtcWrapper::rtc::implementation::Thread>(worker_thread)
->get_webrtc_thread_no_ref(),
get_self<Microsoft::WinRTC::WebRtcWrapper::rtc::implementation::Thread>(signaling_thread)
->get_webrtc_thread_no_ref(),
nullptr /* default_adm */,
get_self<AudioEncoderFactory>(audio_encoder_factory)->get_webrtc_audio_encoder_factory_no_ref(),
get_self<AudioDecoderFactory>(audio_decoder_factory)->get_webrtc_audio_decoder_factory_no_ref(),
get_self<VideoEncoderFactory>(video_encoder_factory)->get_webrtc_video_encoder_factory(),
get_self<VideoDecoderFactory>(video_decoder_factory)->get_webrtc_video_decoder_factory(),
nullptr /* audio_mixer */, nullptr /* audio_processing */))
{
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::PeerConnection
PeerConnectionFactory::CreatePeerConnection(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RTCConfiguration const &configuration,
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionDependencies const &dependencies)
{
return make<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation::PeerConnection>(
webrtc_peer_connection_factory_->CreatePeerConnection(
get_self<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::implementation::RTCConfiguration>(
configuration)
->get_webrtc_rtc_configuration(),
get_self<PeerConnectionDependencies>(dependencies)->build_webrtc_peer_connection_dependencies()));
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSource
PeerConnectionFactory::CreateAudioSource(Microsoft::WinRTC::WebRtcWrapper::cricket::AudioOptions const &options)
{
return make<AudioSource>(webrtc_peer_connection_factory_->CreateAudioSource(
get_self<Microsoft::WinRTC::WebRtcWrapper::cricket::implementation::AudioOptions>(options)
->get_cricket_audio_options()));
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrack
PeerConnectionFactory::CreateAudioTrack(hstring const &label,
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSource const &audio_source)
{
return make<AudioTrack>(webrtc_peer_connection_factory_->CreateAudioTrack(
to_string(label), get_self<AudioSource>(audio_source)->get_webrtc_audio_source()));
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoTrack
PeerConnectionFactory::CreateVideoTrack(
hstring const &label, Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoTrackSource const &video_track_source)
{
return make<VideoTrack>(webrtc_peer_connection_factory_->CreateVideoTrack(
to_string(label), get_self<VideoTrackSource>(video_track_source)->get_webrtc_video_track_source()));
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnectionFactory.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct PeerConnectionFactory : PeerConnectionFactoryT<PeerConnectionFactory>
{
PeerConnectionFactory(Microsoft::WinRTC::WebRtcWrapper::rtc::Thread const &network_thread,
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread const &worker_thread,
Microsoft::WinRTC::WebRtcWrapper::rtc::Thread const &signaling_thread,
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioEncoderFactory const &audio_encoder_factory,
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioDecoderFactory const &audio_decoder_factory,
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoEncoderFactory const &video_encoder_factory,
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoDecoderFactory const &video_decoder_factory);
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::PeerConnection CreatePeerConnection(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::RTCConfiguration const &configuration,
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionDependencies const &dependencies);
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSource CreateAudioSource(
Microsoft::WinRTC::WebRtcWrapper::cricket::AudioOptions const &options);
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioTrack CreateAudioTrack(
hstring const &label, Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioSource const &audio_source);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoTrack CreateVideoTrack(
hstring const &label, Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoTrackSource const &video_track_source);
private:
::rtc::scoped_refptr<::webrtc::PeerConnectionFactoryInterface> webrtc_peer_connection_factory_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct PeerConnectionFactory : PeerConnectionFactoryT<PeerConnectionFactory, implementation::PeerConnectionFactory>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,174 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.PeerConnectionObserver.h"
#include "webrtc.PeerConnectionObserver.g.cpp"
// clang-format on
#include "webrtc.IceCandidate.h"
#include "webrtc.RtpTransceiver.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
event_token
PeerConnectionObserver::OnSignalingChange(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnSignalingChangeDelegate const &handler)
{
return on_signaling_change_event_.add(handler);
}
void
PeerConnectionObserver::OnSignalingChange(event_token const &token) noexcept
{
on_signaling_change_event_.remove(token);
}
event_token
PeerConnectionObserver::OnRenegotiationNeeded(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnRenegotiationNeededDelegate const &handler)
{
return on_renegotiation_needed_event_.add(handler);
}
void
PeerConnectionObserver::OnRenegotiationNeeded(winrt::event_token const &token) noexcept
{
on_renegotiation_needed_event_.remove(token);
}
event_token
PeerConnectionObserver::OnIceGatheringChange(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnIceGatheringChangeDelegate const &handler)
{
return on_ice_gathering_change_event_.add(handler);
}
void
PeerConnectionObserver::OnIceGatheringChange(winrt::event_token const &token) noexcept
{
on_ice_gathering_change_event_.remove(token);
}
event_token
PeerConnectionObserver::OnIceCandidate(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnIceCandidateDelegate const &handler)
{
return on_ice_candidate_event_.add(handler);
}
void
PeerConnectionObserver::OnIceCandidate(event_token const &token) noexcept
{
on_ice_candidate_event_.remove(token);
}
event_token
PeerConnectionObserver::OnTrack(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnTrackDelegate const &handler)
{
return on_track_event_.add(handler);
}
void
PeerConnectionObserver::OnTrack(event_token const &token) noexcept
{
on_track_event_.remove(token);
}
void
PeerConnectionObserver::OnSignalingChange(::webrtc::PeerConnectionInterface::SignalingState webrtc_new_state)
{
switch (webrtc_new_state)
{
case ::webrtc::PeerConnectionInterface::SignalingState::kStable: {
on_signaling_change_event_(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionSignalingState::Stable);
break;
}
case ::webrtc::PeerConnectionInterface::SignalingState::kHaveLocalOffer: {
on_signaling_change_event_(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionSignalingState::HaveLocalOffer);
break;
}
case ::webrtc::PeerConnectionInterface::SignalingState::kHaveLocalPrAnswer: {
on_signaling_change_event_(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionSignalingState::HaveLocalPrAnswer);
break;
}
case ::webrtc::PeerConnectionInterface::SignalingState::kHaveRemoteOffer: {
on_signaling_change_event_(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionSignalingState::HaveRemoteOffer);
break;
}
case ::webrtc::PeerConnectionInterface::SignalingState::kHaveRemotePrAnswer: {
on_signaling_change_event_(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionSignalingState::HaveRemotePrAnswer);
break;
}
case ::webrtc::PeerConnectionInterface::SignalingState::kClosed: {
on_signaling_change_event_(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionSignalingState::Closed);
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
void PeerConnectionObserver::OnDataChannel(::rtc::scoped_refptr<::webrtc::DataChannelInterface> /*data_channel*/)
{
throw hresult_not_implemented(); // FIXME(aurighet)
}
void
PeerConnectionObserver::OnRenegotiationNeeded()
{
on_renegotiation_needed_event_();
}
void
PeerConnectionObserver::OnIceGatheringChange(::webrtc::PeerConnectionInterface::IceGatheringState new_state)
{
switch (new_state)
{
case ::webrtc::PeerConnectionInterface::kIceGatheringNew: {
on_ice_gathering_change_event_(Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceGatheringState::New);
break;
}
case ::webrtc::PeerConnectionInterface::kIceGatheringGathering: {
on_ice_gathering_change_event_(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceGatheringState::Gathering);
break;
}
case ::webrtc::PeerConnectionInterface::kIceGatheringComplete: {
on_ice_gathering_change_event_(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnection::IceGatheringState::Complete);
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
void
PeerConnectionObserver::OnIceCandidate(const ::webrtc::IceCandidateInterface *candidate)
{
if (candidate)
{
auto winrtc_ice_candidate = make<IceCandidate>(candidate);
on_ice_candidate_event_(winrtc_ice_candidate);
}
else
{
throw hresult_invalid_argument();
}
}
void
PeerConnectionObserver::OnTrack(::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface> transceiver)
{
auto winrtc_rtp_transceiver = make<RtpTransceiver>(transceiver);
on_track_event_(winrtc_rtp_transceiver);
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,54 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.PeerConnectionObserver.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct PeerConnectionObserver : PeerConnectionObserverT<PeerConnectionObserver>, public ::webrtc::PeerConnectionObserver
{
PeerConnectionObserver() = default;
winrt::event_token OnSignalingChange(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnSignalingChangeDelegate const &handler);
void OnSignalingChange(winrt::event_token const &token) noexcept;
winrt::event_token OnRenegotiationNeeded(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnRenegotiationNeededDelegate const &handler);
void OnRenegotiationNeeded(winrt::event_token const &token) noexcept;
winrt::event_token OnIceGatheringChange(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnIceGatheringChangeDelegate const &handler);
void OnIceGatheringChange(winrt::event_token const &token) noexcept;
winrt::event_token OnIceCandidate(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnIceCandidateDelegate const &handler);
void OnIceCandidate(winrt::event_token const &token) noexcept;
winrt::event_token OnTrack(
Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnTrackDelegate const &handler);
void OnTrack(winrt::event_token const &token) noexcept;
void OnSignalingChange(::webrtc::PeerConnectionInterface::SignalingState webrtc_new_state) override;
void OnDataChannel(::rtc::scoped_refptr<::webrtc::DataChannelInterface> data_channel) override;
void OnRenegotiationNeeded() override;
void OnIceGatheringChange(::webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
void OnIceCandidate(const ::webrtc::IceCandidateInterface *candidate) override;
void OnTrack(::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface> transceiver) override;
private:
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnSignalingChangeDelegate>
on_signaling_change_event_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnRenegotiationNeededDelegate>
on_renegotiation_needed_event_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnIceGatheringChangeDelegate>
on_ice_gathering_change_event_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnIceCandidateDelegate>
on_ice_candidate_event_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::PeerConnectionObserverOnTrackDelegate> on_track_event_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct PeerConnectionObserver : PeerConnectionObserverT<PeerConnectionObserver, implementation::PeerConnectionObserver>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.RtpReceiver.h"
#include "webrtc.RtpReceiver.g.cpp"
// clang-format on
#include "webrtc.MediaStreamTrack.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
RtpReceiver::RtpReceiver(::rtc::scoped_refptr<::webrtc::RtpReceiverInterface> webrtc_rtp_receiver)
: webrtc_rtp_receiver_(webrtc_rtp_receiver)
{
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::MediaStreamTrack
RtpReceiver::Track()
{
return make<Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::MediaStreamTrack>(
webrtc_rtp_receiver_->track());
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.RtpReceiver.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct RtpReceiver : RtpReceiverT<RtpReceiver>
{
explicit RtpReceiver(::rtc::scoped_refptr<::webrtc::RtpReceiverInterface> webrtc_rtp_receiver);
Microsoft::WinRTC::WebRtcWrapper::webrtc::MediaStreamTrack Track();
private:
::rtc::scoped_refptr<::webrtc::RtpReceiverInterface> webrtc_rtp_receiver_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.RtpSender.h"
#include "webrtc.RtpSender.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
RtpSender::RtpSender(::rtc::scoped_refptr<::webrtc::RtpSenderInterface> webrtc_rtc_sender)
: webrtc_rtc_sender_(webrtc_rtc_sender)
{
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.RtpSender.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct RtpSender : RtpSenderT<RtpSender>
{
explicit RtpSender(::rtc::scoped_refptr<::webrtc::RtpSenderInterface> webrtc_rtc_sender_);
private:
::rtc::scoped_refptr<::webrtc::RtpSenderInterface> webrtc_rtc_sender_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.RtpTransceiver.h"
#include "webrtc.RtpTransceiver.g.cpp"
// clang-format on
#include "webrtc.RtpReceiver.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
RtpTransceiver::RtpTransceiver(::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface> webrtc_rtp_transceiver)
: webrtc_rtp_transceiver_(std::move(webrtc_rtp_transceiver))
{
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::RtpReceiver
RtpTransceiver::Receiver()
{
return make<RtpReceiver>(webrtc_rtp_transceiver_->receiver());
}
::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface>
RtpTransceiver::get_webrtc_rtp_transceiver()
{
return webrtc_rtp_transceiver_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.RtpTransceiver.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct RtpTransceiver : RtpTransceiverT<RtpTransceiver>
{
explicit RtpTransceiver(::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface> webrtc_rtp_transceiver);
Microsoft::WinRTC::WebRtcWrapper::webrtc::RtpReceiver Receiver();
::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface> get_webrtc_rtp_transceiver();
private:
::rtc::scoped_refptr<::webrtc::RtpTransceiverInterface> webrtc_rtp_transceiver_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,174 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.SessionDescription.h"
#include "webrtc.SessionDescription.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
::webrtc::SdpType
SessionDescription::to_webrtc_sdp_type(Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType sdp_type)
{
switch (sdp_type)
{
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Offer: {
return ::webrtc::SdpType::kOffer;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::PrAnswer: {
return ::webrtc::SdpType::kPrAnswer;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Answer: {
return ::webrtc::SdpType::kAnswer;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Rollback: {
return ::webrtc::SdpType::kRollback;
}
default: {
throw hresult_illegal_state_change();
}
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType
SessionDescription::to_winrtc_sdp_type(::webrtc::SdpType sdp_type)
{
switch (sdp_type)
{
case ::webrtc::SdpType::kOffer: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Offer;
}
case ::webrtc::SdpType::kPrAnswer: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::PrAnswer;
}
case ::webrtc::SdpType::kAnswer: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Answer;
}
case ::webrtc::SdpType::kRollback: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Rollback;
}
default: {
throw hresult_illegal_state_change();
}
}
}
hstring
SessionDescription::Offer()
{
return to_hstring(std::string(::webrtc::SessionDescriptionInterface::kOffer));
}
hstring
SessionDescription::PrAnswer()
{
return to_hstring(std::string(::webrtc::SessionDescriptionInterface::kPrAnswer));
}
hstring
SessionDescription::Answer()
{
return to_hstring(std::string(::webrtc::SessionDescriptionInterface::kAnswer));
}
hstring
SessionDescription::Rollback()
{
return to_hstring(std::string(::webrtc::SessionDescriptionInterface::kRollback));
}
SessionDescription::SessionDescription(
std::unique_ptr<::webrtc::SessionDescriptionInterface> webrtc_session_description)
: webrtc_session_description_(webrtc_session_description.release()), owns_webrtc_session_description_(true)
{
}
SessionDescription::SessionDescription(::webrtc::SessionDescriptionInterface *webrtc_session_description)
: webrtc_session_description_(webrtc_session_description), owns_webrtc_session_description_(false)
{
}
SessionDescription::~SessionDescription()
{
if (owns_webrtc_session_description_)
{
delete webrtc_session_description_;
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType
SessionDescription::Type()
{
return to_winrtc_sdp_type(webrtc_session_description_->GetType());
}
hstring
SessionDescription::SdpTypeToString(Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType const &sdp_type)
{
switch (sdp_type)
{
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Offer: {
return Offer();
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::PrAnswer: {
return PrAnswer();
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Answer: {
return Answer();
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Rollback: {
return Rollback();
}
default: {
throw hresult_illegal_state_change();
}
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType
SessionDescription::SdpTypeFromString(hstring const &type_str)
{
if (type_str == Offer())
{
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Offer;
}
else if (type_str == PrAnswer())
{
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::PrAnswer;
}
else if (type_str == Answer())
{
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Answer;
}
else if (type_str == Rollback())
{
return Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType::Rollback;
}
else
{
throw hresult_illegal_state_change();
}
}
::webrtc::SessionDescriptionInterface *
SessionDescription::get_webrtc_session_description() const
{
return webrtc_session_description_;
}
hstring
SessionDescription::ToString()
{
std::string out;
if (webrtc_session_description_->ToString(&out))
{
return to_hstring(out);
}
else
{
throw hresult_illegal_state_change();
}
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,45 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.SessionDescription.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct SessionDescription : SessionDescriptionT<SessionDescription>
{
// This constructor takes ownership (it deletes ::webrtc::SessionDescriptionInterface)
explicit SessionDescription(std::unique_ptr<::webrtc::SessionDescriptionInterface> webrtc_session_description);
// This constructor works like a view (doesn't take ownership)
explicit SessionDescription(::webrtc::SessionDescriptionInterface *webrtc_session_description);
~SessionDescription();
static hstring Offer();
static hstring PrAnswer();
static hstring Answer();
static hstring Rollback();
Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType Type();
static ::webrtc::SdpType to_webrtc_sdp_type(Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType sdp_type);
static Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType to_winrtc_sdp_type(::webrtc::SdpType sdp_type);
static hstring SdpTypeToString(Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType const &sdp_type);
static Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType SdpTypeFromString(hstring const &type_str);
hstring ToString();
::webrtc::SessionDescriptionInterface *get_webrtc_session_description() const;
private:
::webrtc::SessionDescriptionInterface *webrtc_session_description_;
bool owns_webrtc_session_description_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct SessionDescription : SessionDescriptionT<SessionDescription, implementation::SessionDescription>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,99 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.SetSessionDescriptionObserver.h"
#include "webrtc.SetSessionDescriptionObserver.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
// ----------------------------------------------------------------------------
// ::webrtc::SetSessionDescriptionObserver
// ----------------------------------------------------------------------------
// The implementation::SetSessionDescriptionObserver class doesn't
// inherits from ::webrtc::SetSessionDescriptionObserver because the
// latter inherits from rtc::RefCountInterface.
// rtc::RefCountInterface has two methods named AddRef and Release.
// SetSessionDescriptionObserverT<SetSessionDescriptionObserver> also
// have two methods named AddRef and Release.
struct SetSessionDescriptionObserver_Helper : public ::webrtc::SetSessionDescriptionObserver
{
SetSessionDescriptionObserver_Helper(
Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::SetSessionDescriptionObserver
*set_session_description_observer)
: set_session_description_observer_(set_session_description_observer)
{
}
void
AddRef() const
{
}
::rtc::RefCountReleaseStatus
Release() const
{
// The life cycle of this object is attached to
// implementation::SetSessionDescriptionObserver
return ::rtc::RefCountReleaseStatus::kDroppedLastRef;
}
void
OnSuccess() override
{
set_session_description_observer_->on_success_event_();
}
void
OnFailure(::webrtc::RTCError error) override
{
set_session_description_observer_->on_failure_event_(to_hstring(error.message()));
}
private:
Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::SetSessionDescriptionObserver
*set_session_description_observer_;
};
// Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserver
SetSessionDescriptionObserver::SetSessionDescriptionObserver()
: webrtc_set_session_description_observer_helper_(new SetSessionDescriptionObserver_Helper(this))
{
}
SetSessionDescriptionObserver::~SetSessionDescriptionObserver()
{
delete static_cast<SetSessionDescriptionObserver_Helper *>(webrtc_set_session_description_observer_helper_);
}
event_token
SetSessionDescriptionObserver::OnSuccess(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserverOnSuccessDelegate const &handler)
{
return on_success_event_.add(handler);
}
void
SetSessionDescriptionObserver::OnSuccess(winrt::event_token const &token) noexcept
{
on_success_event_.remove(token);
}
event_token
SetSessionDescriptionObserver::OnFailure(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserverOnFailureDelegate const &handler)
{
return on_failure_event_.add(handler);
}
void
SetSessionDescriptionObserver::OnFailure(winrt::event_token const &token) noexcept
{
on_failure_event_.remove(token);
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.SetSessionDescriptionObserver.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct SetSessionDescriptionObserver : SetSessionDescriptionObserverT<SetSessionDescriptionObserver>
{
SetSessionDescriptionObserver();
~SetSessionDescriptionObserver();
winrt::event_token OnSuccess(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserverOnSuccessDelegate const &handler);
void OnSuccess(winrt::event_token const &token) noexcept;
winrt::event_token OnFailure(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserverOnFailureDelegate const &handler);
void OnFailure(winrt::event_token const &token) noexcept;
// FIXME(aurighet): Improve encapsulation
void *webrtc_set_session_description_observer_helper_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserverOnSuccessDelegate>
on_success_event_;
winrt::event<Microsoft::WinRTC::WebRtcWrapper::webrtc::SetSessionDescriptionObserverOnFailureDelegate>
on_failure_event_;
private:
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct SetSessionDescriptionObserver
: SetSessionDescriptionObserverT<SetSessionDescriptionObserver, implementation::SetSessionDescriptionObserver>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,187 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoCaptureCapability.h"
#include "webrtc.VideoCaptureCapability.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
VideoCaptureCapability::VideoCaptureCapability(const ::webrtc::VideoCaptureCapability &video_capability)
{
width = video_capability.width;
height = video_capability.height;
maxFPS = video_capability.maxFPS;
videoType = video_capability.videoType;
interlaced = video_capability.interlaced;
}
int32_t
VideoCaptureCapability::Width()
{
return width;
}
void
VideoCaptureCapability::Width(int32_t value)
{
width = value;
}
int32_t
VideoCaptureCapability::Height()
{
return height;
}
void
VideoCaptureCapability::Height(int32_t value)
{
height = value;
}
int32_t
VideoCaptureCapability::MaxFPS()
{
return maxFPS;
}
void
VideoCaptureCapability::MaxFPS(int32_t value)
{
maxFPS = value;
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType
VideoCaptureCapability::VideoType()
{
switch (videoType)
{
case ::webrtc::VideoType::kUnknown:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::Unknown;
case ::webrtc::VideoType::kI420:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::I420;
case ::webrtc::VideoType::kIYUV:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::IYUV;
case ::webrtc::VideoType::kRGB24:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::RGB24;
case ::webrtc::VideoType::kABGR:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ABGR;
case ::webrtc::VideoType::kARGB:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ARGB;
case ::webrtc::VideoType::kARGB4444:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ARGB4444;
case ::webrtc::VideoType::kRGB565:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::RGB565;
case ::webrtc::VideoType::kARGB1555:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ARGB1555;
case ::webrtc::VideoType::kYUY2:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::YUY2;
case ::webrtc::VideoType::kYV12:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::YV12;
case ::webrtc::VideoType::kUYVY:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::UYVY;
case ::webrtc::VideoType::kMJPEG:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::MJPEG;
case ::webrtc::VideoType::kNV21:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::NV21;
case ::webrtc::VideoType::kNV12:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::NV12;
case ::webrtc::VideoType::kBGRA:
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::BGRA;
default: {
throw hresult_illegal_state_change();
}
}
}
void
VideoCaptureCapability::VideoType(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType const &value)
{
switch (value)
{
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::Unknown: {
videoType = ::webrtc::VideoType::kUnknown;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::I420: {
videoType = ::webrtc::VideoType::kI420;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::IYUV: {
videoType = ::webrtc::VideoType::kIYUV;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::RGB24: {
videoType = ::webrtc::VideoType::kRGB24;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ABGR: {
videoType = ::webrtc::VideoType::kABGR;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ARGB: {
videoType = ::webrtc::VideoType::kARGB;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ARGB4444: {
videoType = ::webrtc::VideoType::kARGB4444;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::RGB565: {
videoType = ::webrtc::VideoType::kRGB565;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::ARGB1555: {
videoType = ::webrtc::VideoType::kARGB1555;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::YUY2: {
videoType = ::webrtc::VideoType::kYUY2;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::YV12: {
videoType = ::webrtc::VideoType::kYV12;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::UYVY: {
videoType = ::webrtc::VideoType::kUYVY;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::MJPEG: {
videoType = ::webrtc::VideoType::kMJPEG;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::NV21: {
videoType = ::webrtc::VideoType::kNV21;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::NV12: {
videoType = ::webrtc::VideoType::kNV12;
break;
}
case Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType::BGRA: {
videoType = ::webrtc::VideoType::kBGRA;
break;
}
default: {
throw hresult_illegal_state_change();
}
}
}
bool
VideoCaptureCapability::Interlaced()
{
return interlaced;
}
void
VideoCaptureCapability::Interlaced(bool value)
{
interlaced = value;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoCaptureCapability.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
// The following APIs are in the works.
struct VideoCaptureCapability : VideoCaptureCapabilityT<VideoCaptureCapability>, ::webrtc::VideoCaptureCapability
{
VideoCaptureCapability() = default;
explicit VideoCaptureCapability(const ::webrtc::VideoCaptureCapability& video_capability);
int32_t Width();
void Width(int32_t value);
int32_t Height();
void Height(int32_t value);
int32_t MaxFPS();
void MaxFPS(int32_t value);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType VideoType();
void VideoType(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoType const &value);
bool Interlaced();
void Interlaced(bool value);
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct VideoCaptureCapability : VideoCaptureCapabilityT<VideoCaptureCapability, implementation::VideoCaptureCapability>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoCaptureFactory.h"
#include "webrtc.VideoCaptureFactory.g.cpp"
// clang-format on
#include "webrtc.VideoCaptureModule_DeviceInfo.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureModule
VideoCaptureFactory::Create(hstring const &device_unique_id)
{
throw hresult_not_implemented();
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureModule_DeviceInfo
VideoCaptureFactory::CreateDeviceInfo()
{
return make<VideoCaptureModule_DeviceInfo>(::webrtc::VideoCaptureFactory::CreateDeviceInfo());
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoCaptureFactory.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoCaptureFactory
{
VideoCaptureFactory() = default;
static Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureModule Create(hstring const &device_unique_id);
static Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureModule_DeviceInfo CreateDeviceInfo();
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct VideoCaptureFactory : VideoCaptureFactoryT<VideoCaptureFactory, implementation::VideoCaptureFactory>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoCaptureModule.h"
#include "webrtc.VideoCaptureModule.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
int32_t
VideoCaptureModule::StartCapture(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability const &capability)
{
throw hresult_not_implemented();
}
int32_t
VideoCaptureModule::StopCapture()
{
throw hresult_not_implemented();
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoCaptureModule.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoCaptureModule : VideoCaptureModuleT<VideoCaptureModule>
{
VideoCaptureModule() = default;
int32_t StartCapture(Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability const &capability);
int32_t StopCapture();
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,117 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoCaptureModule_DeviceInfo.h"
#include "webrtc.VideoCaptureModule_DeviceInfo.g.cpp"
// clang-format on
#include "webrtc.VideoCaptureCapability.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
VideoCaptureModule_DeviceInfo::VideoCaptureModule_DeviceInfo(
::webrtc::VideoCaptureModule::DeviceInfo *webrtc_device_info)
: webrtc_device_info_(webrtc_device_info)
{
}
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::DeviceIdentification>
VideoCaptureModule_DeviceInfo::GetDeviceName()
{
const uint32_t BUFFER_SIZE = 512;
char device_name[BUFFER_SIZE];
char device_unique_id[BUFFER_SIZE];
char product_unique_id[BUFFER_SIZE];
Microsoft::WinRTC::WebRtcWrapper::webrtc::DeviceIdentification device_identification;
std::vector<Microsoft::WinRTC::WebRtcWrapper::webrtc::DeviceIdentification> devices;
const uint32_t number_of_devices = webrtc_device_info_->NumberOfDevices();
for (uint32_t i = 0; i < number_of_devices; ++i)
{
if (webrtc_device_info_->GetDeviceName(i, device_name, BUFFER_SIZE, device_unique_id, BUFFER_SIZE,
product_unique_id, BUFFER_SIZE) != 0)
{
throw hresult_illegal_state_change();
}
device_identification.DeviceName = to_hstring(device_name);
device_identification.DeviceUniqueId = to_hstring(device_unique_id);
device_identification.ProductUniqueId = to_hstring(product_unique_id);
devices.push_back(device_identification);
}
return single_threaded_vector<Microsoft::WinRTC::WebRtcWrapper::webrtc::DeviceIdentification>(move(devices));
}
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability>
VideoCaptureModule_DeviceInfo::GetCapability(hstring const &device_unique_id)
{
std::vector<Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability> capabilities;
std::string device_id = to_string(device_unique_id);
const uint32_t number_of_capabilities = webrtc_device_info_->NumberOfCapabilities(device_id.c_str());
for (uint32_t i = 0; i < number_of_capabilities; ++i)
{
::webrtc::VideoCaptureCapability video_capability;
if (webrtc_device_info_->GetCapability(device_id.c_str(), i, video_capability) != 0)
{
throw hresult_illegal_state_change();
}
capabilities.emplace_back(make<VideoCaptureCapability>(video_capability));
}
return single_threaded_vector<Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability>(move(capabilities));
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability
VideoCaptureModule_DeviceInfo::GetBestMatchedCapability(
hstring const &device_unique_id, Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability const &requested)
{
std::string device_id = to_string(device_unique_id);
::webrtc::VideoCaptureCapability best_video_capability;
if (webrtc_device_info_->GetBestMatchedCapability(device_id.c_str(), *get_self<VideoCaptureCapability>(requested),
best_video_capability) != 0)
{
throw hresult_illegal_state_change();
}
return make<VideoCaptureCapability>(best_video_capability);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoRotation
VideoCaptureModule_DeviceInfo::GetOrientation(hstring const &device_unique_id)
{
std::string device_id = to_string(device_unique_id);
::webrtc::VideoRotation orientation;
if (webrtc_device_info_->GetOrientation(device_id.c_str(), orientation) != 0)
{
throw hresult_illegal_state_change();
}
switch (orientation)
{
case ::webrtc::VideoRotation::kVideoRotation_0: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoRotation::VideoRotation_0;
}
case ::webrtc::VideoRotation::kVideoRotation_90: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoRotation::VideoRotation_90;
}
case ::webrtc::VideoRotation::kVideoRotation_180: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoRotation::VideoRotation_180;
}
case ::webrtc::VideoRotation::kVideoRotation_270: {
return Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoRotation::VideoRotation_270;
}
default: {
throw hresult_illegal_state_change();
}
}
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoCaptureModule_DeviceInfo.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoCaptureModule_DeviceInfo : VideoCaptureModule_DeviceInfoT<VideoCaptureModule_DeviceInfo>
{
VideoCaptureModule_DeviceInfo(::webrtc::VideoCaptureModule::DeviceInfo *webrtc_device_info);
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::DeviceIdentification>
GetDeviceName();
Windows::Foundation::Collections::IVector<Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability>
GetCapability(hstring const &device_unique_id);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability GetBestMatchedCapability(
hstring const &device_unique_id,
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoCaptureCapability const &requested);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoRotation GetOrientation(hstring const &device_unique_id);
private:
std::unique_ptr<::webrtc::VideoCaptureModule::DeviceInfo> webrtc_device_info_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoDecoderFactory.h"
#include "webrtc.VideoDecoderFactory.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
VideoDecoderFactory::VideoDecoderFactory(::std::unique_ptr<::webrtc::VideoDecoderFactory> webrtc_video_decoder_factory)
: webrtc_video_decoder_factory_(move(webrtc_video_decoder_factory))
{
}
::std::unique_ptr<::webrtc::VideoDecoderFactory>
VideoDecoderFactory::get_webrtc_video_decoder_factory()
{
if (webrtc_video_decoder_factory_)
{
return move(webrtc_video_decoder_factory_);
}
else
{
throw hresult_illegal_method_call();
}
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoDecoderFactory.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoDecoderFactory : VideoDecoderFactoryT<VideoDecoderFactory>
{
VideoDecoderFactory(::std::unique_ptr<::webrtc::VideoDecoderFactory> webrtc_video_decoder_factory);
::std::unique_ptr<::webrtc::VideoDecoderFactory> get_webrtc_video_decoder_factory();
private:
::std::unique_ptr<::webrtc::VideoDecoderFactory> webrtc_video_decoder_factory_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoEncoderFactory.h"
#include "webrtc.VideoEncoderFactory.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
VideoEncoderFactory::VideoEncoderFactory(::std::unique_ptr<::webrtc::VideoEncoderFactory> webrtc_video_encoder_factory)
: webrtc_video_encoder_factory_(move(webrtc_video_encoder_factory))
{
}
::std::unique_ptr<::webrtc::VideoEncoderFactory>
VideoEncoderFactory::get_webrtc_video_encoder_factory()
{
if (webrtc_video_encoder_factory_)
{
return move(webrtc_video_encoder_factory_);
}
else
{
throw hresult_illegal_method_call();
}
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoEncoderFactory.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoEncoderFactory : VideoEncoderFactoryT<VideoEncoderFactory>
{
VideoEncoderFactory(::std::unique_ptr<::webrtc::VideoEncoderFactory> webrtc_video_encoder_factory);
::std::unique_ptr<::webrtc::VideoEncoderFactory> get_webrtc_video_encoder_factory();
private:
::std::unique_ptr<::webrtc::VideoEncoderFactory> webrtc_video_encoder_factory_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,45 @@
#include "pch.h"
#include "webrtc.VideoFrame.Builder.h"
#include "webrtc.VideoFrame.Builder.g.cpp"
#include "webrtc.VideoFrame.VideoFrame.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::implementation
{
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::VideoFrame Builder::Build()
{
throw 10;
//return make<winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::implementation::VideoFrame>(
// webrtc_video_frame_builder_.build());
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder Builder::SetTimestampMs(int64_t timestamp_ms)
{
webrtc_video_frame_builder_.set_timestamp_ms(timestamp_ms);
return *get_abi(this);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder Builder::SetTimestampUs(int64_t timestamp_us)
{
webrtc_video_frame_builder_.set_timestamp_us(timestamp_us);
return *get_abi(this);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder Builder::SetTimestampRtp(uint32_t timestamp_rtp)
{
webrtc_video_frame_builder_.set_timestamp_rtp(timestamp_rtp);
return *get_abi(this);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder Builder::SetNtpTimeMs(int64_t ntp_time_ms)
{
webrtc_video_frame_builder_.set_ntp_time_ms(ntp_time_ms);
return *get_abi(this);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder Builder::SetId(uint16_t id)
{
webrtc_video_frame_builder_.set_id(id);
return *get_abi(this);
}
}

Просмотреть файл

@ -0,0 +1,25 @@
#pragma once
#include "webrtc.VideoFrame.Builder.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::implementation
{
struct Builder : BuilderT<Builder>
{
Builder() = default;
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::VideoFrame Build();
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder SetTimestampMs(int64_t timestamp_ms);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder SetTimestampUs(int64_t timestamp_us);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder SetTimestampRtp(uint32_t timestamp_rtp);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder SetNtpTimeMs(int64_t ntp_time_ms);
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::Builder SetId(uint16_t id);
::webrtc::VideoFrame::Builder webrtc_video_frame_builder_;
};
}
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::factory_implementation
{
struct Builder : BuilderT<Builder, implementation::Builder>
{
};
}

Просмотреть файл

@ -0,0 +1,29 @@
#include "pch.h"
#include "webrtc.VideoFrame.VideoFrame.h"
#include "webrtc.VideoFrame.VideoFrame.g.cpp"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::implementation
{
//VideoFrame::VideoFrame(::webrtc::VideoFrame webrtc_videoframe) :
// webrtc_videoframe_(webrtc_videoframe)
//{
//}
int32_t VideoFrame::Width()
{
throw 10;
//return webrtc_videoframe_.width();
}
int32_t VideoFrame::Height()
{
throw 10;
//return webrtc_videoframe_.height();
}
uint32_t VideoFrame::Size()
{
throw 10;
//return webrtc_videoframe_.size();
}
}

Просмотреть файл

@ -0,0 +1,18 @@
#pragma once
#include "webrtc.VideoFrame.VideoFrame.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoFrame::implementation
{
struct VideoFrame : VideoFrameT<VideoFrame>
{
VideoFrame() = default;
// VideoFrame(::webrtc::VideoFrame webrtc_videoframe);
int32_t Width();
int32_t Height();
uint32_t Size();
//::webrtc::VideoFrame webrtc_videoframe_;
};
}

Просмотреть файл

@ -0,0 +1,117 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoSink_VideoFrame.h"
#include "webrtc.VideoSink_VideoFrame.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoRenderer : public ::rtc::VideoSinkInterface<::webrtc::VideoFrame>
{
winrt::Microsoft::Graphics::Canvas::CanvasDevice _canvasDevice;
winrt::Windows::UI::Composition::CompositionDrawingSurface _surface{nullptr};
winrt::Windows::UI::Composition::SpriteVisual visual_{nullptr};
VideoRenderer(const winrt::Windows::UI::Composition::VisualCollection &visual_collection)
{
VideoRendererAsync(visual_collection);
}
~VideoRenderer()
{
}
void
VideoRendererAsync(const winrt::Windows::UI::Composition::VisualCollection &visual_collection)
{
winrt::Windows::UI::Composition::Compositor compositor = visual_collection.Compositor();
winrt::Windows::UI::Composition::CompositionGraphicsDevice compositionGraphicsDevice =
winrt::Microsoft::Graphics::Canvas::UI::Composition::CanvasComposition::CreateCompositionGraphicsDevice(
compositor, _canvasDevice);
_surface = compositionGraphicsDevice.CreateDrawingSurface(
{0, 0}, winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized,
winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied);
winrt::Windows::UI::Composition::CompositionSurfaceBrush brush = compositor.CreateSurfaceBrush(_surface);
brush.HorizontalAlignmentRatio(.5);
brush.VerticalAlignmentRatio(.5);
brush.Stretch(winrt::Windows::UI::Composition::CompositionStretch::Uniform);
visual_ = compositor.CreateSpriteVisual();
visual_.Brush(brush);
visual_collection.InsertAtTop(visual_);
}
void
OnFrame(const ::webrtc::VideoFrame &frame) override
{
::rtc::scoped_refptr<::webrtc::I420BufferInterface> buffer(frame.video_frame_buffer()->ToI420());
::webrtc::VideoRotation rotation = frame.rotation();
if (rotation != ::webrtc::kVideoRotation_0)
{
buffer = ::webrtc::I420Buffer::Rotate(*buffer, rotation);
}
int32_t width = buffer->width();
int32_t height = buffer->height();
visual_.Size({static_cast<float>(width), static_cast<float>(height)});
size_t bits = 32;
size_t size = width * height * (bits >> 3);
std::unique_ptr<uint8_t[]> data(new uint8_t[size]);
::libyuv::I420ToARGB(buffer->DataY(), buffer->StrideY(), buffer->DataU(), buffer->StrideU(), buffer->DataV(),
buffer->StrideV(), data.get(), width * bits / 8, width, height);
PaintFrameAsync(std::move(data), size, width, height);
}
void
PaintFrameAsync(std::unique_ptr<uint8_t[]> data, size_t length, int32_t width, int32_t height)
{
auto raw = data.get();
auto view = winrt::array_view<uint8_t const>(raw, raw + length);
auto bitmap = winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(
_canvasDevice, view, width, height,
winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized);
if (_surface.Size() != bitmap.Size())
winrt::Microsoft::Graphics::Canvas::UI::Composition::CanvasComposition::Resize(_surface, bitmap.Size());
winrt::Microsoft::Graphics::Canvas::CanvasDrawingSession drawingSession =
winrt::Microsoft::Graphics::Canvas::UI::Composition::CanvasComposition::CreateDrawingSession(_surface);
{
drawingSession.Clear(winrt::Windows::UI::Colors::Transparent());
drawingSession.DrawImage(bitmap);
}
drawingSession.Close();
}
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
VideoSink_VideoFrame::VideoSink_VideoFrame(const winrt::Windows::UI::Composition::VisualCollection &visual_collection)
: webrtc_video_sink_video_frame_(new VideoRenderer(visual_collection))
{
}
VideoSink_VideoFrame::~VideoSink_VideoFrame()
{
delete static_cast<VideoRenderer *>(webrtc_video_sink_video_frame_);
}
::rtc::VideoSinkInterface<::webrtc::VideoFrame> *
VideoSink_VideoFrame::get_webrtc_video_sink_video_frame() const
{
return static_cast<VideoRenderer *>(webrtc_video_sink_video_frame_);
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoSink_VideoFrame.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoSink_VideoFrame : VideoSink_VideoFrameT<VideoSink_VideoFrame>
{
VideoSink_VideoFrame(const winrt::Windows::UI::Composition::VisualCollection &visual_collection);
~VideoSink_VideoFrame();
::rtc::VideoSinkInterface<::webrtc::VideoFrame> *get_webrtc_video_sink_video_frame() const;
private:
void *webrtc_video_sink_video_frame_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct VideoSink_VideoFrame : VideoSink_VideoFrameT<VideoSink_VideoFrame, implementation::VideoSink_VideoFrame>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoTrack.h"
#include "webrtc.VideoTrack.g.cpp"
// clang-format on
#include "webrtc.VideoSink_VideoFrame.h"
#include "rtc.VideoSinkWants.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
VideoTrack::VideoTrack(::rtc::scoped_refptr<::webrtc::VideoTrackInterface> video_track)
: VideoTrackT<VideoTrack, Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::MediaStreamTrack>(video_track),
webrtc_video_track_(video_track)
{
}
::rtc::scoped_refptr<::webrtc::VideoTrackInterface>
VideoTrack::get_webrtc_video_track()
{
return webrtc_video_track_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.MediaStreamTrack.h"
#include "webrtc.VideoTrack.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoTrack : VideoTrackT<VideoTrack, Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation::MediaStreamTrack>
{
VideoTrack(::rtc::scoped_refptr<::webrtc::VideoTrackInterface> video_track);
::rtc::scoped_refptr<::webrtc::VideoTrackInterface> get_webrtc_video_track();
private:
::rtc::scoped_refptr<::webrtc::VideoTrackInterface> webrtc_video_track_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,222 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.VideoTrackSource.h"
#include "webrtc.VideoTrackSource.g.cpp"
// clang-format on
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
// FIXME(auright): This entire class needs to be refactored.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
class QuickVideoCapture : public ::rtc::VideoSourceInterface<::webrtc::VideoFrame>
{
public:
class FramePreprocessor
{
public:
virtual ~FramePreprocessor() = default;
virtual ::webrtc::VideoFrame Preprocess(const ::webrtc::VideoFrame &frame) = 0;
};
~QuickVideoCapture() override;
void AddOrUpdateSink(::rtc::VideoSinkInterface<::webrtc::VideoFrame> *sink,
const ::rtc::VideoSinkWants &wants) override;
void RemoveSink(::rtc::VideoSinkInterface<::webrtc::VideoFrame> *sink) override;
void
SetFramePreprocessor(std::unique_ptr<FramePreprocessor> preprocessor)
{
::rtc::CritScope crit(&lock_);
preprocessor_ = std::move(preprocessor);
}
protected:
void OnFrame(const ::webrtc::VideoFrame &frame);
::rtc::VideoSinkWants GetSinkWants();
private:
void UpdateVideoAdapter();
::webrtc::VideoFrame MaybePreprocess(const ::webrtc::VideoFrame &frame);
::rtc::CriticalSection lock_;
std::unique_ptr<FramePreprocessor> preprocessor_ RTC_GUARDED_BY(lock_);
::rtc::VideoBroadcaster broadcaster_;
::cricket::VideoAdapter video_adapter_;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
QuickVideoCapture::~QuickVideoCapture() = default;
void
QuickVideoCapture::OnFrame(const ::webrtc::VideoFrame &original_frame)
{
int cropped_width = 0;
int cropped_height = 0;
int out_width = 0;
int out_height = 0;
::webrtc::VideoFrame frame = MaybePreprocess(original_frame);
if (!video_adapter_.AdaptFrameResolution(frame.width(), frame.height(), frame.timestamp_us() * 1000, &cropped_width,
&cropped_height, &out_width, &out_height))
{
// Drop frame in order to respect frame rate constraint.
return;
}
if (out_height != frame.height() || out_width != frame.width())
{
// Video adapter has requested a down-scale. Allocate a new buffer and
// return scaled version.
// For simplicity, only scale here without cropping.
::rtc::scoped_refptr<::webrtc::I420Buffer> scaled_buffer = ::webrtc::I420Buffer::Create(out_width, out_height);
scaled_buffer->ScaleFrom(*frame.video_frame_buffer()->ToI420());
::webrtc::VideoFrame::Builder new_frame_builder = ::webrtc::VideoFrame::Builder()
.set_video_frame_buffer(scaled_buffer)
.set_rotation(::webrtc::VideoRotation::kVideoRotation_0)
.set_timestamp_us(frame.timestamp_us())
.set_id(frame.id());
if (frame.has_update_rect())
{
::webrtc::VideoFrame::UpdateRect new_rect = frame.update_rect().ScaleWithFrame(
frame.width(), frame.height(), 0, 0, frame.width(), frame.height(), out_width, out_height);
new_frame_builder.set_update_rect(new_rect);
}
broadcaster_.OnFrame(new_frame_builder.build());
}
else
{
// No adaptations needed, just return the frame as is.
broadcaster_.OnFrame(frame);
}
}
::rtc::VideoSinkWants
QuickVideoCapture::GetSinkWants()
{
return broadcaster_.wants();
}
void
QuickVideoCapture::AddOrUpdateSink(::rtc::VideoSinkInterface<::webrtc::VideoFrame> *sink,
const ::rtc::VideoSinkWants &wants)
{
broadcaster_.AddOrUpdateSink(sink, wants);
UpdateVideoAdapter();
}
void
QuickVideoCapture::RemoveSink(::rtc::VideoSinkInterface<::webrtc::VideoFrame> *sink)
{
broadcaster_.RemoveSink(sink);
UpdateVideoAdapter();
}
void
QuickVideoCapture::UpdateVideoAdapter()
{
video_adapter_.OnSinkWants(broadcaster_.wants());
}
::webrtc::VideoFrame
QuickVideoCapture::MaybePreprocess(const ::webrtc::VideoFrame &frame)
{
::rtc::CritScope crit(&lock_);
if (preprocessor_ != nullptr)
{
return preprocessor_->Preprocess(frame);
}
else
{
return frame;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct QuickVideoCapturer : public ::rtc::VideoSinkInterface<::webrtc::VideoFrame>, public QuickVideoCapture
{
::rtc::scoped_refptr<::webrtc::VideoCaptureModule> _videoCaptureModule;
QuickVideoCapturer()
{
std::unique_ptr<::webrtc::VideoCaptureModule::DeviceInfo> device_info(
::webrtc::VideoCaptureFactory::CreateDeviceInfo());
char id[256];
device_info->GetDeviceName(0, nullptr, 0, id, sizeof(id), nullptr, 0);
::webrtc::VideoCaptureCapability capability;
device_info->GetCapability(id, 0, capability);
_videoCaptureModule = ::webrtc::VideoCaptureFactory::Create(id);
_videoCaptureModule->RegisterCaptureDataCallback(this);
_videoCaptureModule->StartCapture(capability);
_videoCaptureModule->CaptureStarted();
}
~QuickVideoCapturer()
{
_videoCaptureModule->StopCapture();
_videoCaptureModule->DeRegisterCaptureDataCallback();
}
void
OnFrame(const ::webrtc::VideoFrame &frame) override
{
QuickVideoCapture::OnFrame(frame);
}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct QuickVideoTrackSource : public ::webrtc::VideoTrackSource
{
QuickVideoCapturer video_capturer_;
QuickVideoTrackSource() : ::webrtc::VideoTrackSource(false)
{
}
::rtc::VideoSourceInterface<::webrtc::VideoFrame> *
source() override
{
return &video_capturer_;
}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
VideoTrackSource::VideoTrackSource() : webrtc_video_track_source_(new ::rtc::RefCountedObject<QuickVideoTrackSource>())
{
}
VideoTrackSource::~VideoTrackSource()
{
}
::rtc::scoped_refptr<::webrtc::VideoTrackSourceInterface>
VideoTrackSource::get_webrtc_video_track_source()
{
return webrtc_video_track_source_;
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.VideoTrackSource.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct VideoTrackSource : VideoTrackSourceT<VideoTrackSource>
{
VideoTrackSource();
~VideoTrackSource();
::rtc::scoped_refptr<::webrtc::VideoTrackSourceInterface> get_webrtc_video_track_source();
private:
::rtc::scoped_refptr<::webrtc::VideoTrackSourceInterface> webrtc_video_track_source_;
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct VideoTrackSource : VideoTrackSourceT<VideoTrackSource, implementation::VideoTrackSource>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation

Просмотреть файл

@ -0,0 +1,88 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// clang-format off
#include "pch.h"
#include "webrtc.WebRTC.h"
#include "webrtc.WebRTC.g.cpp"
// clang-format on
#include "webrtc.AudioDecoderFactory.h"
#include "webrtc.AudioEncoderFactory.h"
#include "webrtc.IceCandidate.h"
#include "webrtc.SessionDescription.h"
#include "webrtc.VideoDecoderFactory.h"
#include "webrtc.VideoEncoderFactory.h"
using winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType;
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
hstring
WebRTC::SdpTypeToString(SdpType const &sdp_type)
{
return SessionDescription::SdpTypeToString(sdp_type);
}
SdpType
WebRTC::SdpTypeFromString(hstring const &type_str)
{
return SessionDescription::SdpTypeFromString(type_str);
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::SessionDescription
WebRTC::CreateSessionDescription(SdpType const &type, hstring const &sdp)
{
return make<SessionDescription>(
::webrtc::CreateSessionDescription(SessionDescription::to_webrtc_sdp_type(type), to_string(sdp)));
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::IceCandidate
WebRTC::CreateIceCandidate(hstring const &sdp_mid, int32_t sdp_mline_index, hstring const &sdp)
{
::webrtc::SdpParseError sdp_parse_error;
const ::webrtc::IceCandidateInterface *ice_candidate =
::webrtc::CreateIceCandidate(to_string(sdp_mid), sdp_mline_index, to_string(sdp), &sdp_parse_error);
if (ice_candidate)
{
return make<IceCandidate>(ice_candidate);
}
else
{
std::wstringstream ss;
ss << L"SdpParserError\r\n";
ss << sdp_parse_error.description.c_str();
ss << L"\r\n";
ss << sdp_parse_error.line.c_str();
ss << L"\r\n";
throw hresult_invalid_argument(to_hstring(ss.str().c_str()));
}
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioDecoderFactory
WebRTC::CreateBuiltinAudioDecoderFactory()
{
return make<AudioDecoderFactory>(::webrtc::CreateBuiltinAudioDecoderFactory());
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioEncoderFactory
WebRTC::CreateBuiltinAudioEncoderFactory()
{
return make<AudioEncoderFactory>(::webrtc::CreateBuiltinAudioEncoderFactory());
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoEncoderFactory
WebRTC::CreateBuiltinVideoEncoderFactory()
{
return make<VideoEncoderFactory>(::webrtc::CreateBuiltinVideoEncoderFactory());
}
Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoDecoderFactory
WebRTC::CreateBuiltinVideoDecoderFactory()
{
return make<VideoDecoderFactory>(::webrtc::CreateBuiltinVideoDecoderFactory());
}
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#pragma once
#include "webrtc.WebRTC.g.h"
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
{
struct WebRTC
{
WebRTC() = default;
static Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioDecoderFactory CreateBuiltinAudioDecoderFactory();
static Microsoft::WinRTC::WebRtcWrapper::webrtc::AudioEncoderFactory CreateBuiltinAudioEncoderFactory();
static Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoDecoderFactory CreateBuiltinVideoDecoderFactory();
static Microsoft::WinRTC::WebRtcWrapper::webrtc::VideoEncoderFactory CreateBuiltinVideoEncoderFactory();
static Microsoft::WinRTC::WebRtcWrapper::webrtc::SessionDescription CreateSessionDescription(
Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType const &type, hstring const &sdp);
static Microsoft::WinRTC::WebRtcWrapper::webrtc::IceCandidate CreateIceCandidate(hstring const &sdp_mid,
int32_t sdp_mline_index,
hstring const &sdp);
static Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType SdpTypeFromString(hstring const &type_str);
static hstring SdpTypeToString(Microsoft::WinRTC::WebRtcWrapper::webrtc::SdpType const &sdp_type);
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::implementation
namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation
{
struct WebRTC : WebRTCT<WebRTC, implementation::WebRTC>
{
};
} // namespace winrt::Microsoft::WinRTC::WebRtcWrapper::webrtc::factory_implementation