OSDN Git Service

make it possible to dynamically create and close multiple libhb instances
[handbrake-jp/handbrake-jp-git.git] / libhb / ports.h
1 /* $Id: ports.h,v 1.7 2005/10/15 18:05:03 titer Exp $
2
3    This file is part of the HandBrake source code.
4    Homepage: <http://handbrake.fr/>.
5    It may be used under the terms of the GNU General Public License. */
6
7 #ifndef HB_PORTS_H
8 #define HB_PORTS_H
9
10 #if defined(_WIN32)
11 #define DIR_SEP_STR "\\"
12 #else
13 #define DIR_SEP_STR "/"
14 #endif
15
16 /************************************************************************
17  * Utils
18  ***********************************************************************/
19 uint64_t hb_get_date();
20 void     hb_snooze( int delay );
21 int      hb_get_cpu_count();
22
23 #ifdef __LIBHB__
24
25 /* Everything from now is only used internally and hidden to the UI */
26
27 /************************************************************************
28  * DVD utils
29  ***********************************************************************/
30 int hb_dvd_region(char *device, int *region_mask);
31
32 /************************************************************************
33  * File utils
34  ***********************************************************************/
35 void hb_get_temporary_directory( char path[512] );
36 void hb_get_tempory_filename( hb_handle_t *, char name[1024],
37                               char * fmt, ... );
38 void hb_mkdir( char * name );
39
40 /************************************************************************
41  * Threads
42  ***********************************************************************/
43 typedef struct hb_thread_s hb_thread_t;
44
45 #if defined( SYS_BEOS )
46 #  define HB_LOW_PRIORITY    5
47 #  define HB_NORMAL_PRIORITY 10
48 #elif defined( SYS_DARWIN )
49 #  define HB_LOW_PRIORITY    0
50 #  define HB_NORMAL_PRIORITY 31
51 #elif defined( SYS_LINUX ) || defined( SYS_FREEBSD ) || defined ( SYS_SunOS )
52 #  define HB_LOW_PRIORITY    0
53 #  define HB_NORMAL_PRIORITY 0
54 #elif defined( SYS_CYGWIN )
55 #  define HB_LOW_PRIORITY    0
56 #  define HB_NORMAL_PRIORITY 1
57 #elif defined( SYS_MINGW )
58 #  define HB_LOW_PRIORITY    0
59 #  define HB_NORMAL_PRIORITY 0
60 #endif
61
62 hb_thread_t * hb_thread_init( char * name, void (* function)(void *),
63                               void * arg, int priority );
64 void          hb_thread_close( hb_thread_t ** );
65 int           hb_thread_has_exited( hb_thread_t * );
66
67 /************************************************************************
68  * Mutexes
69  ***********************************************************************/
70
71 hb_lock_t * hb_lock_init();
72 void        hb_lock_close( hb_lock_t ** );
73 void        hb_lock( hb_lock_t * );
74 void        hb_unlock( hb_lock_t * );
75
76 /************************************************************************
77  * Condition variables
78  ***********************************************************************/
79 typedef struct hb_cond_s hb_cond_t;
80
81 hb_cond_t * hb_cond_init();
82 void        hb_cond_wait( hb_cond_t *, hb_lock_t * );
83 void        hb_cond_timedwait( hb_cond_t * c, hb_lock_t * lock, int msec );
84 void        hb_cond_signal( hb_cond_t * );
85 void        hb_cond_broadcast( hb_cond_t * c );
86 void        hb_cond_close( hb_cond_t ** );
87
88 /************************************************************************
89  * Network
90  ***********************************************************************/
91 typedef struct hb_net_s hb_net_t;
92
93 hb_net_t * hb_net_open( char * address, int port );
94 int        hb_net_send( hb_net_t *, char * );
95 int        hb_net_recv( hb_net_t *, char *, int );
96 void       hb_net_close( hb_net_t ** );
97
98 #endif /* __LIBHB__ */
99
100 #endif
101