using System;
using System.Collections;
using System.Collections.Generic;
using BizHawk.MultiClient;
namespace BizHawk
{
public interface IVideoWriter : IDisposable
{
///
/// sets the codec token to be used for video compression
///
void SetVideoCodecToken(IDisposable token);
///
/// sets to a default video codec token without calling any UI - for automated dumping
///
void SetDefaultVideoCodecToken();
// why no OpenFile(IEnumerator) ?
// different video writers may have different ideas of how and why splitting is to occur
///
/// opens a recording stream
/// set a video codec token first.
///
void OpenFile(string baseName);
///
/// close recording stream
///
void CloseFile();
///
/// adds a frame to the stream
///
void AddFrame(IVideoProvider source);
///
/// adds audio samples to the stream
/// no attempt is made to sync this to the video
/// reccomendation: try not to have the size or pacing of the audio chunks be too "weird"
///
void AddSamples(short[] samples);
///
/// obtain a set of recording compression parameters
/// return null on user cancel
///
/// hwnd to attach to if the user is shown config dialog
/// codec token, dispose of it when you're done with it
IDisposable AcquireVideoCodecToken(System.Windows.Forms.IWin32Window hwnd);
///
/// set framerate to fpsnum/fpsden (assumed to be unchanging over the life of the stream)
///
void SetMovieParameters(int fpsnum, int fpsden);
///
/// set resolution parameters (width x height)
/// must be set before file is opened
/// can be changed in future
/// should always match IVideoProvider
///
///
///
void SetVideoParameters(int width, int height);
///
/// set audio parameters. cannot change later
///
void SetAudioParameters(int sampleRate, int channels, int bits);
///
/// set metadata parameters; should be called before opening file
/// ok to not set at all, if not applicable
///
/// The name of the game loaded
/// Authors on movie file
/// Length of movie file in milliseconds
/// Number of rerecords on movie file
void SetMetaData(string gameName, string authors, UInt64 lengthMS, UInt64 rerecords);
///
/// short description of this IVideoWriter
///
string WriterDescription();
///
/// what default extension this writer would like to put on its output
///
string DesiredExtension();
///
/// name that command line parameters can refer to
///
///
string ShortName();
}
///
/// contains methods to find all IVideoWriter
///
public static class VideoWriterInventory
{
public static IEnumerable GetAllVideoWriters()
{
var ret = new IVideoWriter[]
{
new AviWriter(),
new JMDWriter(),
new WavWriterV(),
new FFmpegWriter(),
new NutWriter(),
new BizHawk.MultiClient.AVOut.GifWriter()
};
return ret;
}
///
/// find an IVideoWriter by its short name
///
///
///
public static IVideoWriter GetVideoWriter(string name)
{
IVideoWriter ret = null;
var vws = GetAllVideoWriters();
foreach (var vw in vws)
if (vw.ShortName() == name)
ret = vw;
foreach (var vw in vws)
if (vw != ret)
vw.Dispose();
return ret;
}
}
}