Skip to content
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

Update for Node v12/v13 - for v8 changes #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
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
2 changes: 1 addition & 1 deletion src/Concater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ConcatProcessData : public iProcessData {
: mPersistentSrcBuf(new Persist(srcBufArray)), mPersistentDstBuf(new Persist(dstBuf)),
mDstBuf(Memory::makeNew((uint8_t *)node::Buffer::Data(dstBuf), (uint32_t)node::Buffer::Length(dstBuf))), mSrcBytes(0) {
for (uint32_t i = 0; i < srcBufArray->Length(); ++i) {
Local<Object> bufferObj = Local<Object>::Cast(srcBufArray->Get(i));
Local<Object> bufferObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), i).ToLocalChecked());
uint32_t bufLen = (uint32_t)node::Buffer::Length(bufferObj);
mSrcBufVec.push_back(std::make_pair((uint8_t *)node::Buffer::Data(bufferObj), bufLen));
mSrcBytes += bufLen;
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ NAN_METHOD(Decoder::Decode) {
std::string err = std::string("Decoder requires single source buffer - received ") + std::to_string(srcBufArray->Length());
return Nan::ThrowError(err.c_str());
}
Local<Object> srcBuf = Local<Object>::Cast(srcBufArray->Get(0));
Local<Object> srcBuf = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());

std::shared_ptr<iProcessData> epd = std::make_shared<DecodeProcessData>(srcBuf, dstBuf);
obj->mWorker->doFrame(epd, obj, new Nan::Callback(callback));
Expand Down
2 changes: 1 addition & 1 deletion src/Encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ NAN_METHOD(Encoder::Encode) {
std::string err = std::string("Encoder requires single source buffer - received ") + std::to_string(srcBufArray->Length());
return Nan::ThrowError(err.c_str());
}
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(0));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());
std::shared_ptr<Memory> convertDstBuf;
if (obj->mPacker)
convertDstBuf = Memory::makeNew(getFormatBytes(obj->mEncoderDriver->packingRequired(), obj->mSrcInfo->width(), obj->mSrcInfo->height()));
Expand Down
3 changes: 1 addition & 2 deletions src/Flipper.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* Copyright 2017 Streampunk Media Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -150,7 +149,7 @@ NAN_METHOD(Flipper::Flip) {
Local<Object> dstBufObj = Local<Object>::Cast(info[1]);
Local<Function> callback = Local<Function>::Cast(info[2]);

Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(0));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());

Flipper* obj = Nan::ObjectWrap::Unwrap<Flipper>(info.Holder());

Expand Down
2 changes: 1 addition & 1 deletion src/Packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ NAN_METHOD(Packer::Pack) {
Local<Object> dstBufObj = Local<Object>::Cast(info[1]);
Local<Function> callback = Local<Function>::Cast(info[2]);

Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(0));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());

Packer* obj = Nan::ObjectWrap::Unwrap<Packer>(info.Holder());

