AVI file playing on Windows is working

Many fixes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6219 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux
2000-02-22 18:20:46 +00:00
parent 85bc0351f7
commit ebaad2ccc7
10 changed files with 548 additions and 415 deletions

View File

@@ -263,13 +263,13 @@ wxString MMBoardSoundFile::GetStringType()
{ {
switch (m_file_type) { switch (m_file_type) {
case MMBoard_WAVE: case MMBoard_WAVE:
return wxString("WAVE file"); return wxString(wxT("WAVE file"));
break; break;
case MMBoard_AIFF: case MMBoard_AIFF:
return wxString("AIFF file"); return wxString(wxT("AIFF file"));
break; break;
default: default:
return wxString("Unknown file"); return wxString(wxT("Unknown file"));
break; break;
} }
} }
@@ -281,15 +281,15 @@ wxString MMBoardSoundFile::GetStringInformation()
format = &(m_file_stream->GetSoundFormat()); format = &(m_file_stream->GetSoundFormat());
info = _T("Data encoding: "); info = wxT("Data encoding: ");
switch (format->GetType()) { switch (format->GetType()) {
case wxSOUND_PCM: { case wxSOUND_PCM: {
wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format; wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format;
info += _T("PCM\n"); info += wxT("PCM\n");
info += wxString::Format(_T("Sampling rate: %d\n") info += wxString::Format(wxT("Sampling rate: %d\n")
_T("Bits per sample: %d\n") wxT("Bits per sample: %d\n")
_T("Number of channels: %d\n"), wxT("Number of channels: %d\n"),
pcm_format->GetSampleRate(), pcm_format->GetSampleRate(),
pcm_format->GetBPS(), pcm_format->GetBPS(),
pcm_format->GetChannels()); pcm_format->GetChannels());
@@ -298,12 +298,12 @@ wxString MMBoardSoundFile::GetStringInformation()
} }
case wxSOUND_ULAW: { case wxSOUND_ULAW: {
wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format; wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format;
info += _T("ULAW\n"); info += wxT("ULAW\n");
info += wxString::Format(_T("Sampling rate: %d\n"), ulaw_format->GetSampleRate()); info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate());
break; break;
} }
default: default:
info += _T("Unknown"); info += wxT("Unknown");
break; break;
} }
return info; return info;
@@ -318,12 +318,11 @@ wxString MMBoardSoundFile::GetStringInformation()
MMBoardVideoFile::MMBoardVideoFile(const wxString& filename) MMBoardVideoFile::MMBoardVideoFile(const wxString& filename)
{ {
m_output_window = NULL; m_output_window = NULL;
m_input_stream = new wxFileInputStream(filename);
#if defined(__UNIX__) #if defined(__UNIX__)
m_video_driver = new wxVideoXANIM(*m_input_stream); m_video_driver = new wxVideoXANIM(filename);
#elif defined(__WIN32__) #elif defined(__WIN32__)
m_video_driver = new wxVideoWindows(m_input_stream); m_video_driver = new wxVideoWindows(filename);
#else #else
m_video_driver = NULL; m_video_driver = NULL;
SetError(MMBoard_UnknownFile); SetError(MMBoard_UnknownFile);
@@ -398,12 +397,12 @@ bool MMBoardVideoFile::IsPaused()
wxString MMBoardVideoFile::GetStringType() wxString MMBoardVideoFile::GetStringType()
{ {
return wxString("Video XANIM"); return wxString(wxT("Video XANIM"));
} }
wxString MMBoardVideoFile::GetStringInformation() wxString MMBoardVideoFile::GetStringInformation()
{ {
return wxString("No info"); return wxString(wxT("No info"));
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -196,19 +196,19 @@ wxUint8 MMBoardApp::TestMultimediaCaps()
caps = 0; caps = 0;
#ifdef __UNIX__ #ifdef __UNIX__
// We test the OSS (Open Sound System) support.
dev = new wxSoundStreamOSS();
if (dev->GetError() == wxSOUND_NOERR)
caps |= MM_SOUND_OSS;
delete dev;
// We now test the ESD support // We now test the ESD support
dev = new wxSoundStreamESD(); dev = new wxSoundStreamESD();
if (dev->GetError() == wxSOUND_NOERR) if (dev->GetError() == wxSOUND_NOERR)
caps |= MM_SOUND_ESD; caps |= MM_SOUND_ESD;
delete dev; delete dev;
// We test the OSS (Open Sound System) support.
dev = new wxSoundStreamOSS();
if (dev->GetError() == wxSOUND_NOERR)
caps |= MM_SOUND_OSS;
delete dev;
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
@@ -355,9 +355,9 @@ void MMBoardFrame::OpenVideoWindow()
if (m_video_window) if (m_video_window)
return; return;
m_video_window = new wxWindow(m_panel, -1, wxDefaultPosition, wxSize(400, 400)); m_video_window = new wxWindow(m_panel, -1, wxDefaultPosition, wxSize(200, 200));
m_video_window->SetBackgroundColour(*wxBLACK); m_video_window->SetBackgroundColour(*wxBLACK);
m_sizer->Prepend(m_video_window, 0, wxGROW | wxSHRINK | wxCENTRE, 0); m_sizer->Prepend(m_video_window, 2, wxGROW | wxSHRINK | wxCENTRE, 1);
m_sizer->Fit(this); m_sizer->Fit(this);
} }

View File

@@ -21,7 +21,7 @@ LIBTARGET=$(WXDIR)\lib\mmedia2.lib
OBJECTS = cdbase.obj cdwin.obj g711.obj g721.obj g723_24.obj sndg72x.obj \ OBJECTS = cdbase.obj cdwin.obj g711.obj g721.obj g723_24.obj sndg72x.obj \
g723_40.obj g72x.obj sndbase.obj sndcodec.obj sndpcm.obj \ g723_40.obj g72x.obj sndbase.obj sndcodec.obj sndpcm.obj \
sndcpcm.obj sndulaw.obj sndfile.obj sndwav.obj sndaiff.obj sndwin.obj \ sndcpcm.obj sndulaw.obj sndfile.obj sndwav.obj sndaiff.obj sndwin.obj \
vidbase.obj vidbase.obj vidwin.obj
!include $(WXDIR)\src\makelib.vc !include $(WXDIR)\src\makelib.vc
@@ -104,3 +104,9 @@ vidbase.obj: vidbase.h vidbase.$(SRCSUFF)
$(cc) @<< $(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) $(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<< <<
vidwin.obj: vidwin.h vidwin.$(SRCSUFF)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<

View File

@@ -28,7 +28,7 @@ wxSoundStreamOSS::wxSoundStreamOSS(const wxString& dev_name)
{ {
wxSoundFormatPcm pcm_default; wxSoundFormatPcm pcm_default;
m_fd = open(dev_name.mb_str(), O_RDWR); m_fd = open(dev_name.mb_str(), O_WRONLY);
if (m_fd == -1) { if (m_fd == -1) {
m_snderror = wxSOUND_INVDEV; m_snderror = wxSOUND_INVDEV;

View File

@@ -37,6 +37,11 @@ wxVideoBaseDriver::wxVideoBaseDriver(wxInputStream& str)
m_video_output = NULL; m_video_output = NULL;
} }
wxVideoBaseDriver::wxVideoBaseDriver(const wxString& filename)
{
m_video_output = NULL;
}
wxVideoBaseDriver::~wxVideoBaseDriver() wxVideoBaseDriver::~wxVideoBaseDriver()
{ {
} }

View File

@@ -13,14 +13,32 @@
#define __VID_bdrv_H__ #define __VID_bdrv_H__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "vidbase.h"
#endif #endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include "wx/defs.h"
#include "wx/stream.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/frame.h" #include "wx/frame.h"
#endif
// ----------------------------------------------------------------------------
// wxMMedia2 (video) types
///
typedef enum { typedef enum {
wxVIDEO_MSAVI, wxVIDEO_MSAVI,
wxVIDEO_MPEG, wxVIDEO_MPEG,
@@ -31,58 +49,49 @@ typedef enum {
wxVIDEO_IFF, wxVIDEO_IFF,
wxVIDEO_SGI, wxVIDEO_SGI,
wxVIDEO_MPEG2 wxVIDEO_MPEG2
} /// } wxVideoType;
wxVideoType;
/// // ----------------------------------------------------------------------------
class wxVideoBaseDriver; // Classes definition
/// class WXDLLEXPORT wxVideoBaseDriver : public wxObject {
class wxVideoBaseDriver : public wxObject {
///
DECLARE_ABSTRACT_CLASS(wxVideoBaseDriver) DECLARE_ABSTRACT_CLASS(wxVideoBaseDriver)
protected: protected:
wxWindow *m_video_output; wxWindow *m_video_output;
public: public:
// // Ctors
wxVideoBaseDriver(); wxVideoBaseDriver();
//
wxVideoBaseDriver(wxInputStream& str); wxVideoBaseDriver(wxInputStream& str);
// wxVideoBaseDriver(const wxString& filename);
// Dtor
virtual ~wxVideoBaseDriver(); virtual ~wxVideoBaseDriver();
// // Usual functions ... They all return FALSE in case of errors.
virtual bool Play() = 0; virtual bool Play() = 0;
//
virtual bool Stop() = 0; virtual bool Stop() = 0;
//
virtual bool Pause() = 0; virtual bool Pause() = 0;
//
virtual bool Resume() = 0; virtual bool Resume() = 0;
// // Size management
virtual bool SetVolume(wxUint8 vol) = 0;
//
virtual bool Resize(wxUint16 w, wxUint16 h) = 0; virtual bool Resize(wxUint16 w, wxUint16 h) = 0;
//
virtual bool GetSize(wxSize& size) const = 0; virtual bool GetSize(wxSize& size) const = 0;
// // Test the capability of the driver to handle the specified type
virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) { return FALSE; } virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) { return FALSE; }
// // Called when the movie finished
virtual void OnFinished() {} virtual void OnFinished() {}
// // Attaches the video output to a window. The video will be shown in that window.
virtual bool AttachOutput(wxWindow& output); virtual bool AttachOutput(wxWindow& output);
//
virtual void DetachOutput(); virtual void DetachOutput();
// They return the state of the movie.
virtual bool IsPaused() = 0; virtual bool IsPaused() = 0;
virtual bool IsStopped() = 0; virtual bool IsStopped() = 0;
}; };
extern wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv); WXDLLEXPORT wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv);
#endif #endif

View File

@@ -12,76 +12,107 @@
#pragma implementation "vidwin.h" #pragma implementation "vidwin.h"
#endif #endif
#if 0
#include "wx/wxprec.h" #include "wx/wxprec.h"
#else
#ifndef WX_PRECOMP
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include "wx/stream.h"
#include "wx/wfstream.h"
#define WXMMEDIA_INTERNAL #define WXMMEDIA_INTERNAL
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include <digitalv.h> #include <digitalv.h>
#include "mmtype.h"
#include "mmfile.h"
#include "vidwin.h" #include "vidwin.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
wxVideoWindows::wxVideoWindows(void) IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows, wxVideoBaseDriver)
wxVideoWindows::wxVideoWindows()
{ {
} }
wxVideoWindows::wxVideoWindows(wxInputStream& str, bool seekable) wxVideoWindows::wxVideoWindows(wxInputStream& str)
: wxVideoBaseDriver(str, seekable) : wxVideoBaseDriver(str)
{ {
OpenFile(GetCurrentFile()); m_internal = new wxVIDWinternal;
m_remove_file = TRUE;
m_filename = wxGetTempFileName("wxvid");
m_paused = FALSE;
m_stopped = TRUE;
wxFileOutputStream temp_file(m_filename);
temp_file << str;
OpenFile();
} }
wxVideoWindows::wxVideoWindows(const char *fname) wxVideoWindows::wxVideoWindows(const wxString& filename)
: wxVideoBaseDriver(fname) : wxVideoBaseDriver(filename)
{ {
OpenFile(fname); m_internal = new wxVIDWinternal;
m_remove_file = FALSE;
m_filename = filename;
m_paused = FALSE;
m_stopped = TRUE;
OpenFile();
} }
wxVideoWindows::~wxVideoWindows(void) wxVideoWindows::~wxVideoWindows(void)
{ {
mciSendCommand(internal->dev_id, MCI_CLOSE, 0, 0); mciSendCommand(m_internal->m_dev_id, MCI_CLOSE, 0, 0);
if (internal) if (m_internal)
delete internal; delete m_internal;
} }
void wxVideoWindows::OpenFile(const char *fname) void wxVideoWindows::OpenFile()
{ {
MCI_DGV_OPEN_PARMS open_struct; MCI_DGV_OPEN_PARMS open_struct;
DWORD ret; DWORD ret;
internal = new VIDW_Internal;
open_struct.lpstrDeviceType = "avivideo"; open_struct.lpstrDeviceType = "avivideo";
open_struct.lpstrElementName = (LPSTR)fname; open_struct.lpstrElementName = (LPSTR)(m_filename.mb_str());
open_struct.hWndParent = 0; open_struct.hWndParent = 0;
ret = mciSendCommand(0, MCI_OPEN, ret = mciSendCommand(0, MCI_OPEN,
MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT, MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT,
(DWORD)(LPVOID)&open_struct); (DWORD)(LPVOID)&open_struct);
internal->dev_id = open_struct.wDeviceID; m_internal->m_dev_id = open_struct.wDeviceID;
} }
bool wxVideoWindows::Pause(void) bool wxVideoWindows::Pause()
{ {
return (mciSendCommand(internal->dev_id, MCI_PAUSE, 0, 0) == 0); if (m_paused || m_stopped)
return TRUE;
m_paused = TRUE;
return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, 0, 0) == 0);
} }
bool wxVideoWindows::Resume(void) bool wxVideoWindows::Resume()
{ {
return (mciSendCommand(internal->dev_id, MCI_PAUSE, 0, 0) == 0); if (!m_paused || m_stopped)
return TRUE;
m_paused = FALSE;
return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, 0, 0) == 0);
} }
bool wxVideoWindows::SetVolume(wxUint8 vol) bool wxVideoWindows::IsPaused()
{
return m_paused;
}
bool wxVideoWindows::IsStopped()
{
return m_stopped;
}
bool wxVideoWindows::GetSize(wxSize& size) const
{ {
return TRUE; return TRUE;
} }
@@ -96,7 +127,7 @@ bool wxVideoWindows::IsCapable(wxVideoType v_type)
return (v_type == wxVIDEO_MSAVI); return (v_type == wxVIDEO_MSAVI);
} }
bool wxVideoWindows::AttachOutput(wxVideoOutput& output) bool wxVideoWindows::AttachOutput(wxWindow& output)
{ {
MCI_DGV_WINDOW_PARMS win_struct; MCI_DGV_WINDOW_PARMS win_struct;
@@ -104,28 +135,34 @@ bool wxVideoWindows::AttachOutput(wxVideoOutput& output)
return FALSE; return FALSE;
win_struct.hWnd = (HWND)output.GetHWND(); win_struct.hWnd = (HWND)output.GetHWND();
mciSendCommand(internal->dev_id, MCI_WINDOW, mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
return TRUE; return TRUE;
} }
void wxVideoWindows::DetachOutput(void) void wxVideoWindows::DetachOutput()
{ {
MCI_DGV_WINDOW_PARMS win_struct; MCI_DGV_WINDOW_PARMS win_struct;
wxVideoBaseDriver::DetachOutput(); wxVideoBaseDriver::DetachOutput();
win_struct.hWnd = 0; win_struct.hWnd = 0;
mciSendCommand(internal->dev_id, MCI_WINDOW, mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
} }
bool wxVideoWindows::StartPlay(void) bool wxVideoWindows::Play()
{ {
return (mciSendCommand(internal->dev_id, MCI_PLAY, 0, NULL) == 0); if (!m_stopped)
return FALSE;
m_stopped = FALSE;
return (mciSendCommand(m_internal->m_dev_id, MCI_PLAY, 0, NULL) == 0);
} }
void wxVideoWindows::StopPlay(void) bool wxVideoWindows::Stop()
{ {
mciSendCommand(internal->dev_id, MCI_STOP, 0, NULL); if (m_stopped)
return FALSE;
m_stopped = TRUE;
return (mciSendCommand(m_internal->m_dev_id, MCI_STOP, 0, NULL) == 0);
} }

View File

@@ -1,4 +1,4 @@
// ///////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
// Name: vidwin.h // Name: vidwin.h
// Purpose: wxMMedia // Purpose: wxMMedia
// Author: Guilhem Lavaux // Author: Guilhem Lavaux
@@ -6,57 +6,82 @@
// Updated: // Updated:
// Copyright: (C) 1998, Guilhem Lavaux // Copyright: (C) 1998, Guilhem Lavaux
// License: wxWindows license // License: wxWindows license
// ///////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------
/* Real -*- C++ -*- */
#ifndef __VID_windows_H__ #ifndef __VID_windows_H__
#define __VID_windows_H__ #define __VID_windows_H__
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "vidwin.h"
#endif #endif
#include "mmtype.h" // ----------------------------------------------------------------------------
#include "mmfile.h" // headers
#ifdef WX_PRECOMP // ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#else
#include "wx/wx.h" #ifdef __BORLANDC__
#pragma hdrstop
#endif #endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/stream.h"
#include "wx/window.h"
#endif
// ----------------------------------------------------------------------------
// wxMMedia2 headers
#include "vidbase.h" #include "vidbase.h"
// ----------------------------------------------------------------------------
// System headers and private types
#ifdef WXMMEDIA_INTERNAL #ifdef WXMMEDIA_INTERNAL
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
typedef struct VIDW_Internal { typedef struct VIDW_Internal {
MCIDEVICEID dev_id; MCIDEVICEID m_dev_id;
} VIDW_Internal; } wxVIDWinternal;
#endif #endif
class wxVideoWindows : public wxVideoBaseDriver { // ----------------------------------------------------------------------------
// Class definition
class WXDLLEXPORT wxVideoWindows : public wxVideoBaseDriver {
DECLARE_DYNAMIC_CLASS(wxVideoWindows) DECLARE_DYNAMIC_CLASS(wxVideoWindows)
protected: protected:
struct VIDW_Internal *internal; struct VIDW_Internal *m_internal;
bool m_paused, m_stopped, m_remove_file;
wxString m_filename;
void OpenFile(const char *fname); void OpenFile();
public: public:
wxVideoWindows(void); wxVideoWindows(void);
wxVideoWindows(wxInputStream& str, bool seekable = FALSE); wxVideoWindows(wxInputStream& str);
wxVideoWindows(const char *fname); wxVideoWindows(const wxString& fname);
virtual ~wxVideoWindows(void); ~wxVideoWindows(void);
virtual bool StartPlay(void); bool Play();
virtual void StopPlay(void); bool Stop();
virtual bool Pause(void); bool Pause();
virtual bool Resume(void); bool Resume();
virtual bool SetVolume(wxUint8 vol); bool Resize(wxUint16 w, wxUint16 h);
virtual bool Resize(wxUint16 w, wxUint16 h); bool GetSize(wxSize& size) const;
virtual bool IsCapable(wxVideoType v_type); bool IsCapable(wxVideoType v_type);
virtual bool AttachOutput(wxVideoOutput& output); bool AttachOutput(wxWindow& output);
virtual void DetachOutput(void); void DetachOutput(void);
bool IsPaused();
bool IsStopped();
}; };
#endif #endif

View File

@@ -1,4 +1,4 @@
//////////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------------
// Name: vidxanm.cpp // Name: vidxanm.cpp
// Purpose: wxMMedia // Purpose: wxMMedia
// Author: Guilhem Lavaux // Author: Guilhem Lavaux
@@ -6,13 +6,15 @@
// Updated: 1998 // Updated: 1998
// Copyright: (C) 1997, 1998, 1999 Guilhem Lavaux // Copyright: (C) 1997, 1998, 1999 Guilhem Lavaux
// License: wxWindows license // License: wxWindows license
//////////////////////////////////////////////////////////////////////////////// // -------------------------------------------------------------------------
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "vidxanm.h" #pragma implementation "vidxanm.h"
#endif #endif
#ifdef WX_PRECOMP
#include <wx_prec.h> #include <wx/wxprec.h>
#else
#ifndef WX_PRECOMP
#include <wx/wx.h> #include <wx/wx.h>
#endif #endif
@@ -37,6 +39,9 @@
IMPLEMENT_DYNAMIC_CLASS(wxVideoXANIM, wxVideoBaseDriver) IMPLEMENT_DYNAMIC_CLASS(wxVideoXANIM, wxVideoBaseDriver)
// -------------------------------------------------------------------------
// End process detector
class wxVideoXANIMProcess: public wxProcess { class wxVideoXANIMProcess: public wxProcess {
public: public:
wxVideoXANIMProcess(wxVideoXANIM *xanim); wxVideoXANIMProcess(wxVideoXANIM *xanim);
@@ -47,6 +52,8 @@ class wxVideoXANIMProcess: public wxProcess {
wxVideoXANIM *m_vid_xanim; wxVideoXANIM *m_vid_xanim;
}; };
// -------------------------------------------------------------------------
// XAnim video driver (implementation)
wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim) wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim)
{ {
@@ -56,6 +63,7 @@ wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim)
void wxVideoXANIMProcess::OnTerminate(int WXUNUSED(pid), int WXUNUSED(status)) void wxVideoXANIMProcess::OnTerminate(int WXUNUSED(pid), int WXUNUSED(status))
{ {
m_vid_xanim->m_xanim_started = FALSE; m_vid_xanim->m_xanim_started = FALSE;
m_vid_xanim->OnFinished();
} }
wxVideoXANIM::wxVideoXANIM() wxVideoXANIM::wxVideoXANIM()
@@ -66,6 +74,7 @@ wxVideoXANIM::wxVideoXANIM()
m_xanim_started = FALSE; m_xanim_started = FALSE;
m_paused = FALSE; m_paused = FALSE;
m_filename = ""; m_filename = "";
m_remove_file = FALSE;
} }
wxVideoXANIM::wxVideoXANIM(wxInputStream& str) wxVideoXANIM::wxVideoXANIM(wxInputStream& str)
@@ -77,11 +86,23 @@ wxVideoXANIM::wxVideoXANIM(wxInputStream& str)
m_paused = FALSE; m_paused = FALSE;
m_filename = wxGetTempFileName("vidxa"); m_filename = wxGetTempFileName("vidxa");
m_remove_file = TRUE;
wxFileOutputStream fout(m_filename); wxFileOutputStream fout(m_filename);
fout << str; fout << str;
} }
wxVideoXANIM::wxVideoXANIM(const wxString& filename)
{
m_internal = new wxXANIMinternal;
m_xanim_detector = new wxVideoXANIMProcess(this);
m_xanim_started = FALSE;
m_paused = FALSE;
m_filename = filename;
m_remove_file = FALSE;
}
wxVideoXANIM::~wxVideoXANIM() wxVideoXANIM::~wxVideoXANIM()
{ {
if (m_xanim_started) if (m_xanim_started)
@@ -89,6 +110,7 @@ wxVideoXANIM::~wxVideoXANIM()
delete m_internal; delete m_internal;
delete m_xanim_detector; delete m_xanim_detector;
if (m_remove_file)
wxRemoveFile(m_filename); wxRemoveFile(m_filename);
} }
@@ -134,31 +156,27 @@ bool wxVideoXANIM::Stop()
SendCommand("q"); SendCommand("q");
m_xanim_started = FALSE; // We are waiting for the termination of the subprocess.
while (m_xanim_started) {
wxYield();
}
m_paused = FALSE; m_paused = FALSE;
return TRUE; return TRUE;
} }
bool wxVideoXANIM::SetVolume(wxUint8 vol) bool wxVideoXANIM::Resize(wxUint16 w, wxUint16 h)
{ {
if (vol > 100) if (!m_video_output)
vol = 100; return FALSE;
wxString str_vol("v%d", vol); m_video_output->SetSize(w, h);
return SendCommand(str_vol.GetData());
}
bool wxVideoXANIM::Resize(wxUint16 WXUNUSED(w), wxUint16 WXUNUSED(h))
{
// Not implemented
// Actually, I think that we just need to resize the output window ...
return FALSE; return FALSE;
} }
bool wxVideoXANIM::GetSize(wxSize& size) const bool wxVideoXANIM::GetSize(wxSize& size) const
{ {
// Not implemented
return FALSE; return FALSE;
} }
@@ -244,7 +262,6 @@ bool wxVideoXANIM::RestartXANIM()
// Get current display // Get current display
#ifdef __WXGTK__ #ifdef __WXGTK__
m_internal->xanim_dpy = gdk_display; m_internal->xanim_dpy = gdk_display;
// We absolutely need the window to be realized.
GtkPizza *pizza = GTK_PIZZA( m_video_output->m_wxwindow ); GtkPizza *pizza = GTK_PIZZA( m_video_output->m_wxwindow );
GdkWindow *window = pizza->bin_window; GdkWindow *window = pizza->bin_window;
@@ -256,7 +273,7 @@ bool wxVideoXANIM::RestartXANIM()
"XANIM_PROPERTY", False); "XANIM_PROPERTY", False);
// Build the command // Build the command
xanim_command.Printf(_T("xanim -Zr +Ze +Sr +f +W%d +f +q " xanim_command.Printf(wxT("xanim -Zr +Ze +Sr +f +W%d +f +q "
"+Av70 %s %s"), m_internal->xanim_window, "+Av70 %s %s"), m_internal->xanim_window,
(xanim_chg_size) ? _T("") : _T(""), (xanim_chg_size) ? _T("") : _T(""),
WXSTRINGCAST m_filename); WXSTRINGCAST m_filename);
@@ -277,6 +294,9 @@ bool wxVideoXANIM::RestartXANIM()
wxYield(); wxYield();
} }
m_video_output->SetSize(m_video_output->GetSize());
// Very useful ! Actually it sends a SETSIZE event to XAnim
m_paused = FALSE; m_paused = FALSE;
return TRUE; return TRUE;

