]>
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::StartPlay()
71 if (!m_paused
&& m_xanim_started
)
73 if (!m_video_output
) {
74 wxVideoCreateFrame(this);
78 if (SendCommand(" ")) {
85 bool wxVideoXANIM::Pause()
87 if (!m_paused
&& SendCommand(" ")) {
94 bool wxVideoXANIM::Resume()
96 if (m_paused
&& SendCommand(" ")) {
103 void wxVideoXANIM::StopPlay()
105 if (!m_xanim_started
)
110 m_xanim_started
= FALSE
;
114 bool wxVideoXANIM::SetVolume(wxUint8 vol
)
119 wxString
str_vol("v%d", vol
);
120 return SendCommand(str_vol
.GetData());
123 bool wxVideoXANIM::Resize(wxUint16
WXUNUSED(w
), wxUint16
WXUNUSED(h
))
126 // Actually, I think that we just need to resize the output window ...
130 bool wxVideoXANIM::IsCapable(wxVideoType v_type
)
132 if (v_type
== wxVIDEO_MSAVI
|| v_type
== wxVIDEO_MPEG
||
133 v_type
== wxVIDEO_QT
|| v_type
== wxVIDEO_GIF
|| v_type
== wxVIDEO_JMOV
||
134 v_type
== wxVIDEO_FLI
|| v_type
== wxVIDEO_IFF
|| v_type
== wxVIDEO_SGI
)
140 bool wxVideoXANIM::AttachOutput(wxVideoOutput
& out
)
142 if (!wxVideoBaseDriver::AttachOutput(out
))
145 return RestartXANIM();
148 void wxVideoXANIM::DetachOutput()
151 m_xanim_started
= FALSE
;
154 wxVideoBaseDriver::DetachOutput();
157 bool wxVideoXANIM::SendCommand(const char *command
, char **ret
,
160 if (!m_xanim_started
)
164 // Send a command to XAnim through X11 Property
165 XChangeProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
166 m_internal
->xanim_atom
,
167 XA_STRING
, 8, PropModeReplace
, (unsigned char *)command
,
169 XFlush(m_internal
->xanim_dpy
);
175 XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
176 m_internal
->xanim_ret
, 0, 16, True
, AnyPropertyType
,
177 &prop_type
, &prop_format
, (unsigned long *)size
,
178 &extra
, (unsigned char **)ret
);
183 bool wxVideoXANIM::RestartXANIM()
185 wxString xanim_command
;
189 unsigned long nitems
;
194 if (!m_video_output
|| m_xanim_started
)
197 // Check if we can change the size of the window dynamicly
198 xanim_chg_size
= m_video_output
->DynamicSize();
199 // Get current display
201 m_internal
->xanim_dpy
= gdk_display
;
202 // We absolutely need the window to be realized.
203 gtk_widget_realize(m_video_output
->m_wxwindow
);
204 m_internal
->xanim_window
=
205 ((GdkWindowPrivate
*)m_video_output
->m_wxwindow
->window
)->xwindow
;
207 // Get the XANIM atom
208 m_internal
->xanim_atom
= XInternAtom(m_internal
->xanim_dpy
,
209 "XANIM_PROPERTY", False
);
212 xanim_command
.Printf(_T("xanim -Zr +Ze +Sr +f +W%d +f +q "
213 "+Av70 %s %s"), m_internal
->xanim_window
,
214 (xanim_chg_size
) ? _T("") : _T(""),
215 WXSTRINGCAST m_filename
);
218 if (!wxExecute(xanim_command
, FALSE
))
221 // Wait for XAnim to be ready
223 while (nitems
== 0) {
224 ret
= XGetWindowProperty(m_internal
->xanim_dpy
, m_internal
->xanim_window
,
225 m_internal
->xanim_atom
,
226 0, 4, False
, AnyPropertyType
, &prop_type
,
227 &prop_format
, &nitems
, &extra
,
228 (unsigned char **)&prop
);
233 m_xanim_started
= TRUE
;