Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Followup on #661 #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
672 changes: 376 additions & 296 deletions 672 .circleci/config.yml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions 10 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.4.7
=====

New Features
------------

- Updated to WebRTC M87. Check the WebRTC release notes for changes included in
M82—M87.
- Added support for RTCRtpTransceiverDirection "stopped".

0.4.6
=====

Expand Down
22 changes: 3 additions & 19 deletions 22 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,14 @@ The following platforms are confirmed to work with node-webrtc and have prebuilt
</thead>
<tbody>
<tr>
<th rowspan="6">Node</th>
<th>8</th>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
</tr>
<tr>
<th rowspan="4">Node</th>
<th>10</th>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
</tr>
<tr>
<th>11</th>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
</tr>
<tr>
<th>12</th>
<td align="center">✓</td>
Expand All @@ -74,15 +58,15 @@ The following platforms are confirmed to work with node-webrtc and have prebuilt
<td align="center">✓</td>
</tr>
<tr>
<th>13</th>
<th>14</th>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
</tr>
<tr>
<th>14</th>
<th>15</th>
<td align="center">✓</td>
<td align="center">✓</td>
<td align="center">✓</td>
Expand Down
2 changes: 1 addition & 1 deletion 2 appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ environment:
node_pre_gyp_secretAccessKey:
secure: NVvJWst8RJXhz/G0Gu+dpljZz5iNT0ko4sPybD313JuIn2wAf9xGDnKEipmY1mow
matrix:
- nodejs_version: "8"
- nodejs_version: "10"
platform: x64
msvs_toolset: 15
CHECK_REFLEXIVE: true
Expand Down
1 change: 1 addition & 0 deletions 1 lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = {
RTCIceTransport,
RTCPeerConnection: require('./peerconnection'),
RTCPeerConnectionIceEvent: require('./rtcpeerconnectioniceevent'),
RTCPeerConnectionIceErrorEvent: require('./rtcpeerconnectioniceerrorevent'),
RTCRtpReceiver,
RTCRtpSender,
RTCRtpTransceiver,
Expand Down
3 changes: 0 additions & 3 deletions 3 lib/peerconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ function RTCPeerConnection() {
};

pc.onicecandidateerror = function onicecandidateerror(eventInitDict) {
var pair = eventInitDict.hostCandidate.split(':');
eventInitDict.address = pair[0];
eventInitDict.port = pair[1];
eventInitDict.target = self;
var icecandidateerror = new RTCPeerConnectionIceErrorEvent('icecandidateerror', eventInitDict);
self.dispatchEvent(icecandidateerror);
Expand Down
26 changes: 8 additions & 18 deletions 26 scripts/build-appveyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,23 @@ ECHO npm run lint
CALL npm run lint
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

@REM ECHO Test using Node 8
@REM SET nodejs_version=8
@REM CALL scripts\run-tests.bat
@REM IF %ERRORLEVEL% NEQ 0 GOTO ERROR

@REM ECHO Test using Node 10
@REM SET nodejs_version=10
@REM CALL scripts\run-tests.bat
@REM IF %ERRORLEVEL% NEQ 0 GOTO ERROR

@REM ECHO Test using Node 11
@REM SET nodejs_version=11
@REM CALL scripts\run-tests.bat
@REM IF %ERRORLEVEL% NEQ 0 GOTO ERROR
ECHO Test using Node 10
SET nodejs_version=10
CALL scripts\run-tests.bat
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

ECHO Test using Node 12
SET nodejs_version=12
CALL scripts\run-tests.bat
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

ECHO Test using Node 13
SET nodejs_version=13
ECHO Test using Node 14
SET nodejs_version=14
CALL scripts\run-tests.bat
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

ECHO Test using Node 14
SET nodejs_version=14
ECHO Test using Node 15
SET nodejs_version=15
CALL scripts\run-tests.bat
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

Expand Down
3 changes: 2 additions & 1 deletion 3 src/dictionaries/rtc_peer_connection_on_ice_error_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

#define RTC_PEER_CONNECTION_ICE_ERROR_EVENT RTCPeerConnectionIceErrorEvent
#define RTC_PEER_CONNECTION_ICE_ERROR_EVENT_LIST \
DICT_REQUIRED(std::string, hostCandidate, "hostCandidate") \
DICT_REQUIRED(std::string, address, "address") \
DICT_REQUIRED(int, port, "port") \
DICT_REQUIRED(std::string, url, "url") \
DICT_REQUIRED(uint8_t, errorCode, "errorCoode") \
DICT_REQUIRED(std::string, errorText, "errorText")
Expand Down
4 changes: 2 additions & 2 deletions 4 src/dictionaries/webrtc/data_channel_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ static Validation<webrtc::DataChannelInit> DATA_CHANNEL_INIT_FN(
}
webrtc::DataChannelInit init;
init.ordered = ordered;
init.maxRetransmitTime = maxPacketLifeTime.Map([](auto i) { return static_cast<int>(i); }).FromMaybe(-1);
init.maxRetransmits = maxRetransmits.Map([](auto i) { return static_cast<int>(i); }).FromMaybe(-1);
init.maxRetransmitTime = maxPacketLifeTime.Map([](auto i) { return absl::make_optional(static_cast<int>(i)); }).FromMaybe(absl::optional<int>());
init.maxRetransmits = maxRetransmits.Map([](auto i) { return absl::make_optional(static_cast<int>(i)); }).FromMaybe(absl::optional<int>());
init.protocol = protocol;
init.negotiated = negotiated;
init.id = id.Map([](auto i) { return static_cast<int>(i); }).FromMaybe(-1);
Expand Down
1 change: 1 addition & 0 deletions 1 src/dictionaries/webrtc/rtc_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ TO_NAPI_IMPL(const webrtc::RTCError*, pair) {
case webrtc::RTCErrorType::NONE:
return Validation<Napi::Value>::Invalid("No error? Please file a bug on https://github.com/node-webrtc/node-webrtc");
case webrtc::RTCErrorType::UNSUPPORTED_PARAMETER:
return Pure(scope.Escape(ErrorFactory::CreateInvalidModificationError(env, error->message())));
case webrtc::RTCErrorType::INVALID_PARAMETER:
return Pure(scope.Escape(ErrorFactory::CreateInvalidAccessError(env, error->message())));
case webrtc::RTCErrorType::INVALID_RANGE:
Expand Down
25 changes: 10 additions & 15 deletions 25 src/dictionaries/webrtc/rtp_encoding_parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,28 @@ static Validation<webrtc::RtpEncodingParameters> RTP_ENCODING_PARAMETERS_FN(
const node_webrtc::Maybe<uint64_t> maxBitrate,
const node_webrtc::Maybe<double> maxFramerate,
const node_webrtc::Maybe<double> scaleResolutionDownBy) {
// NOTE(mroberts): No longer supported in WebRTC 1.0.
(void) codecPayloadType;
(void) dtx;
(void) priority;
(void) ptime;

webrtc::RtpEncodingParameters parameters;
if (rid.IsJust()) {
parameters.rid = rid.UnsafeFromJust();
}
if (ssrc.IsJust()) {
parameters.ssrc = absl::optional<uint32_t>(ssrc.UnsafeFromJust());
}
if (codecPayloadType.IsJust()) {
// NOTE(mroberts): No longer supported in WebRTC 1.0.
}
if (dtx.IsJust()) {
// NOTE(mroberts): No longer supported in WebRTC 1.0.
parameters.ssrc = ssrc.UnsafeFromJust();
}
parameters.active = active;
// TODO(mroberts): Do something with this.
(void) priority;
if (ptime.IsJust()) {
// NOTE(mroberts): No longer supported in WebRTC 1.0.
}
if (maxBitrate.IsJust()) {
parameters.max_bitrate_bps = absl::optional<int>(maxBitrate.UnsafeFromJust());
parameters.max_bitrate_bps = maxBitrate.UnsafeFromJust();
}
if (maxFramerate.IsJust()) {
parameters.max_framerate = absl::optional<int>(maxFramerate.UnsafeFromJust());
parameters.max_framerate = maxFramerate.UnsafeFromJust();
}
if (scaleResolutionDownBy.IsJust()) {
parameters.scale_resolution_down_by = absl::optional<double>(scaleResolutionDownBy.UnsafeFromJust());
parameters.scale_resolution_down_by = scaleResolutionDownBy.UnsafeFromJust();
}
return Pure(parameters);
}
Expand Down
17 changes: 10 additions & 7 deletions 17 src/dictionaries/webrtc/rtp_parameters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

#include <webrtc/api/rtp_parameters.h>

#include "src/converters/absl.h"
#include "src/converters/object.h"
#include "src/enums/webrtc/degradation_preference.h"
#include "src/functional/maybe.h"
#include "src/dictionaries/macros/napi.h"
#include "src/dictionaries/webrtc/rtcp_parameters.h"
#include "src/dictionaries/webrtc/rtp_codec_parameters.h"
Expand All @@ -27,10 +29,9 @@ TO_NAPI_IMPL(webrtc::RtpParameters, pair) {
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "codecs", parameters.codecs)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "rtcp", parameters.rtcp)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "encodings", parameters.encodings)
// TODO: fix this
// if (parameters.degradation_preference != webrtc::DegradationPreference::BALANCED) {
// NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "degradationPreference", parameters.degradation_preference)
// }
if (parameters.degradation_preference && parameters.degradation_preference != webrtc::DegradationPreference::BALANCED) {
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "degradationPreference", parameters.degradation_preference)
}
return Pure(scope.Escape(object));
}