Expand Down
2 changes: 1 addition & 1 deletion src/Params.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Params {

std::string unpackValue(Local<Value> val) {
Local<Array> valueArray = Local<Array>::Cast(val);
return *Nan::Utf8String(valueArray->Get(0));
return *Nan::Utf8String(valueArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());
}

bool unpackBool(Local<Object> tags, const std::string& key, bool dflt) {
Expand Down
6 changes: 3 additions & 3 deletions src/ScaleConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void ScaleConverter::doSetInfo(Local<Object> srcTags, Local<Object> dstTags, v8:
if (!(!scaleXY->IsNull() && scaleXY->IsArray() && (scaleXY->Length() == 2)))
return Nan::ThrowError("Scale parameter invalid");

fXY scale(Nan::To<double>(scaleXY->Get(0)).FromJust(), Nan::To<double>(scaleXY->Get(1)).FromJust());
fXY scale(Nan::To<double>(scaleXY->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked()).FromJust(), Nan::To<double>(scaleXY->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 1).ToLocalChecked()).FromJust());
if ((scale.x > 10.0f) || (scale.y > 10.0f)) {
std::string err = std::string("Unsupported Scale values X:") + std::to_string(scale.x).c_str() + ", Y:" + std::to_string(scale.y).c_str();
return Nan::ThrowError(err.c_str());
Expand All @@ -122,7 +122,7 @@ void ScaleConverter::doSetInfo(Local<Object> srcTags, Local<Object> dstTags, v8:
if (!(!dstOffsetXY->IsNull() && dstOffsetXY->IsArray() && (dstOffsetXY->Length() == 2)))
return Nan::ThrowError("DstOffset parameter invalid");

fXY dstOffset(Nan::To<double>(dstOffsetXY->Get(0)).FromJust(), Nan::To<double>(dstOffsetXY->Get(1)).FromJust());
fXY dstOffset(Nan::To<double>(dstOffsetXY->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked()).FromJust(), Nan::To<double>(dstOffsetXY->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 1).ToLocalChecked()).FromJust());
if ((dstOffset.x > mDstVidInfo->width() / 2) || (dstOffset.y > mDstVidInfo->height() / 2)) {
std::string err = std::string("Unsupported DstOffset values X:") + std::to_string(dstOffset.x).c_str() + ", Y:" + std::to_string(dstOffset.y).c_str();
return Nan::ThrowError(err.c_str());
Expand Down Expand Up @@ -186,7 +186,7 @@ NAN_METHOD(ScaleConverter::ScaleConvert) {
Local<Object> dstBufObj = Local<Object>::Cast(info[1]);
Local<Function> callback = Local<Function>::Cast(info[2]);

Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(0));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());

ScaleConverter* obj = Nan::ObjectWrap::Unwrap<ScaleConverter>(info.Holder());

Expand Down
24 changes: 12 additions & 12 deletions src/Stamper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MixProcessData : public iProcessData {
mPressure(pressure)
{
for (uint32_t i=0; i<srcBufArray->Length(); ++i) {
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(i));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), i).ToLocalChecked());
mPersistentSrcBufs.push_back(std::shared_ptr<Persist>(new Persist(srcBufObj)));
mSrcBufs.push_back(Memory::makeNew((uint8_t *)node::Buffer::Data(srcBufObj), (uint32_t)node::Buffer::Length(srcBufObj)));
}
Expand All @@ -106,7 +106,7 @@ class StampProcessData : public iProcessData {
mDstBuf(Memory::makeNew((uint8_t *)node::Buffer::Data(dstBufObj), (uint32_t)node::Buffer::Length(dstBufObj)))
{
for (uint32_t i=0; i<srcBufArray->Length(); ++i) {
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(i));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), i).ToLocalChecked());
mPersistentSrcBufs.push_back(std::shared_ptr<Persist>(new Persist(srcBufObj)));
mSrcBufs.push_back(Memory::makeNew((uint8_t *)node::Buffer::Data(srcBufObj), (uint32_t)node::Buffer::Length(srcBufObj)));
}
Expand Down Expand Up @@ -163,7 +163,7 @@ uint32_t Stamper::processFrame (std::shared_ptr<iProcessData> processData) {
}

void Stamper::doSetInfo(Local<Array> srcTagsArray, Local<Object> dstTags) {
Local<Object> srcTags = Local<Object>::Cast(srcTagsArray->Get(0));
Local<Object> srcTags = Local<Object>::Cast(srcTagsArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());
mSrcVidInfo = std::make_shared<EssenceInfo>(srcTags);
printDebug(eInfo, "Stamper SrcVidInfo: %s\n", mSrcVidInfo->toString().c_str());
mDstVidInfo = std::make_shared<EssenceInfo>(dstTags);
Expand Down Expand Up @@ -519,17 +519,17 @@ NAN_METHOD(Stamper::Wipe) {
Local<Array> wipeRectArr = Local<Array>::Cast(Nan::Get(paramTags, wipeRectStr).ToLocalChecked());
if (!(!wipeRectArr->IsNull() && wipeRectArr->IsArray() && (wipeRectArr->Length() == 4)))
return Nan::ThrowError("wipeRect parameter invalid");
iRect wipeRect(iXY(Nan::To<uint32_t>(wipeRectArr->Get(0)).FromJust(), Nan::To<uint32_t>(wipeRectArr->Get(1)).FromJust()),
iXY(Nan::To<uint32_t>(wipeRectArr->Get(2)).FromJust(), Nan::To<uint32_t>(wipeRectArr->Get(3)).FromJust()));
iRect wipeRect(iXY(Nan::To<uint32_t>(wipeRectArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked()).FromJust(), Nan::To<uint32_t>(wipeRectArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 1).ToLocalChecked()).FromJust()),
iXY(Nan::To<uint32_t>(wipeRectArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 2).ToLocalChecked()).FromJust(), Nan::To<uint32_t>(wipeRectArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 3).ToLocalChecked()).FromJust()));

