提交 f462f5c4 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

SRTP in PlainRtpTransport may be done. Not tested.

上级 5dd9a605
...@@ -85,6 +85,8 @@ export declare type PlainRtpTransportStat = { ...@@ -85,6 +85,8 @@ export declare type PlainRtpTransportStat = {
export declare class PlainRtpTransport extends Transport { export declare class PlainRtpTransport extends Transport {
/** /**
* @private * @private
* @emits tuple - (tuple: TransportTuple)
* @emits rtcpTuple - (rtcpTuple: TransportTuple)
* @emits sctpstatechange - (sctpState: SctpState) * @emits sctpstatechange - (sctpState: SctpState)
* @emits trace - (trace: TransportTraceEventData) * @emits trace - (trace: TransportTraceEventData)
*/ */
...@@ -96,7 +98,7 @@ export declare class PlainRtpTransport extends Transport { ...@@ -96,7 +98,7 @@ export declare class PlainRtpTransport extends Transport {
/** /**
* Transport RTCP tuple. * Transport RTCP tuple.
*/ */
get rtcpTuple(): TransportTuple; get rtcpTuple(): TransportTuple | undefined;
/** /**
* SCTP parameters. * SCTP parameters.
*/ */
...@@ -118,6 +120,8 @@ export declare class PlainRtpTransport extends Transport { ...@@ -118,6 +120,8 @@ export declare class PlainRtpTransport extends Transport {
* @emits newconsumer - (producer: Producer) * @emits newconsumer - (producer: Producer)
* @emits newdataproducer - (dataProducer: DataProducer) * @emits newdataproducer - (dataProducer: DataProducer)
* @emits newdataconsumer - (dataProducer: DataProducer) * @emits newdataconsumer - (dataProducer: DataProducer)
* @emits tuple - (tuple: TransportTuple)
* @emits rtcpTuple - (rtcpTuple: TransportTuple)
* @emits sctpstatechange - (sctpState: SctpState) * @emits sctpstatechange - (sctpState: SctpState)
* @emits trace - (trace: TransportTraceEventData) * @emits trace - (trace: TransportTraceEventData)
*/ */
...@@ -147,8 +151,8 @@ export declare class PlainRtpTransport extends Transport { ...@@ -147,8 +151,8 @@ export declare class PlainRtpTransport extends Transport {
* @override * @override
*/ */
connect({ ip, port, rtcpPort, srtpParameters }: { connect({ ip, port, rtcpPort, srtpParameters }: {
ip: string; ip?: string;
port: number; port?: number;
rtcpPort?: number; rtcpPort?: number;
srtpParameters?: SrtpParameters; srtpParameters?: SrtpParameters;
}): Promise<void>; }): Promise<void>;
......
{"version":3,"file":"PlainRtpTransport.d.ts","sourceRoot":"","sources":["../src/PlainRtpTransport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACN,SAAS,EACT,iBAAiB,EACjB,cAAc,EAEd,SAAS,EACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnE,oBAAY,wBAAwB,GACpC;IACC;;OAEG;IACH,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAAC;IAErC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;CACd,CAAA;AAED,oBAAY,qBAAqB,GACjC;IAEC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC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AED;;OAEG;IACH,IAAI,SAAS,IAAI,cAAc,GAAG,SAAS,CAG1C;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,cAAc,GAAG,SAAS,CAG/C;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,SAAS,CAGzB;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,cAAc,GAAG,SAAS,CAG/C;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,QAAQ,IAAI,oBAAoB,CAGnC;IAED;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAWb;;;;;OAKG;IACH,YAAY,IAAI,IAAI;IAWpB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAOlD;;;;OAIG;IACG,OAAO,CACZ,EACC,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,EACD;QACC,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,cAAc,CAAC;KAChC,GACC,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQzD,OAAO,CAAC,0BAA0B;CAmElC"}
\ No newline at end of file \ No newline at end of file
...@@ -31,6 +31,8 @@ class PlainRtpTransport extends Transport_1.Transport { ...@@ -31,6 +31,8 @@ class PlainRtpTransport extends Transport_1.Transport {
// - .keyBase64 // - .keyBase64
/** /**
* @private * @private
* @emits tuple - (tuple: TransportTuple)
* @emits rtcpTuple - (rtcpTuple: TransportTuple)
* @emits sctpstatechange - (sctpState: SctpState) * @emits sctpstatechange - (sctpState: SctpState)
* @emits trace - (trace: TransportTraceEventData) * @emits trace - (trace: TransportTraceEventData)
*/ */
...@@ -87,6 +89,8 @@ class PlainRtpTransport extends Transport_1.Transport { ...@@ -87,6 +89,8 @@ class PlainRtpTransport extends Transport_1.Transport {
* @emits newconsumer - (producer: Producer) * @emits newconsumer - (producer: Producer)
* @emits newdataproducer - (dataProducer: DataProducer) * @emits newdataproducer - (dataProducer: DataProducer)
* @emits newdataconsumer - (dataProducer: DataProducer) * @emits newdataconsumer - (dataProducer: DataProducer)
* @emits tuple - (tuple: TransportTuple)
* @emits rtcpTuple - (rtcpTuple: TransportTuple)
* @emits sctpstatechange - (sctpState: SctpState) * @emits sctpstatechange - (sctpState: SctpState)
* @emits trace - (trace: TransportTraceEventData) * @emits trace - (trace: TransportTraceEventData)
*/ */
...@@ -137,8 +141,10 @@ class PlainRtpTransport extends Transport_1.Transport { ...@@ -137,8 +141,10 @@ class PlainRtpTransport extends Transport_1.Transport {
const reqData = { ip, port, rtcpPort, srtpParameters }; const reqData = { ip, port, rtcpPort, srtpParameters };
const data = await this._channel.request('transport.connect', this._internal, reqData); const data = await this._channel.request('transport.connect', this._internal, reqData);
// Update data. // Update data.
this._data.tuple = data.tuple; if (data.tuple)
this._data.rtcpTuple = data.rtcpTuple; this._data.tuple = data.tuple;
if (data.rtcpTuple)
this._data.rtcpTuple = data.rtcpTuple;
this._data.srtpParameters = data.srtpParameters; this._data.srtpParameters = data.srtpParameters;
} }
/** /**
...@@ -154,6 +160,24 @@ class PlainRtpTransport extends Transport_1.Transport { ...@@ -154,6 +160,24 @@ class PlainRtpTransport extends Transport_1.Transport {
_handleWorkerNotifications() { _handleWorkerNotifications() {
this._channel.on(this._internal.transportId, (event, data) => { this._channel.on(this._internal.transportId, (event, data) => {
switch (event) { switch (event) {
case 'tuple':
{
const tuple = data.tuple;
this._data.tuple = tuple;
this.safeEmit('tuple', tuple);
// Emit observer event.
this._observer.safeEmit('tuple', tuple);
break;
}
case 'rtcpTuple':
{
const rtcpTuple = data.rtcpTuple;
this._data.rtcpTuple = rtcpTuple;
this.safeEmit('rtcpTuple', rtcpTuple);
// Emit observer event.
this._observer.safeEmit('rtcpTuple', rtcpTuple);
break;
}
case 'sctpstatechange': case 'sctpstatechange':
{ {
const sctpState = data.sctpState; const sctpState = data.sctpState;
......
...@@ -138,6 +138,8 @@ export class PlainRtpTransport extends Transport ...@@ -138,6 +138,8 @@ export class PlainRtpTransport extends Transport
/** /**
* @private * @private
* @emits tuple - (tuple: TransportTuple)
* @emits rtcpTuple - (rtcpTuple: TransportTuple)
* @emits sctpstatechange - (sctpState: SctpState) * @emits sctpstatechange - (sctpState: SctpState)
* @emits trace - (trace: TransportTraceEventData) * @emits trace - (trace: TransportTraceEventData)
*/ */
...@@ -172,7 +174,7 @@ export class PlainRtpTransport extends Transport ...@@ -172,7 +174,7 @@ export class PlainRtpTransport extends Transport
/** /**
* Transport RTCP tuple. * Transport RTCP tuple.
*/ */
get rtcpTuple(): TransportTuple get rtcpTuple(): TransportTuple | undefined
{ {
return this._data.rtcpTuple; return this._data.rtcpTuple;
} }
...@@ -210,6 +212,8 @@ export class PlainRtpTransport extends Transport ...@@ -210,6 +212,8 @@ export class PlainRtpTransport extends Transport
* @emits newconsumer - (producer: Producer) * @emits newconsumer - (producer: Producer)
* @emits newdataproducer - (dataProducer: DataProducer) * @emits newdataproducer - (dataProducer: DataProducer)
* @emits newdataconsumer - (dataProducer: DataProducer) * @emits newdataconsumer - (dataProducer: DataProducer)
* @emits tuple - (tuple: TransportTuple)
* @emits rtcpTuple - (rtcpTuple: TransportTuple)
* @emits sctpstatechange - (sctpState: SctpState) * @emits sctpstatechange - (sctpState: SctpState)
* @emits trace - (trace: TransportTraceEventData) * @emits trace - (trace: TransportTraceEventData)
*/ */
...@@ -276,8 +280,8 @@ export class PlainRtpTransport extends Transport ...@@ -276,8 +280,8 @@ export class PlainRtpTransport extends Transport
srtpParameters srtpParameters
}: }:
{ {
ip: string; ip?: string;
port: number; port?: number;
rtcpPort?: number; rtcpPort?: number;
srtpParameters?: SrtpParameters; srtpParameters?: SrtpParameters;
} }
...@@ -291,8 +295,12 @@ export class PlainRtpTransport extends Transport ...@@ -291,8 +295,12 @@ export class PlainRtpTransport extends Transport
await this._channel.request('transport.connect', this._internal, reqData); await this._channel.request('transport.connect', this._internal, reqData);
// Update data. // Update data.
this._data.tuple = data.tuple; if (data.tuple)
this._data.rtcpTuple = data.rtcpTuple; this._data.tuple = data.tuple;
if (data.rtcpTuple)
this._data.rtcpTuple = data.rtcpTuple;
this._data.srtpParameters = data.srtpParameters; this._data.srtpParameters = data.srtpParameters;
} }
...@@ -315,6 +323,34 @@ export class PlainRtpTransport extends Transport ...@@ -315,6 +323,34 @@ export class PlainRtpTransport extends Transport
{ {
switch (event) switch (event)
{ {
case 'tuple':
{
const tuple = data.tuple as TransportTuple;
this._data.tuple = tuple;
this.safeEmit('tuple', tuple);
// Emit observer event.
this._observer.safeEmit('tuple', tuple);
break;
}
case 'rtcpTuple':
{
const rtcpTuple = data.rtcpTuple as TransportTuple;
this._data.rtcpTuple = rtcpTuple;
this.safeEmit('rtcpTuple', rtcpTuple);
// Emit observer event.
this._observer.safeEmit('rtcpTuple', rtcpTuple);
break;
}
case 'sctpstatechange': case 'sctpstatechange':
{ {
const sctpState = data.sctpState as SctpState; const sctpState = data.sctpState as SctpState;
......
...@@ -35,6 +35,7 @@ namespace RTC ...@@ -35,6 +35,7 @@ namespace RTC
private: private:
bool IsConnected() const override; bool IsConnected() const override;
bool HasSrtp() const; bool HasSrtp() const;
bool IsSrtpReady() const;
void SendRtpPacket(RTC::RtpPacket* packet, RTC::Transport::onSendCallback* cb = nullptr) override; void SendRtpPacket(RTC::RtpPacket* packet, RTC::Transport::onSendCallback* cb = nullptr) override;
void SendRtcpPacket(RTC::RTCP::Packet* packet) override; void SendRtcpPacket(RTC::RTCP::Packet* packet) override;
void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override;
...@@ -69,6 +70,7 @@ namespace RTC ...@@ -69,6 +70,7 @@ namespace RTC
}; };
std::string srtpKey; std::string srtpKey;
std::string srtpKeyBase64; std::string srtpKeyBase64;
bool connectCalled{ false }; // Whether connect() was succesfully called.
}; };
} // namespace RTC } // namespace RTC
......
...@@ -115,7 +115,7 @@ namespace RTC ...@@ -115,7 +115,7 @@ namespace RTC
RTC::Transport::FillJson(jsonObject); RTC::Transport::FillJson(jsonObject);
// Add tuple. // Add tuple.
if (this->tuple != nullptr) if (this->tuple)
{ {
this->tuple->FillJson(jsonObject["tuple"]); this->tuple->FillJson(jsonObject["tuple"]);
} }
...@@ -159,7 +159,7 @@ namespace RTC ...@@ -159,7 +159,7 @@ namespace RTC
// Add type. // Add type.
jsonObject["type"] = "pipe-transport"; jsonObject["type"] = "pipe-transport";
if (this->tuple != nullptr) if (this->tuple)
{ {
this->tuple->FillJson(jsonObject["tuple"]); this->tuple->FillJson(jsonObject["tuple"]);
} }
...@@ -188,7 +188,7 @@ namespace RTC ...@@ -188,7 +188,7 @@ namespace RTC
case Channel::Request::MethodId::TRANSPORT_CONNECT: case Channel::Request::MethodId::TRANSPORT_CONNECT:
{ {
// Ensure this method is not called twice. // Ensure this method is not called twice.
if (this->tuple != nullptr) if (this->tuple)
MS_THROW_ERROR("connect() already called"); MS_THROW_ERROR("connect() already called");
try try
...@@ -333,7 +333,7 @@ namespace RTC ...@@ -333,7 +333,7 @@ namespace RTC
reinterpret_cast<struct sockaddr_in*>(&this->remoteAddrStorage)); reinterpret_cast<struct sockaddr_in*>(&this->remoteAddrStorage));
if (err != 0) if (err != 0)
MS_ABORT("uv_ip4_addr() failed: %s", uv_strerror(err)); MS_THROW_ERROR("uv_ip4_addr() failed: %s", uv_strerror(err));
break; break;
} }
...@@ -346,7 +346,7 @@ namespace RTC ...@@ -346,7 +346,7 @@ namespace RTC
reinterpret_cast<struct sockaddr_in6*>(&this->remoteAddrStorage)); reinterpret_cast<struct sockaddr_in6*>(&this->remoteAddrStorage));
if (err != 0) if (err != 0)
MS_ABORT("uv_ip6_addr() failed: %s", uv_strerror(err)); MS_THROW_ERROR("uv_ip6_addr() failed: %s", uv_strerror(err));
break; break;
} }
...@@ -402,7 +402,7 @@ namespace RTC ...@@ -402,7 +402,7 @@ namespace RTC
inline bool PipeTransport::IsConnected() const inline bool PipeTransport::IsConnected() const
{ {
return this->tuple != nullptr; return this->tuple;
} }
inline bool PipeTransport::HasSrtp() const inline bool PipeTransport::HasSrtp() const
...@@ -533,14 +533,6 @@ namespace RTC ...@@ -533,14 +533,6 @@ namespace RTC
if (!IsConnected()) if (!IsConnected())
return; return;
// Verify that the packet's tuple matches our tuple.
if (!this->tuple->Compare(tuple))
{
MS_DEBUG_TAG(rtp, "ignoring RTP packet from unknown IP:port");
return;
}
// Decrypt the SRTP packet. // Decrypt the SRTP packet.
if (HasSrtp() && !this->srtpRecvSession->DecryptSrtp(const_cast<uint8_t*>(data), &len)) if (HasSrtp() && !this->srtpRecvSession->DecryptSrtp(const_cast<uint8_t*>(data), &len))
{ {
...@@ -565,6 +557,14 @@ namespace RTC ...@@ -565,6 +557,14 @@ namespace RTC
return; return;
} }
// Verify that the packet's tuple matches our tuple.
if (!this->tuple->Compare(tuple))
{
MS_DEBUG_TAG(rtp, "ignoring RTP packet from unknown IP:port");
return;
}
RTC::RtpPacket* packet = RTC::RtpPacket::Parse(data, len); RTC::RtpPacket* packet = RTC::RtpPacket::Parse(data, len);
if (packet == nullptr) if (packet == nullptr)
...@@ -586,6 +586,12 @@ namespace RTC ...@@ -586,6 +586,12 @@ namespace RTC
if (!IsConnected()) if (!IsConnected())
return; return;
// Decrypt the SRTCP packet.
if (HasSrtp() && !this->srtpRecvSession->DecryptSrtcp(const_cast<uint8_t*>(data), &len))
{
return;
}
// Verify that the packet's tuple matches our tuple. // Verify that the packet's tuple matches our tuple.
if (!this->tuple->Compare(tuple)) if (!this->tuple->Compare(tuple))
{ {
...@@ -594,10 +600,6 @@ namespace RTC ...@@ -594,10 +600,6 @@ namespace RTC
return; return;
} }
// Decrypt the SRTCP packet.
if (HasSrtp() && !this->srtpRecvSession->DecryptSrtcp(const_cast<uint8_t*>(data), &len))
return;
RTC::RTCP::Packet* packet = RTC::RTCP::Packet::Parse(data, len); RTC::RTCP::Packet* packet = RTC::RTCP::Packet::Parse(data, len);
if (packet == nullptr) if (packet == nullptr)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论