Expand All @@ -40,14 +41,16 @@ static webrtc::RtpParameters NapiToRtpParameters(
webrtc::RtcpParameters rtcp,
std::vector<webrtc::RtpCodecParameters> codecs,
std::vector<webrtc::RtpEncodingParameters> encodings,
webrtc::DegradationPreference degradationPreference) {
node_webrtc::Maybe<webrtc::DegradationPreference> degradationPreference) {
webrtc::RtpParameters parameters;
parameters.transaction_id = transactionId;
parameters.header_extensions = headerExtensions;
parameters.rtcp = rtcp;
parameters.codecs = codecs;
parameters.encodings = encodings;
parameters.degradation_preference = degradationPreference;
parameters.degradation_preference = degradationPreference
.Map([](auto degradationPreference) { return absl::make_optional(static_cast<webrtc::DegradationPreference>(degradationPreference)); })
.FromMaybe(absl::optional<webrtc::DegradationPreference>());
return parameters;
}

Expand All @@ -59,7 +62,7 @@ FROM_NAPI_IMPL(webrtc::RtpParameters, value) {
* GetRequired<webrtc::RtcpParameters>(object, "rtcp")
* GetRequired<std::vector<webrtc::RtpCodecParameters>>(object, "codecs")
* GetRequired<std::vector<webrtc::RtpEncodingParameters>>(object, "encodings")
* GetOptional<webrtc::DegradationPreference>(object, "degradationPreference", webrtc::DegradationPreference::BALANCED);
* GetOptional<webrtc::DegradationPreference>(object, "degradationPreference");
});
}

