• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * camsession.h - GStreamer CAM (EN50221) Session Layer
3  * Copyright (C) 2007 Alessandro Decina
4  *
5  * Authors:
6  *   Alessandro Decina <alessandro.d@gmail.com>
7  *
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.
12  *
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.
17  *
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., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef CAM_SESSION_H
25 #define CAM_SESSION_H
26 
27 #include "cam.h"
28 #include "camtransport.h"
29 
30 #define CAM_SL(obj) ((CamSL *) obj)
31 #define CAM_SL_SESSION(obj) ((CamSLSession *) obj)
32 
33 typedef struct _CamSL CamSL;
34 typedef struct _CamSLSession CamSLSession;
35 
36 typedef enum
37 {
38   CAM_SL_SESSION_STATE_IDLE,
39   CAM_SL_SESSION_STATE_OPENING,
40   CAM_SL_SESSION_STATE_ACTIVE,
41   CAM_SL_SESSION_STATE_CLOSING
42 } CamSLSessionState;
43 
44 typedef enum
45 {
46   CAM_SL_RESOURCE_STATUS_OPEN = 0x00,
47   CAM_SL_RESOURCE_STATUS_NOT_FOUND = 0xF0,
48   CAM_SL_RESOURCE_STATUS_UNAVAILABLE = 0xF1,
49   CAM_SL_RESOURCE_STATUS_INVALID_VERSION = 0xF2,
50   CAM_SL_RESOURCE_STATUS_BUSY = 0xF3
51 } CamSLResourceStatus;
52 
53 struct _CamSL
54 {
55   CamTL *tl;
56 
57   GHashTable *sessions;
58   guint session_ids;
59 
60   /* callbacks */
61   CamReturn (*open_session_request) (CamSL *sl, CamSLSession *session,
62     CamSLResourceStatus *status);
63   CamReturn (*session_opened) (CamSL *sl, CamSLSession *session);
64   CamReturn (*session_closed) (CamSL *sl, CamSLSession *session);
65   CamReturn (*session_data) (CamSL *sl, CamSLSession *session,
66     guint8 *data, guint length);
67 
68   gpointer user_data;
69 };
70 
71 struct _CamSLSession
72 {
73   CamSL *sl;
74   CamTLConnection *connection;
75 
76   guint resource_id;
77   guint16 session_nb;
78 
79   CamSLSessionState state;
80 
81   gpointer user_data;
82 };
83 
84 CamSL *cam_sl_new (CamTL *transport);
85 void cam_sl_destroy (CamSL *sl);
86 
87 CamReturn cam_sl_create_session (CamSL *sl, CamTLConnection *connection,
88   guint resource_id, CamSLSession **session);
89 CamReturn cam_sl_session_close (CamSLSession *session);
90 
91 void cam_sl_calc_buffer_size (CamSL *sl,
92   guint body_length, guint *buffer_size, guint *offset);
93 CamReturn cam_sl_session_write (CamSLSession *session,
94   guint8 *buffe, guint buffer_size, guint body_length);
95 
96 #endif /* CAM_SESSION_H */
97