RTC Peer Connection
TsgcRTCPeerConnection — sgcWebRTC를 이루는 단 하나의 컴포넌트입니다: ICE/TURN 연결, 수동 SDP 오퍼/앤서 시그널링(RFC 8829 JSEP), DTLS-SRTP 암호화 전송, SCTP 데이터 채널(RFC 8831/8832), RTP 오디오/영상 트랙을 Delphi와 C++ Builder에서 제공합니다.
TsgcRTCPeerConnection — sgcWebRTC를 이루는 단 하나의 컴포넌트입니다: ICE/TURN 연결, 수동 SDP 오퍼/앤서 시그널링(RFC 8829 JSEP), DTLS-SRTP 암호화 전송, SCTP 데이터 채널(RFC 8831/8832), RTP 오디오/영상 트랙을 Delphi와 C++ Builder에서 제공합니다.
RTCOptions를 설정하고 SDP 및 ICE 이벤트를 연결한 다음, 오퍼/앤서 교환을 직접 처리하거나 데이터 채널을 열어 CreateOffer가 대신 처리하도록 합니다. sgcWebSockets Enterprise의 기본 컴포넌트와 동일한 ICE/DTLS 전송 위에 구축되었습니다.
TsgcRTCPeerConnection
sgcP2P(sgcP2P_RTCPeerConnection을 재노출)
RFC 8445, 8489, 8656, 8827, 5764, 8831, 8832, 3550, 3711, 8829
Delphi, C++ Builder
AddTrack으로 트랙을 연결하고, SDP 이벤트를 연결한 다음 CreateOffer를 호출합니다. aSDP를 자신의 시그널링 채널을 통해 원격 피어에 전달하고, 그 앤서를 SetRemoteDescription으로 다시 전달합니다.
uses
sgcP2P;
var
oRTC: TsgcRTCPeerConnection;
oTrack: TsgcRTCTrack;
begin
oRTC := TsgcRTCPeerConnection.Create(nil);
oRTC.RTCOptions.ICEServers.AddURL('stun:stun.l.google.com:19302');
oRTC.OnLocalDescription := OnLocalDescriptionHandler;
oRTC.OnICECandidate := OnICECandidateHandler;
oRTC.OnConnectionStateChange := OnConnectionStateChangeHandler;
oRTC.OnTrack := OnTrackHandler;
oTrack := oRTC.AddTrack(rtctkVideo, cctVideoH264);
oTrack.OnEncodedFrame := OnEncodedFrameHandler; // remote frames, once negotiated
oRTC.CreateOffer; // gathers ICE candidates, builds the SDP offer, fires OnLocalDescription
end;
procedure TForm1.OnLocalDescriptionHandler(Sender: TObject;
const aType, aSDP: string);
begin
// send { type: aType, sdp: aSDP } to the remote peer
end;
// once the remote answer arrives over your signaling channel:
oRTC.SetRemoteDescription('answer', vRemoteSDP);
// and for every remote ICE candidate it sends:
oRTC.AddIceCandidate(vCandidate, vSdpMid, vSdpMLineIndex);
// includes: sgcP2P.hpp
TsgcRTCPeerConnection *oRTC = new TsgcRTCPeerConnection(NULL);
oRTC->RTCOptions->ICEServers->AddURL("stun:stun.l.google.com:19302");
oRTC->OnLocalDescription = OnLocalDescriptionHandler;
oRTC->OnICECandidate = OnICECandidateHandler;
oRTC->OnConnectionStateChange = OnConnectionStateChangeHandler;
oRTC->OnTrack = OnTrackHandler;
TsgcRTCTrack *oTrack = oRTC->AddTrack(rtctkVideo, cctVideoH264);
oTrack->OnEncodedFrame = OnEncodedFrameHandler; // remote frames, once negotiated
oRTC->CreateOffer(); // gathers ICE candidates, builds the SDP offer, fires OnLocalDescription
void __fastcall TForm1::OnLocalDescriptionHandler(TObject *Sender,
const String aType, const String aSDP)
{
// send { type: aType, sdp: aSDP } to the remote peer
}
// once the remote answer arrives over your signaling channel:
oRTC->SetRemoteDescription("answer", vRemoteSDP);
// and for every remote ICE candidate it sends:
oRTC->AddIceCandidate(vCandidate, vSdpMid, vSdpMLineIndex);
RTCOptions에는 ICE, ICEServers, DTLS / DTLSOptions, Media(혼잡 제어, FEC, 페이싱, RTX)와 레거시 WebSocket 시그널링 설정이 있습니다.
CreateOffer, CreateAnswer, SetLocalDescription, SetRemoteDescription, AddIceCandidate, RestartIce, Close.
ConnectionState, SignalingState, LocalDescription, RemoteDescription, Renegotiating, NegotiationNeeded, Polite, TrickleICE.
CreateDataChannel, DataChannelCount, DataChannels[i], OnDataChannel.
AddTrack, RemoveTrack, TrackCount, Tracks[i], OnTrack.
OnLocalDescription, OnICECandidate, OnConnectionStateChange, OnNegotiationNeeded, OnError, 그리고 레거시 OnRTCConnect / OnRTCCandidatePairNominated / OnRTCException 계열입니다.