]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia2/lib/vidxanm.cpp
1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1997, 1998, 1999 Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "vidxanm.h"
19 #include <X11/Intrinsic.h>
21 #include <gtk/gtkwidget.h>
22 #include <gtk/gtkwindow.h>
24 #include <gdk/gdkprivate.h>
27 #include <wx/filefn.h>
28 #include <wx/wfstream.h>
30 #define WXMMEDIA_INTERNAL
34 IMPLEMENT_DYNAMIC_CLASS(wxVideoXANIM
, wxVideoBaseDriver
)
36 wxVideoXANIM::wxVideoXANIM()
39 m_internal
= new wxXANIMinternal
;
40 m_xanim_started
= FALSE
;
45 wxVideoXANIM::wxVideoXANIM(wxInputStream
& str
)
46 : wxVideoBaseDriver(str
)
48 m_internal
= new wxXANIMinternal
;
49 m_xanim_started
= FALSE
;
52 m_filename
= wxGetTempFileName("vidxa");
53 wxFileOutputStream
fout(m_filename
);
58 wxVideoXANIM::~wxVideoXANIM()
64 wxRemoveFile(m_filename
);
67 bool wxVideoXANIM::Play()
69 if (!m_paused
&& m_xanim_started
)
71 if (!m_video_output
) {
72 wxVideoCreateFrame(this);
76 // The movie starts with xanim
84 bool wxVideoXANIM::Pause()
86 if (!m_paused
&& SendCommand(" ")) {
93 bool wxVideoXANIM::Resume()
95 if (m_paused
&& SendCommand(" ")) {
102 bool wxVideoXANIM::Stop()
104 if (!m_xanim_started
)
109 m_xanim_started
= FALSE
;
115 bool wxVideoXANIM::SetVolume(wxUint8 vol
)
120 wxString
str_vol("v%d", vol
);
121 return SendCommand(str_vol
.GetData());
124 bool wxVideoXANIM::Resize(wxUint16
WXUNUSED(w
), wxUint16
WXUNUSED(h
))
127 // Actually, I think that we just need to resize the output window ...
131 bool wxVideoXANIM::GetSize(wxSize
& size
) const
137 bool wxVideoXANIM::IsCapable(wxVideoType v_type
)
139 if (v_type
== wxVIDEO_MSAVI
|| v_type
== wxVIDEO_MPEG
||
140 v_type
== wxVIDEO_QT
|| v_type
== wxVIDEO_GIF
|| v_type
== wxVIDEO_JMOV
||
141 v_type
== wxVIDEO_FLI
|| v_type
== wxVIDEO_IFF
|| v_type
== wxVIDEO_SGI
)
147 bool wxVideoXANIM::AttachOutput(wxVideoOutput
& out
)
149 if (!wxVideoBaseDriver::AttachOutput(out
))
155 void wxVideoXANIM::DetachOutput()
158 m_xanim_started
= FALSE
;
161 wxVideoBaseDriver::DetachOutput();
164 bool wxVideoXANIM::SendCommand(const char *command
, char **ret
,
167 if (!m_xanim_started
)
171 // Send a command to XAnim through X11 Property
172 XChangeProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
173 m_internal
->xanim_atom
,
174 XA_STRING
, 8, PropModeReplace
, (unsigned char *)command
,
176 XFlush(m_internal
->xanim_dpy
);
182 XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
183 m_internal
->xanim_ret
, 0, 16, True
, AnyPropertyType
,
184 &prop_type
, &prop_format
, (unsigned long *)size
,
185 &extra
, (unsigned char **)ret
);
190 bool wxVideoXANIM::RestartXANIM()
192 wxString xanim_command
;
196 unsigned long nitems
;
201 if (!m_video_output
|| m_xanim_started
)
204 // Check if we can change the size of the window dynamicly
205 xanim_chg_size
= m_video_output
->DynamicSize();
206 // Get current display
208 m_internal
->xanim_dpy
= gdk_display
;
209 // We absolutely need the window to be realized.
210 gtk_widget_realize(m_video_output
->m_wxwindow
);
211 m_internal
->xanim_window
=
212 ((GdkWindowPrivate
*)m_video_output
->m_wxwindow
->window
)->xwindow
;
214 // Get the XANIM atom
215 m_internal
->xanim_atom
= XInternAtom(m_internal
->xanim_dpy
,
216 "XANIM_PROPERTY", False
);
219 xanim_command
.Printf(_T("xanim -Zr +Ze +Sr +f +W%d +f +q "
220 "+Av70 %s %s"), m_internal
->xanim_window
,
221 (xanim_chg_size
) ? _T("") : _T(""),
222 WXSTRINGCAST m_filename
);
225 if (!wxExecute(xanim_command
, FALSE
))
228 // Wait for XAnim to be ready
230 while (nitems
== 0) {
231 ret
= XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
232 m_internal
->xanim_atom
,
233 0, 4, False
, AnyPropertyType
, &prop_type
,
234 &prop_format
, &nitems
, &extra
,
235 (unsigned char **)&prop
);
240 m_xanim_started
= TRUE
;