示例#1
0
        /// <summary>
        /// <para>Events:</para>
        /// <para>@emits icestatechange - (iceState: IceState)</para>
        /// <para>@emits iceselectedtuplechange - (iceSelectedTuple: TransportTuple)</para>
        /// <para>@emits dtlsstatechange - (dtlsState: DtlsState)</para>
        /// <para>@emits sctpstatechange - (sctpState: SctpState)</para>
        /// <para>@emits trace - (trace: TransportTraceEventData)</para>
        /// <para>Observer events:</para>
        /// <para>@emits close</para>
        /// <para>@emits newproducer - (producer: Producer)</para>
        /// <para>@emits newconsumer - (consumer: Consumer)</para>
        /// <para>@emits newdataproducer - (dataProducer: DataProducer)</para>
        /// <para>@emits newdataconsumer - (dataConsumer: DataConsumer)</para>
        /// <para>@emits icestatechange - (iceState: IceState)</para>
        /// <para>@emits iceselectedtuplechange - (iceSelectedTuple: TransportTuple)</para>
        /// <para>@emits dtlsstatechange - (dtlsState: DtlsState)</para>
        /// <para>@emits sctpstatechange - (sctpState: SctpState)</para>
        /// <para>@emits trace - (trace: TransportTraceEventData)</para>
        /// </summary>
        /// <param name="loggerFactory"></param>
        /// <param name="transportInternalData"></param>
        /// <param name="sctpParameters"></param>
        /// <param name="sctpState"></param>
        /// <param name="channel"></param>
        /// <param name="payloadChannel"></param>
        /// <param name="appData"></param>
        /// <param name="getRouterRtpCapabilities"></param>
        /// <param name="getProducerById"></param>
        /// <param name="getDataProducerById"></param>
        /// <param name="iceRole"></param>
        /// <param name="iceParameters"></param>
        /// <param name="iceCandidates"></param>
        /// <param name="iceState"></param>
        /// <param name="iceSelectedTuple"></param>
        /// <param name="dtlsParameters"></param>
        /// <param name="dtlsState"></param>
        /// <param name="dtlsRemoteCert"></param>
        public WebRtcTransport(ILoggerFactory loggerFactory,
                               TransportInternalData transportInternalData,
                               SctpParameters?sctpParameters,
                               SctpState?sctpState,
                               Channel channel,
                               PayloadChannel payloadChannel,
                               Dictionary <string, object>?appData,
                               Func <RtpCapabilities> getRouterRtpCapabilities,
                               Func <string, Producer?> getProducerById,
                               Func <string, DataProducer?> getDataProducerById,
                               string iceRole,
                               IceParameters iceParameters,
                               IceCandidate[] iceCandidates,
                               IceState iceState,
                               TransportTuple?iceSelectedTuple,
                               DtlsParameters dtlsParameters,
                               DtlsState dtlsState,
                               string?dtlsRemoteCert) : base(loggerFactory, transportInternalData, sctpParameters, sctpState, channel, payloadChannel, appData, getRouterRtpCapabilities, getProducerById, getDataProducerById)
        {
            _logger = loggerFactory.CreateLogger <WebRtcTransport>();

            // Data
            IceRole          = iceRole;
            IceParameters    = iceParameters;
            IceCandidates    = iceCandidates;
            IceState         = iceState;
            IceSelectedTuple = iceSelectedTuple;
            DtlsParameters   = dtlsParameters;
            DtlsState        = dtlsState;
            DtlsRemoteCert   = dtlsRemoteCert;

            HandleWorkerNotifications();
        }
示例#2
0
        private async Task ConnectAsync(DtlsParameters dtlsParameters)
        {
            var reqData = new { DtlsParameters = dtlsParameters };
            var resData = await Channel.RequestAsync(MethodId.TRANSPORT_CONNECT, Internal, reqData);

            if (resData == null)
            {
                throw new Exception($"{nameof(resData)} is null");
            }
            var responseData = JsonSerializer.Deserialize <WebRtcTransportConnectResponseData>(resData, ObjectExtensions.DefaultJsonSerializerOptions) !;

            // Update data.
            DtlsParameters.Role = responseData.DtlsLocalRole;
        }