]>
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 #if !USE_SHARED_LIBRARY
35 IMPLEMENT_DYNAMIC_CLASS(wxVideoXANIM
, wxVideoBaseDriver
)
38 wxVideoXANIM::wxVideoXANIM()
41 m_internal
= new wxXANIMinternal
;
42 m_xanim_started
= FALSE
;
47 wxVideoXANIM::wxVideoXANIM(wxInputStream
& str
)
48 : wxVideoBaseDriver(str
)
50 m_internal
= new wxXANIMinternal
;
51 m_xanim_started
= FALSE
;
54 m_filename
= wxGetTempFileName("vidxa");
55 wxFileOutputStream
fout(m_filename
);
60 wxVideoXANIM::~wxVideoXANIM()
66 wxRemoveFile(m_filename
);
69 bool wxVideoXANIM::Play()
71 if (!m_paused
&& m_xanim_started
)
73 if (!m_video_output
) {
74 wxVideoCreateFrame(this);
78 // The movie starts with xanim
86 bool wxVideoXANIM::Pause()
88 if (!m_paused
&& SendCommand(" ")) {
95 bool wxVideoXANIM::Resume()
97 if (m_paused
&& SendCommand(" ")) {
104 bool wxVideoXANIM::Stop()
106 if (!m_xanim_started
)
111 m_xanim_started
= FALSE
;
117 bool wxVideoXANIM::SetVolume(wxUint8 vol
)
122 wxString
str_vol("v%d", vol
);
123 return SendCommand(str_vol
.GetData());
126 bool wxVideoXANIM::Resize(wxUint16
WXUNUSED(w
), wxUint16
WXUNUSED(h
))
129 // Actually, I think that we just need to resize the output window ...
133 bool wxVideoXANIM::GetSize(wxSize
& size
) const
139 bool wxVideoXANIM::IsCapable(wxVideoType v_type
)
141 if (v_type
== wxVIDEO_MSAVI
|| v_type
== wxVIDEO_MPEG
||
142 v_type
== wxVIDEO_QT
|| v_type
== wxVIDEO_GIF
|| v_type
== wxVIDEO_JMOV
||
143 v_type
== wxVIDEO_FLI
|| v_type
== wxVIDEO_IFF
|| v_type
== wxVIDEO_SGI
)
149 bool wxVideoXANIM::AttachOutput(wxVideoOutput
& out
)
151 if (!wxVideoBaseDriver::AttachOutput(out
))
157 void wxVideoXANIM::DetachOutput()
160 m_xanim_started
= FALSE
;
163 wxVideoBaseDriver::DetachOutput();
166 bool wxVideoXANIM::SendCommand(const char *command
, char **ret
,
169 if (!m_xanim_started
)
173 // Send a command to XAnim through X11 Property
174 XChangeProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
175 m_internal
->xanim_atom
,
176 XA_STRING
, 8, PropModeReplace
, (unsigned char *)command
,
178 XFlush(m_internal
->xanim_dpy
);
184 XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
185 m_internal
->xanim_ret
, 0, 16, True
, AnyPropertyType
,
186 &prop_type
, &prop_format
, (unsigned long *)size
,
187 &extra
, (unsigned char **)ret
);
192 bool wxVideoXANIM::RestartXANIM()
194 wxString xanim_command
;
198 unsigned long nitems
;
203 if (!m_video_output
|| m_xanim_started
)
206 // Check if we can change the size of the window dynamicly
207 xanim_chg_size
= m_video_output
->DynamicSize();
208 // Get current display
210 m_internal
->xanim_dpy
= gdk_display
;
211 // We absolutely need the window to be realized.
212 gtk_widget_realize(m_video_output
->m_wxwindow
);
213 m_internal
->xanim_window
=
214 ((GdkWindowPrivate
*)m_video_output
->m_wxwindow
->window
)->xwindow
;
216 // Get the XANIM atom
217 m_internal
->xanim_atom
= XInternAtom(m_internal
->xanim_dpy
,
218 "XANIM_PROPERTY", False
);
221 xanim_command
.Printf(_T("xanim -Zr +Ze +Sr +f +W%d +f +q "
222 "+Av70 %s %s"), m_internal
->xanim_window
,
223 (xanim_chg_size
) ? _T("") : _T(""),
224 WXSTRINGCAST m_filename
);
227 if (!wxExecute(xanim_command
, FALSE
))
230 // Wait for XAnim to be ready
232 while (nitems
== 0) {
233 ret
= XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
234 m_internal
->xanim_atom
,
235 0, 4, False
, AnyPropertyType
, &prop_type
,
236 &prop_format
, &nitems
, &extra
,
237 (unsigned char **)&prop
);
242 m_xanim_started
= TRUE
;