2
fbmngplay - fb console MNG player.
3
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
5
This program is based on mngplay, part of libmng, written and (C) by
6
Ralph Giles <giles :at: ashlu.bc.ca>
8
This program my be redistributed under the terms of the
9
GNU General Public Licence, version 2, or at your preference,
18
#include <sys/ioctl.h>
21
#include "fbmngplay.h"
34
void sigint_handler(int signal);
35
void sigterm_handler(int signal);
36
void sigusr1_handler(int signal);
38
void sigint_handler(int signal)
43
void sigterm_handler(int signal)
49
void sigusr1_handler(int signal)
54
int main(int argc, char *argv[])
56
int fbdev,c,option_index;
58
struct fb_var_screeninfo var;
60
/* Check which console we're running on */
63
/* allocate our stream data structure */
64
mng = (mngstuff *) calloc(1, sizeof(*mng));
66
fprintf(stderr, "could not allocate stream structure.\n");
73
mng->background = NULL;
76
static struct option long_options[] = {
78
{"verbose", 0, 0, 'v'},
80
{"buffered", 0, 0, 'b'},
81
{"signal", 0, 0, 's'},
83
{"position", 0, 0, 'p'},
84
{"version", 0, 0, 'V'},
85
{"start-console",0,0,'S'},
90
c = getopt_long(argc, argv, "a:x:y:bh?vsd:pVSc:",
91
long_options, &option_index);
104
mng->fbx = atoi(optarg);
107
mng->fby = atoi(optarg);
110
delta = atoi(optarg);
132
start_console=atoi(optarg);
141
if (optind >= argc) {
142
printf("Which files do you want to play?\n");
148
/* Initialize framebuffer */
149
fbdev = open("/dev/fb0", O_RDWR);
151
fprintf(stderr, "error while opening framebuffer.\n");
155
ioctl(fbdev, FBIOGET_VSCREENINFO, &var);
156
mng->fbwidth = var.xres;
157
mng->fbheight = var.yres;
158
mng->fbbpp = var.bits_per_pixel;
161
mmap(NULL, var.xres * var.yres * (var.bits_per_pixel >> 3),
162
PROT_WRITE | PROT_READ, MAP_SHARED, fbdev, 0);
164
/* arrange to call the shutdown routine before we exit */
167
while (optind < argc) {
168
// leftover arguements are filenames.
169
mng->filename = argv[optind++];
171
/* set up the mng decoder for our stream */
172
mng->mng = mng_initialize(mng, mngalloc, mngfree, MNG_NULL);
173
if (mng->mng == MNG_NULL) {
174
fprintf(stderr, "could not initialize libmng.\n");
178
/* set the callbacks */
179
mng_setcb_errorproc(mng->mng, mngerror);
180
mng_setcb_openstream(mng->mng, mngopenstream);
181
mng_setcb_closestream(mng->mng, mngclosestream);
182
mng_setcb_readdata(mng->mng, mngreadstream);
183
mng_setcb_gettickcount(mng->mng, mnggetticks);
184
mng_setcb_settimer(mng->mng, mngsettimer);
185
mng_setcb_processheader(mng->mng, mngprocessheader);
186
mng_setcb_getcanvasline(mng->mng, mnggetcanvasline);
187
mng_setcb_refresh(mng->mng, mngrefresh);
188
/* FIXME: should check for errors here */
190
signal(SIGINT, sigint_handler);
191
signal(SIGTERM, sigterm_handler);
193
mng_readdisplay(mng->mng);
195
/* loop though the frames */
196
while (mng->delay && run) {
199
mng_display_resume(mng->mng);
209
if (waitsignal && optind < argc) {
210
signal(SIGUSR1, sigusr1_handler);
217
memset(mng->copybuffer, 0,
218
4 * mng->width * mng->height);
221
if (optind == argc) { /* last file */
226
/* cleanup and quit */
227
return mngquit(mng->mng);
2
fbmngplay - fb console MNG player.
3
(c) 2001 by Stefan Reinauer, <stepan :at: suse.de>
5
This program is based on mngplay, part of libmng, written and (C) by
6
Ralph Giles <giles :at: ashlu.bc.ca>
8
This program my be redistributed under the terms of the
9
GNU General Public Licence, version 2, or at your preference,
18
#include <sys/ioctl.h>
21
#include "fbmngplay.h"
34
void sigint_handler(int signal);
35
void sigterm_handler(int signal);
36
void sigusr1_handler(int signal);
38
void sigint_handler(int signal)
43
void sigterm_handler(int signal)
49
void sigusr1_handler(int signal)
54
int main(int argc, char *argv[])
56
int fbdev,c,option_index;
58
struct fb_var_screeninfo var;
60
/* Check which console we're running on */
63
/* allocate our stream data structure */
64
mng = (mngstuff *) calloc(1, sizeof(*mng));
66
fprintf(stderr, "could not allocate stream structure.\n");
73
mng->background = NULL;
76
static struct option long_options[] = {
78
{"verbose", 0, 0, 'v'},
80
{"buffered", 0, 0, 'b'},
81
{"signal", 0, 0, 's'},
83
{"position", 0, 0, 'p'},
84
{"version", 0, 0, 'V'},
85
{"start-console",0,0,'S'},
90
c = getopt_long(argc, argv, "a:x:y:bh?vsd:pVSc:",
91
long_options, &option_index);
104
mng->fbx = atoi(optarg);
107
mng->fby = atoi(optarg);
110
delta = atoi(optarg);
132
start_console=atoi(optarg);
141
if (optind >= argc) {
142
printf("Which files do you want to play?\n");
148
/* Initialize framebuffer */
149
fbdev = open("/dev/fb0", O_RDWR);
151
fprintf(stderr, "error while opening framebuffer.\n");
155
ioctl(fbdev, FBIOGET_VSCREENINFO, &var);
156
mng->fbwidth = var.xres;
157
mng->fbheight = var.yres;
158
mng->fbbpp = var.bits_per_pixel;
161
mmap(NULL, var.xres * var.yres * (var.bits_per_pixel >> 3),
162
PROT_WRITE | PROT_READ, MAP_SHARED, fbdev, 0);
164
/* arrange to call the shutdown routine before we exit */
167
while (optind < argc) {
168
// leftover arguements are filenames.
169
mng->filename = argv[optind++];
171
/* set up the mng decoder for our stream */
172
mng->mng = mng_initialize(mng, mngalloc, mngfree, MNG_NULL);
173
if (mng->mng == MNG_NULL) {
174
fprintf(stderr, "could not initialize libmng.\n");
178
/* set the callbacks */
179
mng_setcb_errorproc(mng->mng, mngerror);
180
mng_setcb_openstream(mng->mng, mngopenstream);
181
mng_setcb_closestream(mng->mng, mngclosestream);
182
mng_setcb_readdata(mng->mng, mngreadstream);
183
mng_setcb_gettickcount(mng->mng, mnggetticks);
184
mng_setcb_settimer(mng->mng, mngsettimer);
185
mng_setcb_processheader(mng->mng, mngprocessheader);
186
mng_setcb_getcanvasline(mng->mng, mnggetcanvasline);
187
mng_setcb_refresh(mng->mng, mngrefresh);
188
/* FIXME: should check for errors here */
190
signal(SIGINT, sigint_handler);
191
signal(SIGTERM, sigterm_handler);
193
mng_readdisplay(mng->mng);
195
/* loop though the frames */
196
while (mng->delay && run) {
199
mng_display_resume(mng->mng);
209
if (waitsignal && optind < argc) {
210
signal(SIGUSR1, sigusr1_handler);
217
memset(mng->copybuffer, 0,
218
4 * mng->width * mng->height);
221
if (optind == argc) { /* last file */
226
/* cleanup and quit */
227
return mngquit(mng->mng);