Composant RTC Peer Connection — sgcWebRTC | eSeGeCe

RTC Peer Connection

TsgcRTCPeerConnection — le seul composant derrière sgcWebRTC : connectivité ICE/TURN, signalisation SDP manuelle offre/réponse (RFC 8829 JSEP), transport chiffré DTLS-SRTP, canaux de données SCTP (RFC 8831/8832) et pistes audio/vidéo RTP, en Delphi et C++ Builder.

TsgcRTCPeerConnection

Configure RTCOptions, raccorde les événements SDP et ICE, puis pilote toi-même l'échange offre/réponse ou ouvre un canal de données et laisse CreateOffer s'en charger. Construit sur le même transport ICE/DTLS que le composant de base de sgcWebSockets Enterprise.

Classe du composant

TsgcRTCPeerConnection

Unité

sgcP2P (réexporte sgcP2P_RTCPeerConnection)

Standards

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

Langages

Delphi, C++ Builder

Ajoute une piste vidéo et propose-la

Attache une piste avec AddTrack, raccorde les événements SDP, puis appelle CreateOffer. Envoie aSDP au pair distant sur ton propre canal de signalisation et fais transiter sa réponse par 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);

Propriétés, méthodes & événements clés

Les membres que tu utiliseras le plus souvent. Voir la matrice des fonctionnalités pour le détail complet par capacité.

Configuration

RTCOptions regroupe ICE, ICEServers, DTLS / DTLSOptions, Media (contrôle de congestion, FEC, lissage, RTX) et les réglages historiques de signalisation WebSocket.

Signalisation

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

État

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

Canaux de données

CreateDataChannel, DataChannelCount, DataChannels[i], OnDataChannel.

Pistes média

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

Événements

OnLocalDescription, OnICECandidate, OnConnectionStateChange, OnNegotiationNeeded, OnError, plus la famille historique OnRTCConnect / OnRTCCandidatePairNominated / OnRTCException.

Continue d'explorer

Aide en ligneRéférence API complète et guide d'utilisation de TsgcRTCPeerConnection.
Matrice complète des fonctionnalitésAudio, vidéo, canaux de données, partage d'écran, SRTP et estimation de bande passante.
Télécharger l'essai gratuitExécute la connexion pair à pair contre un navigateur ou un autre pair natif.
TarifsLicences Single, Team et Site avec code source complet.
Meilleur rapport qualité-prix : All-AccessTous les produits eSeGeCe, Support Premium inclus, à partir de €1,059/an.
Voir les tarifs All-Access

Prêt à te lancer ?

Télécharge l'essai gratuit et ouvre une connexion pair à pair depuis Delphi ou C++ Builder.