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

HTMLVideoElement unlock #1361

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
775f6f2
Clean up HTMLAudioElement native audio binding guards
Nov 10, 2018
2433fd7
Merge DOM.js HTMLVideoElement video and webcam implementations
Nov 10, 2018
6bbafab
Hook in missinf Video play in HTMLVideoElement
Nov 11, 2018
6eae16d
Bugfix Video.cpp bits per pixel
Nov 11, 2018
b70ac37
Bugfix video load error message
Nov 11, 2018
fd02e53
Add Video.cpp error message output
Nov 11, 2018
d732265
Clean up Video.cpp error result capture
Nov 11, 2018
528654c
Bugfix sws_scale called on incomplete video frames
Nov 11, 2018
01a649d
Bump video buffer size
Nov 11, 2018
9169223
Flag format context as AVFMT_FLAG_CUSTOM_IO
Nov 11, 2018
36f5de2
Clean up video set data stream index
Nov 11, 2018
33c5349
Small video.cpp cleanup
Nov 11, 2018
c5037f1
Clean up video.cpp connnntext initialization
Nov 11, 2018
ced25fa
Clean up video.cpp sws context initialization
Nov 11, 2018
c77a2b7
Bump native-video-deps version
Nov 11, 2018
6c49df3
Bugfix video devices query in DOM.js
Nov 11, 2018
454b15f
Add missing linux libx264 linkage
Nov 12, 2018
8164bcd
Initial video threading
Nov 12, 2018
d8509ed
More major video load debugging
Nov 13, 2018
8aa0286
Video.h class order cleanup
Nov 13, 2018
fa4099e
Bugfix parallel video loading
Nov 13, 2018
a459834
Use new parallel video loading api
Nov 13, 2018
f170d6b
Clean up Video.cpp logging
Nov 13, 2018
3bf9d57
Major Video texture refactoring
Nov 14, 2018
ec01d57
Add video texturing comment
Nov 14, 2018
f25f92d
Clean up native gl framebuffer
Nov 14, 2018
34e2997
Auto-create <video> GL context as needed
Nov 14, 2018
7e6d8e2
Add jellyfish.mkv sample video
Nov 14, 2018
1af2f6a
Add video.html video sphere test
Nov 14, 2018
2a1f938
Unlock Video.cpp hardware acceleration
Nov 15, 2018
cbb2706
Disable video tests
Nov 15, 2018
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
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
'-lXxf86vm',
'-lXrandr',
'-lXi',
'-lx264',
'-lasound',
'-lexpat',
],
Expand Down
47 changes: 40 additions & 7 deletions deps/exokit-bindings/videocontext/include/Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include <v8.h>
#include <node.h>
#include <nan.h>
#include <deque>
#include <thread>
#include <mutex>
#include <functional>

extern "C" {
#include <libavformat/avformat.h>
Expand All @@ -13,6 +17,7 @@ extern "C" {
#include <libavutil/time.h>
}

#include <webgl.h>
#include <defines.h>

using namespace std;
Expand All @@ -33,7 +38,7 @@ class AppData {
~AppData();

void resetState();
bool set(vector<unsigned char> &memory, string *error = nullptr);
bool set(vector<unsigned char> &&memory, string *error = nullptr);
static int bufferRead(void *opaque, unsigned char *buf, int buf_size);
static int64_t bufferSeek(void *opaque, int64_t offset, int whence);
double getTimeBase();
Expand All @@ -56,10 +61,20 @@ class AppData {
double lastTimestamp;
};

class VideoRequest {
public:
std::function<void(std::function<void(std::function<void()>)>)> fn;
};

class VideoResponse {
public:
std::function<void()> fn;
};

class Video : public ObjectWrap {
public:
static Handle<Object> Initialize(Isolate *isolate);
bool Load(uint8_t *bufferValue, size_t bufferLength, string *error = nullptr);
void Load(WebGLRenderingContext *gl, uint8_t *bufferValue, size_t bufferLength);
void Update();
void Play();
void Pause();
Expand All @@ -77,7 +92,12 @@ class Video : public ObjectWrap {
static NAN_GETTER(HeightGetter);
static NAN_GETTER(LoopGetter);
static NAN_SETTER(LoopSetter);
static NAN_GETTER(DataGetter);
static NAN_GETTER(OnLoadGetter);
static NAN_SETTER(OnLoadSetter);
static NAN_GETTER(OnErrorGetter);
static NAN_SETTER(OnErrorSetter);
// static NAN_GETTER(DataGetter);
static NAN_GETTER(TextureGetter);
static NAN_GETTER(CurrentTimeGetter);
static NAN_SETTER(CurrentTimeSetter);
static NAN_GETTER(DurationGetter);
Expand All @@ -87,23 +107,32 @@ class Video : public ObjectWrap {
double getRequiredCurrentTimeS();
double getFrameCurrentTimeS();
FrameStatus advanceToFrameAt(double timestamp);
void queueInVideoThread(std::function<void(std::function<void(std::function<void()>)>)> fn);
static void runInMainThread(uv_async_t *handle);

Video();
~Video();

private:
AppData data;
AppData appData;
WebGLRenderingContext *gl;
GLuint texture;
bool loaded;
bool playing;
bool loop;
int64_t startTime;
double startFrameTime;
Nan::Persistent<Uint8ClampedArray> dataArray;
bool dataDirty;
Nan::Persistent<Function> onload;
Nan::Persistent<Function> onerror;

std::thread thread;
uv_sem_t requestSem;
// uv_sem_t responseSem;
std::mutex requestMutex;
std::deque<VideoRequest> requestQueue;
};

class VideoCamera;

class VideoDevice : public ObjectWrap {
public:
static Handle<Object> Initialize(Isolate *isolate, Local<Value> imageDataCons);
Expand All @@ -116,6 +145,7 @@ class VideoDevice : public ObjectWrap {
static NAN_GETTER(HeightGetter);
static NAN_GETTER(SizeGetter);
static NAN_GETTER(DataGetter);
// static NAN_GETTER(TextureGetter);
static NAN_GETTER(ImageDataGetter);

VideoDevice();
Expand All @@ -126,6 +156,9 @@ class VideoDevice : public ObjectWrap {
Nan::Persistent<Object> imageData;
};

extern std::mutex responseMutex;
extern std::deque<VideoResponse> responseQueue;
extern uv_async_t responseAsync;
extern std::vector<Video *> videos;
extern std::vector<VideoDevice *> videoDevices;

Expand Down
Loading