1
/******************************************************************************
3
*******************************************************************************
5
* Copyright (C) 2006,2007,2008 John Varouhakis *
8
* This program is free software; you can redistribute it and/or modify *
9
* it under the terms of the GNU General Public License as published by *
10
* the Free Software Foundation; either version 2 of the License, or *
11
* (at your option) any later version. *
13
* This program is distributed in the hope that it will be useful, *
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16
* GNU General Public License for more details. *
18
* You should have received a copy of the GNU General Public License *
19
* along with this program; if not, write to the Free Software *
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
24
* For further information contact me at johnvarouhakis@gmail.com *
25
******************************************************************************/
29
#include "rmd_cache.h"
30
#include "rmd_encode_cache.h"
31
#include "rmd_error.h"
32
#include "rmd_initialize_data.h"
33
#include "rmd_parseargs.h"
34
#include "rmd_queryextensions.h"
35
#include "rmd_rescue.h"
36
#include "rmd_setbrwindow.h"
37
#include "rmd_shortcuts.h"
38
#include "rmd_threads.h"
39
#include "rmd_wm_is_compositing.h"
40
#include "rmd_types.h"
48
int main(int argc,char **argv){
52
SetupDefaultArgs(&pdata.args);
54
if (!ParseArgs(argc, argv, &pdata.args)) {
57
if (pdata.args.rescue_path != NULL) {
58
exit(rmdRescue(pdata.args.rescue_path));
60
if(XInitThreads ()==0){
61
fprintf(stderr,"Couldn't initialize thread support!\n");
64
if(pdata.args.display!=NULL){
65
pdata.dpy = XOpenDisplay(pdata.args.display);
66
XSetErrorHandler(rmdErrorHandler);
69
fprintf(stderr,"No display specified for connection!\n");
72
if (pdata.dpy == NULL) {
73
fprintf(stderr, "Cannot connect to X server %s\n",pdata.args.display);
82
// Give jack access to program data, mainly for program state
87
// Query display specs
88
pdata.specs.screen = DefaultScreen(pdata.dpy);
89
pdata.specs.width = DisplayWidth(pdata.dpy, pdata.specs.screen);
90
pdata.specs.height = DisplayHeight(pdata.dpy, pdata.specs.screen);
91
pdata.specs.root = RootWindow(pdata.dpy, pdata.specs.screen);
92
pdata.specs.visual = DefaultVisual(pdata.dpy, pdata.specs.screen);
93
pdata.specs.gc = DefaultGC(pdata.dpy, pdata.specs.screen);
94
pdata.specs.depth = DefaultDepth(pdata.dpy, pdata.specs.screen);
96
if((pdata.specs.depth!=32)&&
97
(pdata.specs.depth!=24)&&
98
(pdata.specs.depth!=16)){
99
fprintf(stderr,"Only 32bpp,24bpp and 16bpp"
100
" color depth modes are currently supported.\n");
103
if (!SetBRWindow(pdata.dpy, &pdata.brwin, &pdata.specs, &pdata.args))
106
if( !pdata.args.nowmcheck &&
107
rmdWMIsCompositing( pdata.dpy, pdata.specs.screen ) ) {
109
fprintf(stderr,"\nDetected compositing window manager.\n"
110
"Reverting to full screen capture at every frame.\n"
111
"To disable this check run with --no-wm-check\n"
112
"(though that is not advised, since it will "
113
"probably produce faulty results).\n\n");
114
pdata.args.full_shots=1;
115
pdata.args.noshared=0;
119
QueryExtensions(pdata.dpy,
126
if((exit_status=InitializeData(&pdata,&enc_data,&cache_data))==0){
128
if(!strcmp(pdata.args.pause_shortcut,
129
pdata.args.stop_shortcut)||
130
RegisterShortcut(pdata.dpy,
132
pdata.args.pause_shortcut,
133
&(pdata.pause_key)) ||
134
RegisterShortcut(pdata.dpy,
136
pdata.args.stop_shortcut,
139
fprintf(stderr,"Invalid shortcut,"
140
" or shortcuts are the same!\n\n"
141
"Using defaults.\n");
143
RegisterShortcut(pdata.dpy,
147
RegisterShortcut(pdata.dpy,
153
//this is where the capturing happens.
156
XCloseDisplay(pdata.dpy);
157
fprintf(stderr,".\n");
159
//encode and then cleanup cache
160
if(!pdata.args.encOnTheFly && !pdata.args.no_encode){
161
if (!pdata.aborted) {
164
fprintf(stderr,"Cleanning up cache...\n");
165
if(PurgeCache(pdata.cache_data,!pdata.args.nosound))
166
fprintf(stderr,"Some error occured "
167
"while cleaning up cache!\n");
168
fprintf(stderr,"Done!!!\n");
172
if (pdata.aborted && pdata.args.encOnTheFly) {
173
if(remove(pdata.args.filename)){
174
perror("Error while removing file:\n");
178
fprintf(stderr,"SIGABRT received,file %s removed\n",
179
pdata.args.filename);
184
fprintf(stderr,"Goodbye!\n");