Merge branch 'release-0.3' into develop
This commit is contained in:
commit
d14c8fd37e
2 files changed
+76
-22
No files matched your search
@@ -40,7 +40,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
|
|
||||||
private float _FrameDuration; // frame time in s
|
private float _FrameDuration; // frame time in s
|
||||||
private float _LastDecodedTime; // time of last decoded frame
|
private float _LastDecodedTime; // time of last decoded frame
|
||||||
private float _LastShownTime; // current video position
|
private float _LastShownTime; // time if the last shown frame in s
|
||||||
|
|
||||||
private float _Time;
|
private float _Time;
|
||||||
private float _Gap;
|
private float _Gap;
|
||||||
@@ -123,12 +123,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
|
|
||||||
public bool GetFrame(ref CTexture frame, float time, out float videoTime)
|
public bool GetFrame(ref CTexture frame, float time, out float videoTime)
|
||||||
{
|
{
|
||||||
if (_Paused)
|
|
||||||
{
|
|
||||||
videoTime = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loop)
|
if (Loop)
|
||||||
{
|
{
|
||||||
lock (_MutexSyncSignals)
|
lock (_MutexSyncSignals)
|
||||||
@@ -137,17 +131,17 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
_LoopTimer.Restart();
|
_LoopTimer.Restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Math.Abs(_SetTime - time) > float.Epsilon)
|
else if (Math.Abs(_SetTime - time) >= 1f / 1000f) //Check 1 ms difference
|
||||||
{
|
{
|
||||||
lock (_MutexSyncSignals)
|
lock (_MutexSyncSignals)
|
||||||
{
|
{
|
||||||
_SetTime = time;
|
_SetTime = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (Math.Abs(_LastShownTime - time) < 1f / 1000 && frame != null) //Check 1 ms difference
|
||||||
{
|
{
|
||||||
videoTime = 0;
|
videoTime = _LastShownTime;
|
||||||
return false; //Check if this false is right. But should as we don't give a frame here
|
return true;
|
||||||
}
|
}
|
||||||
_UploadNewFrame(ref frame);
|
_UploadNewFrame(ref frame);
|
||||||
videoTime = _LastShownTime;
|
videoTime = _LastShownTime;
|
||||||
@@ -185,11 +179,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
}
|
}
|
||||||
_LastDecodedTime = _SkipTime;
|
_LastDecodedTime = _SkipTime;
|
||||||
|
|
||||||
lock (_MutexSyncSignals)
|
|
||||||
{
|
|
||||||
_LastShownTime = _LastDecodedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_MutexFramebuffer)
|
lock (_MutexFramebuffer)
|
||||||
{
|
{
|
||||||
_Framebuffer.Clear();
|
_Framebuffer.Clear();
|
||||||
@@ -425,13 +414,15 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
|||||||
float now = _SetTime + _Gap;
|
float now = _SetTime + _Gap;
|
||||||
float maxEnd = now - _FrameDuration * 2; //Get only frames younger than 2
|
float maxEnd = now - _FrameDuration * 2; //Get only frames younger than 2
|
||||||
CFrame frame;
|
CFrame frame;
|
||||||
|
bool paused = _Paused;
|
||||||
while ((frame = _Framebuffer.Get()) != null)
|
while ((frame = _Framebuffer.Get()) != null)
|
||||||
{
|
{
|
||||||
float frameEnd = frame.Time + _FrameDuration;
|
float frameEnd = frame.Time + _FrameDuration;
|
||||||
//Don't show frames that are shown during or after now
|
//Don't show frames that are shown during or after now
|
||||||
if (frameEnd >= now)
|
if (frameEnd >= now)
|
||||||
break; //All following frames are after that one
|
break; //All following frames are after that one
|
||||||
|
if (paused) // Don't modify anything
|
||||||
|
break;
|
||||||
_Framebuffer.SetRead();
|
_Framebuffer.SetRead();
|
||||||
//Get the last(newest) possible frame and skip the rest to force in-order showing
|
//Get the last(newest) possible frame and skip the rest to force in-order showing
|
||||||
if (frameEnd <= maxEnd)
|
if (frameEnd <= maxEnd)
|
||||||
|
|||||||
@@ -21,31 +21,94 @@ namespace Vocaluxe.Lib.Video
|
|||||||
{
|
{
|
||||||
interface IVideoDecoder
|
interface IVideoDecoder
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes videodecoder. Got to be called before usage
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True on success, false if something went wrong.</returns>
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Close all video streams
|
||||||
|
/// </summary>
|
||||||
void CloseAll();
|
void CloseAll();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the file with the given file path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="videoFileName">Absolute file path of the video file</param>
|
||||||
|
/// <returns>StreamID >=0 on success or -1 on failure</returns>
|
||||||
int Load(string videoFileName);
|
int Load(string videoFileName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the stream with the given ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">ID of the stream</param>
|
||||||
|
/// <returns>true if stream was closed, false if stream doesn't exist or already closed</returns>
|
||||||
bool Close(int streamID);
|
bool Close(int streamID);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of streams currently active
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
int GetNumStreams();
|
int GetNumStreams();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the length of the video in s
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">Id of the stream</param>
|
||||||
|
/// <returns>Length of the video in s</returns>
|
||||||
float GetLength(int streamID);
|
float GetLength(int streamID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Gets a frame of the video and sets the current video time
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="streamID"></param>
|
/// <param name="streamID">Id of the stream</param>
|
||||||
/// <param name="frame"></param>
|
/// <param name="frame">Reference to already initialized video texture (from previous calls). If null, one will be created.<br/>
|
||||||
/// <param name="time"></param>
|
/// Returns the current video frame which might be outdated if time != current (internal) video position or unchanged (even null) if none is available.</param>
|
||||||
/// <param name="videoTime"></param>
|
/// <param name="time">The position in s of the video you want to get a frame of. If != current (internal) video position, it will seek to get to right position.<br/>
|
||||||
/// <returns>True if frame is valid</returns>
|
/// <b>Note:</b>Will be ignored for looped playback!</param>
|
||||||
|
/// <param name="videoTime">The actual position in s of the returned frame. Should be ~ time+VideoGap</param>
|
||||||
|
/// <returns>True if frame is valid, false: frame and videoTime might be unchanged or invalid</returns>
|
||||||
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
|
bool GetFrame(int streamID, ref CTexture frame, float time, out float videoTime);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Seeks to given position
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">Id of the stream</param>
|
||||||
|
/// <param name="start">Position to seek to</param>
|
||||||
|
/// <param name="gap">New video gap -> Actual position will be start+gap</param>
|
||||||
|
/// <returns>True on success</returns>
|
||||||
bool Skip(int streamID, float start, float gap);
|
bool Skip(int streamID, float start, float gap);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set if the video should be looped
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">Id of the stream</param>
|
||||||
|
/// <param name="loop">True if it should be looped</param>
|
||||||
void SetLoop(int streamID, bool loop);
|
void SetLoop(int streamID, bool loop);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pauses the video (no new frames will be decoded)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">Id of the stream</param>
|
||||||
void Pause(int streamID);
|
void Pause(int streamID);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resumes a paused video
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">Id of the stream</param>
|
||||||
void Resume(int streamID);
|
void Resume(int streamID);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the given video is finished
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="streamID">Id of the stream</param>
|
||||||
|
/// <returns>True if all frames are shown</returns>
|
||||||
bool Finished(int streamID);
|
bool Finished(int streamID);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Do a step of the decoder in unthreaded decoders. Should be called once every frame.
|
||||||
|
/// </summary>
|
||||||
void Update();
|
void Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user