#include "stdafx.h" #include "GstreamerVideo.h" #include "GstreamerVideoStream.h" map VideoStreams; queue VideoIDs; DllExport void SetVideoLogCallback (LogCallback Callback) { Log = Callback; } DllExport bool InitVideo() { for(int i = 0; i < 1000; i++) { VideoIDs.push(i); } #if _WIN64 SetDllDirectory(L".\\x64\\gstreamer"); #else SetDllDirectory(L".\\x86\gstreamer"); #endif gst_init(NULL, NULL); GstRegistry* registry = gst_registry_get(); #if _WIN64 gst_registry_scan_path(registry, ".\\x64\\gstreamer"); #else gst_registry_scan_path(registry, ".\\x86\\gstreamer"); #endif return true; } DllExport void CloseAllVideos(void) { map::iterator p; for(p = VideoStreams.begin(); p != VideoStreams.end(); p++) { p->second->CloseVideo(); } } DllExport int LoadVideo(const wchar_t* Media) { GstreamerVideoStream *s = new GstreamerVideoStream(VideoIDs.front()); VideoStreams.insert(pair (VideoIDs.front(), s)); VideoIDs.pop(); return s->LoadVideo(Media); } DllExport bool CloseVideo(int Stream) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { delete it->second; VideoStreams.erase(it); } else return false; return true; } DllExport int GetVideoNumStreams() { return VideoStreams.size(); } DllExport float GetVideoLength(int Stream) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { return it->second->GetVideoLength(); } else return -1.0; } DllExport guint8* GetFrame(int Stream, float Time, float &VideoTime, int &Size, int &Width, int &Height) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { return it->second->GetFrame(Time, VideoTime, Size, Width, Height); } } DllExport bool Skip(int Stream, float Start, float Gap) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { return it->second->Skip(Start, Gap); } else return false; } DllExport void SetVideoLoop(int Stream, bool Loop) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { it->second->SetVideoLoop(Loop); } } DllExport void PauseVideo(int Stream) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { it->second->PauseVideo(); } } DllExport void ResumeVideo(int Stream) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { it->second->ResumeVideo(); } } DllExport bool Finished(int Stream) { map::iterator it = VideoStreams.find(Stream); if(it != VideoStreams.end()) { return it->second->IsFinished(); } else return true; } DllExport void UpdateVideo(void) { map::iterator p = VideoStreams.begin(); while(p != VideoStreams.end()) { if(p->second->Closed) { delete p->second; VideoStreams.erase(p++); } else { p->second->UpdateVideo(); ++p; } } } void LogVideoError(const char* msg) { Log(msg); }