RTC ピア接続
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 系イベントです。