2
The mediastreamer library aims at providing modular media processing and I/O
3
for linphone, but also for any telephony application.
4
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
static MSXineClass *ms_xine_class=NULL;
27
static void change_window_size(void *user_data,
28
int video_width, int video_height,
29
int *dest_x, int *dest_y,
30
int *dest_height, int *dest_width)
32
MSXine *obj=(MSXine*)user_data;
33
XLockDisplay(obj->vis.display);
34
g_message("entering change window size!!!!");
35
g_message("video_width=%i, video_height=%i",video_width,video_height);
38
XUnlockDisplay(obj->vis.display);
42
void calc_dest_size (void *this,
43
int video_width, int video_height,
44
int *dest_width, int *dest_height) {
45
g_message("entering video_window_calc_dest_size() !");
46
*dest_width=video_width;
47
*dest_height=video_height;
49
void ms_xine_init(MSXine *obj)
51
MSXineClass *klass=MS_XINE_CLASS(MS_FILTER(obj)->klass);
53
XSetWindowAttributes att;
54
ao_driver_t *ao_driver;
58
ms_filter_init(MS_FILTER(obj));
59
MS_FILTER(obj)->inqueues=obj->input;
60
memset(&obj->vis,0,sizeof(x11_visual_t));
61
/* create an X11 window */
62
obj->vis.display=XOpenDisplay(NULL);
63
obj->vis.screen=DefaultScreen(obj->vis.display);
65
res_h = (DisplayWidth (obj->vis.display, obj->vis.screen)*1000
66
/ DisplayWidthMM (obj->vis.display, obj->vis.screen));
67
res_v = (DisplayHeight (obj->vis.display, obj->vis.screen)*1000
68
/ DisplayHeightMM (obj->vis.display, obj->vis.screen));
69
obj->vis.display_ratio = res_h / res_v;
70
if (fabs(obj->vis.display_ratio - 1.0) < 0.01) {
72
* we have a display with *almost* square pixels (<1% error),
73
* to avoid time consuming software scaling in video_out_xshm,
74
* correct this to the exact value of 1.0 and pretend we have
75
* perfect square pixels.
77
obj->vis.display_ratio = 1.0;
80
att.colormap=DefaultColormap(obj->vis.display,obj->vis.screen);
81
att.background_pixel = BlackPixel(obj->vis.display,obj->vis.screen);
82
att.border_pixel = BlackPixel(obj->vis.display,obj->vis.screen);
83
obj->vis.d=XCreateWindow(obj->vis.display,RootWindow(obj->vis.display,obj->vis.screen),0,0,1000,800,0,
84
DefaultDepth(obj->vis.display,obj->vis.screen),CopyFromParent,
85
DefaultVisual(obj->vis.display,obj->vis.screen),
86
CWColormap | CWBackPixel | CWBorderPixel,
88
XMapWindow(obj->vis.display,obj->vis.d);
89
XSync(obj->vis.display,False);
90
XSetStandardProperties(obj->vis.display, obj->vis.d,
91
"Linphone video display", "Linphone video display", None, NULL, 0, 0);
92
XCreateGC(obj->vis.display, obj->vis.d, 0L, &xgcv);
94
//XMapRaised(obj->vis.display,obj->vis.d);
96
//XFlush(obj->vis.display);
98
/* select the first availlable output plugin type*/
99
obj->vo_driver=xine_load_video_output_plugin(klass->config,
100
klass->video_plugins[0],
103
if (obj->vo_driver==NULL){
104
g_error("Could not load a xine output plugin.");
106
else g_message("New vo driver %x created.",obj->vo_driver);
107
ao_driver=xine_load_audio_output_plugin(klass->config,"esd");
108
if (ao_driver==NULL) g_message("Could not load audio output plugin");
110
/* set some callbacks */
111
obj->vis.user_data=(void*)obj;
112
obj->vis.request_dest_size=change_window_size;
113
obj->vis.calc_dest_size=calc_dest_size;
115
/* initializing a xine engine*/
116
obj->engine=xine_init(obj->vo_driver,ao_driver,klass->config);
117
if (obj->engine==NULL){
118
g_error("Could not create a new xine engine");
121
obj->vo_driver->gui_data_exchange (obj->vo_driver,
122
GUI_DATA_EX_DRAWABLE_CHANGED,
126
void ms_xine_class_init(MSXineClass *klass)
130
ms_filter_class_init(MS_FILTER_CLASS(klass));
131
MS_FILTER_CLASS(klass)->max_qinputs=1;
132
MS_FILTER_CLASS(klass)->destroy=(MSFilterDestroyFunc)ms_xine_destroy;
133
/* read xine config file */
134
klass->config=config_file_init(NULL);
135
if (klass->config==NULL){
136
g_error("Could not read xine config file");
138
/* list availlable video output plugins */
139
klass->video_plugins=xine_list_video_output_plugins(VISUAL_TYPE_X11);
140
g_message("Xine video plugins for X11 are:");
142
while (klass->video_plugins[i]!=NULL)
144
g_message("\t- %s",klass->video_plugins[i]);
150
MSFilter * ms_xine_new()
152
MSXine *obj=g_malloc(sizeof(MSXine));
154
if (ms_xine_class==NULL)
156
ms_xine_class=g_malloc(sizeof(MSXineClass));
157
ms_xine_class_init(ms_xine_class);
159
MS_FILTER(obj)->klass=MS_FILTER_CLASS(ms_xine_class);
161
return MS_FILTER(obj);
164
void ms_xine_start(MSXine *obj)
166
xine_play(obj->engine,
167
"file://cdrom/Videos/(smr)shrek-ts(1of2).avi",
171
void ms_xine_uninit(MSXine *obj)
173
xine_exit(obj->engine);
174
free(obj->vo_driver);
175
XDestroyWindow(obj->vis.display,obj->vis.d);
178
void ms_xine_stop(MSXine *obj)
180
xine_stop(obj->engine);
184
void ms_xine_destroy(MSXine *obj)