Expand Down
3 changes: 2 additions & 1 deletion 3 src/enums/webrtc/rtp_transceiver_direction.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
ENUM_SUPPORTED(RTP_TRANSCEIVER_DIRECTION::kSendRecv, "sendrecv") \
ENUM_SUPPORTED(RTP_TRANSCEIVER_DIRECTION::kSendOnly, "sendonly") \
ENUM_SUPPORTED(RTP_TRANSCEIVER_DIRECTION::kRecvOnly, "recvonly") \
ENUM_SUPPORTED(RTP_TRANSCEIVER_DIRECTION::kInactive, "inactive")
ENUM_SUPPORTED(RTP_TRANSCEIVER_DIRECTION::kInactive, "inactive") \
ENUM_SUPPORTED(RTP_TRANSCEIVER_DIRECTION::kStopped, "stopped")

#define ENUM(X) RTP_TRANSCEIVER_DIRECTION ## X
#include "src/enums/macros/decls.h"
Expand Down
3 changes: 2 additions & 1 deletion 3 src/enums/webrtc/video_frame_buffer_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
ENUM_SUPPORTED(VIDEO_FRAME_BUFFER_TYPE::kI420, "I420") \
ENUM_SUPPORTED(VIDEO_FRAME_BUFFER_TYPE::kI420A, "I420A") \
ENUM_SUPPORTED(VIDEO_FRAME_BUFFER_TYPE::kI444, "I444") \
ENUM_SUPPORTED(VIDEO_FRAME_BUFFER_TYPE::kI010, "I010")
ENUM_SUPPORTED(VIDEO_FRAME_BUFFER_TYPE::kI010, "I010") \
ENUM_SUPPORTED(VIDEO_FRAME_BUFFER_TYPE::kNV12, "NV12")

#define ENUM(X) VIDEO_FRAME_BUFFER_TYPE ## X
#include "src/enums/macros/decls.h"
Expand Down
4 changes: 4 additions & 0 deletions 4 src/interfaces/media_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Napi::FunctionReference& MediaStream::constructor() {
return constructor;
}

MediaStream::~MediaStream() {
wrap()->Release(this);
}

