1 /* videoreader_dummy.cc
2 Simple example for a videoreader.
4 Part of the swftools package.
6 Copyright (c) 2004 Matthias Kramm <kramm@quiss.org>
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 */
25 #include "videoreader.h"
27 typedef struct _my_internal
40 int my_getsamples(videoreader_t
* v
, void*buffer
, int num
)
42 /* generate audio data */
43 my_internal
*i
= (my_internal
*)v
->internal
;
44 // printf("request for %d samples\n", num);
49 int my_getimage(videoreader_t
* v
, void*buffer
)
51 /* generate video frame */
52 my_internal
*i
= (my_internal
*)v
->internal
;
53 RGBA
*buf
= (RGBA
*)buffer
;
56 return 0; /* end of video */
58 i
->pos
++; // next frame
61 /* generate a simple color gradient */
62 for(y
=0;y
<v
->height
;y
++)
63 for(x
=0;x
<v
->width
;x
++) {
68 buf
[y
*v
->width
+ x
].r
= r
;
69 buf
[y
*v
->width
+ x
].g
= g
;
70 buf
[y
*v
->width
+ x
].b
= b
;
71 buf
[y
*v
->width
+ x
].a
= 255;
73 return v
->width
*v
->height
*4;
75 void my_close(videoreader_t
* v
)
77 my_internal
*i
= (my_internal
*)v
->internal
;
78 free(v
->internal
);v
->internal
= 0;
80 void my_setparameter(videoreader_t
*v
, char*name
, char*value
)
83 int videoreader_dummy_open(videoreader_t
* v
, char* filename
)
86 i
= (my_internal
*)malloc(sizeof(my_internal
));
87 memset(i
, 0, sizeof(my_internal
));
89 v
->getsamples
= my_getsamples
;
91 v
->getimage
= my_getimage
;
92 v
->getsamples
= my_getsamples
;
93 v
->setparameter
= my_setparameter
;
95 i
->len
= 2000; //number of frames
97 v
->width
= 320; // video
101 v
->channels
= 0; // no audio