Added empty gstreamer video implementation

This commit is contained in:
Stephan Sundermann committed 2013-02-10 18:03:53 +01:00
1 parent 94ee25cd49
commit 2be1c021ce
12 files changed
+405 -2

No files matched your search

+4
View File
@@ -164,6 +164,8 @@
<ItemGroup>
<ClInclude Include="GstreamerAudio.h" />
<ClInclude Include="GstreamerAudioStream.h" />
<ClInclude Include="GstreamerVideo.h" />
<ClInclude Include="GstreamerVideoStream.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
@@ -184,6 +186,8 @@
</ClCompile>
<ClCompile Include="GstreamerAudio.cpp" />
<ClCompile Include="GstreamerAudioStream.cpp" />
<ClCompile Include="GstreamerVideo.cpp" />
<ClCompile Include="GstreamerVideoStream.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugWin|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugWin|x64'">Create</PrecompiledHeader>
@@ -27,6 +27,12 @@
<ClInclude Include="GstreamerAudio.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="GstreamerVideo.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="GstreamerVideoStream.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@@ -41,5 +47,11 @@
<ClCompile Include="GstreamerAudio.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="GstreamerVideo.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="GstreamerVideoStream.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
</Project>
+133
View File
@@ -0,0 +1,133 @@
#include "stdafx.h"
#include "GstreamerVideo.h"
#include "GstreamerVideoStream.h"
map<int, GstreamerVideoStream*> VideoStreams;
queue<int> 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<int, GstreamerVideoStream*>::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<int, GstreamerVideoStream*> (VideoIDs.front(), s));
VideoIDs.pop();
return s->LoadVideo(Media);
}
DllExport bool CloseVideo(int Stream)
{
map<int,GstreamerVideoStream*>::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<int,GstreamerVideoStream*>::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<int,GstreamerVideoStream*>::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<int,GstreamerVideoStream*>::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<int,GstreamerVideoStream*>::iterator it = VideoStreams.find(Stream);
if(it != VideoStreams.end())
{
it->second->SetVideoLoop(Loop);
}
}
DllExport void PauseVideo(int Stream)
{
map<int,GstreamerVideoStream*>::iterator it = VideoStreams.find(Stream);
if(it != VideoStreams.end())
{
it->second->PauseVideo();
}
}
DllExport void ResumeVideo(int Stream)
{
map<int,GstreamerVideoStream*>::iterator it = VideoStreams.find(Stream);
if(it != VideoStreams.end())
{
it->second->ResumeVideo();
}
}
DllExport bool Finished(int Stream)
{
map<int,GstreamerVideoStream*>::iterator it = VideoStreams.find(Stream);
if(it != VideoStreams.end())
{
return it->second->Finished();
}
else return true;
}
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <string>
#include <map>
#include <queue>
#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);
+56
View File
@@ -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;
}
+25
View File
@@ -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();
};
Binary file not shown.
+3 -1
View File
@@ -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;
@@ -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);
}
}
}
@@ -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);
}
}
+2
View File
@@ -224,6 +224,8 @@
<Compile Include="Lib\Video\Acinerella\CAcinerella.cs" />
<Compile Include="Lib\Video\CVideoDecoder.cs" />
<Compile Include="Lib\Video\CVideoDecoderFFmpeg.cs" />
<Compile Include="Lib\Video\CVideoDecoderGstreamer.cs" />
<Compile Include="Lib\Video\Gstreamer\CGstreamerVideoWrapper.cs" />
<Compile Include="Lib\Video\IVideoDecoder.cs" />
<Compile Include="Lib\Webcam\CAForgeNet.cs" />
<Compile Include="Lib\Webcam\IWebcam.cs" />
+2 -1
View File
@@ -657,7 +657,8 @@ namespace Vocaluxe.Menu
public enum EVideoDecoder
{
FFmpeg
FFmpeg,
Gstreamer
}
public enum ESongMenu