2 * camtransport.h - GStreamer CAM (EN50221) transport layer
3 * Copyright (C) 2007 Alessandro Decina
6 * Alessandro Decina <alessandro@nnva.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #ifndef CAM_TRANSPORT_H
25 #define CAM_TRANSPORT_H
31 #define HOST_BUFFER_SIZE 1024
33 #define CAM_TL(obj) ((CamTL *) obj)
34 #define CAM_TL_CONNECTION(obj) ((CamTLConnection *) obj)
36 typedef struct _CamTL CamTL;
37 typedef struct _CamTLPrivate CamTLPrivate;
39 typedef struct _CamTLConnection CamTLConnection;
40 typedef struct _CamTLConnectionPrivate CamTLConnectionPrivate;
44 CAM_TL_CONNECTION_STATE_CLOSED,
45 CAM_TL_CONNECTION_STATE_IN_CREATION,
46 CAM_TL_CONNECTION_STATE_OPEN,
47 CAM_TL_CONNECTION_STATE_IN_DELETION
48 } CamTLConnectionState;
55 GHashTable *connections;
59 /* buffer containing module data */
60 guint8 buffer [HOST_BUFFER_SIZE];
61 /* number of bytes written in the buffer */
63 /* index pointing to the first byte of a TPDU's body */
65 /* length of the body part */
69 void (*request_connection) (CamTL *tl, CamTLConnection *connection);
70 void (*connection_created) (CamTL *tl, CamTLConnection *connection);
71 void (*connection_deleted) (CamTL *tl, CamTLConnection *connection);
72 CamReturn (*connection_data) (CamTL *tl, CamTLConnection *connection,
73 guint8 *data, guint length);
75 /* used by the upper layer to extend this layer */
79 struct _CamTLConnection
85 CamTLConnectionState state;
86 /* TRUE if the last status byte was 0x80, FALSE otherwise */
88 /* NCAS 1.0 sometimes reports that it has data even if it doesn't. After
89 * MAX_EMPTY_DATA times that we don't get any data we assume that there's
93 /* timer restarted every time the connection is polled */
99 CamTL *cam_tl_new (int cam_device_fd);
100 void cam_tl_destroy (CamTL *tl);
102 CamReturn cam_tl_create_connection (CamTL *tl,
103 guint8 slot, CamTLConnection **connnection);
104 CamReturn cam_tl_connection_delete (CamTLConnection *connection);
106 void cam_tl_calc_buffer_size (CamTL *tl,
107 guint body_length, guint *buffer_size, guint *offset);
109 CamReturn cam_tl_connection_write (CamTLConnection *connection,
110 guint8 *data, guint buffer_size, guint body_length);
112 CamReturn cam_tl_connection_poll (CamTLConnection *connection, gboolean force);
113 CamReturn cam_tl_read_all (CamTL *tl, gboolean poll);
115 #endif /* CAM_TRANSPORT_H */