diff --git a/GstreamerHelper/GstreamerHelper.vcxproj b/GstreamerHelper/GstreamerHelper.vcxproj index 70d35fea..4ae10323 100644 --- a/GstreamerHelper/GstreamerHelper.vcxproj +++ b/GstreamerHelper/GstreamerHelper.vcxproj @@ -164,6 +164,8 @@ + + @@ -184,6 +186,8 @@ + + Create Create diff --git a/GstreamerHelper/GstreamerHelper.vcxproj.filters b/GstreamerHelper/GstreamerHelper.vcxproj.filters index f0255fed..342e0d36 100644 --- a/GstreamerHelper/GstreamerHelper.vcxproj.filters +++ b/GstreamerHelper/GstreamerHelper.vcxproj.filters @@ -27,6 +27,12 @@ Headerdateien + + Headerdateien + + + Headerdateien + @@ -41,5 +47,11 @@ Quelldateien + + Quelldateien + + + Quelldateien + \ No newline at end of file diff --git a/GstreamerHelper/GstreamerVideo.cpp b/GstreamerHelper/GstreamerVideo.cpp new file mode 100644 index 00000000..f84837c6 --- /dev/null +++ b/GstreamerHelper/GstreamerVideo.cpp @@ -0,0 +1,133 @@ +#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()) + { + return it->second->CloseVideo(); + } + else return false; +} + +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 UINT8* GetFrame(int Stream, float Time, float &VideoTime) +{ + map::iterator it = VideoStreams.find(Stream); + if(it != VideoStreams.end()) + { + return it->second->GetFrame(Time, VideoTime); + } +} + +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->Finished(); + } + else return true; +} diff --git a/GstreamerHelper/GstreamerVideo.h b/GstreamerHelper/GstreamerVideo.h new file mode 100644 index 00000000..57930064 --- /dev/null +++ b/GstreamerHelper/GstreamerVideo.h @@ -0,0 +1,32 @@ +#pragma once +#include +#include +#include +#include "gst/gst.h" +#define DllExport extern "C" __declspec(dllexport) + +using namespace std; + + typedef void (__stdcall * LogCallback)(const char* text); + static LogCallback Log; + + DllExport void SetVideoLogCallback(LogCallback Callback); + + DllExport bool InitVideo(); + DllExport void CloseAllVideos(); + + DllExport int LoadVideo(const wchar_t* Media); + DllExport bool CloseVideo(int StreamID); + DllExport int GetVideoNumStreams(); + + DllExport float GetVideoLength(int StreamID); + DllExport UINT8* GetFrame(int StreamID, float Time, float &VideoTime); + DllExport bool Skip(int StreamID, float Start, float Gap); + DllExport void SetVideoLoop(int StreamID, bool Loop); + DllExport void PauseVideo(int StreamID); + DllExport void ResumeVideo(int StreamID); + + DllExport bool Finished(int StreamID); + + void LogVideoError(const char* msg); + diff --git a/GstreamerHelper/GstreamerVideoStream.cpp b/GstreamerHelper/GstreamerVideoStream.cpp new file mode 100644 index 00000000..c23f90d0 --- /dev/null +++ b/GstreamerHelper/GstreamerVideoStream.cpp @@ -0,0 +1,56 @@ +#include "stdafx.h" +#include "GstreamerVideoStream.h" + + +GstreamerVideoStream::GstreamerVideoStream(int ID) +{ + this->ID = ID; +} + + +GstreamerVideoStream::~GstreamerVideoStream(void) +{ +} + +int GstreamerVideoStream::LoadVideo(const wchar_t* Filename) +{ + return ID; +} + + +bool GstreamerVideoStream::CloseVideo() +{ + return true; +} + +float GstreamerVideoStream::GetVideoLength() +{ + return 0.0; +} + +UINT8* GstreamerVideoStream::GetFrame(float Time, float &VideoTime) +{ + return 0; +} + +bool GstreamerVideoStream::Skip(float Start, float Gap) +{ + return true; +} + +void GstreamerVideoStream::SetVideoLoop(bool Loop) +{ +} + +void GstreamerVideoStream::PauseVideo() +{ +} + +void GstreamerVideoStream::ResumeVideo() +{ +} + +bool GstreamerVideoStream::Finished() +{ + return true; +} diff --git a/GstreamerHelper/GstreamerVideoStream.h b/GstreamerHelper/GstreamerVideoStream.h new file mode 100644 index 00000000..a355a254 --- /dev/null +++ b/GstreamerHelper/GstreamerVideoStream.h @@ -0,0 +1,25 @@ +#pragma once +#include "gst/gst.h" + using namespace std; +class GstreamerVideoStream +{ + +public: + int ID; + + GstreamerVideoStream(int ID); + ~GstreamerVideoStream(void); + + int LoadVideo(const wchar_t* VideoFileName); + bool CloseVideo(); + + float GetVideoLength(); + UINT8* GetFrame(float Time, float &VideoTime); + bool Skip(float Start, float Gap); + void SetVideoLoop(bool Loop); + void PauseVideo(); + void ResumeVideo(); + + bool Finished(); +}; + diff --git a/Output/x64/gstreamer/GstreamerHelper.dll b/Output/x64/gstreamer/GstreamerHelper.dll index 2a84bfd0..22465ffd 100644 Binary files a/Output/x64/gstreamer/GstreamerHelper.dll and b/Output/x64/gstreamer/GstreamerHelper.dll differ diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs index 0124494e..766e90d2 100644 --- a/Vocaluxe/Base/CVideo.cs +++ b/Vocaluxe/Base/CVideo.cs @@ -22,7 +22,9 @@ namespace Vocaluxe.Base case EVideoDecoder.FFmpeg: _VideoDecoder = new CVideoDecoderFFmpeg(); break; - + case EVideoDecoder.Gstreamer: + _VideoDecoder = new CVideoDecoderGstreamer(); + break; default: _VideoDecoder = new CVideoDecoderFFmpeg(); break; diff --git a/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs b/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs new file mode 100644 index 00000000..391a0f09 --- /dev/null +++ b/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Vocaluxe.Lib.Video.Gstreamer; + +namespace Vocaluxe.Lib.Video +{ + class CVideoDecoderGstreamer : IVideoDecoder + { + public bool Init() + { + return CGstreamerVideoWrapper.InitVideo(); + } + + public void CloseAll() + { + CGstreamerVideoWrapper.CloseAllVideos(); + } + + public int Load(string VideoFileName) + { + return CGstreamerVideoWrapper.LoadVideo(VideoFileName); + } + + public bool Close(int StreamID) + { + return CGstreamerVideoWrapper.CloseVideo(StreamID); + } + + public int GetNumStreams() + { + return CGstreamerVideoWrapper.GetVideoNumStreams(); + } + + public float GetLength(int StreamID) + { + return CGstreamerVideoWrapper.GetVideoLength(StreamID); + } + + public bool GetFrame(int StreamID, ref Menu.STexture Frame, float Time, ref float VideoTime) + { + IntPtr buffer = CGstreamerVideoWrapper.GetFrame(StreamID, Time, ref VideoTime); + return true; + } + + public bool Skip(int StreamID, float Start, float Gap) + { + return CGstreamerVideoWrapper.Skip(StreamID, Start, Gap); + } + + public void SetLoop(int StreamID, bool Loop) + { + CGstreamerVideoWrapper.SetVideoLoop(StreamID, Loop); + } + + public void Pause(int StreamID) + { + CGstreamerVideoWrapper.PauseVideo(StreamID); + } + + public void Resume(int StreamID) + { + CGstreamerVideoWrapper.ResumeVideo(StreamID); + } + + public bool Finished(int StreamID) + { + return CGstreamerVideoWrapper.Finished(StreamID); + } + } +} diff --git a/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs b/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs new file mode 100644 index 00000000..ea9b775e --- /dev/null +++ b/Vocaluxe/Lib/Video/Gstreamer/CGstreamerVideoWrapper.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +namespace Vocaluxe.Lib.Video.Gstreamer +{ + public static class CGstreamerVideoWrapper + { +#region arch +#if ARCH_X86 +#if WIN + private const string Dll = "x86\\gstreamerhelper.dll"; +#endif +#endif + +#if ARCH_X64 +#if WIN + private const string Dll = "x64\\gstreamer\\gstreamerhelper.dll"; +#endif +#endif +#endregion arch + public delegate void LogCallback(string message); + + [DllImport(Dll)] + public static extern void SetVideoLogCallback(LogCallback c); + + [DllImport(Dll)] + public static extern bool InitVideo(); + + [DllImport(Dll)] + public static extern void CloseAllVideos(); + + [DllImport(Dll)] + public static extern int LoadVideo(string VideoFileName); + + [DllImport(Dll)] + public static extern bool CloseVideo(int StreamID); + + [DllImport(Dll)] + public static extern int GetVideoNumStreams(); + + [DllImport(Dll)] + public static extern float GetVideoLength(int StreamID); + + [DllImport(Dll)] + public static extern IntPtr GetFrame(int StreamID, float Time, ref float VideoTime); + + [DllImport(Dll)] + public static extern bool Skip(int StreamID, float Start, float Gap); + + [DllImport(Dll)] + public static extern void SetVideoLoop(int StreamID, bool Loop); + + [DllImport(Dll)] + public static extern void PauseVideo(int StreamID); + + [DllImport(Dll)] + public static extern void ResumeVideo(int StreamID); + + [DllImport(Dll)] + public static extern bool Finished(int StreamID); + + } +} diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index b3c711de..ce5349c8 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -224,6 +224,8 @@ + + diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 5bc80276..310dfaa1 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -657,7 +657,8 @@ namespace Vocaluxe.Menu public enum EVideoDecoder { - FFmpeg + FFmpeg, + Gstreamer } public enum ESongMenu