MediaStream::Impl::Impl(PeerConnectionFactory* factory)
: _factory(factory ? factory : PeerConnectionFactory::GetOrCreateDefault())
, _stream(_factory->factory()->CreateLocalMediaStream(rtc::CreateRandomUuid()))
Expand Down
4 changes: 3 additions & 1 deletion 4 src/interfaces/media_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ struct RTCMediaStreamInit;
class MediaStream
: public Napi::ObjectWrap<MediaStream> {
public:
MediaStream(const Napi::CallbackInfo&);
explicit MediaStream(const Napi::CallbackInfo&);

~MediaStream();

static void Init(Napi::Env, Napi::Object);

Expand Down
1 change: 1 addition & 0 deletions 1 src/interfaces/rtc_dtls_transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ RTCDtlsTransport::~RTCDtlsTransport() {
Napi::HandleScope scope(PeerConnectionFactory::constructor().Env());
_factory->Unref();
_factory = nullptr;
wrap()->Release(this);
} // NOLINT

void RTCDtlsTransport::Stop() {
Expand Down
31 changes: 21 additions & 10 deletions 31 src/interfaces/rtc_peer_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <webrtc/p2p/client/basic_port_allocator.h>

#include "src/converters.h"
#include "src/converters/absl.h"
#include "src/converters/arguments.h"
#include "src/converters/interfaces.h"
#include "src/converters/napi.h"
Expand Down Expand Up @@ -163,25 +164,28 @@ void RTCPeerConnection::OnIceCandidate(const webrtc::IceCandidateInterface* ice_
}

static Validation<Napi::Value> CreateRTCPeerConnectionIceErrorEvent(
const Napi::Value hostCandidate,
const Napi::Value address,
const Napi::Value port,
const Napi::Value url,
const Napi::Value errorCode,
const Napi::Value errorText) {
auto env = hostCandidate.Env();
auto env = address.Env();
Napi::EscapableHandleScope scope(env);
NODE_WEBRTC_CREATE_OBJECT_OR_RETURN(env, object)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "hostCandidate", hostCandidate)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "address", address)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "port", port)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "url", url)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "errorCode", errorCode)
NODE_WEBRTC_CONVERT_AND_SET_OR_RETURN(env, object, "errorText", errorText)
return Pure(scope.Escape(object));
}

void RTCPeerConnection::OnIceCandidateError(const std::string& host_candidate, const std::string& url, int error_code, const std::string& error_text) {
Dispatch(CreateCallback<RTCPeerConnection>([this, host_candidate, url, error_code, error_text]() {
void RTCPeerConnection::OnIceCandidateError(const std::string& address, int port, const std::string& url, int error_code, const std::string& error_text) {
Dispatch(CreateCallback<RTCPeerConnection>([this, address, port, url, error_code, error_text]() {
auto env = Env();
auto maybeEvent = Validation<Napi::Value>::Join(curry(CreateRTCPeerConnectionIceErrorEvent)
% From<Napi::Value>(std::make_pair(env, host_candidate))
% From<Napi::Value>(std::make_pair(env, address))
* From<Napi::Value>(std::make_pair(env, port))
* From<Napi::Value>(std::make_pair(env, url))
* From<Napi::Value>(std::make_pair(env, error_code))
* From<Napi::Value>(std::make_pair(env, error_text)));
Expand Down Expand Up @@ -315,9 +319,10 @@ Napi::Value RTCPeerConnection::RemoveTrack(const Napi::CallbackInfo& info) {
Napi::Error(env, ErrorFactory::CreateInvalidAccessError(env, "Cannot removeTrack")).ThrowAsJavaScriptException();
return env.Undefined();
}
if (!_jinglePeerConnection->RemoveTrack(sender->sender())) {
Napi::Error(env, ErrorFactory::CreateInvalidAccessError(env, "Cannot removeTrack")).ThrowAsJavaScriptException();
return env.Undefined();
auto error = _jinglePeerConnection->RemoveTrackNew(sender->sender());
if (!error.ok()) {
CONVERT_OR_THROW_AND_RETURN_NAPI(info.Env(), &error, result, Napi::Value)
Napi::Error(info.Env(), result).ThrowAsJavaScriptException();
}
return env.Undefined();
}
Expand Down Expand Up @@ -618,7 +623,13 @@ Napi::Value RTCPeerConnection::RestartIce(const Napi::CallbackInfo& info) {
}

Napi::Value RTCPeerConnection::GetCanTrickleIceCandidates(const Napi::CallbackInfo& info) {
return info.Env().Null();
auto env = info.Env();
if (!_jinglePeerConnection) {
return env.Null();
}
auto canTrickleIceCandidates = _jinglePeerConnection->can_trickle_ice_candidates();
CONVERT_OR_THROW_AND_RETURN_NAPI(env, canTrickleIceCandidates, result, Napi::Value)
return result;
}

Napi::Value RTCPeerConnection::GetConnectionState(const Napi::CallbackInfo& info) {
Expand Down
2 changes: 1 addition & 1 deletion 2 src/interfaces/rtc_peer_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RTCPeerConnection
void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
void OnIceCandidateError(const std::string& host_candidate, const std::string& url, int error_code, const std::string& error_text) override;
void OnIceCandidateError(const std::string& address, int port, const std::string& url, int error_code, const std::string& error_text) override;
void OnRenegotiationNeeded() override;

void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.