RTC ピア接続コンポーネント — sgcWebRTC | eSeGeCe

RTC ピア接続

TsgcRTCPeerConnection — sgcWebRTC の裏にある唯一のコンポーネントです。ICE/TURN 接続性、手動の SDP オファー/アンサーシグナリング(RFC 8829 JSEP)、DTLS-SRTP 暗号化トランスポート、SCTP データチャネル(RFC 8831/8832)、RTP 音声/映像トラックを、Delphi と C++ Builder で提供します。

TsgcRTCPeerConnection

RTCOptions を設定し、SDP と ICE のイベントをフックしてから、オファー/アンサーの交換をご自身で駆動するか、データチャネルを開いて CreateOffer に任せます。sgcWebSockets Enterprise の基本コンポーネントと同じ ICE/DTLS トランスポートの上に構築されています。

コンポーネントクラス

TsgcRTCPeerConnection

ユニット

sgcP2PsgcP2P_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 は、ICEICEServersDTLS / DTLSOptionsMedia(輻輳制御、FEC、ペーシング、RTX)、そして従来型の WebSocket シグナリング設定を保持します。

シグナリング

CreateOfferCreateAnswerSetLocalDescriptionSetRemoteDescriptionAddIceCandidateRestartIceClose

状態

ConnectionStateSignalingStateLocalDescriptionRemoteDescriptionRenegotiatingNegotiationNeededPoliteTrickleICE

データチャネル

CreateDataChannelDataChannelCountDataChannels[i]OnDataChannel

メディアトラック

AddTrackRemoveTrackTrackCountTracks[i]OnTrack

イベント

OnLocalDescriptionOnICECandidateOnConnectionStateChangeOnNegotiationNeededOnError、加えて従来型の OnRTCConnect / OnRTCCandidatePairNominated / OnRTCException 系イベントです。

さらに詳しく

オンラインヘルプTsgcRTCPeerConnection の完全な API リファレンスと使用ガイドです。
完全な機能マトリックス音声、映像、データチャネル、画面共有、SRTP、帯域幅推定です。
無料体験版をダウンロードブラウザーや別のネイティブピアに対して、ピア接続を実行できます。
価格完全なソースコード付きの Single、Team、Site ライセンス。
最もお得な選択: All-AccesseSeGeCe の全製品にプレミアムサポートが付いて、年間 €1,059 からご利用いただけます。
All-Access の価格を見る

始める準備はできましたか?

無料体験版をダウンロードして、Delphi や C++ Builder からピア接続を開きましょう。