~ubuntu-branches/ubuntu/raring/gst-plugins-good0.10/raring-proposed

« back to all changes in this revision

Viewing changes to sys/shm/shmpipe.h

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-02-09 16:44:53 UTC
  • mfrom: (40.2.38 experimental)
  • Revision ID: package-import@ubuntu.com-20120209164453-6hjokwrvdn42zopb
Tags: 0.10.30.3-1ubuntu1
* Merge from Debian experimental, remaining changes:
  - 04_move_farsight_plugins_to_good.patch
    Import autoconvert, dtmf, liveadder, rptmux from -plugins-bad
  - 05_move_shm_to_good.patch
    Import shm from -plugins-bad.
  - 07_move-camerabin.patch
    Import camerabin, camerabin2, jpegformat and basecamerabinsrc
    from -plugins-bad.
  - control*:
    * Drop dependency from gstreamer0.10-plugins-good on
      gstreamer0.10-gconf. It pulls gconf and gtk3 onto the Kubuntu cd.
    * Use Breaks instead of Conflicts.
    * Add a 'Pre-Depends: ${misc:Pre-Depends}' to the plugin package,
      since we're shipping shared libraries in the package that Debian
      isn't.
* Update the patches by pulling new version of the code from
  -plugins-bad 0.10.22.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 */
24
24
 
25
25
/*
26
 
 * None of this code is thread safe, if you want to use it in a multi-threaded
27
 
 * context, please protect it with a mutex.
28
 
 *
29
 
 * First, create a writer with sp_writer_create()
30
 
 * And selectes() on the socket from sp_get_fd()
31
 
 * If the socket is closed or there are errors from any function, the app
32
 
 * should call sp_close() and assume the writer is dead
33
 
 * The server calls sp_writer_accept_client() when there is something to read
34
 
 * from the server fd
35
 
 * It then needs to select() on the socket from sp_writer_get_client_fd()
36
 
 * If it gets an error on that socket, it call sp_writer_close_client().
37
 
 * If there is something to read, it calls sp_writer_recv().
38
 
 *
39
 
 * The writer allocates buffers with sp_writer_alloc_block(),
40
 
 * writes something in the buffer (retrieved with sp_writer_block_get_buf(),
41
 
 * then calls  sp_writer_send_buf() to send the buffer or a subsection to
42
 
 * the other side. When it is done with the block, it calls
43
 
 * sp_writer_free_block().
44
 
 * If alloc fails, then the server must wait for events from the clients before
45
 
 * trying again.
46
 
 *
47
 
 *
48
 
 * The clients connect with sp_client_open()
49
 
 * And select() on the fd from sp_get_fd() until there is something to read.
50
 
 * Then they must read using sp_client_recv() which will return > 0 if there
51
 
 * is a valid buffer (which is read only). It will return 0 if it is an internal
52
 
 * message and <0 if there was an error. If there was an error, one must close
53
 
 * it with sp_close(). If was valid buffer was received, the client must release
54
 
 * it with sp_client_recv_finish() when it is done reading from it.
 
26
 * None of this code is thread safe, if you want to use it in a
 
27
 * multi-threaded context, please protect it with a mutex.
 
28
 *
 
29
 * First, create a writer with sp_writer_create(), then select() on
 
30
 * the socket returned by sp_get_fd(). If the socket is closed or any
 
31
 * function returns an error, the app should call sp_close() and
 
32
 * assume the other side is dead. The writer calls
 
33
 * sp_writer_accept_client() when there is something to read from the
 
34
 * main server fd. This returns a new ShmClient (representing a client
 
35
 * connection), the writer needs to do a select() on the socket
 
36
 * returned by sp_writer_get_client_fd(). If it gets an error on that
 
37
 * socket, it calls sp_writer_close_client(). If there is something to
 
38
 * read, it calls sp_writer_recv().
 
39
 *
 
40
 * The writer allocates a block containing a free buffer with
 
41
 * sp_writer_alloc_block(), then writes something in the buffer
 
42
 * (retrieved with sp_writer_block_get_buf(), then calls
 
43
 * sp_writer_send_buf() to send the buffer or a subsection to the
 
44
 * other side. When it is done with the block, it calls
 
45
 * sp_writer_free_block().  If alloc fails, then the server must wait
 
46
 * for events on the client fd (the ones where sp_writer_recv() is
 
47
 * called), and then try to re-alloc.
 
48
 *
 
49
 * The reader (client) connect to the writer with sp_client_open() And
 
50
 * select()s on the fd from sp_get_fd() until there is something to
 
51
 * read.  Then they must read using sp_client_recv() which will return
 
52
 * the size of the buffer (positive) if there is a valid buffer (which
 
53
 * is read only).  It will return 0 if it is an internal message and a
 
54
 * negative number if there was an error.  If there was an error, the
 
55
 * application must close the pipe with sp_close() and assume that all
 
56
 * buffers are no longer valid. If was valid buffer was received, the
 
57
 * client must release it with sp_client_recv_finish() when it is done
 
58
 * reading from it.
55
59
 */
56
60
 
57
61
 
59
63
#define __SHMPIPE_H__
60
64
 
61
65
#include <stdlib.h>
 
66
#include <stdint.h>
62
67
#include <sys/types.h>
63
68
#include <sys/stat.h>
64
69
#include <fcntl.h>
71
76
typedef struct _ShmClient ShmClient;
72
77
typedef struct _ShmPipe ShmPipe;
73
78
typedef struct _ShmBlock ShmBlock;
 
79
typedef struct _ShmBuffer ShmBuffer;
74
80
 
75
81
ShmPipe *sp_writer_create (const char *path, size_t size, mode_t perms);
76
82
const char *sp_writer_get_path (ShmPipe *pipe);
86
92
 
87
93
ShmBlock *sp_writer_alloc_block (ShmPipe * self, size_t size);
88
94
void sp_writer_free_block (ShmBlock *block);
89
 
int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size);
 
95
int sp_writer_send_buf (ShmPipe * self, char *buf, size_t size, uint64_t tag);
90
96
char *sp_writer_block_get_buf (ShmBlock *block);
91
97
ShmPipe *sp_writer_block_get_pipe (ShmBlock *block);
92
98
 
100
106
long int sp_client_recv (ShmPipe * self, char **buf);
101
107
int sp_client_recv_finish (ShmPipe * self, char *buf);
102
108
 
 
109
ShmBuffer *sp_writer_get_pending_buffers (ShmPipe * self);
 
110
ShmBuffer *sp_writer_get_next_buffer (ShmBuffer * buffer);
 
111
uint64_t sp_writer_buf_get_tag (ShmBuffer * buffer);
 
112
 
103
113
#ifdef __cplusplus
104
114
}
105
115
#endif