add haupauge-1657 dual usb capture support, add deinterlace to recordmonitor, asset...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / forkbase.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef __FORKBASE_H__
23 #define __FORKBASE_H__
24
25 #include "forkbase.inc"
26 #include "mutex.h"
27 #include "thread.h"
28
29 // Utility functions for all the forking classes
30
31 #include <stdint.h>
32
33 class ForkBase : public Mutex
34 {
35 public:
36         enum { EXIT_CODE=0x7fff };
37         typedef struct { int64_t token; int bytes; } token_bfr_t;
38
39         ForkBase();
40         virtual ~ForkBase();
41
42         virtual int is_running() = 0;
43         void send_bfr(int fd, const void *bfr, int len);
44         int read_timeout(int64_t usec, int fd, void *data, int bytes);
45
46         int read_parent(int64_t usec);
47         int send_parent(int64_t value, const void *data, int bytes);
48         int read_child(int64_t usec);
49         int send_child(int64_t value, const void *data, int bytes);
50
51         int parent_done;
52         int ppid, pid;
53         ForkChild *child;
54
55         int child_fd;
56         int64_t child_token;
57         int child_bytes;
58         int child_allocated;
59         uint8_t *child_data;
60
61         int parent_fd;
62         int64_t parent_token;
63         int parent_bytes;
64         int parent_allocated;
65         uint8_t *parent_data;
66 };
67
68 class ForkChild : public ForkBase
69 {
70 public:
71         ForkChild();
72         virtual ~ForkChild();
73         virtual int child_iteration(int64_t usec) = 0;
74         int is_running();
75         virtual void run() {}
76 };
77
78 class ForkParent : public Thread, public ForkBase
79 {
80 public:
81         ForkParent();
82         virtual ~ForkParent();
83         virtual int handle_parent();
84         virtual ForkChild *new_fork() = 0;
85         int is_running();
86
87         void start_child();
88         void start();
89         void stop();
90         void run();
91         int parent_iteration();
92 };
93
94 #endif