]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/vidxanm.cpp
1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1997, 1998, Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "vidxanm.h"
13 #define WXMMEDIA_INTERNAL
16 #define Uses_XtIntrinsic
26 #include <X11/Intrinsic.h>
29 #include <gdk/gdkprivate.h>
32 wxVideoXANIM::wxVideoXANIM()
35 internal
= new wxXANIMinternal
;
36 xanim_started
= false;
40 wxVideoXANIM::wxVideoXANIM(wxInputStream
& str
)
41 : wxVideoBaseDriver(str
, false)
43 internal
= new wxXANIMinternal
;
44 xanim_started
= false;
48 wxVideoXANIM::wxVideoXANIM(const wxString
& fname
)
49 : wxVideoBaseDriver(fname
)
51 internal
= new wxXANIMinternal
;
52 xanim_started
= false;
55 wxVideoXANIM::~wxVideoXANIM()
62 bool wxVideoXANIM::StartPlay()
64 if (!paused
&& xanim_started
)
67 wxVideoCreateFrame(this);
69 if (SendCommand(" ")) {
76 bool wxVideoXANIM::Pause()
78 if (!paused
&& SendCommand(" ")) {
85 bool wxVideoXANIM::Resume()
87 if (paused
&& SendCommand(" ")) {
94 void wxVideoXANIM::StopPlay()
101 xanim_started
= FALSE
;
105 bool wxVideoXANIM::SetVolume(wxUint8 vol
)
110 wxString
str_vol("v%d", vol
);
111 return SendCommand(str_vol
.GetData());
114 bool wxVideoXANIM::Resize(wxUint16
WXUNUSED(w
), wxUint16
WXUNUSED(h
))
117 // Actually, I think that we just need to resize the output window ...
121 bool wxVideoXANIM::IsCapable(wxVideoType v_type
)
123 if (v_type
== wxVIDEO_MSAVI
|| v_type
== wxVIDEO_MPEG
||
124 v_type
== wxVIDEO_QT
|| v_type
== wxVIDEO_GIF
|| v_type
== wxVIDEO_JMOV
||
125 v_type
== wxVIDEO_FLI
|| v_type
== wxVIDEO_IFF
|| v_type
== wxVIDEO_SGI
)
131 bool wxVideoXANIM::AttachOutput(wxVideoOutput
& out
)
133 if (!wxVideoBaseDriver::AttachOutput(out
))
136 return RestartXANIM();
139 void wxVideoXANIM::DetachOutput()
142 xanim_started
= false;
145 wxVideoBaseDriver::DetachOutput();
148 bool wxVideoXANIM::SendCommand(const char *command
, char **ret
,
155 // Send a command to XAnim through X11 Property
156 XChangeProperty(internal
->xanim_dpy
, internal
->xanim_window
,
157 internal
->xanim_atom
,
158 XA_STRING
, 8, PropModeReplace
, (unsigned char *)command
,
160 XFlush(internal
->xanim_dpy
);
166 XGetWindowProperty(internal
->xanim_dpy
, internal
->xanim_window
,
167 internal
->xanim_ret
, 0, 16, True
, AnyPropertyType
,
168 &prop_type
, &prop_format
, (unsigned long *)size
,
169 &extra
, (unsigned char **)ret
);
174 bool wxVideoXANIM::RestartXANIM()
176 wxString xanim_command
;
180 unsigned long nitems
;
185 if (!video_output
|| xanim_started
|| !GetCurrentFile())
188 // Check if we can change the size of the window dynamicly
189 xanim_chg_size
= video_output
->DynamicSize();
190 // Get current display
192 internal
->xanim_dpy
= wxAPP_DISPLAY
;
195 internal
->xanim_dpy
= gdk_display
;
199 internal
->xanim_window
= XtWindow(video_output
->FWidget());
201 internal
->xanim_window
=
202 ((GdkWindowPrivate
*)video_output
->m_widget
->window
)->xwindow
;
204 // Get the XANIM atom
205 internal
->xanim_atom
= XInternAtom(internal
->xanim_dpy
,
206 "XANIM_PROPERTY", False
);
209 xanim_command
.sprintf(__XANIM_COMMAND__
" +W%d +Wp +f +B -Zr +q +Zpe +Ae "
210 "+Av70 %s %s", internal
->xanim_window
,
211 (xanim_chg_size
== true) ? "+Sr" : "",
212 (const char *)GetCurrentFile());
214 if (!wxExecute(xanim_command
, false))
217 // Wait for XAnim to be ready
219 while (nitems
== 0) {
220 ret
= XGetWindowProperty(internal
->xanim_dpy
, internal
->xanim_window
,
221 internal
->xanim_atom
,
222 0, 4, False
, AnyPropertyType
, &prop_type
,
223 &prop_format
, &nitems
, &extra
,
224 (unsigned char **)&prop
);
228 xanim_started
= true;