#include "wx/wx.h"
#endif
-// Personnal headers
+// Personal headers
#include "wx/stream.h"
#include "wx/wfstream.h"
#include "sndwin.h"
#endif
+#include "vidbase.h"
+#ifdef __UNIX__
+#include "vidxanm.h"
+#endif
+
+#ifdef __WIN32__
+#include "vidwin.h"
+#endif
+
#include "mmboard.h"
#include "mmbman.h"
MMBoardTime GetLength();
bool IsStopped();
+ bool IsPaused();
wxString GetStringType();
wxString GetStringInformation();
wxSoundFileStream *m_file_stream;
MMBoardTime m_length;
+ wxUint8 m_file_type;
+};
+
+class MMBoardVideoFile: public MMBoardFile {
+public:
+ MMBoardVideoFile(const wxString& filename);
+ ~MMBoardVideoFile();
+
+ bool NeedWindow();
+
+ void SetWindow(wxWindow *window);
+
+ void Play();
+ void Pause();
+ void Resume();
+ void Stop();
+
+ MMBoardTime GetPosition();
+ MMBoardTime GetLength();
+
+ bool IsStopped();
+ bool IsPaused();
+
+ wxString GetStringType();
+ wxString GetStringInformation();
+
+protected:
+ wxWindow *m_output_window;
+ wxInputStream *m_input_stream;
+ wxVideoBaseDriver *m_video_driver;
};
// ----------------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------------
+#define MMBoard_UNKNOWNTYPE 0
+#define MMBoard_WAVE 1
+#define MMBoard_AIFF 2
// ----------------------------------------------------------------------------
// MMBoardSoundFile
m_file_stream = GetDecoder();
- if (!m_file_stream)
+ if (!m_file_stream) {
SetError(MMBoard_UnknownFile);
-
+ return;
+ }
+
// Compute length
wxUint32 length, seconds;
MMBoardSoundFile::~MMBoardSoundFile()
{
- delete m_file_stream;
+ if (m_file_stream)
+ delete m_file_stream;
MMBoardManager::UnrefSoundStream(m_output_stream);
delete m_input_stream;
}
// First, we try a Wave decoder
f_stream = new wxSoundWave(*m_input_stream, *m_output_stream);
+ m_file_type = MMBoard_WAVE;
if (f_stream->CanRead())
return f_stream;
delete f_stream;
// Then, a AIFF decoder
f_stream = new wxSoundAiff(*m_input_stream, *m_output_stream);
+ m_file_type = MMBoard_AIFF;
if (f_stream->CanRead())
return f_stream;
delete f_stream;
+ m_file_type = MMBoard_UNKNOWNTYPE;
+
// TODO: automate
return NULL;
return m_file_stream->IsStopped();
}
+bool MMBoardSoundFile::IsPaused()
+{
+ return m_file_stream->IsPaused();
+}
+
MMBoardTime MMBoardSoundFile::GetPosition()
{
wxUint32 length, seconds;
wxString MMBoardSoundFile::GetStringType()
{
- return wxString("WAVE file");
+ switch (m_file_type) {
+ case MMBoard_WAVE:
+ return wxString("WAVE file");
+ break;
+ case MMBoard_AIFF:
+ return wxString("AIFF file");
+ break;
+ default:
+ return wxString("Unknown file");
+ break;
+ }
}
wxString MMBoardSoundFile::GetStringInformation()
// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// MMBoardVideoFile
+
+MMBoardVideoFile::MMBoardVideoFile(const wxString& filename)
+{
+ m_output_window = NULL;
+ m_input_stream = new wxFileInputStream(filename);
+
+#if defined(__UNIX__)
+ m_video_driver = new wxVideoXANIM(*m_input_stream);
+#elif defined(__WIN32__)
+ m_video_driver = new wxVideoWindows(m_input_stream);
+#else
+ m_video_driver = NULL;
+ SetError(MMBoard_UnknownFile);
+#endif
+}
+
+MMBoardVideoFile::~MMBoardVideoFile()
+{
+ if (m_video_driver)
+ delete m_video_driver;
+
+ delete m_input_stream;
+}
+
+bool MMBoardVideoFile::NeedWindow()
+{
+ return TRUE;
+}
+
+void MMBoardVideoFile::SetWindow(wxWindow *window)
+{
+ m_output_window = window;
+ m_video_driver->AttachOutput(*window);
+}
+
+void MMBoardVideoFile::Play()
+{
+ m_video_driver->Play();
+}
+
+void MMBoardVideoFile::Pause()
+{
+ m_video_driver->Pause();
+}
+
+void MMBoardVideoFile::Resume()
+{
+ m_video_driver->Resume();
+}
+
+void MMBoardVideoFile::Stop()
+{
+ m_video_driver->Stop();
+}
+
+MMBoardTime MMBoardVideoFile::GetPosition()
+{
+ MMBoardTime btime;
+
+ btime.seconds = btime.minutes = btime.hours = 0;
+ return btime;
+}
+
+MMBoardTime MMBoardVideoFile::GetLength()
+{
+ MMBoardTime btime;
+
+ btime.seconds = 1;
+ btime.minutes = btime.hours = 0;
+ return btime;
+}
+
+bool MMBoardVideoFile::IsStopped()
+{
+ return m_video_driver->IsStopped();
+}
+
+bool MMBoardVideoFile::IsPaused()
+{
+ return m_video_driver->IsPaused();
+}
+
+wxString MMBoardVideoFile::GetStringType()
+{
+ return wxString("Video XANIM");
+}
+
+wxString MMBoardVideoFile::GetStringInformation()
+{
+ return wxString("No info");
+}
+
+// ----------------------------------------------------------------------------
+
// ----------------------------------------------------------------------------
// MMBoardFile
{
MMBoardFile *file;
+ // Test the audio codec
file = new MMBoardSoundFile(filename);
- if (file->GetError()) {
- delete file;
- return NULL;
- }
- return file;
+ if (!file->GetError())
+ return file;
+ delete file;
+
+ // Test the video codec
+ file = new MMBoardVideoFile(filename);
+ if (!file->GetError())
+ return file;
+ delete file;
+
+ // Arrrgh, we just could not see what is that file ...
+ return NULL;
}
DECLARE_APP(MMBoardApp)