| 1 |
#include "genctl.h" |
| 2 |
#include "recwnd.h" |
| 3 |
|
| 4 |
#include <avm_except.h> |
| 5 |
|
| 6 |
#include <qapplication.h> |
| 7 |
|
| 8 |
#include <unistd.h> |
| 9 |
#include <string.h> |
| 10 |
#include <stdlib.h> |
| 11 |
#include <stdio.h> |
| 12 |
|
| 13 |
#ifdef __FreeBSD__ |
| 14 |
#include <floatingpoint.h> |
| 15 |
#endif |
| 16 |
#ifdef __NetBSD__ |
| 17 |
#include <ieeefp.h> |
| 18 |
#endif |
| 19 |
|
| 20 |
void Usage() |
| 21 |
{ |
| 22 |
printf("Usage: avirecompress [config-file-name]\n" |
| 23 |
" Without options: interactive mode\n" |
| 24 |
" With one option: batch mode ( processes one file according to config options and exits )\n"); |
| 25 |
} |
| 26 |
|
| 27 |
struct ConsoleCallback: public IRecompressCallback |
| 28 |
{ |
| 29 |
int state; |
| 30 |
ConsoleCallback():state(0){} |
| 31 |
virtual void setNewState(double progress, double elapsed, int64_t filesize) |
| 32 |
{ |
| 33 |
printf("percent: %3.1f elapsed: %f size: %" PRId64 "\n", progress * 100, elapsed, filesize); |
| 34 |
} |
| 35 |
virtual void setTotal(framepos_t vtotal, framepos_t atotal, |
| 36 |
double vtime, double atime) {} |
| 37 |
virtual void addVideo(framepos_t vframe, unsigned int vsize, double vtime, bool keyframe) {} |
| 38 |
virtual void addAudio(framepos_t asample, unsigned int asize, double atime) {} |
| 39 |
virtual void finished() { state=1; } |
| 40 |
}; |
| 41 |
|
| 42 |
int main(int argc, char** argv) |
| 43 |
{ |
| 44 |
#if defined(__FreeBSD__) || defined(__NetBSD__) |
| 45 |
fpsetmask(fpgetmask() & ~(FP_X_DZ|FP_X_INV)); |
| 46 |
#endif |
| 47 |
if (argc == 1) |
| 48 |
{ |
| 49 |
try |
| 50 |
{ |
| 51 |
QApplication app(argc, argv); |
| 52 |
QtRecompressorCtl ctl; |
| 53 |
ctl.show(); |
| 54 |
app.setMainWidget(&ctl); |
| 55 |
app.exec(); |
| 56 |
} |
| 57 |
catch (avm::FatalError& e) |
| 58 |
{ |
| 59 |
e.PrintAll(); |
| 60 |
} |
| 61 |
} |
| 62 |
else if (argc == 2) |
| 63 |
{ |
| 64 |
if (strcmp(argv[1], "--help")!=0) |
| 65 |
{ |
| 66 |
ConsoleCallback ck; |
| 67 |
RecKernel kernel; |
| 68 |
kernel.loadConfig(argv[1]); |
| 69 |
kernel.setCallback(&ck); |
| 70 |
kernel.startRecompress(); |
| 71 |
while (!ck.state) |
| 72 |
sleep(1); |
| 73 |
// RecWindow* wnd=new RecWindow(0, &kernel); |
| 74 |
// wnd->show(); |
| 75 |
// app.setMainWidget(wnd); |
| 76 |
// wnd->exec(); |
| 77 |
} |
| 78 |
else |
| 79 |
Usage(); |
| 80 |
} |
| 81 |
else |
| 82 |
Usage(); |
| 83 |
return 0; |
| 84 |
} |