]> git.mxchange.org Git - flightgear.git/blob - 3rdparty/iaxclient/lib/video_portvideo.cpp
VS2015 compatability fixes.
[flightgear.git] / 3rdparty / iaxclient / lib / video_portvideo.cpp
1 /*
2  * iaxclient: a cross-platform IAX softphone library
3  *
4  * Copyrights:
5  * Copyright (C) 2003 HorizonLive.com, (c) 2004, Horizon Wimba, Inc.
6  *
7  * Contributors:
8  * Steve Kann <stevek@stevek.com>
9  *
10  * This program is free software, distributed under the terms of
11  * the GNU Lesser (Library) General Public License
12  *
13  * Module: video_portvideo
14  * Purpose: Video code to provide portvideo driver support for IAX library
15  * Developed by: Steve Kann
16  * Creation Date: April 7, 2005
17  *
18  *
19  */
20
21 #include "iaxclient_lib.h"
22 #include "PortVideoSDL/common/cameraEngine.h"
23 #include "PortVideoSDL/common/cameraTool.h"
24
25 static cameraEngine *engine;
26 int running;
27
28
29 int pv_start (struct iaxc_video_driver *d ) {
30     if(!running) {  
31        if(!engine->startCamera()) {
32           fprintf(stderr, "pv: couldn't start camera\n");
33           return -1;
34        }
35        running = 1;
36     }
37    return 0;
38 }
39
40 int pv_stop (struct iaxc_video_driver *d ) {
41     return 0;
42 }
43
44 void pv_shutdown() {
45 }
46
47 int pv_input(struct iaxc_video_driver *d, unsigned char **in) {
48     unsigned char *data = NULL;
49     data = engine->getFrame();
50     if(!data) {
51         if(!engine->stillRunning()) {
52             fprintf(stderr, "camera disconnected\n");
53             running = 0;
54         }
55         fprintf(stderr, "pv_input: no frame\n");
56         return 0;
57     }
58     *in = data;
59     return 0;
60 }
61
62 int pv_output(struct iaxc_video_driver *d, unsigned char *data) {
63         return 0;
64 }
65
66 int pv_select_devices (struct iaxc_video_driver *d, int input, int output) {
67     return 0;
68 }
69
70 int pv_selected_devices (struct iaxc_video_driver *d, int *input, int *output) {
71     return 0;
72 }
73
74 int pv_destroy (struct iaxc_video_driver *d ) {
75     //implementme
76     return 0;
77 }
78
79
80
81 /* initialize video driver */
82 int pv_initialize (struct iaxc_video_driver *d, int w, int h, int framerate) {
83     /* setup methods */
84     d->initialize = pv_initialize;
85     d->destroy = pv_destroy;
86     d->select_devices = pv_select_devices;
87     d->selected_devices = pv_selected_devices;
88     d->start = pv_start;
89     d->stop = pv_stop;
90     d->output = pv_output;
91     d->input = pv_input;
92
93     engine = cameraTool::findCamera();
94     if(!engine) {
95         fprintf(stderr, "video_portvideo: can't find camera\n");
96         return -1;
97     }
98
99     if(!engine->initCamera(w,h,true)) {
100         fprintf(stderr, "can't initialize camera");
101         return -1;
102     }
103         
104
105     return 0;
106 }