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:
@@ -263,50 +263,50 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString MMBoardSoundFile::GetStringInformation()
|
wxString MMBoardSoundFile::GetStringInformation()
|
||||||
{
|
{
|
||||||
wxString info;
|
wxString info;
|
||||||
wxSoundFormatBase *format;
|
wxSoundFormatBase *format;
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -317,93 +317,92 @@ 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);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MMBoardVideoFile::~MMBoardVideoFile()
|
MMBoardVideoFile::~MMBoardVideoFile()
|
||||||
{
|
{
|
||||||
if (m_video_driver)
|
if (m_video_driver)
|
||||||
delete m_video_driver;
|
delete m_video_driver;
|
||||||
|
|
||||||
delete m_input_stream;
|
delete m_input_stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MMBoardVideoFile::NeedWindow()
|
bool MMBoardVideoFile::NeedWindow()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardVideoFile::SetWindow(wxWindow *window)
|
void MMBoardVideoFile::SetWindow(wxWindow *window)
|
||||||
{
|
{
|
||||||
m_output_window = window;
|
m_output_window = window;
|
||||||
m_video_driver->AttachOutput(*window);
|
m_video_driver->AttachOutput(*window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardVideoFile::Play()
|
void MMBoardVideoFile::Play()
|
||||||
{
|
{
|
||||||
m_video_driver->Play();
|
m_video_driver->Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardVideoFile::Pause()
|
void MMBoardVideoFile::Pause()
|
||||||
{
|
{
|
||||||
m_video_driver->Pause();
|
m_video_driver->Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardVideoFile::Resume()
|
void MMBoardVideoFile::Resume()
|
||||||
{
|
{
|
||||||
m_video_driver->Resume();
|
m_video_driver->Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardVideoFile::Stop()
|
void MMBoardVideoFile::Stop()
|
||||||
{
|
{
|
||||||
m_video_driver->Stop();
|
m_video_driver->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
MMBoardTime MMBoardVideoFile::GetPosition()
|
MMBoardTime MMBoardVideoFile::GetPosition()
|
||||||
{
|
{
|
||||||
MMBoardTime btime;
|
MMBoardTime btime;
|
||||||
|
|
||||||
btime.seconds = btime.minutes = btime.hours = 0;
|
btime.seconds = btime.minutes = btime.hours = 0;
|
||||||
return btime;
|
return btime;
|
||||||
}
|
}
|
||||||
|
|
||||||
MMBoardTime MMBoardVideoFile::GetLength()
|
MMBoardTime MMBoardVideoFile::GetLength()
|
||||||
{
|
{
|
||||||
MMBoardTime btime;
|
MMBoardTime btime;
|
||||||
|
|
||||||
btime.seconds = 1;
|
btime.seconds = 1;
|
||||||
btime.minutes = btime.hours = 0;
|
btime.minutes = btime.hours = 0;
|
||||||
return btime;
|
return btime;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MMBoardVideoFile::IsStopped()
|
bool MMBoardVideoFile::IsStopped()
|
||||||
{
|
{
|
||||||
return m_video_driver->IsStopped();
|
return m_video_driver->IsStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MMBoardVideoFile::IsPaused()
|
bool MMBoardVideoFile::IsPaused()
|
||||||
{
|
{
|
||||||
return m_video_driver->IsPaused();
|
return m_video_driver->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"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
<<
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
@@ -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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -13,14 +13,32 @@
|
|||||||
#define __VID_bdrv_H__
|
#define __VID_bdrv_H__
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface "vidbase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/string.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/window.h"
|
// headers
|
||||||
#include "wx/frame.h"
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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/window.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 Resume() = 0;
|
||||||
virtual bool Pause() = 0;
|
|
||||||
//
|
// Size management
|
||||||
virtual bool Resume() = 0;
|
virtual bool Resize(wxUint16 w, wxUint16 h) = 0;
|
||||||
|
virtual bool GetSize(wxSize& size) const = 0;
|
||||||
//
|
|
||||||
virtual bool SetVolume(wxUint8 vol) = 0;
|
// Test the capability of the driver to handle the specified type
|
||||||
//
|
virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) { return FALSE; }
|
||||||
virtual bool Resize(wxUint16 w, wxUint16 h) = 0;
|
|
||||||
//
|
// Called when the movie finished
|
||||||
virtual bool GetSize(wxSize& size) const = 0;
|
virtual void OnFinished() {}
|
||||||
|
|
||||||
//
|
// Attaches the video output to a window. The video will be shown in that window.
|
||||||
virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) { return FALSE; }
|
virtual bool AttachOutput(wxWindow& output);
|
||||||
|
virtual void DetachOutput();
|
||||||
//
|
|
||||||
virtual void OnFinished() {}
|
// They return the state of the movie.
|
||||||
|
virtual bool IsPaused() = 0;
|
||||||
//
|
virtual bool IsStopped() = 0;
|
||||||
virtual bool AttachOutput(wxWindow& output);
|
|
||||||
//
|
|
||||||
virtual void DetachOutput();
|
|
||||||
|
|
||||||
virtual bool IsPaused() = 0;
|
|
||||||
virtual bool IsStopped() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv);
|
WXDLLEXPORT wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -12,120 +12,157 @@
|
|||||||
#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.lpstrElementName = (LPSTR)(m_filename.mb_str());
|
||||||
open_struct.lpstrDeviceType = "avivideo";
|
open_struct.hWndParent = 0;
|
||||||
open_struct.lpstrElementName = (LPSTR)fname;
|
|
||||||
open_struct.hWndParent = 0;
|
ret = mciSendCommand(0, MCI_OPEN,
|
||||||
|
MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT,
|
||||||
ret = mciSendCommand(0, MCI_OPEN,
|
(DWORD)(LPVOID)&open_struct);
|
||||||
MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT,
|
m_internal->m_dev_id = open_struct.wDeviceID;
|
||||||
(DWORD)(LPVOID)&open_struct);
|
|
||||||
internal->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 TRUE;
|
return m_paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxVideoWindows::IsStopped()
|
||||||
|
{
|
||||||
|
return m_stopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxVideoWindows::GetSize(wxSize& size) const
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoWindows::Resize(wxUint16 w, wxUint16 h)
|
bool wxVideoWindows::Resize(wxUint16 w, wxUint16 h)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoWindows::IsCapable(wxVideoType v_type)
|
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;
|
||||||
|
|
||||||
if (!wxVideoBaseDriver::AttachOutput(output))
|
if (!wxVideoBaseDriver::AttachOutput(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);
|
||||||
}
|
}
|
||||||
|
@@ -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 {
|
// ----------------------------------------------------------------------------
|
||||||
DECLARE_DYNAMIC_CLASS(wxVideoWindows)
|
// Class definition
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxVideoWindows : public wxVideoBaseDriver {
|
||||||
|
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
|
||||||
|
@@ -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,247 +39,265 @@
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
void OnTerminate(int pid, int status);
|
void OnTerminate(int pid, int status);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxVideoXANIM *m_vid_xanim;
|
wxVideoXANIM *m_vid_xanim;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// XAnim video driver (implementation)
|
||||||
|
|
||||||
wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim)
|
wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim)
|
||||||
{
|
{
|
||||||
m_vid_xanim = xanim;
|
m_vid_xanim = 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()
|
||||||
: wxVideoBaseDriver()
|
: wxVideoBaseDriver()
|
||||||
{
|
{
|
||||||
m_internal = new wxXANIMinternal;
|
m_internal = new wxXANIMinternal;
|
||||||
m_xanim_detector = new wxVideoXANIMProcess(this);
|
m_xanim_detector = new wxVideoXANIMProcess(this);
|
||||||
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)
|
||||||
: wxVideoBaseDriver(str)
|
: wxVideoBaseDriver(str)
|
||||||
{
|
{
|
||||||
m_internal = new wxXANIMinternal;
|
m_internal = new wxXANIMinternal;
|
||||||
m_xanim_detector = new wxVideoXANIMProcess(this);
|
m_xanim_detector = new wxVideoXANIMProcess(this);
|
||||||
m_xanim_started = FALSE;
|
m_xanim_started = FALSE;
|
||||||
m_paused = FALSE;
|
m_paused = FALSE;
|
||||||
|
|
||||||
|
m_filename = wxGetTempFileName("vidxa");
|
||||||
|
m_remove_file = TRUE;
|
||||||
|
wxFileOutputStream fout(m_filename);
|
||||||
|
|
||||||
|
fout << str;
|
||||||
|
}
|
||||||
|
|
||||||
m_filename = wxGetTempFileName("vidxa");
|
wxVideoXANIM::wxVideoXANIM(const wxString& filename)
|
||||||
wxFileOutputStream fout(m_filename);
|
{
|
||||||
|
m_internal = new wxXANIMinternal;
|
||||||
|
m_xanim_detector = new wxVideoXANIMProcess(this);
|
||||||
|
m_xanim_started = FALSE;
|
||||||
|
m_paused = FALSE;
|
||||||
|
|
||||||
fout << str;
|
m_filename = filename;
|
||||||
|
m_remove_file = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVideoXANIM::~wxVideoXANIM()
|
wxVideoXANIM::~wxVideoXANIM()
|
||||||
{
|
{
|
||||||
if (m_xanim_started)
|
if (m_xanim_started)
|
||||||
Stop();
|
Stop();
|
||||||
delete m_internal;
|
delete m_internal;
|
||||||
delete m_xanim_detector;
|
delete m_xanim_detector;
|
||||||
|
|
||||||
wxRemoveFile(m_filename);
|
if (m_remove_file)
|
||||||
|
wxRemoveFile(m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Play()
|
bool wxVideoXANIM::Play()
|
||||||
{
|
{
|
||||||
if (!m_paused && m_xanim_started)
|
if (!m_paused && m_xanim_started)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if (!m_video_output) {
|
if (!m_video_output) {
|
||||||
wxVideoCreateFrame(this);
|
wxVideoCreateFrame(this);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The movie starts with xanim
|
// The movie starts with xanim
|
||||||
if (RestartXANIM()) {
|
if (RestartXANIM()) {
|
||||||
m_paused = FALSE;
|
m_paused = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Pause()
|
bool wxVideoXANIM::Pause()
|
||||||
{
|
{
|
||||||
if (!m_paused && SendCommand(" ")) {
|
if (!m_paused && SendCommand(" ")) {
|
||||||
m_paused = TRUE;
|
m_paused = TRUE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Resume()
|
bool wxVideoXANIM::Resume()
|
||||||
{
|
{
|
||||||
if (m_paused && SendCommand(" ")) {
|
if (m_paused && SendCommand(" ")) {
|
||||||
m_paused = FALSE;
|
m_paused = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Stop()
|
bool wxVideoXANIM::Stop()
|
||||||
{
|
{
|
||||||
if (!m_xanim_started)
|
if (!m_xanim_started)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
SendCommand("q");
|
||||||
|
|
||||||
|
// We are waiting for the termination of the subprocess.
|
||||||
|
while (m_xanim_started) {
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_paused = FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxVideoXANIM::Resize(wxUint16 w, wxUint16 h)
|
||||||
|
{
|
||||||
|
if (!m_video_output)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
m_video_output->SetSize(w, h);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
SendCommand("q");
|
|
||||||
|
|
||||||
m_xanim_started = FALSE;
|
|
||||||
m_paused = FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxVideoXANIM::SetVolume(wxUint8 vol)
|
|
||||||
{
|
|
||||||
if (vol > 100)
|
|
||||||
vol = 100;
|
|
||||||
|
|
||||||
wxString str_vol("v%d", vol);
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::GetSize(wxSize& size) const
|
bool wxVideoXANIM::GetSize(wxSize& size) const
|
||||||
{
|
{
|
||||||
// Not implemented
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::IsCapable(wxVideoType v_type)
|
bool wxVideoXANIM::IsCapable(wxVideoType v_type)
|
||||||
{
|
{
|
||||||
if (v_type == wxVIDEO_MSAVI || v_type == wxVIDEO_MPEG ||
|
if (v_type == wxVIDEO_MSAVI || v_type == wxVIDEO_MPEG ||
|
||||||
v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV ||
|
v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV ||
|
||||||
v_type == wxVIDEO_FLI || v_type == wxVIDEO_IFF || v_type == wxVIDEO_SGI)
|
v_type == wxVIDEO_FLI || v_type == wxVIDEO_IFF || v_type == wxVIDEO_SGI)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::IsPaused()
|
bool wxVideoXANIM::IsPaused()
|
||||||
{
|
{
|
||||||
return m_paused;
|
return m_paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::IsStopped()
|
bool wxVideoXANIM::IsStopped()
|
||||||
{
|
{
|
||||||
return !m_xanim_started;
|
return !m_xanim_started;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::AttachOutput(wxWindow& out)
|
bool wxVideoXANIM::AttachOutput(wxWindow& out)
|
||||||
{
|
{
|
||||||
if (!wxVideoBaseDriver::AttachOutput(out))
|
if (!wxVideoBaseDriver::AttachOutput(out))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxVideoXANIM::DetachOutput()
|
void wxVideoXANIM::DetachOutput()
|
||||||
{
|
{
|
||||||
SendCommand("q");
|
SendCommand("q");
|
||||||
m_xanim_started = FALSE;
|
m_xanim_started = FALSE;
|
||||||
m_paused = FALSE;
|
m_paused = FALSE;
|
||||||
|
|
||||||
wxVideoBaseDriver::DetachOutput();
|
wxVideoBaseDriver::DetachOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::SendCommand(const char *command, char **ret,
|
bool wxVideoXANIM::SendCommand(const char *command, char **ret,
|
||||||
wxUint32 *size)
|
wxUint32 *size)
|
||||||
{
|
{
|
||||||
if (!m_xanim_started)
|
if (!m_xanim_started)
|
||||||
if (!RestartXANIM())
|
if (!RestartXANIM())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Send a command to XAnim through X11 Property
|
// Send a command to XAnim through X11 Property
|
||||||
XChangeProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
XChangeProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
||||||
m_internal->xanim_atom,
|
m_internal->xanim_atom,
|
||||||
XA_STRING, 8, PropModeReplace, (unsigned char *)command,
|
XA_STRING, 8, PropModeReplace, (unsigned char *)command,
|
||||||
strlen(command));
|
strlen(command));
|
||||||
XFlush(m_internal->xanim_dpy);
|
XFlush(m_internal->xanim_dpy);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
int prop_format;
|
int prop_format;
|
||||||
Atom prop_type;
|
Atom prop_type;
|
||||||
unsigned long extra;
|
unsigned long extra;
|
||||||
|
|
||||||
XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
||||||
m_internal->xanim_ret, 0, 16, True, AnyPropertyType,
|
m_internal->xanim_ret, 0, 16, True, AnyPropertyType,
|
||||||
&prop_type, &prop_format, (unsigned long *)size,
|
&prop_type, &prop_format, (unsigned long *)size,
|
||||||
&extra, (unsigned char **)ret);
|
&extra, (unsigned char **)ret);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::RestartXANIM()
|
bool wxVideoXANIM::RestartXANIM()
|
||||||
{
|
{
|
||||||
wxString xanim_command;
|
wxString xanim_command;
|
||||||
int ret;
|
int ret;
|
||||||
Atom prop_type;
|
Atom prop_type;
|
||||||
int prop_format;
|
int prop_format;
|
||||||
unsigned long nitems;
|
unsigned long nitems;
|
||||||
unsigned long extra;
|
unsigned long extra;
|
||||||
char prop[4];
|
char prop[4];
|
||||||
bool xanim_chg_size;
|
bool xanim_chg_size;
|
||||||
|
|
||||||
if (!m_video_output || m_xanim_started)
|
if (!m_video_output || m_xanim_started)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Check if we can change the size of the window dynamicly
|
// Check if we can change the size of the window dynamicly
|
||||||
xanim_chg_size = TRUE;
|
xanim_chg_size = TRUE;
|
||||||
// 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;
|
|
||||||
|
m_internal->xanim_window =
|
||||||
m_internal->xanim_window =
|
((GdkWindowPrivate *)window)->xwindow;
|
||||||
((GdkWindowPrivate *)window)->xwindow;
|
|
||||||
#endif
|
#endif
|
||||||
// Get the XANIM atom
|
// Get the XANIM atom
|
||||||
m_internal->xanim_atom = XInternAtom(m_internal->xanim_dpy,
|
m_internal->xanim_atom = XInternAtom(m_internal->xanim_dpy,
|
||||||
"XANIM_PROPERTY", False);
|
"XANIM_PROPERTY", False);
|
||||||
|
|
||||||
|
// Build the command
|
||||||
|
xanim_command.Printf(wxT("xanim -Zr +Ze +Sr +f +W%d +f +q "
|
||||||
|
"+Av70 %s %s"), m_internal->xanim_window,
|
||||||
|
(xanim_chg_size) ? _T("") : _T(""),
|
||||||
|
WXSTRINGCAST m_filename);
|
||||||
|
|
||||||
|
// Execute it
|
||||||
|
if (!wxExecute(xanim_command, FALSE, m_xanim_detector))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
// Wait for XAnim to be ready
|
||||||
|
nitems = 0;
|
||||||
|
m_xanim_started = TRUE;
|
||||||
|
while (nitems == 0 && m_xanim_started) {
|
||||||
|
ret = XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
||||||
|
m_internal->xanim_atom,
|
||||||
|
0, 4, False, AnyPropertyType, &prop_type,
|
||||||
|
&prop_format, &nitems, &extra,
|
||||||
|
(unsigned char **)&prop);
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
// Build the command
|
m_video_output->SetSize(m_video_output->GetSize());
|
||||||
xanim_command.Printf(_T("xanim -Zr +Ze +Sr +f +W%d +f +q "
|
// Very useful ! Actually it sends a SETSIZE event to XAnim
|
||||||
"+Av70 %s %s"), m_internal->xanim_window,
|
|
||||||
(xanim_chg_size) ? _T("") : _T(""),
|
m_paused = FALSE;
|
||||||
WXSTRINGCAST m_filename);
|
|
||||||
|
return TRUE;
|
||||||
// Execute it
|
|
||||||
if (!wxExecute(xanim_command, FALSE, m_xanim_detector))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// Wait for XAnim to be ready
|
|
||||||
nitems = 0;
|
|
||||||
m_xanim_started = TRUE;
|
|
||||||
while (nitems == 0 && m_xanim_started) {
|
|
||||||
ret = XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
|
||||||
m_internal->xanim_atom,
|
|
||||||
0, 4, False, AnyPropertyType, &prop_type,
|
|
||||||
&prop_format, &nitems, &extra,
|
|
||||||
(unsigned char **)&prop);
|
|
||||||
wxYield();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_paused = FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
@@ -15,65 +15,97 @@
|
|||||||
#pragma interface "vidxanm.h"
|
#pragma interface "vidxanm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/string.h"
|
// headers
|
||||||
#include "wx/process.h"
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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/string.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;
|
||||||
Window xanim_window;
|
Window xanim_window;
|
||||||
Atom xanim_atom, xanim_ret;
|
Atom xanim_atom, xanim_ret;
|
||||||
} wxXANIMinternal;
|
} wxXANIMinternal;
|
||||||
|
|
||||||
#ifndef __XANIM_COMMAND__
|
#ifndef __XANIM_COMMAND__
|
||||||
#define __XANIM_COMMAND__ "/usr/X11R6/bin/xanim"
|
#define __XANIM_COMMAND__ "/usr/X11R6/bin/xanim"
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class wxVideoXANIM : public wxVideoBaseDriver {
|
#endif
|
||||||
DECLARE_DYNAMIC_CLASS(wxVideoXANIM)
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Class definition
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxVideoXANIM : public wxVideoBaseDriver {
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxVideoXANIM)
|
||||||
protected:
|
protected:
|
||||||
bool m_xanim_started, m_paused;
|
// Remember the state of the subprocess
|
||||||
struct wxXANIMinternal *m_internal;
|
bool m_xanim_started, m_paused;
|
||||||
wxString m_filename;
|
// Pure X11 variables
|
||||||
wxProcess *m_xanim_detector;
|
struct wxXANIMinternal *m_internal;
|
||||||
|
wxString m_filename;
|
||||||
|
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();
|
wxVideoXANIM(const wxString& filename);
|
||||||
|
~wxVideoXANIM();
|
||||||
bool Play();
|
|
||||||
bool Pause();
|
bool Play();
|
||||||
bool Resume();
|
bool Pause();
|
||||||
bool Stop();
|
bool Resume();
|
||||||
|
bool Stop();
|
||||||
bool SetVolume(wxUint8 vol);
|
|
||||||
bool Resize(wxUint16 w, wxUint16 h);
|
bool SetVolume(wxUint8 vol);
|
||||||
bool GetSize(wxSize& size) const;
|
bool Resize(wxUint16 w, wxUint16 h);
|
||||||
|
bool GetSize(wxSize& size) const;
|
||||||
bool IsCapable(wxVideoType v_type);
|
|
||||||
|
|
||||||
bool AttachOutput(wxWindow& output);
|
|
||||||
void DetachOutput();
|
|
||||||
|
|
||||||
bool IsPaused();
|
|
||||||
bool IsStopped();
|
|
||||||
|
|
||||||
friend class wxVideoXANIMProcess;
|
|
||||||
|
|
||||||
|
bool IsCapable(wxVideoType v_type);
|
||||||
|
|
||||||
|
bool AttachOutput(wxWindow& output);
|
||||||
|
void DetachOutput();
|
||||||
|
|
||||||
|
bool IsPaused();
|
||||||
|
bool IsStopped();
|
||||||
|
|
||||||
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user