RTC Peer Connection 컴포넌트 — sgcWebRTC | eSeGeCe

RTC Peer Connection

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

유닛

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 계열입니다.

계속 살펴보기

온라인 도움말TsgcRTCPeerConnection의 전체 API 레퍼런스와 사용 가이드입니다.
전체 기능 매트릭스오디오, 영상, 데이터 채널, 화면 공유, SRTP, 대역폭 추정입니다.
무료 체험판 다운로드브라우저나 다른 네이티브 피어를 대상으로 피어 연결을 실행해 보세요.
가격전체 소스 코드가 포함된 Single, Team, Site 라이선스입니다.
최고의 가성비: All-Access모든 eSeGeCe 제품과 프리미엄 지원이 포함되어 연 €1,059부터 이용할 수 있어요.
All-Access 가격 보기

시작할 준비가 되셨나요?

무료 체험판을 다운로드하고 Delphi 또는 C++ Builder에서 피어 연결을 열어 보세요.