include
ClpeStream.h
Go to the documentation of this file.
1
#ifndef ClpeStream_header
2
#define ClpeStream_header
3
4
#include <stdio.h>
5
#include <string.h>
6
#include <unistd.h>
7
#include <fcntl.h>
8
#include <stdlib.h>
9
#include <errno.h>
10
#include <time.h>
11
#include <sys/time.h>
12
#include <sys/types.h>
13
#include <sys/socket.h>
14
#include <netinet/in.h>
15
#include <netinet/ip.h>
/* superset of previous */
16
#include <arpa/inet.h>
17
#include <pthread.h>
18
19
#include <gst/gst.h>
20
#include <gst/app/gstappsrc.h>
21
#include <gst/app/gstappsink.h>
22
#include "
ClpeStreamApi.h
"
23
24
#define START_PORT 50000
25
#define END_PORT 50003
26
#define MAX_PORT (END_PORT - START_PORT + 1)
27
//#define AVAILALE_PORT (MAX_PORT * 2) // master & slave
28
#define AVAILALE_PORT (MAX_PORT) // master & slave
29
#define PORT_NUM(_idx) (START_PORT + (_idx))
30
31
#define DEST_IP_FROM "192.168.7.8"
32
33
#define FORM_LTM "%02d/%02d %02d:%02d:%02d.%06ld "
34
#define ARGS_LTM(_ltm, _tv) (_ltm).tm_mon+1, (_ltm).tm_mday, (_ltm).tm_hour, (_ltm).tm_min, (_ltm).tm_sec, (_tv).tv_usec
35
36
#define IMG_WIDTH_IMX390 1920//2048
37
#define IMG_HEIGHT_IMX390 1080//1280
38
#define IMG_WIDTH_IMX490 2880
39
#define IMG_HEIGHT_IMX490 1860
40
41
/* ---------------------------------------------------------------------------- */
42
/* ---------------------------------------------------------------------------- */
43
// Send UDP
44
#define UDP_GST_MAX_BUFFER_SIZE 1073741823
45
46
#define UDP_FRAME_SIZE 4147200 // 1920 * 1080 * 2 //5242880 // 2048*1280*2
47
#define UDP_BLOCK_SIZE 64000
48
#define UDP_MAX_BLOCK_NUM 64 // 65 - 1(Last) 81 // 82 - 1(Last)
49
// #define UDP_LAST_BLOCK_SIZE 58880
50
//#define UDP_LAST_BLOCK_SIZE (5242880 - (UDP_MAX_BLOCK_NUM * UDP_BLOCK_SIZE))
51
#define UDP_LAST_BLOCK_SIZE (UDP_FRAME_SIZE - (UDP_MAX_BLOCK_NUM * UDP_BLOCK_SIZE))
52
/* ---------------------------------------------------------------------------- */
53
/* ---------------------------------------------------------------------------- */
54
#define UDP_PORT_IDX_IMX490 10 // temporal value because IMX490 doesn't support in clpe_soc
55
#define UDP_FRAME_SIZE_IMX490 (IMG_WIDTH_IMX490*IMG_HEIGHT_IMX490*2)
56
#define UDP_MAX_BLOCK_NUM_IMX490 167 // 168 - 1(Last)
57
#define UDP_LAST_BLOCK_SIZE_IMX490 (UDP_FRAME_SIZE_IMX490-(UDP_MAX_BLOCK_NUM_IMX490*UDP_BLOCK_SIZE))
58
#define UDP_LAST_BLOCK_INFO_SIZE_IMX490 (UDP_LAST_BLOCK_SIZE_IMX490 + UDP_LAST_INFO_SIZE)
59
/* ---------------------------------------------------------------------------- */
60
61
/* ---------------------------------------------------------------------------- */
62
typedef
char
xc8
;
63
typedef
unsigned
char
xu8
;
64
typedef
unsigned
short
xu16
;
65
typedef
int
x32
;
66
typedef
unsigned
int
xu32
;
67
typedef
unsigned
long
long
xu64
;
68
69
/* ---------------------------------------------------------------------------- */
70
typedef
struct
{
71
xu32
seq
;
72
xu16
block_id
;
73
struct
timeval frame;
74
}
T_MSG_BLOCK_INFO
;
75
76
typedef
struct
{
77
T_MSG_BLOCK_INFO
info
;
78
xu8
block[
UDP_BLOCK_SIZE
];
79
}
T_UDP_BLOCK_CONTENT
;
80
81
/* ---------------------------------------------------------------------------- */
82
typedef
struct
{
83
xu8
block[
UDP_LAST_BLOCK_SIZE
];
84
}
T_UDP_BLOCK_LAST
;
85
86
typedef
struct
{
87
xu8
block[
UDP_MAX_BLOCK_NUM_IMX490
][
UDP_BLOCK_SIZE
];
88
T_UDP_BLOCK_LAST
last
;
89
}
T_UDP_BLOCK
;
90
91
/* ---------------------------------------------------------------------------- */
92
typedef
struct
93
{
94
xu32
seq
;
95
//#define IS_BLOCK_DONE(_frame) ((_frame)->block_set_num == (UDP_MAX_BLOCK_NUM+1))
96
xu32
block_set_num
;
97
xu8
block_set[
UDP_MAX_BLOCK_NUM_IMX490
+1
/*last*/
];
98
struct
timeval tv_frame;
99
100
T_UDP_BLOCK
block
;
101
}
PortDataFrameX
;
102
103
#if 0
104
#ifdef CANLAB_LOGGING_ENABLE
105
typedef
int (*
T_CB_APP
) (
unsigned
int
inst,
unsigned
int
seq,
unsigned
char
* buffer,
unsigned
int
size,
struct
timeval* frame_us,
unsigned
int
dropped);
106
#else
107
typedef
int (*
T_CB_APP
) (
unsigned
int
inst,
unsigned
char
* buffer,
unsigned
int
size,
struct
timeval* frame_us);
108
#endif
109
#endif
110
111
#ifdef CANLAB_LOGGING_ENABLE
112
typedef
int (*
T_CB_APP
) (
unsigned
int
inst,
unsigned
int
seq,
unsigned
char
* buffer,
unsigned
int
size,
struct
timeval* frame_us,
unsigned
int
dropped);
113
#endif // #ifdef CANLAB_LOGGING_ENABLE
114
115
struct
_ProgramMain
;
116
typedef
struct
117
{
118
xu16
idx
;
119
xu32
seq
;
120
121
struct
timeval frame_base_tv;
122
//#define MAX_SKIP_COUNT ((UDP_MAX_BLOCK_NUM+1) * 30 * 3) /* 3 sec */
123
xu16
skip_count
;
124
#define FRAME_INTERVAL 33327
/* 33ms */
125
xu32
do_check
;
126
xu32
dropped
;
127
xu32
up_count
;
128
xu64
discard_low_seq
;
129
// Lock
130
#define DATA_LOCK(_data) GST_OBJECT_LOCK(&(_data)->lock)
131
#define DATA_UNLOCK(_data) GST_OBJECT_UNLOCK(&(_data)->lock)
132
GstObject
lock
;
133
134
#define MAX_FRAME 16
135
PortDataFrameX
frameX[
MAX_FRAME
];
136
xu32
frame_now_seq
;
137
xu32
frame_max_seq
;
// frame_now_seq + MAX_FRAME - 1
138
139
T_CB_APP
cb_app
;
140
x32
play
;
141
142
GstElement*
appsink
;
143
GstElement*
appsrc
;
144
GstElement*
up_appsrc
;
145
x32
appSinkBusWatchId[
AVAILALE_PORT
];
146
x32
appSrcBusWatchId[
AVAILALE_PORT
];
147
T_UDP_BLOCK_CONTENT
*
recv
;
148
struct
_ProgramMain
*
parent
;
149
}
PortData
;
150
151
typedef
struct
_ProgramMain
152
{
153
GMainLoop*
loop
;
154
155
PortData
port
[
AVAILALE_PORT
];
156
157
xu32
dropped
;
158
xu32
up_count
;
159
160
xu32
ui32_use_camera_cnt
;
161
162
}
ProgramMain
;
163
164
165
166
/* ---------------------------------------------------------------------------- */
167
/* ---------------------------------------------------------------------------- */
168
169
#endif
/* ClpeStream_header */
PortData::frame_now_seq
xu32 frame_now_seq
Definition:
ClpeStream.h:136
xu64
unsigned long long xu64
Definition:
ClpeStream.h:67
T_CB_APP
int(* T_CB_APP)(unsigned int inst, unsigned char *buffer, unsigned int size, struct timeval *frame_us)
Definition:
ClpeStreamApi.h:10
PortDataFrameX
Definition:
ClpeStream.h:92
UDP_MAX_BLOCK_NUM_IMX490
#define UDP_MAX_BLOCK_NUM_IMX490
Definition:
ClpeStream.h:56
PortData::up_appsrc
GstElement * up_appsrc
Definition:
ClpeStream.h:144
_ProgramMain::loop
GMainLoop * loop
Definition:
ClpeStream.h:153
PortData
Definition:
ClpeStream.h:116
AVAILALE_PORT
#define AVAILALE_PORT
Definition:
ClpeStream.h:28
T_UDP_BLOCK_CONTENT::info
T_MSG_BLOCK_INFO info
Definition:
ClpeStream.h:77
PortDataFrameX::seq
xu32 seq
Definition:
ClpeStream.h:94
PortDataFrameX::block_set_num
xu32 block_set_num
Definition:
ClpeStream.h:96
UDP_BLOCK_SIZE
#define UDP_BLOCK_SIZE
Definition:
ClpeStream.h:47
PortData::parent
struct _ProgramMain * parent
Definition:
ClpeStream.h:148
PortData::appsink
GstElement * appsink
Definition:
ClpeStream.h:142
x32
int x32
Definition:
ClpeStream.h:65
MAX_FRAME
#define MAX_FRAME
Definition:
ClpeStream.h:134
PortData::discard_low_seq
xu64 discard_low_seq
Definition:
ClpeStream.h:128
_ProgramMain::ui32_use_camera_cnt
xu32 ui32_use_camera_cnt
Definition:
ClpeStream.h:160
xu16
unsigned short xu16
Definition:
ClpeStream.h:64
PortData::do_check
xu32 do_check
Definition:
ClpeStream.h:125
PortData::dropped
xu32 dropped
Definition:
ClpeStream.h:126
T_UDP_BLOCK_CONTENT
Definition:
ClpeStream.h:76
T_UDP_BLOCK_LAST
Definition:
ClpeStream.h:82
PortData::up_count
xu32 up_count
Definition:
ClpeStream.h:127
PortData::idx
xu16 idx
Definition:
ClpeStream.h:118
_ProgramMain::port
PortData port[AVAILALE_PORT]
Definition:
ClpeStream.h:155
PortData::seq
xu32 seq
Definition:
ClpeStream.h:119
T_MSG_BLOCK_INFO::seq
xu32 seq
Definition:
ClpeStream.h:71
ClpeStreamApi.h
PortDataFrameX::block
T_UDP_BLOCK block
Definition:
ClpeStream.h:100
_ProgramMain::dropped
xu32 dropped
Definition:
ClpeStream.h:157
xu32
unsigned int xu32
Definition:
ClpeStream.h:66
xu8
unsigned char xu8
Definition:
ClpeStream.h:63
PortData::frame_max_seq
xu32 frame_max_seq
Definition:
ClpeStream.h:137
T_UDP_BLOCK
Definition:
ClpeStream.h:86
PortData::recv
T_UDP_BLOCK_CONTENT * recv
Definition:
ClpeStream.h:147
PortData::lock
GstObject lock
Definition:
ClpeStream.h:132
PortData::appsrc
GstElement * appsrc
Definition:
ClpeStream.h:143
T_MSG_BLOCK_INFO::block_id
xu16 block_id
Definition:
ClpeStream.h:72
PortData::skip_count
xu16 skip_count
Definition:
ClpeStream.h:123
_ProgramMain::up_count
xu32 up_count
Definition:
ClpeStream.h:158
xc8
char xc8
Definition:
ClpeStream.h:62
_ProgramMain
Definition:
ClpeStream.h:151
T_MSG_BLOCK_INFO
Definition:
ClpeStream.h:70
ProgramMain
struct _ProgramMain ProgramMain
T_UDP_BLOCK::last
T_UDP_BLOCK_LAST last
Definition:
ClpeStream.h:88
UDP_LAST_BLOCK_SIZE
#define UDP_LAST_BLOCK_SIZE
Definition:
ClpeStream.h:51
PortData::play
x32 play
Definition:
ClpeStream.h:140
PortData::cb_app
T_CB_APP cb_app
Definition:
ClpeStream.h:139
clpe_sdk
Author(s): Can-lab Corporation
autogenerated on Wed Oct 12 2022 02:17:28