Componente de conexión de pares RTC — sgcWebRTC | eSeGeCe

Conexión de pares RTC

TsgcRTCPeerConnection — el único componente detrás de sgcWebRTC: conectividad ICE/TURN, señalización manual de oferta/respuesta SDP (RFC 8829 JSEP), transporte cifrado DTLS-SRTP, canales de datos SCTP (RFC 8831/8832) y pistas de audio/vídeo RTP, en Delphi y C++ Builder.

TsgcRTCPeerConnection

Configura RTCOptions, engancha los eventos de SDP e ICE, y luego dirige tú mismo el intercambio de oferta/respuesta o abre un canal de datos y deja que lo haga CreateOffer. Construido sobre el mismo transporte ICE/DTLS que el componente base en sgcWebSockets Enterprise.

Clase del componente

TsgcRTCPeerConnection

Unidad

sgcP2P (reexporta sgcP2P_RTCPeerConnection)

Estándares

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

Lenguajes

Delphi, C++ Builder

Añade una pista de vídeo y ofrécela

Adjunta una pista con AddTrack, engancha los eventos de SDP y luego llama a CreateOffer. Envía aSDP al par remoto por tu propio canal de señalización y devuelve su respuesta a través de 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);

Propiedades, métodos y eventos clave

Los miembros que más usarás. Consulta la matriz de características para el desglose completo por capacidad.

Configuración

RTCOptions contiene ICE, ICEServers, DTLS / DTLSOptions, Media (control de congestión, FEC, pacing, RTX) y los ajustes heredados de señalización WebSocket.

Señalización

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

Estado

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

Canales de datos

CreateDataChannel, DataChannelCount, DataChannels[i], OnDataChannel.

Pistas de medios

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

Eventos

OnLocalDescription, OnICECandidate, OnConnectionStateChange, OnNegotiationNeeded, OnError, además de la familia heredada OnRTCConnect / OnRTCCandidatePairNominated / OnRTCException.

Sigue explorando

Ayuda en líneaReferencia completa de la API y guía de uso de TsgcRTCPeerConnection.
Matriz de características completaAudio, vídeo, canales de datos, uso compartido de pantalla, SRTP y estimación de ancho de banda.
Descargar prueba gratuitaEjecuta la conexión de pares contra un navegador u otro par nativo.
PreciosLicencias Single, Team y Site con código fuente completo.
La mejor opción: All-AccessTodos los productos de eSeGeCe, con Premium Support incluido, desde €1,059 al año.
Ver precios de All-Access

¿Listo para empezar?

Descarga la prueba gratuita y abre una conexión de pares desde Delphi o C++ Builder.