]>
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>
28 #include <gtk/gtkwidget.h>
30 #include <gdk/gdkprivate.h>
33 wxVideoXANIM::wxVideoXANIM()
36 internal
= new wxXANIMinternal
;
37 xanim_started
= false;
41 wxVideoXANIM::wxVideoXANIM(wxInputStream
& str
)
42 : wxVideoBaseDriver(str
, false)
44 internal
= new wxXANIMinternal
;
45 xanim_started
= false;
49 wxVideoXANIM::wxVideoXANIM(const wxString
& fname
)
50 : wxVideoBaseDriver(fname
)
52 internal
= new wxXANIMinternal
;
53 xanim_started
= false;
56 wxVideoXANIM::~wxVideoXANIM()
63 bool wxVideoXANIM::StartPlay()
65 if (!paused
&& xanim_started
)
68 wxVideoCreateFrame(this);
70 if (SendCommand(" ")) {
77 bool wxVideoXANIM::Pause()
79 if (!paused
&& SendCommand(" ")) {
86 bool wxVideoXANIM::Resume()
88 if (paused
&& SendCommand(" ")) {
95 void wxVideoXANIM::StopPlay()
102 xanim_started
= FALSE
;
106 bool wxVideoXANIM::SetVolume(wxUint8 vol
)
111 wxString
str_vol("v%d", vol
);
112 return SendCommand(str_vol
.GetData());
115 bool wxVideoXANIM::Resize(wxUint16
WXUNUSED(w
), wxUint16
WXUNUSED(h
))
118 // Actually, I think that we just need to resize the output window ...
122 bool wxVideoXANIM::IsCapable(wxVideoType v_type
)
124 if (v_type
== wxVIDEO_MSAVI
|| v_type
== wxVIDEO_MPEG
||
125 v_type
== wxVIDEO_QT
|| v_type
== wxVIDEO_GIF
|| v_type
== wxVIDEO_JMOV
||
126 v_type
== wxVIDEO_FLI
|| v_type
== wxVIDEO_IFF
|| v_type
== wxVIDEO_SGI
)
132 bool wxVideoXANIM::AttachOutput(wxVideoOutput
& out
)
134 if (!wxVideoBaseDriver::AttachOutput(out
))
137 return RestartXANIM();
140 void wxVideoXANIM::DetachOutput()
143 xanim_started
= false;
146 wxVideoBaseDriver::DetachOutput();
149 bool wxVideoXANIM::SendCommand(const char *command
, char **ret
,
156 // Send a command to XAnim through X11 Property
157 XChangeProperty(internal
->xanim_dpy
, internal
->xanim_window
,
158 internal
->xanim_atom
,
159 XA_STRING
, 8, PropModeReplace
, (unsigned char *)command
,
161 XFlush(internal
->xanim_dpy
);
167 XGetWindowProperty(internal
->xanim_dpy
, internal
->xanim_window
,
168 internal
->xanim_ret
, 0, 16, True
, AnyPropertyType
,
169 &prop_type
, &prop_format
, (unsigned long *)size
,
170 &extra
, (unsigned char **)ret
);
175 bool wxVideoXANIM::RestartXANIM()
177 wxString xanim_command
;
181 unsigned long nitems
;
186 if (!video_output
|| xanim_started
|| !GetCurrentFile())
189 // Check if we can change the size of the window dynamicly
190 xanim_chg_size
= video_output
->DynamicSize();
191 // Get current display
193 internal
->xanim_dpy
= wxAPP_DISPLAY
;
196 internal
->xanim_dpy
= gdk_display
;
200 internal
->xanim_window
= XtWindow(video_output
->FWidget());
202 internal
->xanim_window
=
203 ((GdkWindowPrivate
*)video_output
->m_widget
->window
)->xwindow
;
205 // Get the XANIM atom
206 internal
->xanim_atom
= XInternAtom(internal
->xanim_dpy
,
207 "XANIM_PROPERTY", False
);
210 xanim_command
.sprintf(__XANIM_COMMAND__
" +W%d +Wp +f +B -Zr +q +Zpe +Ae "
211 "+Av70 %s %s", internal
->xanim_window
,
212 (xanim_chg_size
== true) ? "+Sr" : "",
213 (const char *)GetCurrentFile());
215 if (!wxExecute(xanim_command
, false))
218 // Wait for XAnim to be ready
220 while (nitems
== 0) {
221 ret
= XGetWindowProperty(internal
->xanim_dpy
, internal
->xanim_window
,
222 internal
->xanim_atom
,
223 0, 4, False
, AnyPropertyType
, &prop_type
,
224 &prop_format
, &nitems
, &extra
,
225 (unsigned char **)&prop
);
229 xanim_started
= true;