Skip to content

Commit 298f8b8

Browse files
committed
Add setStreams support
1 parent 300cf43 commit 298f8b8

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ New Features
88
- Added support for `sendEncodings` to RTCRtpEncodingParameters, including
99
`rid`, `ssrc`, `codecPayloadType`, `dtx`, `active`, `ptime`, `maxBitrate`,
1010
`maxFramerate`, and `scaleResolutionDownBy`.
11+
- Added support for `setStreams` to RTCRtpSender. At this time, up to one
12+
MediaStream argument is supported.
1113

1214
0.4.2
1315
=====

src/interfaces/rtc_rtp_sender.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "src/converters/null.h"
1414
#include "src/dictionaries/webrtc/rtp_parameters.h"
1515
#include "src/interfaces/media_stream_track.h"
16+
#include "src/interfaces/media_stream.h"
1617
#include "src/interfaces/rtc_dtls_transport.h"
1718
#include "src/interfaces/rtc_peer_connection/peer_connection_factory.h"
1819
#include "src/node/error_factory.h"
@@ -116,6 +117,16 @@ Napi::Value RTCRtpSender::ReplaceTrack(const Napi::CallbackInfo& info) {
116117
return deferred.Promise();
117118
}
118119

120+
Napi::Value RTCRtpSender::SetStreams(const Napi::CallbackInfo& info) {
121+
CONVERT_ARGS_OR_THROW_AND_RETURN_NAPI(info, maybeStream, Maybe<MediaStream*>)
122+
auto streams = std::vector<std::string>();
123+
if (maybeStream.IsJust()) {
124+
streams.emplace_back(maybeStream.UnsafeFromJust()->stream()->id());
125+
}
126+
_sender->SetStreams(streams);
127+
return info.Env().Undefined();
128+
}
129+
119130
Wrap <
120131
RTCRtpSender*,
121132
rtc::scoped_refptr<webrtc::RtpSenderInterface>,
@@ -152,6 +163,7 @@ void RTCRtpSender::Init(Napi::Env env, Napi::Object exports) {
152163
InstanceMethod("setParameters", &RTCRtpSender::SetParameters),
153164
InstanceMethod("getStats", &RTCRtpSender::GetStats),
154165
InstanceMethod("replaceTrack", &RTCRtpSender::ReplaceTrack),
166+
InstanceMethod("setStreams", &RTCRtpSender::SetStreams),
155167
StaticMethod("getCapabilities", &RTCRtpSender::GetCapabilities)
156168
});
157169

src/interfaces/rtc_rtp_sender.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class RTCRtpSender: public AsyncObjectWrap<RTCRtpSender> {
5555
Napi::Value SetParameters(const Napi::CallbackInfo&);
5656
Napi::Value GetStats(const Napi::CallbackInfo&);
5757
Napi::Value ReplaceTrack(const Napi::CallbackInfo&);
58+
Napi::Value SetStreams(const Napi::CallbackInfo&);
5859

5960
PeerConnectionFactory* _factory;
6061
rtc::scoped_refptr<webrtc::RtpSenderInterface> _sender;

0 commit comments

Comments
 (0)