Uncommented beaudio code
[pwlib.git] / src / ptlib / common / vfakeio.cxx
blob97875711045f5323dbd8df208ed0c58912db85cc
1 /*
2 * vfakeio.cxx
4 * Classes to support streaming video input (grabbing) and output.
6 * Portable Windows Library
8 * Copyright (c) 1993-2000 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): Derek J Smithies (derek@indranet.co.nz)
26 * $Log$
27 * Revision 1.29 2004/03/17 22:24:29 rjongbloed
28 * Fixed MSVC warnings
30 * Revision 1.28 2004/03/16 10:10:47 csoutheren
31 * Proper fix that does not generate warnings
33 * Revision 1.27 2004/03/16 08:27:14 csoutheren
34 * Removed illegal characters
36 * Revision 1.26 2003/12/14 10:01:02 rjongbloed
37 * Resolved issue with name space conflict os static and virtual forms of GetDeviceNames() function.
39 * Revision 1.25 2003/11/19 09:29:45 csoutheren
40 * Added super hack to avoid problems with multiple plugins in a single file
42 * Revision 1.24 2003/11/19 04:29:46 csoutheren
43 * Changed to support video output plugins
45 * Revision 1.23 2003/08/12 22:04:18 dereksmithies
46 * Add fix from Philippe Massicotte to fix segfaults on large images. Thanks!
48 * Revision 1.22 2003/06/14 03:28:50 rjongbloed
49 * Further MSVC warning fix up
51 * Revision 1.21 2003/06/14 02:59:34 rjongbloed
52 * Fixed MSVC warning.
54 * Revision 1.20 2003/06/11 22:17:54 dereksmithies
55 * Add fake video device which display text, on --videoinput 5
57 * Revision 1.19 2003/06/10 03:45:11 dereksmithies
58 * Change so box on left moves all the way down left side of image.
60 * Revision 1.18 2003/06/10 00:36:57 dereksmithies
61 * Formatting changes. Remove rounding errors.
63 * Revision 1.17 2003/06/03 04:21:49 dereksmithies
64 * Add PTRACE statement, and tidy up format of one if statement.
66 * Revision 1.16 2003/03/17 07:46:49 robertj
67 * Migrated vflip member variable and functions into PVideoDevice class.
69 * Revision 1.15 2002/09/23 07:17:24 robertj
70 * Changes to allow winsock2 to be included.
72 * Revision 1.14 2002/01/28 21:22:10 dereks
73 * Fix the method for returning the device name.
75 * Revision 1.13 2002/01/17 03:47:27 dereks
76 * Fix latest addition to the fake images gallery.
78 * Revision 1.12 2002/01/16 08:02:06 robertj
79 * MSVC compatibilty changes
81 * Revision 1.11 2002/01/16 03:49:23 dereks
82 * Add new test image.
84 * Revision 1.10 2002/01/04 04:11:45 dereks
85 * Add video flip code from Walter Whitlock, which flips code at the grabber.
87 * Revision 1.9 2001/11/28 04:39:25 robertj
88 * Fixed MSVC warning
90 * Revision 1.8 2001/11/28 00:07:32 dereks
91 * Locking added to PVideoChannel, allowing reader/writer to be changed mid call
92 * Enabled adjustment of the video frame rate
93 * New fictitous image, a blank grey area
95 * Revision 1.7 2001/03/12 03:54:11 dereks
96 * Make setting frame rate consistent with that for real video device.
98 * Revision 1.6 2001/03/09 00:12:40 robertj
99 * Fixed incorrect number of channels returned on fake video.
101 * Revision 1.5 2001/03/08 22:56:25 robertj
102 * Fixed compatibility with new meaning of channelNumber variable, cannot be negative.
104 * Revision 1.4 2001/03/03 05:06:31 robertj
105 * Major upgrade of video conversion and grabbing classes.
107 * Revision 1.3 2001/03/02 06:52:33 yurik
108 * Got rid of unknown for WinCE pragma
110 * Revision 1.2 2000/12/19 23:58:14 robertj
111 * Fixed MSVC compatibility issues.
113 * Revision 1.1 2000/12/19 22:20:26 dereks
114 * Add video channel classes to connect to the PwLib PVideoInputDevice class.
115 * Add PFakeVideoInput class to generate test images for video.
119 #ifdef __GNUC__
120 #pragma implementation "vfakeio.h"
121 #endif
123 #define P_FORCE_STATIC_PLUGIN
125 #include <ptlib.h>
126 #include <ptlib/videoio.h>
129 #define NUM_PATTERNS 6
132 #define MAX_L_HEIGHT 11
134 typedef struct {
135 char ascii;
136 char *line[MAX_L_HEIGHT];
137 } OneVFakeLetterData;
140 /****
141 * The fonts for these letters were written by Sverre H. Huseby, and have been included
142 * in vfakeio by Derek Smithies.
144 static OneVFakeLetterData vFakeLetterData[] = {
145 { ' ', { " ",
146 " ",
147 " ",
148 " ",
149 " ",
150 " ",
151 " ",
152 " ",
153 " ",
154 " ",
155 " " }},
156 { 'a', { " ",
157 " ",
158 " ",
159 " **** ",
160 " *",
161 " *****",
162 "* *",
163 "* **",
164 " *** *",
165 " ",
166 " " }},
167 { 'b', { "* ",
168 "* ",
169 "* ",
170 "* *** ",
171 "** *",
172 "* *",
173 "* *",
174 "** *",
175 "* *** ",
176 " ",
177 " " }},
178 { 'c', { " ",
179 " ",
180 " ",
181 " **** ",
182 "* *",
183 "* ",
184 "* ",
185 "* *",
186 " **** ",
187 " ",
188 " " }},
189 { 'd', { " *",
190 " *",
191 " *",
192 " *** *",
193 "* **",
194 "* *",
195 "* *",
196 "* **",
197 " *** *",
198 " ",
199 " " }},
200 { 'e', { " ",
201 " ",
202 " ",
203 " **** ",
204 "* *",
205 "******",
206 "* ",
207 "* *",
208 " **** ",
209 " ",
210 " " }},
211 { 'f', { " *** ",
212 " * *",
213 " * ",
214 " * ",
215 "**** ",
216 " * ",
217 " * ",
218 " * ",
219 " * ",
220 " ",
221 " " }},
222 { 'g', { " ",
223 " ",
224 " ",
225 " *** *",
226 "* * ",
227 "* * ",
228 " *** ",
229 "* ",
230 " **** ",
231 "* *",
232 " **** " }},
233 { 'h', { "* ",
234 "* ",
235 "* ",
236 "* *** ",
237 "** *",
238 "* *",
239 "* *",
240 "* *",
241 "* *",
242 " ",
243 " " }},
244 { 'i', { " ",
245 " * ",
246 " ",
247 " ** ",
248 " * ",
249 " * ",
250 " * ",
251 " * ",
252 "*****",
253 " ",
254 " " }},
255 { 'j', { " ",
256 " *",
257 " ",
258 " **",
259 " *",
260 " *",
261 " *",
262 " *",
263 "* *",
264 "* *",
265 " *** " }},
266 { 'k', { "* ",
267 "* ",
268 "* ",
269 "* * ",
270 "* * ",
271 "*** ",
272 "* * ",
273 "* * ",
274 "* *",
275 " ",
276 " " }},
277 { 'l', { " ** ",
278 " * ",
279 " * ",
280 " * ",
281 " * ",
282 " * ",
283 " * ",
284 " * ",
285 "*****",
286 " ",
287 " " }},
288 { 'm', { " ",
289 " ",
290 " ",
291 "* * ** ",
292 "** * *",
293 "* * *",
294 "* * *",
295 "* * *",
296 "* * *",
297 " ",
298 " " }},
299 { 'n', { " ",
300 " ",
301 " ",
302 "* *** ",
303 "** *",
304 "* *",
305 "* *",
306 "* *",
307 "* *",
308 " ",
309 " " }},
310 { 'o', { " ",
311 " ",
312 " ",
313 " **** ",
314 "* *",
315 "* *",
316 "* *",
317 "* *",
318 " **** ",
319 " ",
320 " " }},
321 { 'p', { " ",
322 " ",
323 " ",
324 "* *** ",
325 "** *",
326 "* *",
327 "** *",
328 "* *** ",
329 "* ",
330 "* ",
331 "* " }},
332 { 'q', { " ",
333 " ",
334 " ",
335 " *** *",
336 "* **",
337 "* *",
338 "* **",
339 " *** *",
340 " *",
341 " *",
342 " *" }},
343 { 'r', { " ",
344 " ",
345 " ",
346 "* **",
347 " * ",
348 " * ",
349 " * ",
350 " * ",
351 " * ",
352 " ",
353 " " }},
354 { 's', { " ",
355 " ",
356 " ",
357 " **** ",
358 "* *",
359 " ** ",
360 " ** ",
361 "* *",
362 " **** ",
363 " ",
364 " " }},
365 { 't', { " * ",
366 " * ",
367 " * ",
368 "**** ",
369 " * ",
370 " * ",
371 " * ",
372 " * *",
373 " ** ",
374 " ",
375 " " }},
376 { 'u', { " ",
377 " ",
378 " ",
379 "* *",
380 "* *",
381 "* *",
382 "* *",
383 "* **",
384 " *** *",
385 " ",
386 " " }},
387 { 'v', { " ",
388 " ",
389 " ",
390 "* *",
391 "* *",
392 "* *",
393 " * * ",
394 " * * ",
395 " * ",
396 " ",
397 " " }},
398 { 'w', { " ",
399 " ",
400 " ",
401 "* *",
402 "* *",
403 "* * *",
404 "* * *",
405 "* * *",
406 " ** ** ",
407 " ",
408 " " }},
409 { 'x', { " ",
410 " ",
411 " ",
412 "* *",
413 " * * ",
414 " ** ",
415 " ** ",
416 " * * ",
417 "* *",
418 " ",
419 " " }},
420 { 'y', { " ",
421 " ",
422 " ",
423 "* *",
424 "* *",
425 "* *",
426 "* **",
427 " *** *",
428 " *",
429 "* *",
430 " **** " }},
431 { 'z', { " ",
432 " ",
433 " ",
434 "******",
435 " * ",
436 " * ",
437 " * ",
438 " * ",
439 "******",
440 " ",
441 " " }},
442 { '\xe6', { " ",
443 " ",
444 " ",
445 " ** * ",
446 " * *",
447 " *****",
448 "* * ",
449 "* * *",
450 " ** * ",
451 " ",
452 " " }},
453 { '\xf8', { " ",
454 " ",
455 " *",
456 " **** ",
457 "* **",
458 "* * *",
459 "* * *",
460 "** *",
461 " **** ",
462 "* ",
463 " " }},
464 { '\xe5', { " ** ",
465 " * * ",
466 " ** ",
467 " **** ",
468 " *",
469 " *****",
470 "* *",
471 "* **",
472 " *** *",
473 " ",
474 " " }},
475 { 'A', { " ** ",
476 " * * ",
477 "* *",
478 "* *",
479 "* *",
480 "******",
481 "* *",
482 "* *",
483 "* *",
484 " ",
485 " " }},
486 { 'B', { "***** ",
487 " * *",
488 " * *",
489 " * *",
490 " **** ",
491 " * *",
492 " * *",
493 " * *",
494 "***** ",
495 " ",
496 " " }},
497 { 'C', { " *** ",
498 "* *",
499 "* ",
500 "* ",
501 "* ",
502 "* ",
503 "* ",
504 "* *",
505 " *** ",
506 " ",
507 " " }},
508 { 'D', { "***** ",
509 " * *",
510 " * *",
511 " * *",
512 " * *",
513 " * *",
514 " * *",
515 " * *",
516 "***** ",
517 " ",
518 " " }},
519 { 'E', { "*****",
520 "* ",
521 "* ",
522 "* ",
523 "**** ",
524 "* ",
525 "* ",
526 "* ",
527 "*****",
528 " ",
529 " " }},
530 { 'F', { "*****",
531 "* ",
532 "* ",
533 "* ",
534 "**** ",
535 "* ",
536 "* ",
537 "* ",
538 "* ",
539 " ",
540 " " }},
541 { 'G', { " **** ",
542 "* *",
543 "* ",
544 "* ",
545 "* ",
546 "* ***",
547 "* *",
548 "* **",
549 " *** *",
550 " ",
551 " " }},
552 { 'H', { "* *",
553 "* *",
554 "* *",
555 "* *",
556 "******",
557 "* *",
558 "* *",
559 "* *",
560 "* *",
561 " ",
562 " " }},
563 { 'I', { "***",
564 " * ",
565 " * ",
566 " * ",
567 " * ",
568 " * ",
569 " * ",
570 " * ",
571 "***",
572 " ",
573 " " }},
574 { 'J', { " ***",
575 " *",
576 " *",
577 " *",
578 " *",
579 " *",
580 " *",
581 "* *",
582 " *** ",
583 " ",
584 " " }},
585 { 'K', { "* *",
586 "* * ",
587 "* * ",
588 "* * ",
589 "** ",
590 "* * ",
591 "* * ",
592 "* * ",
593 "* *",
594 " ",
595 " " }},
596 { 'L', { "* ",
597 "* ",
598 "* ",
599 "* ",
600 "* ",
601 "* ",
602 "* ",
603 "* ",
604 "*****",
605 " ",
606 " " }},
607 { 'M', { "* *",
608 "** **",
609 "* * * *",
610 "* * *",
611 "* *",
612 "* *",
613 "* *",
614 "* *",
615 "* *",
616 " ",
617 " " }},
618 { 'N', { "* *",
619 "* *",
620 "** *",
621 "* * *",
622 "* * *",
623 "* **",
624 "* *",
625 "* *",
626 "* *",
627 " ",
628 " " }},
629 { 'O', { " *** ",
630 "* *",
631 "* *",
632 "* *",
633 "* *",
634 "* *",
635 "* *",
636 "* *",
637 " *** ",
638 " ",
639 " " }},
640 { 'P', { "**** ",
641 "* *",
642 "* *",
643 "* *",
644 "**** ",
645 "* ",
646 "* ",
647 "* ",
648 "* ",
649 " ",
650 " " }},
651 { 'Q', { " *** ",
652 "* * ",
653 "* * ",
654 "* * ",
655 "* * ",
656 "* * ",
657 "* * * ",
658 "* ** ",
659 " **** ",
660 " *",
661 " " }},
662 { 'R', { "**** ",
663 "* *",
664 "* *",
665 "* *",
666 "**** ",
667 "** ",
668 "* * ",
669 "* * ",
670 "* *",
671 " ",
672 " " }},
673 { 'S', { " *** ",
674 "* *",
675 "* ",
676 "* ",
677 " *** ",
678 " *",
679 " *",
680 "* *",
681 " *** ",
682 " ",
683 " " }},
684 { 'T', { "*****",
685 " * ",
686 " * ",
687 " * ",
688 " * ",
689 " * ",
690 " * ",
691 " * ",
692 " * ",
693 " ",
694 " " }},
695 { 'U', { "* *",
696 "* *",
697 "* *",
698 "* *",
699 "* *",
700 "* *",
701 "* *",
702 "* *",
703 " *** ",
704 " ",
705 " " }},
706 { 'V', { "* *",
707 "* *",
708 "* *",
709 " * * ",
710 " * * ",
711 " * * ",
712 " * ",
713 " * ",
714 " * ",
715 " ",
716 " " }},
717 { 'W', { "* *",
718 "* *",
719 "* *",
720 "* *",
721 "* *",
722 "* * *",
723 "* * * *",
724 "** **",
725 "* *",
726 " ",
727 " " }},
728 { 'X', { "* *",
729 "* *",
730 " * * ",
731 " * * ",
732 " * ",
733 " * * ",
734 " * * ",
735 "* *",
736 "* *",
737 " ",
738 " " }},
739 { 'Y', { "* *",
740 "* *",
741 " * * ",
742 " * * ",
743 " * ",
744 " * ",
745 " * ",
746 " * ",
747 " * ",
748 " ",
749 " " }},
750 { 'Z', { "*****",
751 " *",
752 " * ",
753 " * ",
754 " * ",
755 " * ",
756 " * ",
757 "* ",
758 "*****",
759 " ",
760 " " }},
761 { '\xc6', { " ** ***",
762 "* * ",
763 "* * ",
764 "* * ",
765 "****** ",
766 "* * ",
767 "* * ",
768 "* * ",
769 "* ****",
770 " ",
771 " " }},
772 { '\xd8', { " *** ",
773 "* **",
774 "* * *",
775 "* * *",
776 "* * *",
777 "* * *",
778 "* * *",
779 "** *",
780 " *** ",
781 "* ",
782 " " }},
783 { '\xc5', { " ** ",
784 " * * ",
785 " ** ",
786 " ** ",
787 " * * ",
788 "* *",
789 "******",
790 "* *",
791 "* *",
792 " ",
793 " " }},
794 { '!', { "*",
795 "*",
796 "*",
797 "*",
798 "*",
799 "*",
800 "*",
801 " ",
802 "*",
803 " ",
804 " " }},
805 { '"', { "* *",
806 "* *",
807 " ",
808 " ",
809 " ",
810 " ",
811 " ",
812 " ",
813 " ",
814 " ",
815 " " }},
816 { '#', { " * * ",
817 " * * ",
818 "******",
819 " * * ",
820 " * * ",
821 " * * ",
822 "******",
823 " * * ",
824 " * * ",
825 " ",
826 " " }},
827 { '$', { " * ",
828 " **** ",
829 "* * *",
830 "* * ",
831 "* * ",
832 " **** ",
833 " * *",
834 "* * *",
835 " **** ",
836 " * ",
837 " " }},
838 { '%', { " * *",
839 "* * *",
840 " * * ",
841 " * ",
842 " * ",
843 " * ",
844 " * * ",
845 "* * *",
846 "* * ",
847 " ",
848 " " }},
849 { '&', { " ",
850 " ",
851 " ** ",
852 "* * ",
853 "* * ",
854 " ** ",
855 "* * *",
856 "* * ",
857 " *** *",
858 " ",
859 " " }},
860 { '\'',{ " ***",
861 " ** ",
862 "* ",
863 " ",
864 " ",
865 " ",
866 " ",
867 " ",
868 " ",
869 " ",
870 " " }},
871 { '(', { " *",
872 " * ",
873 " * ",
874 "* ",
875 "* ",
876 "* ",
877 " * ",
878 " * ",
879 " *",
880 " ",
881 " " }},
882 { ')', { "* ",
883 " * ",
884 " * ",
885 " *",
886 " *",
887 " *",
888 " * ",
889 " * ",
890 "* ",
891 " ",
892 " " }},
893 { '*', { " ",
894 " ",
895 " ",
896 " * * ",
897 " ** ",
898 "******",
899 " ** ",
900 " * * ",
901 " ",
902 " ",
903 " " }},
904 { '+', { " ",
905 " ",
906 " ",
907 " * ",
908 " * ",
909 "*****",
910 " * ",
911 " * ",
912 " ",
913 " ",
914 " " }},
915 { ',', { " ",
916 " ",
917 " ",
918 " ",
919 " ",
920 " ",
921 " ",
922 " ***",
923 " ** ",
924 "* ",
925 " " }},
926 { '-', { " ",
927 " ",
928 " ",
929 " ",
930 " ",
931 "*****",
932 " ",
933 " ",
934 " ",
935 " ",
936 " " }},
937 { '.', { " ",
938 " ",
939 " ",
940 " ",
941 " ",
942 " ",
943 " ",
944 "**",
945 "**",
946 " ",
947 " " }},
948 { '/', { " *",
949 " * ",
950 " * ",
951 " * ",
952 " * ",
953 " * ",
954 " * ",
955 "* ",
956 "* ",
957 " ",
958 " " }},
959 { '0', { " * ",
960 " * * ",
961 "* *",
962 "* *",
963 "* *",
964 "* *",
965 "* *",
966 " * * ",
967 " * ",
968 " ",
969 " " }},
970 { '1', { " * ",
971 " ** ",
972 "* * ",
973 " * ",
974 " * ",
975 " * ",
976 " * ",
977 " * ",
978 "*****",
979 " ",
980 " " }},
981 { '2', { " *** ",
982 "* *",
983 " *",
984 " *",
985 " * ",
986 " * ",
987 " * ",
988 "* ",
989 "*****",
990 " ",
991 " " }},
992 { '3', { "*****",
993 " *",
994 " * ",
995 " * ",
996 " *** ",
997 " *",
998 " *",
999 "* *",
1000 " *** ",
1001 " ",
1002 " " }},
1003 { '4', { " * ",
1004 " ** ",
1005 " * * ",
1006 " * * ",
1007 "* * ",
1008 "******",
1009 " * ",
1010 " * ",
1011 " * ",
1012 " ",
1013 " " }},
1014 { '5', { "*****",
1015 "* ",
1016 "* ",
1017 "* ** ",
1018 "** *",
1019 " *",
1020 " *",
1021 "* *",
1022 " *** ",
1023 " ",
1024 " " }},
1025 { '6', { " *** ",
1026 "* *",
1027 "* ",
1028 "* ",
1029 "* ** ",
1030 "** *",
1031 "* *",
1032 "* *",
1033 " *** ",
1034 " ",
1035 " " }},
1036 { '7', { "*****",
1037 " *",
1038 " * ",
1039 " * ",
1040 " * ",
1041 " * ",
1042 " * ",
1043 "* ",
1044 "* ",
1045 " ",
1046 " " }},
1047 { '8', { " *** ",
1048 "* *",
1049 "* *",
1050 "* *",
1051 " *** ",
1052 "* *",
1053 "* *",
1054 "* *",
1055 " *** ",
1056 " ",
1057 " " }},
1058 { '9', { " *** ",
1059 "* *",
1060 "* *",
1061 "* **",
1062 " ** *",
1063 " *",
1064 " *",
1065 "* *",
1066 " *** ",
1067 " ",
1068 " " }},
1069 { ':', { " ",
1070 " ",
1071 "**",
1072 "**",
1073 " ",
1074 " ",
1075 " ",
1076 "**",
1077 "**",
1078 " ",
1079 " " }},
1080 { ';', { " ",
1081 " ",
1082 " ",
1083 " **",
1084 " **",
1085 " ",
1086 " ",
1087 " **",
1088 " **",
1089 "* ",
1090 " " }},
1091 { '<', { " *",
1092 " * ",
1093 " * ",
1094 " * ",
1095 "* ",
1096 " * ",
1097 " * ",
1098 " * ",
1099 " *",
1100 " ",
1101 " " }},
1102 { '=', { " ",
1103 " ",
1104 " ",
1105 "*****",
1106 " ",
1107 "*****",
1108 " ",
1109 " ",
1110 " ",
1111 " ",
1112 " " }},
1113 { '>', { "* ",
1114 " * ",
1115 " * ",
1116 " * ",
1117 " *",
1118 " * ",
1119 " * ",
1120 " * ",
1121 "* ",
1122 " ",
1123 " " }},
1124 { '?', { " *** ",
1125 "* *",
1126 " *",
1127 " *",
1128 " * ",
1129 " * ",
1130 " * ",
1131 " ",
1132 " * ",
1133 " ",
1134 " " }},
1135 { '@', { " **** ",
1136 "* *",
1137 "* *",
1138 "* ***",
1139 "* * *",
1140 "* * **",
1141 "* * *",
1142 "* ",
1143 " **** ",
1144 " ",
1145 " " }},
1146 { '[', { "***",
1147 "* ",
1148 "* ",
1149 "* ",
1150 "* ",
1151 "* ",
1152 "* ",
1153 "* ",
1154 "***",
1155 " ",
1156 " " }},
1157 { '\\',{ "* ",
1158 "* ",
1159 " * ",
1160 " * ",
1161 " * ",
1162 " * ",
1163 " * ",
1164 " *",
1165 " *",
1166 " ",
1167 " " }},
1168 { ']', { "***",
1169 " *",
1170 " *",
1171 " *",
1172 " *",
1173 " *",
1174 " *",
1175 " *",
1176 "***",
1177 " ",
1178 " " }},
1179 { '^', { " * ",
1180 " * * ",
1181 "* *",
1182 " ",
1183 " ",
1184 " ",
1185 " ",
1186 " ",
1187 " ",
1188 " ",
1189 " " }},
1190 { '_', { " ",
1191 " ",
1192 " ",
1193 " ",
1194 " ",
1195 " ",
1196 " ",
1197 " ",
1198 "*****",
1199 " ",
1200 " " }},
1201 { '`', { "*** ",
1202 " ** ",
1203 " *",
1204 " ",
1205 " ",
1206 " ",
1207 " ",
1208 " ",
1209 " ",
1210 " ",
1211 " " }},
1212 { '{', { " *",
1213 " * ",
1214 " * ",
1215 " * ",
1216 "* ",
1217 " * ",
1218 " * ",
1219 " * ",
1220 " *",
1221 " ",
1222 " " }},
1223 { '|', { "*",
1224 "*",
1225 "*",
1226 "*",
1227 "*",
1228 "*",
1229 "*",
1230 "*",
1231 "*",
1232 " ",
1233 " " }},
1234 { '}', { "* ",
1235 " * ",
1236 " * ",
1237 " * ",
1238 " *",
1239 " * ",
1240 " * ",
1241 " * ",
1242 "* ",
1243 " ",
1244 " " }},
1245 { '~', { " * ",
1246 "* * *",
1247 " * ",
1248 " ",
1249 " ",
1250 " ",
1251 " ",
1252 " ",
1253 " ",
1254 " ",
1255 " " }},
1260 /** This class defines a video input device that
1261 generates fictitous image data.
1263 class PVideoInputDevice_FakeVideo : public PVideoInputDevice
1265 PCLASSINFO(PVideoInputDevice_FakeVideo, PVideoInputDevice);
1266 public:
1267 /** Create a new (fake) video input device.
1269 PVideoInputDevice_FakeVideo();
1272 /**Open the device given the device name.
1274 BOOL Open(
1275 const PString & deviceName, /// Device name to open
1276 BOOL startImmediate = TRUE /// Immediately start device
1279 /**Determine of the device is currently open.
1281 BOOL IsOpen() ;
1283 /**Close the device.
1285 BOOL Close();
1287 /**Start the video device I/O.
1289 BOOL Start();
1291 /**Stop the video device I/O capture.
1293 BOOL Stop();
1295 /**Determine if the video device I/O capture is in progress.
1297 BOOL IsCapturing();
1299 /**Get a list of all of the drivers available.
1301 static PStringList GetInputDeviceNames();
1303 virtual PStringList GetDeviceNames() const
1304 { return GetInputDeviceNames(); }
1306 /**Get the maximum frame size in bytes.
1308 Note a particular device may be able to provide variable length
1309 frames (eg motion JPEG) so will be the maximum size of all frames.
1311 virtual PINDEX GetMaxFrameBytes();
1313 BOOL GetFrame(PBYTEArray & frame);
1316 /**Grab a frame.
1318 There will be a delay in returning, as specified by frame rate.
1320 virtual BOOL GetFrameData(
1321 BYTE * buffer, /// Buffer to receive frame
1322 PINDEX * bytesReturned = NULL /// Optional bytes returned.
1325 /**Grab a frame.
1327 Do not delay according to the current frame rate.
1329 virtual BOOL GetFrameDataNoDelay(
1330 BYTE * buffer, /// Buffer to receive frame
1331 PINDEX * bytesReturned = NULL /// OPtional bytes returned.
1335 /**A test image that contains area of low and high resolution.
1336 The picture changes every second*/
1337 void GrabMovingBlocksTestFrame(BYTE *resFrame);
1339 /**a test image consisting of a horizontal line moving down the image,
1340 with a constantly varying background. */
1341 void GrabMovingLineTestFrame(BYTE *resFrame);
1343 /**Generate a constant image, which contains the colours for
1344 a NTSC test frame.*/
1345 void GrabNTSCTestFrame(BYTE *resFrame);
1347 /**Generate three bouncing boxes, which bounce from a different height
1349 void GrabBouncingBoxes(BYTE *resFrame);
1351 /**Generate a static image, containing a constant field of grey.
1353 void GrabBlankImage(BYTE *resFrame);
1355 /**Generate the original form of the moving blocks test frame.
1357 void GrabOriginalMovingBlocksFrame(BYTE *resFrame);
1359 /**Generate a textual output on the fake video image
1361 void GrabTextVideoFrame(BYTE *resFrame);
1363 /**Get the stucture holding required letter for GetTextVideoFrame()
1365 OneVFakeLetterData *FindLetter(char ascii);
1367 /** Fills a region of the image with a constant colour.
1369 void FillRect(BYTE * frame, unsigned width, unsigned height,
1370 int x, int y,
1371 int rectWidth, int rectHeight,
1372 int r, int g, int b);
1374 /** Given a preset interval of n milliseconds, this function
1375 returns n msecs after the previous frame capture was initiated.
1377 virtual void WaitFinishPreviousFrame();
1379 /**Set the video format to be used.
1381 Default behaviour sets the value of the videoFormat variable and then
1382 returns the IsOpen() status.
1384 virtual BOOL SetVideoFormat(
1385 VideoFormat videoFormat /// New video format
1388 /**Get the number of video channels available on the device.
1390 Default behaviour returns 1.
1392 virtual int GetNumChannels() ;
1394 /**Set the video channel to be used on the device.
1396 Default behaviour sets the value of the channelNumber variable and then
1397 returns the IsOpen() status.
1399 virtual BOOL SetChannel(
1400 int channelNumber /// New channel number for device.
1403 /**Set the colour format to be used.
1405 Default behaviour sets the value of the colourFormat variable and then
1406 returns the IsOpen() status.
1408 virtual BOOL SetColourFormat(
1409 const PString & colourFormat // New colour format for device.
1412 /**Set the video frame rate to be used on the device.
1414 Default behaviour sets the value of the frameRate variable and then
1415 return the IsOpen() status.
1417 virtual BOOL SetFrameRate(
1418 unsigned rate /// Frames per second
1421 /**Get the minimum & maximum size of a frame on the device.
1423 Default behaviour returns the value 1 to UINT_MAX for both and returns
1424 FALSE.
1426 virtual BOOL GetFrameSizeLimits(
1427 unsigned & minWidth, /// Variable to receive minimum width
1428 unsigned & minHeight, /// Variable to receive minimum height
1429 unsigned & maxWidth, /// Variable to receive maximum width
1430 unsigned & maxHeight /// Variable to receive maximum height
1433 /**Set the frame size to be used.
1435 Default behaviour sets the frameWidth and frameHeight variables and
1436 returns the IsOpen() status.
1438 virtual BOOL SetFrameSize(
1439 unsigned width, /// New width of frame
1440 unsigned height /// New height of frame
1443 void ClearMapping() { return ; }
1445 /**Try all known video formats & see which ones are accepted by the video driver
1447 virtual BOOL TestAllFormats()
1448 { return TRUE; }
1450 protected:
1451 PINDEX videoFrameSize;
1452 int grabCount;
1454 PString textLine[MAX_L_HEIGHT];
1457 PCREATE_VIDINPUT_PLUGIN(FakeVideo, PVideoInputDevice_FakeVideo);
1459 ///////////////////////////////////////////////////////////////////////////////
1460 // PVideoInputDevice_FakeVideo
1463 PVideoInputDevice_FakeVideo::PVideoInputDevice_FakeVideo()
1465 grabCount = 0;
1466 SetFrameRate(10);
1467 doVFlip = FALSE;
1472 BOOL PVideoInputDevice_FakeVideo::Open(const PString & /*devName*/, BOOL /*startImmediate*/)
1474 return TRUE;
1478 BOOL PVideoInputDevice_FakeVideo::IsOpen()
1480 return TRUE;
1484 BOOL PVideoInputDevice_FakeVideo::Close()
1486 return TRUE;
1490 BOOL PVideoInputDevice_FakeVideo::Start()
1492 return TRUE;
1496 BOOL PVideoInputDevice_FakeVideo::Stop()
1498 return TRUE;
1502 BOOL PVideoInputDevice_FakeVideo::IsCapturing()
1504 return IsOpen();
1508 PStringList PVideoInputDevice_FakeVideo::GetInputDeviceNames()
1510 PStringList list;
1512 list.AppendString("fake");
1514 return list;
1518 BOOL PVideoInputDevice_FakeVideo::SetVideoFormat(VideoFormat newFormat)
1520 return PVideoDevice::SetVideoFormat(newFormat);
1524 int PVideoInputDevice_FakeVideo::GetNumChannels()
1526 return NUM_PATTERNS;
1530 BOOL PVideoInputDevice_FakeVideo::SetChannel(int newChannel)
1532 return PVideoDevice::SetChannel(newChannel);
1536 BOOL PVideoInputDevice_FakeVideo::SetColourFormat(const PString & newFormat)
1538 return PVideoDevice::SetColourFormat(newFormat);
1542 BOOL PVideoInputDevice_FakeVideo::SetFrameRate(unsigned rate)
1544 if ((rate < 1) || (rate > 50))
1545 PVideoDevice::SetFrameRate(10);
1546 else
1547 PVideoDevice::SetFrameRate(rate);
1549 return TRUE;
1553 BOOL PVideoInputDevice_FakeVideo::GetFrameSizeLimits(unsigned & minWidth,
1554 unsigned & minHeight,
1555 unsigned & maxWidth,
1556 unsigned & maxHeight)
1558 minWidth = 10;
1559 minHeight = 10;
1560 maxWidth = 1000;
1561 maxHeight = 800;
1563 return TRUE;
1567 BOOL PVideoInputDevice_FakeVideo::SetFrameSize(unsigned width, unsigned height)
1569 if (!PVideoDevice::SetFrameSize(width, height))
1570 return FALSE;
1572 videoFrameSize = CalculateFrameBytes(frameWidth, frameHeight, colourFormat);
1574 return TRUE;
1578 PINDEX PVideoInputDevice_FakeVideo::GetMaxFrameBytes()
1580 return videoFrameSize;
1583 void PVideoInputDevice_FakeVideo::WaitFinishPreviousFrame()
1585 frameTimeError += msBetweenFrames;
1587 PTime now;
1588 PTimeInterval delay = now - previousFrameTime;
1589 frameTimeError -= (int)delay.GetMilliSeconds();
1590 previousFrameTime = now;
1592 if (frameTimeError > 0) {
1593 PTRACE(6, "FakeVideo\t Sleep for " << frameTimeError << " milli seconds");
1594 #ifdef P_LINUX
1595 usleep(frameTimeError * 1000);
1596 #else
1597 PThread::Current()->Sleep(frameTimeError);
1598 #endif
1602 BOOL PVideoInputDevice_FakeVideo::GetFrame(PBYTEArray & frame)
1604 PINDEX returned;
1605 if (!GetFrameData(frame.GetPointer(GetMaxFrameBytes()), &returned))
1606 return FALSE;
1608 frame.SetSize(returned);
1609 return TRUE;
1613 BOOL PVideoInputDevice_FakeVideo::GetFrameData(BYTE * buffer, PINDEX * bytesReturned)
1615 WaitFinishPreviousFrame();
1617 GetFrameDataNoDelay(buffer, bytesReturned);
1619 *bytesReturned= videoFrameSize;
1621 return TRUE;
1625 BOOL PVideoInputDevice_FakeVideo::GetFrameDataNoDelay(BYTE *destFrame, PINDEX * /*bytesReturned*/)
1627 grabCount++;
1629 // Make sure are NUM_PATTERNS cases here.
1630 switch(channelNumber){
1631 case 0:
1632 GrabMovingBlocksTestFrame(destFrame);
1633 break;
1634 case 1:
1635 GrabMovingLineTestFrame(destFrame);
1636 break;
1637 case 2:
1638 GrabBouncingBoxes(destFrame);
1639 break;
1640 case 3:
1641 GrabBlankImage(destFrame);
1642 break;
1643 case 4:
1644 GrabOriginalMovingBlocksFrame(destFrame);
1645 break;
1646 case 5:
1647 GrabTextVideoFrame(destFrame);
1648 break;
1649 default:
1650 GrabNTSCTestFrame(destFrame);
1653 return TRUE;
1657 void PVideoInputDevice_FakeVideo::FillRect(BYTE * frame, unsigned width, unsigned height,
1658 int xPos, int initialYPos,
1659 int rectWidth, int rectHeight,
1660 int r, int g, int b)
1662 // PTRACE(0,"x,y is"<<xPos<<" "<<yPos<<" and size is "<<rectWidth<<" "<<rectHeight);
1663 //This routine fills a region of the video image with data. It is used as the central
1664 //point because one only has to add other image formats here.
1665 int yPos;
1666 if ( doVFlip ) {
1667 yPos = height - ( initialYPos + rectHeight );
1668 yPos = ( yPos >> 2 ) * 4;
1670 else
1671 yPos = initialYPos;
1673 int offset = ( yPos * width ) + xPos;
1674 int colourOffset = ( (yPos * width) >> 2) + (xPos >> 1);
1676 int Y = (int)( (0.257 * r) + (0.504 * g) + (0.098 * b) + 16);
1677 int Cb = (int)(-(0.148 * r) - (0.291 * g) + (0.439 * b) + 128);
1678 int Cr = (int)( (0.439 * r) - (0.368 * g) - (0.071 * b) + 128);
1680 unsigned char * Yptr = frame + offset;
1681 unsigned char * CbPtr = frame + (width * height) + colourOffset;
1682 unsigned char * CrPtr = frame + (width * height) + (width * height/4) + colourOffset;
1684 int rr ;
1685 int halfRectWidth = rectWidth >> 1;
1686 int halfWidth = width >> 1;
1688 for (rr = 0; rr < rectHeight;rr+=2) {
1689 memset(Yptr, Y, rectWidth);
1690 Yptr += width;
1691 memset(Yptr, Y, rectWidth);
1692 Yptr += width;
1694 memset(CbPtr, Cb, halfRectWidth);
1695 memset(CrPtr, Cr, halfRectWidth);
1697 CbPtr += halfWidth;
1698 CrPtr += halfWidth;
1702 void PVideoInputDevice_FakeVideo::GrabBouncingBoxes(BYTE *resFrame)
1704 unsigned width = 0;
1705 unsigned height = 0;
1706 GetFrameSize(width, height);
1708 grabCount++;
1710 FillRect(resFrame, width, height,
1711 0, 0, //Position x,y
1712 width, height, //Fill the whole frame with the colour.
1713 200,200,200); //a light grey colour.
1715 double t= (grabCount%50) -25 ;
1716 double h= t*t*height*0.85/625;
1717 int yBox = (int)h;
1718 yBox= (yBox>>1) * 2; //yBox is even.
1720 int boxHeight= (int)(height*0.1);
1721 boxHeight= (boxHeight >>1) * 2;
1722 int boxWidth = (int)(width*0.1);
1723 boxWidth = (boxWidth >>1) * 2;
1725 FillRect(resFrame, width, height,
1726 width >> 2, yBox,
1727 boxWidth, boxHeight,
1728 255, 0, 0); // Red Box.
1730 t= (grabCount%40) -20 ;
1731 h= t*t*height*0.85/400 ;
1732 yBox = (int)h;
1733 yBox= (yBox>>1) * 2; //yBox is even.
1735 FillRect(resFrame, width, height,
1736 width>>1,yBox,
1737 boxWidth,boxHeight,
1738 0, 255, 0); // Green
1740 t= (grabCount%100) -50 ;
1741 h= t*t*height*0.85/2500;
1742 yBox = (int)h;
1743 yBox= (yBox>>1) * 2; //yBox is even.
1745 FillRect(resFrame, width, height,
1746 (width>>1) + (width>>2),yBox,
1747 boxWidth,boxHeight,
1748 0, 0, 255); // Blue
1753 void PVideoInputDevice_FakeVideo::GrabNTSCTestFrame(BYTE *resFrame)
1755 // Test image # 1
1756 // A static image is generated, consisting of a series of coloured block.
1757 // Sample NTSC test frame is found at http://www.displaymate.com/patterns.html
1759 static int row1[7][3] = {
1760 { 204, 204, 204 }, // 80% grey
1761 { 255, 255, 0 }, // yellow
1762 { 0, 255, 255 }, // cyan
1763 { 0, 255, 0 }, // green
1764 { 255, 0, 255 }, // magenta
1765 { 255, 0, 0 }, // red
1766 { 0, 0, 255 }, // blue
1769 static int row2[7][3] = {
1770 { 0, 0, 255 }, // blue
1771 { 19, 19, 19 }, // black
1772 { 255, 0, 255 }, // magenta
1773 { 19, 19, 19 }, // black
1774 { 0, 255, 255 }, // cyan
1775 { 19, 19, 19 }, // black
1776 { 204, 204, 204 }, // grey
1779 static int row3a[4][3] = {
1780 { 8, 62, 89 }, // I
1781 { 255, 255, 255 }, // white
1782 { 58, 0, 126 }, // +Q
1783 { 19, 19, 19 }, // black
1786 static int row3b[3][3] = {
1787 { 0, 0, 0 }, // 3.5
1788 { 19, 19, 19 }, // 7.5
1789 { 38, 38, 38 }, // 11.5
1792 static int row3c[3] = { 19, 19, 19 };
1794 unsigned width=0;
1795 unsigned height=0;
1796 GetFrameSize(width,height);
1798 int row1Height = (int)(0.66 * height);
1799 int row2Height = (int)((0.75 * height) - row1Height);
1800 row1Height = (row1Height>>1)*2; //Require that height is even.
1801 row2Height = (row2Height>>1)*2;
1802 int row3Height = height - row1Height - row2Height;
1804 int columns[8];
1805 PINDEX i;
1807 for(i=0;i<7;i++){
1808 columns[i]= i*width/7;
1809 columns[i]= (columns[i]>>1)*2; // require that columns[i] is even.
1811 columns[7] = width;
1814 // first row
1815 for (i = 0; i < 6; i++)
1816 FillRect(resFrame, width, height,
1817 columns[i], 0, //Position x,y
1818 columns[i+1]-columns[i], row1Height, //Size (width*height)
1819 row1[i][0], row1[i][1], row1[i][2]); // rgb
1823 // second row
1824 for (i = 0; i < 7; i++)
1825 FillRect(resFrame, width, height,
1826 columns[i], row1Height,
1827 columns[i+1]-columns[i], row2Height,
1828 row2[i][0], row2[i][1], row2[i][2]);
1830 // third row
1831 int columnBot[5];
1833 for (i=0; i<4; i++) {
1834 columnBot[i]= i*columns[5]/4;
1835 columnBot[i] = 2 * (columnBot[i]>>1);
1837 columnBot[4]= columns[5];
1839 for (i = 0; i < 4; i++)
1840 FillRect(resFrame, width, height,
1841 columnBot[i],row1Height + row2Height,
1842 columnBot[i+1]-columnBot[i], row3Height,
1843 row3a[i][0], row3a[i][1], row3a[i][2]);
1845 for (i=0; i<3; i++) {
1846 columnBot[i] = columns[4]+(i*width)/(7*3);
1847 columnBot[i] = 2 * (columnBot[i]>>1); //Force even.
1849 columnBot[3]= columns[5];
1851 for (i = 0; i < 3; i++)
1852 FillRect(resFrame, width, height,
1853 columnBot[i], row1Height + row2Height,
1854 columnBot[i+1] - columnBot[i], row3Height,
1855 row3b[i][0], row3b[i][1], row3b[i][2]);
1857 FillRect(resFrame, width, height,
1858 columns[6], row1Height + row2Height,
1859 columns[7] - columns[6], row3Height,
1860 row3c[0], row3c[1], row3c[2]);
1866 void PVideoInputDevice_FakeVideo::GrabMovingBlocksTestFrame(BYTE * resFrame)
1868 // Test image # 2
1869 /*Brightness is set to alter, left to right.
1870 Colour component alters top to bottom.
1872 Image contains lots of high and low resolution areas.
1874 unsigned width, height, wi,hi, colourIndex,colNo, boxSize;
1876 #define COL(b,x,y) ((b+x+y)%7)
1878 static int background[7][3] = {
1879 { 254, 254, 254 }, // white
1880 { 255, 255, 0 }, // yellow
1881 { 0, 255, 255 }, // cyan
1882 { 0, 255, 0 }, // green
1883 { 255, 0, 255 }, // magenta
1884 { 255, 0, 0 }, // red
1885 { 0, 0, 255 }, // blue
1888 width = 0; //Stops compiler warning about unitialized variables.
1889 height = 0;
1890 GetFrameSize(width, height);
1892 int columns[9];
1893 int heights[9];
1894 int offset;
1895 offset = (width >> 3) & 0xffe;
1897 for(wi = 0; wi < 8; wi++)
1898 columns[wi] = wi * offset;
1899 columns[8] = width;
1901 offset = (height >> 3) & 0xffe;
1902 for(hi = 0; hi < 9; hi++)
1903 heights[hi] = hi * offset;
1904 heights[8] = height;
1906 grabCount++;
1907 colourIndex = time(NULL);//time in seconds since last epoch.
1908 // Provides a difference if run on two ohphone sessions.
1909 colNo = (colourIndex / 10) % 7; //Every 10 seconds, coloured background blocks move.
1911 for(hi = 0; hi < 8; hi++) //Fill the background in.
1912 for(wi = 0 ; wi < 8; wi++) {
1913 FillRect(resFrame, width, height, //frame details.
1914 columns[wi], heights[hi], //X,Y Pos.
1915 columns[wi + 1] - columns[wi], heights[hi + 1] - heights[hi],
1916 background[COL(colNo, wi, hi)][0], background[COL(colNo, wi, hi)][1], background[COL(colNo, wi, hi)][2]);
1919 //Draw a black box rapidly moving down the left of the window.
1920 boxSize= height / 10;
1921 hi = ((3 * colourIndex) % (height-boxSize)) & 0xffe; //Make certain hi is even.
1922 FillRect(resFrame, width, height, 10, hi, boxSize, boxSize, 0, 0, 0); //Black Box.
1924 //Draw four parallel black lines, which move up the middle of the window.
1925 colourIndex = colourIndex / 3; //Every three seconds, lines move.
1927 for(wi = 0; wi < 2; wi++)
1928 columns[wi]= (((wi + 1) * width) / 3) & 0xffe;// Force columns to be even.
1930 hi = colourIndex % ((height - 16) / 2);
1931 hi = (height - 16) - (hi * 2); //hi is even, Lines move in opp. direction to box.
1933 unsigned yi;
1934 for(yi = 0; yi < 4; yi++)
1935 FillRect(resFrame, width, height,
1936 columns[0], hi+(yi * 4),
1937 columns[1] - columns[0], 2, 0, 0, 0);
1941 void PVideoInputDevice_FakeVideo::GrabMovingLineTestFrame(BYTE *resFrame)
1943 // Test image # 3
1944 // Faster image generation. Same every times system runs.
1945 // Colours cycle through. Have a vertical lines style of pattern.
1946 // There is a horizontal bar which moves down the screen .
1947 unsigned width,height;
1948 static int v=0;
1949 int r,g,b;
1951 width=0; //Stops compiler warning about unitialized variables.
1952 height=0;
1954 GetFrameSize(width,height);
1956 v++;
1957 r = (200+v) & 255;
1958 g = (100+v) & 255;
1959 b = (000+v) & 255;
1961 FillRect(resFrame, width, height, 0, 0,width, height, r, g, b);
1963 int hi = (v % (height-2) >> 1) *2;
1965 FillRect(resFrame, width, height, 0, hi, width, 2, 0, 0, 0);
1968 void PVideoInputDevice_FakeVideo::GrabBlankImage(BYTE *resFrame)
1970 unsigned width=0;
1971 unsigned height=0;
1972 GetFrameSize(width,height);
1974 grabCount++;
1976 FillRect(resFrame, width, height,
1977 0, 0, //Position x,y
1978 width, height, //Fill the whole frame with the colour.
1979 200,200,200); //a light grey colour.
1982 void PVideoInputDevice_FakeVideo::GrabOriginalMovingBlocksFrame(BYTE *frame)
1984 unsigned w=0;
1985 unsigned h=0;
1986 GetFrameSize(w,h);
1987 int width = w;
1988 int height = h;
1990 int wi,hi,colourIndex,colourNumber;
1991 int framesize = width*height;
1993 static int gCount=0;
1994 gCount++;
1996 colourIndex = gCount/10;
1997 colourNumber= (colourIndex/10)%7; //Every 10 seconds, coloured background blocks move.
1999 for(hi=0; hi<height; hi++) //slow moving group of lines going upwards.
2000 for(wi=0; wi<width; wi++)
2001 if ( (wi>width/3)&&(wi<width*2/3)&&
2002 ( ((gCount+hi)%height)<16)&&
2003 ( (hi%4)<2) )
2004 frame[(hi*width)+wi] = 16;
2005 else
2006 frame[(hi*width)+wi] = (BYTE)(((colourNumber+((wi*7)/width))%7)*35+26);
2008 for(hi=1; hi<=height; hi++) //fast moving block going downwards.
2009 for(wi=width/9; wi<(2*width/9); wi++)
2010 if( (( (gCount*4)+hi)%height)<20)
2011 frame[((height-hi)*width)+wi] = 16;
2013 int halfWidth = width/2;
2014 int halfHeight = height/2;
2015 for(hi=1; hi<halfHeight; hi++)
2016 for(wi=0; wi<halfWidth; wi++)
2017 frame[framesize+(hi*halfWidth)+wi] = (BYTE)(((((hi*7)/halfHeight)+colourNumber)%7)*35+26);
2020 void PVideoInputDevice_FakeVideo::GrabTextVideoFrame(BYTE *resFrame)
2022 PINDEX i, j;
2023 unsigned width = 0;
2024 unsigned height = 0;
2025 GetFrameSize(width, height);
2026 static PTime startTime;
2028 grabCount++;
2029 FillRect(resFrame, width, height,
2030 0, 0, //Position x,y
2031 width, height, //Fill the whole frame with the colour.
2032 200, 200, 200); //a light grey colour.
2035 if (textLine[0].GetLength() < 2) {
2036 PStringStream message;
2037 message << PProcess::Current().GetUserName() << " on " <<
2038 PProcess::Current().GetOSName() << ":" <<
2039 PProcess::Current().GetOSHardware();
2040 PINDEX nChars = message.GetLength();
2041 OneVFakeLetterData *ld;
2043 for (j = 0; j < MAX_L_HEIGHT; j++)
2044 textLine[j] = "";
2046 for (i = 0; i < (nChars + 2); i++){
2047 if (i >= nChars)
2048 ld = FindLetter(' ');
2049 else
2050 ld = FindLetter(message[i]);
2051 if (ld == NULL)
2052 continue;
2053 for (j = 0; j < MAX_L_HEIGHT; j++)
2054 textLine[j] += ld->line[j] + PString(" ");
2058 PINDEX boxSize = (height / (MAX_L_HEIGHT * 2) ) & 0xffe;
2059 int index = (int)((PTime() - startTime).GetMilliSeconds() / 300);
2061 PINDEX maxI = (width / boxSize) - 2;
2062 for (i = 0; i < maxI; i++)
2063 for (j = 0; j < MAX_L_HEIGHT; j++) {
2064 PINDEX ii = (index + i) % textLine[0].GetLength();
2065 if (textLine[j][ii] != ' ')
2066 FillRect(resFrame, width, height,
2067 (i + 1) * boxSize, (height / 3) + ((j + 1) * boxSize), //x,y start pos
2068 boxSize, boxSize, //x,y dimension
2069 250, 00, 00); //red box.
2073 OneVFakeLetterData *PVideoInputDevice_FakeVideo::FindLetter(char ascii)
2075 int q;
2076 int fontNumLetters = sizeof(vFakeLetterData) / sizeof(OneVFakeLetterData);
2077 if (ascii == '\t')
2078 ascii = ' ';
2079 for (q = 0; q < fontNumLetters; q++)
2080 if (vFakeLetterData[q].ascii == ascii)
2081 return vFakeLetterData + q;
2083 return NULL;
2087 /////////////////////////////////////////////////////////////////////////////////////////////////////////
2090 /**This class defines a NULL video output device.
2091 This will do precisely nothing with the output.
2093 class PVideoOutputDevice_NULLOutput : public PVideoOutputDevice
2095 PCLASSINFO(PVideoOutputDevice_NULLOutput, PVideoOutputDevice);
2097 public:
2098 /** Create a new video output device.
2100 PVideoOutputDevice_NULLOutput();
2102 /**Get a list of all of the drivers available.
2104 static PStringList GetOutputDeviceNames();
2106 virtual PStringList GetDeviceNames() const
2107 { return GetOutputDeviceNames(); }
2109 /**Open the device given the device name.
2111 virtual BOOL Open(
2112 const PString & deviceName, /// Device name to open
2113 BOOL startImmediate = TRUE /// Immediately start device
2116 /**Start the video device I/O.
2118 BOOL Start();
2120 /**Stop the video device I/O capture.
2122 BOOL Stop();
2124 /**Close the device.
2126 virtual BOOL Close();
2128 /**Determine if the device is currently open.
2130 virtual BOOL IsOpen();
2132 /**Get the maximum frame size in bytes.
2134 Note a particular device may be able to provide variable length
2135 frames (eg motion JPEG) so will be the maximum size of all frames.
2137 virtual PINDEX GetMaxFrameBytes();
2139 /**Set a section of the output frame buffer.
2141 virtual BOOL SetFrameData(
2142 unsigned x,
2143 unsigned y,
2144 unsigned width,
2145 unsigned height,
2146 const BYTE * data,
2147 BOOL endFrame = TRUE
2150 /**Indicate frame may be displayed.
2152 virtual BOOL EndFrame();
2155 PCREATE_VIDOUTPUT_PLUGIN(NULLOutput, PVideoOutputDevice_NULLOutput);
2157 ///////////////////////////////////////////////////////////////////////////////
2158 // PVideoOutputDevice_NULLOutput
2160 PVideoOutputDevice_NULLOutput::PVideoOutputDevice_NULLOutput()
2162 deviceName = "NULL";
2166 BOOL PVideoOutputDevice_NULLOutput::Open(const PString & /*deviceName*/,
2167 BOOL /*startImmediate*/)
2169 return TRUE;
2172 BOOL PVideoOutputDevice_NULLOutput::Close()
2174 return TRUE;
2177 BOOL PVideoOutputDevice_NULLOutput::Start()
2179 return TRUE;
2182 BOOL PVideoOutputDevice_NULLOutput::Stop()
2184 return TRUE;
2187 BOOL PVideoOutputDevice_NULLOutput::IsOpen()
2189 return TRUE;
2193 PStringList PVideoOutputDevice_NULLOutput::GetOutputDeviceNames()
2195 PStringList list;
2196 list += "NULL";
2197 return list;
2201 PINDEX PVideoOutputDevice_NULLOutput::GetMaxFrameBytes()
2203 return CalculateFrameBytes(frameWidth, frameHeight, colourFormat);
2207 BOOL PVideoOutputDevice_NULLOutput::SetFrameData(unsigned /*x*/, unsigned /*y*/,
2208 unsigned /*width*/, unsigned /*height*/,
2209 const BYTE * /*data*/,
2210 BOOL /*endFrame*/)
2212 return TRUE;
2216 BOOL PVideoOutputDevice_NULLOutput::EndFrame()
2218 return TRUE;
2222 // End Of File ///////////////////////////////////////////////////////////////