Create new interface VideoWriter, which AviWriter inherits from. Sets up for other video dumping systems.
This commit is contained in:
parent
857d0a5b39
commit
02ca0e82e9
|
@ -10,7 +10,7 @@ using BizHawk;
|
||||||
|
|
||||||
namespace BizHawk.MultiClient
|
namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
class AviWriter : IDisposable
|
class AviWriter : VideoWriter
|
||||||
{
|
{
|
||||||
CodecToken currVideoCodecToken = null;
|
CodecToken currVideoCodecToken = null;
|
||||||
AviWriterSegment currSegment;
|
AviWriterSegment currSegment;
|
||||||
|
@ -27,9 +27,12 @@ namespace BizHawk.MultiClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// sets the codec token to be used for video compression
|
/// sets the codec token to be used for video compression
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetVideoCodecToken(CodecToken token)
|
public void SetVideoCodecToken(IDisposable token)
|
||||||
{
|
{
|
||||||
currVideoCodecToken = token;
|
if (token is CodecToken)
|
||||||
|
currVideoCodecToken = (CodecToken)token;
|
||||||
|
else
|
||||||
|
throw new ArgumentException("AviWriter only takes its own Codec Tokens!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerator<string> CreateBasicNameProvider(string template)
|
public static IEnumerator<string> CreateBasicNameProvider(string template)
|
||||||
|
@ -192,7 +195,7 @@ namespace BizHawk.MultiClient
|
||||||
/// Acquires a video codec configuration from the user. you may save it for future use, but you must dispose of it when youre done with it.
|
/// Acquires a video codec configuration from the user. you may save it for future use, but you must dispose of it when youre done with it.
|
||||||
/// returns null if the user canceled the dialog
|
/// returns null if the user canceled the dialog
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static CodecToken AcquireVideoCodecToken(IntPtr hwnd, CodecToken lastToken)
|
public IDisposable AcquireVideoCodecToken(IntPtr hwnd) //, CodecToken lastToken)
|
||||||
{
|
{
|
||||||
var temp_params = new Parameters();
|
var temp_params = new Parameters();
|
||||||
temp_params.height = 256;
|
temp_params.height = 256;
|
||||||
|
@ -206,8 +209,8 @@ namespace BizHawk.MultiClient
|
||||||
string tempfile = Path.GetTempFileName();
|
string tempfile = Path.GetTempFileName();
|
||||||
File.Delete(tempfile);
|
File.Delete(tempfile);
|
||||||
tempfile = Path.ChangeExtension(tempfile, "avi");
|
tempfile = Path.ChangeExtension(tempfile, "avi");
|
||||||
temp.OpenFile(tempfile, temp_params, lastToken);
|
temp.OpenFile(tempfile, temp_params, null); //lastToken);
|
||||||
CodecToken token = temp.AcquireVideoCodecToken(hwnd);
|
CodecToken token = (CodecToken) temp.AcquireVideoCodecToken(hwnd);
|
||||||
temp.CloseFile();
|
temp.CloseFile();
|
||||||
File.Delete(tempfile);
|
File.Delete(tempfile);
|
||||||
return token;
|
return token;
|
||||||
|
@ -469,7 +472,7 @@ namespace BizHawk.MultiClient
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Acquires a video codec configuration from the user
|
/// Acquires a video codec configuration from the user
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CodecToken AcquireVideoCodecToken(IntPtr hwnd)
|
public IDisposable AcquireVideoCodecToken(IntPtr hwnd)
|
||||||
{
|
{
|
||||||
if (!IsOpen) throw new InvalidOperationException("File must be opened before acquiring a codec token (or else the stream formats wouldnt be known)");
|
if (!IsOpen) throw new InvalidOperationException("File must be opened before acquiring a codec token (or else the stream formats wouldnt be known)");
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,7 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="VideoWriter.cs" />
|
||||||
<EmbeddedResource Include="config\GifAnimator.resx">
|
<EmbeddedResource Include="config\GifAnimator.resx">
|
||||||
<DependentUpon>GifAnimator.cs</DependentUpon>
|
<DependentUpon>GifAnimator.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace BizHawk.MultiClient
|
||||||
public bool PressRewind = false;
|
public bool PressRewind = false;
|
||||||
|
|
||||||
//avi/wav state
|
//avi/wav state
|
||||||
AviWriter CurrAviWriter = null;
|
VideoWriter CurrAviWriter = null;
|
||||||
|
|
||||||
//runloop control
|
//runloop control
|
||||||
bool exit;
|
bool exit;
|
||||||
|
@ -2666,13 +2666,13 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
//TODO - cores should be able to specify exact values for these instead of relying on this to calculate them
|
//TODO - cores should be able to specify exact values for these instead of relying on this to calculate them
|
||||||
int fps = (int)(Global.Emulator.CoreOutputComm.VsyncRate * 0x01000000);
|
int fps = (int)(Global.Emulator.CoreOutputComm.VsyncRate * 0x01000000);
|
||||||
AviWriter aw = new AviWriter();
|
VideoWriter aw = new AviWriter();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
aw.SetMovieParameters(fps, 0x01000000);
|
aw.SetMovieParameters(fps, 0x01000000);
|
||||||
aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight);
|
aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight);
|
||||||
aw.SetAudioParameters(44100, 2, 16);
|
aw.SetAudioParameters(44100, 2, 16);
|
||||||
var token = AviWriter.AcquireVideoCodecToken(Global.MainForm.Handle, null);
|
var token = aw.AcquireVideoCodecToken(Global.MainForm.Handle); //, null);
|
||||||
aw.SetVideoCodecToken(token);
|
aw.SetVideoCodecToken(token);
|
||||||
aw.OpenFile(sfd.FileName);
|
aw.OpenFile(sfd.FileName);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BizHawk
|
||||||
|
{
|
||||||
|
public interface VideoWriter : IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// sets the codec token to be used for video compression
|
||||||
|
/// </summary>
|
||||||
|
void SetVideoCodecToken(IDisposable token);
|
||||||
|
|
||||||
|
|
||||||
|
// why no OpenFile(IEnumerator<string>) ?
|
||||||
|
// different video writers may have different ideas of how and why splitting is to occur
|
||||||
|
/// <summary>
|
||||||
|
/// opens a recording stream
|
||||||
|
/// set a video codec token first.
|
||||||
|
/// </summary>
|
||||||
|
void OpenFile(string baseName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// close recording stream
|
||||||
|
/// </summary>
|
||||||
|
void CloseFile();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// adds a frame to the stream
|
||||||
|
/// </summary>
|
||||||
|
void AddFrame(IVideoProvider source);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// adds audio samples to the stream
|
||||||
|
/// no attempt is made to sync this to the video
|
||||||
|
/// </summary>
|
||||||
|
void AddSamples(short[] samples);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// obtain a set of recording compression parameters
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwnd">hwnd to attach to if the user is shown config dialog</param>
|
||||||
|
/// <returns>codec token, dispose of it when you're done with it</returns>
|
||||||
|
IDisposable AcquireVideoCodecToken(IntPtr hwnd);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set framerate to fpsnum/fpsden (assumed to be unchanging over the life of the stream)
|
||||||
|
/// </summary>
|
||||||
|
void SetMovieParameters(int fpsnum, int fpsden);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set resolution parameters (width x height)
|
||||||
|
/// must be set before file is opened
|
||||||
|
/// can be changed in future
|
||||||
|
/// should always match IVideoProvider
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="width"></param>
|
||||||
|
/// <param name="height"></param>
|
||||||
|
void SetVideoParameters(int width, int height);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set audio parameters. cannot change later
|
||||||
|
/// </summary>
|
||||||
|
void SetAudioParameters(int sampleRate, int channels, int bits);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue