]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia2/lib/vidxanm.cpp
6f9ff545e66323751dc1ac0159e9590f8cf9dfab
1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1997, 1998, 1999 Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "vidxanm.h"
20 #include <wx/gtk/win_gtk.h>
23 #include <X11/Intrinsic.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtkwindow.h>
28 #include <gdk/gdkprivate.h>
31 #include <wx/filefn.h>
32 #include <wx/wfstream.h>
34 #define WXMMEDIA_INTERNAL
38 IMPLEMENT_DYNAMIC_CLASS(wxVideoXANIM
, wxVideoBaseDriver
)
40 wxVideoXANIM::wxVideoXANIM()
43 m_internal
= new wxXANIMinternal
;
44 m_xanim_started
= FALSE
;
49 wxVideoXANIM::wxVideoXANIM(wxInputStream
& str
)
50 : wxVideoBaseDriver(str
)
52 m_internal
= new wxXANIMinternal
;
53 m_xanim_started
= FALSE
;
56 m_filename
= wxGetTempFileName("vidxa");
57 wxFileOutputStream
fout(m_filename
);
62 wxVideoXANIM::~wxVideoXANIM()
68 wxRemoveFile(m_filename
);
71 bool wxVideoXANIM::Play()
73 if (!m_paused
&& m_xanim_started
)
75 if (!m_video_output
) {
76 wxVideoCreateFrame(this);
80 // The movie starts with xanim
88 bool wxVideoXANIM::Pause()
90 if (!m_paused
&& SendCommand(" ")) {
97 bool wxVideoXANIM::Resume()
99 if (m_paused
&& SendCommand(" ")) {
106 bool wxVideoXANIM::Stop()
108 if (!m_xanim_started
)
113 m_xanim_started
= FALSE
;
119 bool wxVideoXANIM::SetVolume(wxUint8 vol
)
124 wxString
str_vol("v%d", vol
);
125 return SendCommand(str_vol
.GetData());
128 bool wxVideoXANIM::Resize(wxUint16
WXUNUSED(w
), wxUint16
WXUNUSED(h
))
131 // Actually, I think that we just need to resize the output window ...
135 bool wxVideoXANIM::GetSize(wxSize
& size
) const
141 bool wxVideoXANIM::IsCapable(wxVideoType v_type
)
143 if (v_type
== wxVIDEO_MSAVI
|| v_type
== wxVIDEO_MPEG
||
144 v_type
== wxVIDEO_QT
|| v_type
== wxVIDEO_GIF
|| v_type
== wxVIDEO_JMOV
||
145 v_type
== wxVIDEO_FLI
|| v_type
== wxVIDEO_IFF
|| v_type
== wxVIDEO_SGI
)
151 bool wxVideoXANIM::AttachOutput(wxWindow
& out
)
153 if (!wxVideoBaseDriver::AttachOutput(out
))
159 void wxVideoXANIM::DetachOutput()
162 m_xanim_started
= FALSE
;
165 wxVideoBaseDriver::DetachOutput();
168 bool wxVideoXANIM::SendCommand(const char *command
, char **ret
,
171 if (!m_xanim_started
)
175 // Send a command to XAnim through X11 Property
176 XChangeProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
177 m_internal
->xanim_atom
,
178 XA_STRING
, 8, PropModeReplace
, (unsigned char *)command
,
180 XFlush(m_internal
->xanim_dpy
);
186 XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
187 m_internal
->xanim_ret
, 0, 16, True
, AnyPropertyType
,
188 &prop_type
, &prop_format
, (unsigned long *)size
,
189 &extra
, (unsigned char **)ret
);
194 bool wxVideoXANIM::RestartXANIM()
196 wxString xanim_command
;
200 unsigned long nitems
;
205 if (!m_video_output
|| m_xanim_started
)
208 // Check if we can change the size of the window dynamicly
209 xanim_chg_size
= TRUE
;
210 // Get current display
212 m_internal
->xanim_dpy
= gdk_display
;
213 // We absolutely need the window to be realized.
214 GtkPizza
*pizza
= GTK_PIZZA( m_video_output
->m_wxwindow
);
215 GdkWindow
*window
= pizza
->bin_window
;
217 m_internal
->xanim_window
=
218 ((GdkWindowPrivate
*)window
)->xwindow
;
220 // Get the XANIM atom
221 m_internal
->xanim_atom
= XInternAtom(m_internal
->xanim_dpy
,
222 "XANIM_PROPERTY", False
);
225 xanim_command
.Printf(_T("xanim -Zr +Ze +Sr +f +W%d +f +q "
226 "+Av70 %s %s"), m_internal
->xanim_window
,
227 (xanim_chg_size
) ? _T("") : _T(""),
228 WXSTRINGCAST m_filename
);
231 if (!wxExecute(xanim_command
, FALSE
))
234 // Wait for XAnim to be ready
236 while (nitems
== 0) {
237 ret
= XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
238 m_internal
->xanim_atom
,
239 0, 4, False
, AnyPropertyType
, &prop_type
,
240 &prop_format
, &nitems
, &extra
,
241 (unsigned char **)&prop
);
246 m_xanim_started
= TRUE
;