Componente RTC Peer Connection — sgcWebRTC | eSeGeCe

RTC Peer Connection

TsgcRTCPeerConnection — il componente unico dietro sgcWebRTC: connettività ICE/TURN, segnalazione SDP offer/answer manuale (JSEP RFC 8829), trasporto crittografato DTLS-SRTP, canali dati SCTP (RFC 8831/8832) e tracce audio/video RTP, in Delphi e C++ Builder.

TsgcRTCPeerConnection

Imposta RTCOptions, aggancia gli eventi SDP e ICE, poi guida tu stesso lo scambio offer/answer oppure apri un canale dati e lascia che sia CreateOffer a farlo. Costruito sullo stesso trasporto ICE/DTLS del componente base in sgcWebSockets Enterprise.

Classe del componente

TsgcRTCPeerConnection

Unità

sgcP2P (riesporta sgcP2P_RTCPeerConnection)

Standard

RFC 8445, 8489, 8656, 8827, 5764, 8831, 8832, 3550, 3711, 8829

Linguaggi

Delphi, C++ Builder

Aggiungi una traccia video e offrila

Collega una traccia con AddTrack, aggancia gli eventi SDP, poi chiama CreateOffer. Invia aSDP al peer remoto sul tuo canale di segnalazione e restituisci la sua risposta tramite 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);

Proprietà, metodi ed eventi principali

I membri che userai più spesso. Consulta la matrice delle funzionalità per il quadro completo per capacità.

Configurazione

RTCOptions contiene ICE, ICEServers, DTLS / DTLSOptions, Media (controllo della congestione, FEC, pacing, RTX) e le impostazioni di segnalazione legacy WebSocket.

Segnalazione

CreateOffer, CreateAnswer, SetLocalDescription, SetRemoteDescription, AddIceCandidate, RestartIce, Close.

Stato

ConnectionState, SignalingState, LocalDescription, RemoteDescription, Renegotiating, NegotiationNeeded, Polite, TrickleICE.

Canali dati

CreateDataChannel, DataChannelCount, DataChannels[i], OnDataChannel.

Tracce media

AddTrack, RemoveTrack, TrackCount, Tracks[i], OnTrack.

Eventi

OnLocalDescription, OnICECandidate, OnConnectionStateChange, OnNegotiationNeeded, OnError, più la famiglia legacy OnRTCConnect / OnRTCCandidatePairNominated / OnRTCException.

Continua a esplorare

Guida onlineRiferimento completo dell'API e guida all'uso di TsgcRTCPeerConnection.
Matrice completa delle funzionalitàAudio, video, canali dati, condivisione schermo, SRTP e stima della banda.
Scarica la versione di provaEsegui la connessione peer contro un browser o un altro peer nativo.
PrezziLicenze Single, Team e Site con codice sorgente completo.
La scelta più conveniente: All-AccessTutti i prodotti eSeGeCe, con Supporto Premium incluso, a partire da €1,059/anno.
Vedi i prezzi All-Access

Pronto per iniziare?

Scarica la versione di prova gratuita e apri una connessione peer da Delphi o C++ Builder.