Local<String> wipeColStr = Nan::New<String>("wipeCol").ToLocalChecked();
Local<Array> wipeColArr = Local<Array>::Cast(Nan::Get(paramTags, wipeColStr).ToLocalChecked());
if (!(!wipeColArr->IsNull() && wipeColArr->IsArray() && (wipeColArr->Length() == 3)))
return Nan::ThrowError("wipeCol parameter invalid");

fCol wipeCol(Nan::To<double>(wipeColArr->Get(0)).FromJust(),
Nan::To<double>(wipeColArr->Get(1)).FromJust(),
Nan::To<double>(wipeColArr->Get(2)).FromJust());
fCol wipeCol(Nan::To<double>(wipeColArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked()).FromJust(),
Nan::To<double>(wipeColArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 1).ToLocalChecked()).FromJust(),
Nan::To<double>(wipeColArr->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 2).ToLocalChecked()).FromJust());

std::shared_ptr<iProcessData> wpd =
std::make_shared<WipeProcessData>(dstBufObj, wipeRect, wipeCol);
Expand All @@ -555,7 +555,7 @@ NAN_METHOD(Stamper::Copy) {
Local<Object> paramTags = Local<Object>::Cast(info[2]);
Local<Function> callback = Local<Function>::Cast(info[3]);

Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(0));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked());

Stamper* obj = Nan::ObjectWrap::Unwrap<Stamper>(info.Holder());

Expand All @@ -573,7 +573,7 @@ NAN_METHOD(Stamper::Copy) {
Local<Array> dstOrgXY = Local<Array>::Cast(Nan::Get(paramTags, dstOrgStr).ToLocalChecked());
if (!(!dstOrgXY->IsNull() && dstOrgXY->IsArray() && (dstOrgXY->Length() == 2)))
return Nan::ThrowError("dstOrg parameter invalid");
iXY dstOrg(Nan::To<uint32_t>(dstOrgXY->Get(0)).FromJust(), Nan::To<uint32_t>(dstOrgXY->Get(1)).FromJust());
iXY dstOrg(Nan::To<uint32_t>(dstOrgXY->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 0).ToLocalChecked()).FromJust(), Nan::To<uint32_t>(dstOrgXY->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), 1).ToLocalChecked()).FromJust());

std::shared_ptr<iProcessData> cpd =
std::make_shared<CopyProcessData>(srcBufObj, dstBufObj, dstOrg);
Expand Down Expand Up @@ -606,7 +606,7 @@ NAN_METHOD(Stamper::Mix) {

uint32_t srcFormatBytes = getFormatBytes(obj->mSrcVidInfo->packing(), obj->mSrcVidInfo->width(), obj->mSrcVidInfo->height());
for (uint32_t i=0; i<srcBufArray->Length(); ++i) {
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(i));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), i).ToLocalChecked());
if (srcFormatBytes > (uint32_t)node::Buffer::Length(srcBufObj))
Nan::ThrowError("Insufficient source buffer for Mix\n");
}
Expand Down Expand Up @@ -654,7 +654,7 @@ NAN_METHOD(Stamper::Stamp) {

for (uint32_t i=0; i<srcBufArray->Length(); ++i) {
uint32_t srcFormatBytes = getFormatBytes(obj->mSrcVidInfo->packing(), obj->mSrcVidInfo->width(), obj->mSrcVidInfo->height(), 0==i);
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(i));
Local<Object> srcBufObj = Local<Object>::Cast(srcBufArray->Get(v8::Isolate::GetCurrent()->GetCurrentContext(), i).ToLocalChecked());
if (srcFormatBytes > (uint32_t)node::Buffer::Length(srcBufObj))
Nan::ThrowError("Insufficient source buffer for Stamp\n");
}
Expand Down