Skip to content
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
28 changes: 25 additions & 3 deletions GObjectWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Local<Value> GObjectWrap::NewInstance( const Nan::FunctionCallbackInfo<Value>& i
}
if (GST_IS_APP_SRC(obj)) {
Nan::SetMethod(instance, "push", GstAppSrcPush);
Nan::SetMethod(instance, "sendEos", GstAppSrcSendEndOfStream);
}

info.GetReturnValue().Set(instance);
Expand Down Expand Up @@ -106,6 +107,7 @@ class PullWorker : public Nan::AsyncWorker {
Nan::HandleScope scope;

Local<Value> buf;
Local<Value> pts;
Local<Object> caps = Nan::New<Object>();
if (sample) {

Expand All @@ -116,14 +118,24 @@ class PullWorker : public Nan::AsyncWorker {
}

buf = gstsample_to_v8(sample);

// Extracting pts from the sample
GstBuffer *buffer = gst_sample_get_buffer(sample);
if (buffer) {
pts = Nan::New<Number>(static_cast<double>(buffer->pts));
} else {
pts = Nan::Null();
}

gst_sample_unref(sample);
sample = NULL;
} else {
buf = Nan::Null();
pts = Nan::Null();
buf = Nan::Null();
}

Local<Value> argv[] = { buf, caps };
callback->Call(2, argv, async_resource);
Local<Value> argv[] = { buf, caps, pts };
callback->Call(3, argv, async_resource);
}

private:
Expand Down Expand Up @@ -161,3 +173,13 @@ NAN_METHOD(GObjectWrap::GstAppSrcPush) {
}
// TODO throw an error if no args are given?
}

NAN_METHOD(GObjectWrap::GstAppSrcSendEndOfStream) {
auto *obj = Nan::ObjectWrap::Unwrap<GObjectWrap>(info.This());
GstFlowReturn result = gst_app_src_end_of_stream(GST_APP_SRC(obj->obj));

if (result != GST_FLOW_OK) {
// Handle error
Nan::ThrowError("Failed to send End-Of-Stream event.");
}
}
3 changes: 2 additions & 1 deletion GObjectWrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class GObjectWrap : public Nan::ObjectWrap {
static void _pulledBuffer( uv_work_t *req, int );
*/
static NAN_METHOD(GstAppSinkPull);
static NAN_METHOD(GstAppSrcPush);
static NAN_METHOD(GstAppSrcPush);
static NAN_METHOD(GstAppSrcSendEndOfStream);
};

#endif