View File

@@ -15,17 +15,40 @@
#pragma interface "vidxanm.h" #pragma interface "vidxanm.h"
#endif #endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/process.h" #include "wx/process.h"
#endif
// ----------------------------------------------------------------------------
// System dependent headers
#if defined(WXMMEDIA_INTERNAL) && (defined(__X__) || defined(__WXGTK__)) #if defined(WXMMEDIA_INTERNAL) && (defined(__X__) || defined(__WXGTK__))
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#endif #endif
// ----------------------------------------------------------------------------
// wxMMedia2 headers
#include "vidbase.h" #include "vidbase.h"
// ----------------------------------------------------------------------------
// Internal types
#ifdef WXMMEDIA_INTERNAL #ifdef WXMMEDIA_INTERNAL
typedef struct wxXANIMinternal { typedef struct wxXANIMinternal {
Display *xanim_dpy; Display *xanim_dpy;
@@ -36,18 +59,27 @@ typedef struct wxXANIMinternal {
#ifndef __XANIM_COMMAND__ #ifndef __XANIM_COMMAND__
#define __XANIM_COMMAND__ "/usr/X11R6/bin/xanim" #define __XANIM_COMMAND__ "/usr/X11R6/bin/xanim"
#endif #endif
#endif #endif
class wxVideoXANIM : public wxVideoBaseDriver { // ----------------------------------------------------------------------------
// Class definition
class WXDLLEXPORT wxVideoXANIM : public wxVideoBaseDriver {
DECLARE_DYNAMIC_CLASS(wxVideoXANIM) DECLARE_DYNAMIC_CLASS(wxVideoXANIM)
protected: protected:
// Remember the state of the subprocess
bool m_xanim_started, m_paused; bool m_xanim_started, m_paused;
// Pure X11 variables
struct wxXANIMinternal *m_internal; struct wxXANIMinternal *m_internal;
wxString m_filename; wxString m_filename;
wxProcess *m_xanim_detector; wxProcess *m_xanim_detector;
// Remember to delete the temporary file when necessary
bool m_remove_file;
public: public:
wxVideoXANIM(); wxVideoXANIM();
wxVideoXANIM(wxInputStream& str); wxVideoXANIM(wxInputStream& str);
wxVideoXANIM(const wxString& filename);
~wxVideoXANIM(); ~wxVideoXANIM();
bool Play(); bool Play();
@@ -70,9 +102,9 @@ public:
friend class wxVideoXANIMProcess; friend class wxVideoXANIMProcess;
protected: protected:
/// // Start the subprocess with the right parameters
bool RestartXANIM(); bool RestartXANIM();
/// // Send a command to the subprocess
bool SendCommand(const char *command,char **ret = NULL, bool SendCommand(const char *command,char **ret = NULL,
wxUint32 *size = NULL); wxUint32 *size = NULL);
}; };