Major changes in wxVidXANIM (support for output filtering)

Several API addings
Added process.cpp, process.h and utilsunx.cpp in wxMMedia directory
They should be moved to src/unix, src/common and include/wx to use them


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6280 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux
2000-02-25 09:08:52 +00:00
parent 079bb992e1
commit 2018e574e7
17 changed files with 1326 additions and 66 deletions
+9 -1
View File
@@ -30,10 +30,18 @@ Video features:
time
Video bugs:
* Recode windows port
* AVI file works on Windows
CD features:
* standard access to the CDAUDIO interface
CD bugs:
----------------
| INSTALLATION |
----------------
You need to move the three files included in this directory:
- utilsunx.cpp => src/unix
- process.cpp => src/common
- process.h => include/wx
+4 -4
View File
@@ -15,22 +15,22 @@ program_dir = utils/wxMMedia2/board
PROGRAM=mmboard
OBJECTS=$(PROGRAM).o
OBJECTS=mmboard.o mmbman.o
EXTRA_CPPFLAGS= -I$(top_srcdir)/utils/wxMMedia2/lib
EXTRA_LIBS= ../lib/libwxmmedia2.a
EXTRA_LIBS= ../lib/libwxmmedia2.a -lesd
# the comment at the end of the next line is needed because otherwise autoconf
# would remove this line completely - it contains a built-in hack to remove
# any VPATH assignment not containing ':'
VPATH = @PATH_IFS@$(top_srcdir)/utils/wxMMedia2/sample # ':' for autoconf
VPATH = @PATH_IFS@$(top_srcdir)/utils/wxMMedia2/board # ':' for autoconf
include ../../../src/make.env
.SUFFIXES: .o .cpp .c
.cpp.o:
$(CC) $(CPPFLAGS) $(EXTRA_CPPFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(EXTRA_CPPFLAGS) -o $@ $<
all: $(PROGRAM)
+22 -6
View File
@@ -126,7 +126,6 @@ public:
protected:
wxWindow *m_output_window;
wxInputStream *m_input_stream;
wxVideoBaseDriver *m_video_driver;
};
@@ -333,8 +332,6 @@ MMBoardVideoFile::~MMBoardVideoFile()
{
if (m_video_driver)
delete m_video_driver;
delete m_input_stream;
}
bool MMBoardVideoFile::NeedWindow()
@@ -346,6 +343,12 @@ void MMBoardVideoFile::SetWindow(wxWindow *window)
{
m_output_window = window;
m_video_driver->AttachOutput(*window);
wxSize size;
m_video_driver->GetSize(size);
window->SetSize(size);
// BAD BAD
window->GetParent()->GetSizer()->Fit(window->GetParent());
}
void MMBoardVideoFile::Play()
@@ -379,9 +382,13 @@ MMBoardTime MMBoardVideoFile::GetPosition()
MMBoardTime MMBoardVideoFile::GetLength()
{
MMBoardTime btime;
int frameTime;
btime.seconds = 1;
btime.minutes = btime.hours = 0;
frameTime = (int)( m_video_driver->GetNbFrames() / m_video_driver->GetFrameRate());
btime.seconds = frameTime % 60;
btime.minutes = (frameTime / 60) % 60;
btime.hours = frameTime / 3600;
return btime;
}
@@ -402,7 +409,16 @@ wxString MMBoardVideoFile::GetStringType()
wxString MMBoardVideoFile::GetStringInformation()
{
return wxString(wxT("No info"));
wxString info;
info = wxT("Video codec: ");
info += m_video_driver->GetMovieCodec() + "\n";
info += wxT("Audio codec: ");
info += m_video_driver->GetAudioCodec();
info += wxString::Format(" Sample rate: %d Channels: %d\n", m_video_driver->GetSampleRate(),
m_video_driver->GetBPS());
info += wxString::Format(" Frame rate: %.01f", m_video_driver->GetFrameRate());
return info;
}
// ----------------------------------------------------------------------------
+2
View File
@@ -205,11 +205,13 @@ wxUint8 MMBoardApp::TestMultimediaCaps()
// We test the OSS (Open Sound System) support.
#if 0
dev = new wxSoundStreamOSS();
if (dev->GetError() == wxSOUND_NOERR)
caps |= MM_SOUND_OSS;
delete dev;
#endif
#endif
#ifdef __WIN32__
// We test the Windows sound support.
+1 -1
View File
@@ -17,7 +17,7 @@ VPATH= $(top_srcdir)/utils/wxMMedia2/lib
LIBTARGET=libwxmmedia2
OBJECTS=sndbase.o sndcodec.o sndpcm.o sndcpcm.o sndulaw.o sndfile.o sndoss.o\
sndaiff.o sndwav.o sndg72x.o \
sndesd.o sndaiff.o sndwav.o sndg72x.o \
g711.o g721.o g723_24.o g723_40.o g72x.o \
cdbase.o cdunix.o \
vidbase.o vidxanm.o
+5
View File
@@ -42,6 +42,11 @@ wxSoundAiff::~wxSoundAiff()
{
}
wxString wxSoundAiff::GetCodecName() const
{
return "wxSoundAiff codec";
}
bool wxSoundAiff::CanRead()
{
wxUint32 signature1, signature2, len;
+13 -12
View File
@@ -23,19 +23,20 @@
class wxSoundAiff: public wxSoundFileStream {
public:
wxSoundAiff(wxInputStream& stream, wxSoundStream& io_sound);
wxSoundAiff(wxOutputStream& stream, wxSoundStream& io_sound);
~wxSoundAiff();
bool CanRead();
wxSoundAiff(wxInputStream& stream, wxSoundStream& io_sound);
wxSoundAiff(wxOutputStream& stream, wxSoundStream& io_sound);
~wxSoundAiff();
bool CanRead();
wxString GetCodecName() const;
protected:
bool PrepareToPlay();
bool PrepareToRecord(unsigned long time);
bool FinishRecording();
wxUint32 GetData(void *buffer, wxUint32 len);
wxUint32 PutData(const void *buffer, wxUint32 len);
bool PrepareToPlay();
bool PrepareToRecord(unsigned long time);
bool FinishRecording();
wxUint32 GetData(void *buffer, wxUint32 len);
wxUint32 PutData(const void *buffer, wxUint32 len);
};
#endif
+5
View File
@@ -317,6 +317,11 @@ void wxSoundFileStream::FinishPreparation(wxUint32 len)
m_prepared = TRUE;
}
wxString wxSoundFileStream::GetCodecName() const
{
return wxString(wxT("wxSoundFileStream base codec"));
}
wxUint32 wxSoundFileStream::GetLength()
{
if (m_input && !m_prepared && GetError() == wxSOUND_NOERR)
+4
View File
@@ -90,6 +90,10 @@ class wxSoundFileStream: public wxSoundStream {
// For this action, you must use wxSoundRouterStream applied to wxSoundFileStream.
bool SetSoundFormat(const wxSoundFormatBase& format);
// This function returns the Codec name. This is useful for those who want to build
// a player (But also in some other case).
virtual wxString GetCodecName() const;
// You should use this function to test whether this file codec can read the stream you passed
// to it.
virtual bool CanRead() { return FALSE; }
+5
View File
@@ -48,6 +48,11 @@ wxSoundWave::~wxSoundWave()
{
}
wxString wxSoundWave::GetCodecName() const
{
return wxString(wxT("wxSoundWave codec"));
}
#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return FALSE; }
bool wxSoundWave::CanRead()
+22 -21
View File
@@ -25,28 +25,29 @@
class wxSoundWave: public wxSoundFileStream {
public:
wxSoundWave(wxInputStream& stream, wxSoundStream& io_sound);
wxSoundWave(wxOutputStream& stream, wxSoundStream& io_sound);
~wxSoundWave();
bool CanRead();
wxSoundWave(wxInputStream& stream, wxSoundStream& io_sound);
wxSoundWave(wxOutputStream& stream, wxSoundStream& io_sound);
~wxSoundWave();
bool CanRead();
wxString GetCodecName() const;
protected:
bool PrepareToPlay();
bool PrepareToRecord(unsigned long time);
bool FinishRecording();
wxUint32 GetData(void *buffer, wxUint32 len);
wxUint32 PutData(const void *buffer, wxUint32 len);
bool HandleOutputPCM(wxDataInputStream& data, wxUint16 channels,
wxUint32 sample_fq, wxUint32 byte_p_sec,
wxUint16 byte_p_spl, wxUint16 bits_p_spl);
bool HandleOutputG721(wxDataInputStream& data, wxUint16 channels,
wxUint32 sample_fq, wxUint32 byte_p_sec,
wxUint16 byte_p_spl, wxUint16 bits_p_spl);
wxSoundFormatBase *HandleInputPCM(wxDataOutputStream& data);
wxSoundFormatBase *HandleInputG72X(wxDataOutputStream& data);
bool PrepareToPlay();
bool PrepareToRecord(unsigned long time);
bool FinishRecording();
wxUint32 GetData(void *buffer, wxUint32 len);
wxUint32 PutData(const void *buffer, wxUint32 len);
bool HandleOutputPCM(wxDataInputStream& data, wxUint16 channels,
wxUint32 sample_fq, wxUint32 byte_p_sec,
wxUint16 byte_p_spl, wxUint16 bits_p_spl);
bool HandleOutputG721(wxDataInputStream& data, wxUint16 channels,
wxUint32 sample_fq, wxUint32 byte_p_sec,
wxUint16 byte_p_spl, wxUint16 bits_p_spl);
wxSoundFormatBase *HandleInputPCM(wxDataOutputStream& data);
wxSoundFormatBase *HandleInputG72X(wxDataOutputStream& data);
};
#endif
+17 -4
View File
@@ -73,11 +73,24 @@ public:
virtual bool Resume() = 0;
// Size management
virtual bool Resize(wxUint16 w, wxUint16 h) = 0;
virtual bool SetSize(wxSize size) = 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)) const { return FALSE; }
// Return the video codec name
virtual wxString GetMovieCodec() const = 0;
// Return the audio codec name
virtual wxString GetAudioCodec() const = 0;
// Return misc info about audio
virtual wxUint32 GetSampleRate() const = 0;
virtual wxUint8 GetChannels() const = 0;
virtual wxUint8 GetBPS() const = 0;
// Return frame rate
virtual double GetFrameRate() const = 0;
// Return number of frames
virtual wxUint32 GetNbFrames() const = 0;
// Called when the movie finished
virtual void OnFinished() {}
@@ -87,8 +100,8 @@ public:
virtual void DetachOutput();
// They return the state of the movie.
virtual bool IsPaused() = 0;
virtual bool IsStopped() = 0;
virtual bool IsPaused() const = 0;
virtual bool IsStopped() const = 0;
};
WXDLLEXPORT wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv);
+218 -11
View File
@@ -32,6 +32,8 @@
#include <wx/filefn.h>
#include <wx/wfstream.h>
#include <wx/datstrm.h>
#include <wx/tokenzr.h>
#define WXMMEDIA_INTERNAL
#include "vidbase.h"
@@ -52,8 +54,19 @@ protected:
wxVideoXANIM *m_vid_xanim;
};
class wxVideoXANIMOutput: public wxProcess {
public:
wxVideoXANIMOutput();
void OnTerminate(int pid, int status);
bool IsTerminated() const;
protected:
bool m_terminated;
};
// -------------------------------------------------------------------------
// XAnim video driver (implementation)
// XAnim video driver (process handling implementation)
wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim)
{
@@ -66,6 +79,25 @@ void wxVideoXANIMProcess::OnTerminate(int WXUNUSED(pid), int WXUNUSED(status))
m_vid_xanim->OnFinished();
}
wxVideoXANIMOutput::wxVideoXANIMOutput()
: wxProcess(NULL, TRUE, -1)
{
m_terminated = FALSE;
}
bool wxVideoXANIMOutput::IsTerminated() const
{
return m_terminated;
}
void wxVideoXANIMOutput::OnTerminate(int pid, int status)
{
m_terminated = TRUE;
}
// -------------------------------------------------------------------------
// XAnim video driver (implementation)
wxVideoXANIM::wxVideoXANIM()
: wxVideoBaseDriver()
{
@@ -84,12 +116,16 @@ wxVideoXANIM::wxVideoXANIM(wxInputStream& str)
m_xanim_detector = new wxVideoXANIMProcess(this);
m_xanim_started = FALSE;
m_paused = FALSE;
m_size[0] = 0;
m_size[1] = 0;
m_filename = wxGetTempFileName("vidxa");
m_remove_file = TRUE;
wxFileOutputStream fout(m_filename);
fout << str;
CollectInfo();
}
wxVideoXANIM::wxVideoXANIM(const wxString& filename)
@@ -101,6 +137,10 @@ wxVideoXANIM::wxVideoXANIM(const wxString& filename)
m_filename = filename;
m_remove_file = FALSE;
m_size[0] = 0;
m_size[1] = 0;
CollectInfo();
}
wxVideoXANIM::~wxVideoXANIM()
@@ -114,6 +154,9 @@ wxVideoXANIM::~wxVideoXANIM()
wxRemoveFile(m_filename);
}
// -------------------------------------------------------------------------
// Movie controller
bool wxVideoXANIM::Play()
{
if (!m_paused && m_xanim_started)
@@ -166,21 +209,30 @@ bool wxVideoXANIM::Stop()
return TRUE;
}
bool wxVideoXANIM::Resize(wxUint16 w, wxUint16 h)
// -------------------------------------------------------------------------
// Movie size controller
bool wxVideoXANIM::SetSize(wxSize size)
{
if (!m_video_output)
return FALSE;
m_video_output->SetSize(w, h);
m_video_output->SetSize(size.GetWidth(), size.GetHeight());
return FALSE;
}
bool wxVideoXANIM::GetSize(wxSize& size) const
{
return FALSE;
if (m_size[0] == 0)
return FALSE;
size.Set(m_size[0], m_size[1]);
return TRUE;
}
bool wxVideoXANIM::IsCapable(wxVideoType v_type)
// -------------------------------------------------------------------------
// Capabilities of XAnim
bool wxVideoXANIM::IsCapable(wxVideoType v_type) const
{
if (v_type == wxVIDEO_MSAVI || v_type == wxVIDEO_MPEG ||
v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV ||
@@ -190,21 +242,77 @@ bool wxVideoXANIM::IsCapable(wxVideoType v_type)
return FALSE;
}
bool wxVideoXANIM::IsPaused()
// -------------------------------------------------------------------------
// Movie state
wxString wxVideoXANIM::GetMovieCodec() const
{
if (m_size[0] == 0)
return wxT("");
return m_movieCodec;
}
wxString wxVideoXANIM::GetAudioCodec() const
{
if (m_size[0] == 0)
return wxT("");
return m_audioCodec;
}
wxUint32 wxVideoXANIM::GetSampleRate() const
{
if (m_size[0] == 0)
return 0;
return m_sampleRate;
}
wxUint8 wxVideoXANIM::GetChannels() const
{
if (m_size[0] == 0)
return 0;
return m_channels;
}
wxUint8 wxVideoXANIM::GetBPS() const
{
if (m_size[0] == 0)
return 0;
return m_bps;
}
double wxVideoXANIM::GetFrameRate() const
{
if (m_size[0] == 0)
return 0.0;
return m_frameRate;
}
wxUint32 wxVideoXANIM::GetNbFrames() const
{
if (m_size[0] == 0)
return 0;
return m_frames;
}
bool wxVideoXANIM::IsPaused() const
{
return m_paused;
}
bool wxVideoXANIM::IsStopped()
bool wxVideoXANIM::IsStopped() const
{
return !m_xanim_started;
}
// -------------------------------------------------------------------------
// Output management
bool wxVideoXANIM::AttachOutput(wxWindow& out)
{
if (!wxVideoBaseDriver::AttachOutput(out))
return FALSE;
return TRUE;
}
@@ -217,6 +325,9 @@ void wxVideoXANIM::DetachOutput()
wxVideoBaseDriver::DetachOutput();
}
// -------------------------------------------------------------------------
// Lowlevel XAnim controller
bool wxVideoXANIM::SendCommand(const char *command, char **ret,
wxUint32 *size)
{
@@ -243,6 +354,95 @@ bool wxVideoXANIM::SendCommand(const char *command, char **ret,
return TRUE;
}
bool wxVideoXANIM::CollectInfo()
{
wxVideoXANIMOutput *xanimProcess;
wxString xanim_command;
wxStringTokenizer tokenizer;
xanimProcess = new wxVideoXANIMOutput;
xanim_command = wxT("xanim +v +Zv -Ae ");
xanim_command += m_filename;
if (!wxExecute(xanim_command, FALSE, xanimProcess))
return FALSE;
wxInputStream *infoStream = xanimProcess->GetInputStream();
wxString totalOutput;
while (infoStream->LastError() == wxSTREAM_NOERROR) {
char line[100];
infoStream->Read(line, sizeof(line)-1);
if (infoStream->LastRead() == 0)
break;
line[infoStream->LastRead()] = 0;
totalOutput += line;
}
// This is good for everything ... :-)
int position = totalOutput.Find(wxT("Video Codec:"));
totalOutput.Remove(0, position+13);
position = totalOutput.Find(wxT("depth="));
m_movieCodec = totalOutput(0, position);
totalOutput.Remove(0, position);
tokenizer.SetString(totalOutput, "\n\r");
// the rest of the line
wxString token = tokenizer.GetNextToken();
unsigned long my_long;
#define GETINT(i) \
totalOutput.ToULong(&my_long); \
i = my_long;
// 'Audio Codec:'
totalOutput = tokenizer.GetString();
totalOutput.Remove(0, totalOutput.Find(wxT(":"))+2);
position = totalOutput.Find(wxT("Rate"));
m_audioCodec = totalOutput(0, position-1);
// 'Rate='
totalOutput.Remove(0, totalOutput.Find(wxT("="))+1);
GETINT(m_sampleRate);
// 'Chans='
totalOutput.Remove(0, totalOutput.Find(wxT("="))+1);
GETINT(m_channels);
// 'Bps='
totalOutput.Remove(0, totalOutput.Find(wxT("="))+1);
GETINT(m_bps);
// 'Frame Stats:'
tokenizer.Reinit(totalOutput);
tokenizer.GetNextToken();
totalOutput = tokenizer.GetString();
totalOutput.Remove(0, totalOutput.Find(wxT(":"))+2);
// 'Size='
totalOutput.Remove(0, totalOutput.Find(wxT("="))+1);
GETINT(m_size[0]);
// 'x'
totalOutput.Remove(0,1);
GETINT(m_size[1]);
// 'Frames='
totalOutput.Remove(0, totalOutput.Find(wxT("="))+1);
GETINT(m_frames);
// 'avfps='
totalOutput.Remove(0, totalOutput.Find(wxT("="))+1);
totalOutput.ToDouble(&m_frameRate);
// We wait for the conclusion
while (!xanimProcess->IsTerminated())
wxYield();
delete xanimProcess;
return TRUE;
}
bool wxVideoXANIM::RestartXANIM()
{
wxString xanim_command;
@@ -278,7 +478,7 @@ bool wxVideoXANIM::RestartXANIM()
(xanim_chg_size) ? _T("") : _T(""),
WXSTRINGCAST m_filename);
// Execute it
// Execute it
if (!wxExecute(xanim_command, FALSE, m_xanim_detector))
return FALSE;
@@ -294,8 +494,15 @@ bool wxVideoXANIM::RestartXANIM()
wxYield();
}
m_video_output->SetSize(m_video_output->GetSize());
// Very useful ! Actually it sends a SETSIZE event to XAnim
wxSize vibrato_size;
vibrato_size = m_video_output->GetSize();
vibrato_size.SetWidth(vibrato_size.GetWidth()+1);
m_video_output->SetSize(vibrato_size);
vibrato_size.SetWidth(vibrato_size.GetWidth()-1);
m_video_output->SetSize(vibrato_size);
// Very useful ! Actually it sends a SETSIZE event to XAnim
m_paused = FALSE;
+30 -6
View File
@@ -67,7 +67,7 @@ typedef struct wxXANIMinternal {
class WXDLLEXPORT wxVideoXANIM : public wxVideoBaseDriver {
DECLARE_DYNAMIC_CLASS(wxVideoXANIM)
protected:
protected:
// Remember the state of the subprocess
bool m_xanim_started, m_paused;
// Pure X11 variables
@@ -76,7 +76,15 @@ protected:
wxProcess *m_xanim_detector;
// Remember to delete the temporary file when necessary
bool m_remove_file;
public:
wxUint32 m_size[2];
wxUint32 m_sampleRate;
wxUint8 m_channels;
wxUint8 m_bps;
wxUint32 m_frames;
double m_frameRate;
wxString m_movieCodec, m_audioCodec;
public:
wxVideoXANIM();
wxVideoXANIM(wxInputStream& str);
wxVideoXANIM(const wxString& filename);
@@ -88,16 +96,29 @@ public:
bool Stop();
bool SetVolume(wxUint8 vol);
bool Resize(wxUint16 w, wxUint16 h);
bool SetSize(wxSize size);
bool GetSize(wxSize& size) const;
bool IsCapable(wxVideoType v_type);
// Return the video codec name
wxString GetMovieCodec() const;
// Return the audio codec name
wxString GetAudioCodec() const;
// Return misc info about audio
wxUint32 GetSampleRate() const;
wxUint8 GetChannels() const;
wxUint8 GetBPS() const;
// Return frame rate
double GetFrameRate() const;
// Return number of frames in the movie
wxUint32 GetNbFrames() const;
bool IsCapable(wxVideoType v_type) const;
bool AttachOutput(wxWindow& output);
void DetachOutput();
bool IsPaused();
bool IsStopped();
bool IsPaused() const;
bool IsStopped() const;
friend class wxVideoXANIMProcess;
@@ -107,6 +128,9 @@ protected:
// Send a command to the subprocess
bool SendCommand(const char *command,char **ret = NULL,
wxUint32 *size = NULL);
// Collect informations from XAnim
bool CollectInfo();
};
#endif
+85
View File
@@ -0,0 +1,85 @@
/////////////////////////////////////////////////////////////////////////////
// Name: process.cpp
// Purpose: Process termination classes
// Author: Guilhem Lavaux
// Modified by: Vadim Zeitlin to check error codes, added Detach() method
// Created: 24/06/98
// RCS-ID: $Id$
// Copyright: (c) Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "process.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/defs.h"
#endif
#include "wx/process.h"
IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
wxProcess::wxProcess(wxEvtHandler *parent, bool needPipe, int id)
{
if (parent)
SetNextHandler(parent);
m_id = id;
m_needPipe = needPipe;
m_in_stream = NULL;
m_out_stream = NULL;
}
wxProcess::~wxProcess()
{
if (m_in_stream)
delete m_in_stream;
if (m_out_stream)
delete m_out_stream;
}
void wxProcess::OnTerminate(int pid, int status)
{
wxProcessEvent event(m_id, pid, status);
if ( !ProcessEvent(event) )
delete this;
//else: the object which processed the event is responsible for deleting
// us!
}
void wxProcess::Detach()
{
SetNextHandler(NULL);
}
void wxProcess::SetPipeStreams(wxInputStream *in_stream, wxOutputStream *out_stream)
{
m_in_stream = in_stream;
m_out_stream = out_stream;
}
wxInputStream *wxProcess::GetInputStream() const
{
return m_in_stream;
}
wxOutputStream *wxProcess::GetOutputStream() const
{
return m_out_stream;
}
bool wxProcess::NeedPipe() const
{
return m_needPipe;
}
+86
View File
@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////
// Name: process.h
// Purpose: wxProcess class
// Author: Guilhem Lavaux
// Modified by: Vadim Zeitlin to check error codes, added Detach() method
// Created: 24/06/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PROCESSH__
#define _WX_PROCESSH__
#ifdef __GNUG__
#pragma interface "process.h"
#endif
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/event.h"
#include "wx/stream.h"
// Process Event handling
class WXDLLEXPORT wxProcessEvent : public wxEvent
{
DECLARE_DYNAMIC_CLASS(wxProcessEvent)
public:
wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0) : wxEvent(id)
{
m_eventType = wxEVT_END_PROCESS;
m_pid = pid;
m_exitcode = exitcode;
}
// accessors
// PID of process which terminated
int GetPid() { return m_pid; }
// the exit code
int GetExitCode() { return m_exitcode; }
public:
int m_pid, m_exitcode;
};
// A wxProcess object should be passed to wxExecute - than its OnTerminate()
// function will be called when the process terminates.
class WXDLLEXPORT wxProcess : public wxEvtHandler
{
DECLARE_DYNAMIC_CLASS(wxProcess)
public:
wxProcess(wxEvtHandler *parent = (wxEvtHandler *) NULL, bool needPipe = FALSE, int id = -1);
~wxProcess();
virtual void OnTerminate(int pid, int status);
// detach from the parent - should be called by the parent if it's deleted
// before the process it started terminates
void Detach();
// Pipe handling
wxInputStream *GetInputStream() const;
wxOutputStream *GetOutputStream() const;
// These functions should not be called by the usual user. They are only
// intended to be used by wxExecute.
// Install pipes
void SetPipeStreams(wxInputStream *in_stream, wxOutputStream *out_stream);
bool NeedPipe() const;
protected:
int m_id;
bool m_needPipe;
wxInputStream *m_in_stream;
wxOutputStream *m_out_stream;
};
typedef void (wxObject::*wxProcessEventFunction)(wxProcessEvent&);
#define EVT_END_PROCESS(id, func) { wxEVT_END_PROCESS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxProcessEventFunction) & func, NULL},
#endif
// _WX_PROCESSH__
File diff suppressed because it is too large Load Diff