66#define BUILDING_NODE_EXTENSION
77#endif
88
9+ #include " CallBaseWrapper.h"
910#include " MediaWrapper.h"
1011#include " VideoFramePacketizerWrapper.h"
1112#include " WebRtcConnection.h"
@@ -29,6 +30,9 @@ void VideoFramePacketizer::Init(v8::Local<v8::Object> exports) {
2930 NODE_SET_PROTOTYPE_METHOD (tpl, " unbindTransport" , unbindTransport);
3031 NODE_SET_PROTOTYPE_METHOD (tpl, " enable" , enable);
3132 NODE_SET_PROTOTYPE_METHOD (tpl, " ssrc" , getSsrc);
33+ NODE_SET_PROTOTYPE_METHOD (tpl, " getTotalBitrateBps" , getTotalBitrate);
34+ NODE_SET_PROTOTYPE_METHOD (tpl, " getRetransmitBitrateBps" , getRetransmitBitrate);
35+ NODE_SET_PROTOTYPE_METHOD (tpl, " getEstimatedBandwidthBps" , getEstimatedBandwidth);
3236
3337 constructor.Reset (isolate, tpl->GetFunction ());
3438 exports->Set (String::NewFromUtf8 (isolate, " VideoFramePacketizer" ), tpl->GetFunction ());
@@ -40,15 +44,25 @@ void VideoFramePacketizer::New(const FunctionCallbackInfo<Value>& args) {
4044
4145 bool supportRED = (args[0 ]->ToBoolean (Nan::GetCurrentContext ()).ToLocalChecked ())->BooleanValue ();
4246 bool supportULPFEC = (args[1 ]->ToBoolean (Nan::GetCurrentContext ()).ToLocalChecked ())->BooleanValue ();
43- int transportccExt = (args.Length () = = 3 ) ? args[2 ]->IntegerValue (Nan::GetCurrentContext ()).ToChecked () : -1 ;
47+ int transportccExt = (args.Length () > = 3 ) ? args[2 ]->IntegerValue (Nan::GetCurrentContext ()).ToChecked () : -1 ;
4448 std::string mid;
4549 int midExtId = -1 ;
4650 if (args.Length () >= 5 ) {
4751 v8::String::Utf8Value param4 (isolate, Nan::To<v8::String>(args[3 ]).ToLocalChecked ());
4852 mid = std::string (*param4);
4953 midExtId = args[4 ]->IntegerValue (Nan::GetCurrentContext ()).ToChecked ();
5054 }
51- bool selfRequestKeyframe = (args.Length () == 6 ) ? (args[5 ]->ToBoolean (Nan::GetCurrentContext ()).ToLocalChecked ())->BooleanValue () : false ;
55+ bool selfRequestKeyframe = (args.Length () >= 6 )
56+ ? (args[5 ]->ToBoolean (Nan::GetCurrentContext ()).ToLocalChecked ())->BooleanValue ()
57+ : false ;
58+
59+ CallBase* baseWrapper = (args.Length () >= 7 )
60+ ? Nan::ObjectWrap::Unwrap<CallBase>(Nan::To<v8::Object>(args[6 ]).ToLocalChecked ())
61+ : nullptr ;
62+
63+ bool enableBandwidthEstimation = (args.Length () >= 8 )
64+ ? (args[7 ]->ToBoolean (Nan::GetCurrentContext ()).ToLocalChecked ())->BooleanValue ()
65+ : false ;
5266
5367 VideoFramePacketizer* obj = new VideoFramePacketizer ();
5468 owt_base::VideoFramePacketizer::Config config;
@@ -57,6 +71,10 @@ void VideoFramePacketizer::New(const FunctionCallbackInfo<Value>& args) {
5771 config.transportccExt = transportccExt;
5872 config.mid = mid;
5973 config.midExtId = midExtId;
74+ config.enableBandwidthEstimation = enableBandwidthEstimation;
75+ if (baseWrapper) {
76+ config.rtcAdapter = baseWrapper->rtcAdapter ;
77+ }
6078
6179 if (transportccExt > 0 ) {
6280 config.enableTransportcc = true ;
@@ -129,3 +147,35 @@ void VideoFramePacketizer::getSsrc(const v8::FunctionCallbackInfo<v8::Value>& ar
129147 args.GetReturnValue ().Set (Number::New (isolate, ssrc));
130148}
131149
150+ void VideoFramePacketizer::getTotalBitrate (const v8::FunctionCallbackInfo<v8::Value>& args) {
151+ Isolate* isolate = Isolate::GetCurrent ();
152+ HandleScope scope (isolate);
153+
154+ VideoFramePacketizer* obj = ObjectWrap::Unwrap<VideoFramePacketizer>(args.Holder ());
155+ owt_base::VideoFramePacketizer* me = obj->me ;
156+
157+ uint32_t bitrate = me->getTotalBitrate ();
158+ args.GetReturnValue ().Set (Number::New (isolate, bitrate));
159+ }
160+
161+ void VideoFramePacketizer::getRetransmitBitrate (const v8::FunctionCallbackInfo<v8::Value>& args) {
162+ Isolate* isolate = Isolate::GetCurrent ();
163+ HandleScope scope (isolate);
164+
165+ VideoFramePacketizer* obj = ObjectWrap::Unwrap<VideoFramePacketizer>(args.Holder ());
166+ owt_base::VideoFramePacketizer* me = obj->me ;
167+
168+ uint32_t bitrate = me->getRetransmitBitrate ();
169+ args.GetReturnValue ().Set (Number::New (isolate, bitrate));
170+ }
171+
172+ void VideoFramePacketizer::getEstimatedBandwidth (const v8::FunctionCallbackInfo<v8::Value>& args) {
173+ Isolate* isolate = Isolate::GetCurrent ();
174+ HandleScope scope (isolate);
175+
176+ VideoFramePacketizer* obj = ObjectWrap::Unwrap<VideoFramePacketizer>(args.Holder ());
177+ owt_base::VideoFramePacketizer* me = obj->me ;
178+
179+ uint32_t bitrate = me->getEstimatedBandwidth ();
180+ args.GetReturnValue ().Set (Number::New (isolate, bitrate));
181+ }
0 commit comments