hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#include <inttypes.h>
 
#include <glib.h>
 
#include <pthread.h>
#include <gdbus.h>
 
#include "json-c/json.h"
#include "rkdb.h"
#include "common.h"
 
#define TABLE_VIDEO "video"
#define TABLE_VIDEO_ADVANCED_ENC "video_advanced_enc"
#define TABLE_VIDEO_REGION_CLIP "video_region_clip"
#define TABLE_AUDIO "audio"
#define TABLE_STREAM_URL "stream_url"
 
#define TABLE_IMAGE_SCENARIO "image_scenario"
#define TABLE_IMAGE_ADJUSTMENT "image_adjustment"
#define TABLE_IMAGE_EXPOSURE "image_exposure"
#define TABLE_IMAGE_NIGHT_TO_DAY "image_night_to_day"
#define TABLE_IMAGE_BLC "image_blc"
#define TABLE_IMAGE_WHITE_BLANCE "image_white_blance"
#define TABLE_IMAGE_ENHANCEMENT "image_enhancement"
#define TABLE_IMAGE_VIDEO_ADJUSTMEN "image_video_adjustment"
 
#define TABLE_NORMALIZED_SCREEN_SIZE "normalized_screen_size"
#define TABLE_OSD "osd"
#define TABLE_ROI "roi"
 
#define TABLE_PROFILE                       "profile"
#define TABLE_METADATA                      "metadata"
#define TABLE_VIDEO_SOURCE                  "video_source"
#define TABLE_VIDEO_SOURCE_CONFIGURATION    "video_source_configuration"
 
#define TABLE_MEDIA_VERSION       "MediaVersion"
 
#define MEDIA_VERSION             "1.0.1"
 
int media_dbus_register(DBusConnection *dbus_conn)
{
    g_dbus_register_interface(dbus_conn, "/",
                              DB_MEDIA_INTERFACE,
                              methods,
                              signals, NULL, DB_MEDIA_INTERFACE, NULL);
 
    return 0;
}
 
void media_init(void)
{
    char *col_para;
 
    if (equal_version(TABLE_MEDIA_VERSION, MEDIA_VERSION))
        return;
 
    g_free(rkdb_drop(TABLE_VIDEO));
    g_free(rkdb_drop(TABLE_VIDEO_ADVANCED_ENC));
    g_free(rkdb_drop(TABLE_VIDEO_REGION_CLIP));
    g_free(rkdb_drop(TABLE_AUDIO));
    g_free(rkdb_drop(TABLE_STREAM_URL));
    g_free(rkdb_drop(TABLE_IMAGE_SCENARIO));
    g_free(rkdb_drop(TABLE_IMAGE_ADJUSTMENT));
    g_free(rkdb_drop(TABLE_IMAGE_EXPOSURE));
    g_free(rkdb_drop(TABLE_IMAGE_NIGHT_TO_DAY));
    g_free(rkdb_drop(TABLE_IMAGE_BLC));
    g_free(rkdb_drop(TABLE_IMAGE_WHITE_BLANCE));
    g_free(rkdb_drop(TABLE_IMAGE_ENHANCEMENT));
    g_free(rkdb_drop(TABLE_IMAGE_VIDEO_ADJUSTMEN));
    g_free(rkdb_drop(TABLE_NORMALIZED_SCREEN_SIZE));
    g_free(rkdb_drop(TABLE_OSD));
    g_free(rkdb_drop(TABLE_ROI));
    g_free(rkdb_drop(TABLE_PROFILE));
    g_free(rkdb_drop(TABLE_VIDEO_SOURCE));
    g_free(rkdb_drop(TABLE_VIDEO_SOURCE_CONFIGURATION));
    g_free(rkdb_drop(TABLE_METADATA));
    g_free(rkdb_drop(TABLE_MEDIA_VERSION));
 
    creat_version_table(TABLE_MEDIA_VERSION, MEDIA_VERSION);
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sStreamType TEXT DEFAULT 'mainStream'," \
               "sVideoType TEXT DEFAULT 'compositeStream'," \
               "sResolution TEXT DEFAULT '2688*1520'," \
               "sRCMode TEXT DEFAULT 'CBR'," \
               "sRCQuality TEXT DEFAULT 'high'," \
               "sFrameRate TEXT DEFAULT '25'," \
               "sFrameRateIn TEXT DEFAULT '25'," \
               "iTargetRate INT DEFAULT 0," \
               "iMaxRate INT DEFAULT 4096," \
               "iMinRate INT DEFAULT 0," \
               "sOutputDataType TEXT DEFAULT 'H.264'," \
               "sSmart TEXT DEFAULT 'close'," \
               "sH264Profile TEXT DEFAULT 'high'," \
               "iGOP INT DEFAULT 50," \
               "sSVC TEXT DEFAULT 'close'," \
               "iStreamSmooth INT DEFAULT 50,"\
               "sVideoSourceToken TEXT DEFAULT 'VideoSource_0'," \
               "sVideoEncoderConfigurationToken TEXT DEFAULT 'VideoEncoderToken_0'," \
               "sVideoEncoderConfigurationName TEXT DEFAULT 'VideoEncoder_0'";
    g_free(rkdb_create(TABLE_VIDEO, col_para));
    /* TODO: Three tables need different initial values */
    g_free(rkdb_insert(TABLE_VIDEO, "id, sStreamType, sResolution, iMaxRate, sOutputDataType, sVideoEncoderConfigurationToken, sVideoEncoderConfigurationName",
                                    "0, 'mainStream', '2688*1520', 8192, 'H.264', 'VideoEncoderToken_0', 'VideoEncoder_0'"));
    g_free(rkdb_insert(TABLE_VIDEO, "id, sStreamType, sResolution, iMaxRate, sVideoEncoderConfigurationToken, sVideoEncoderConfigurationName",
                                    "1, 'subStream', '640*480', 1024, 'VideoEncoderToken_1', 'VideoEncoder_1'"));
    g_free(rkdb_insert(TABLE_VIDEO, "id, sStreamType, sResolution, iMaxRate, sOutputDataType, sVideoEncoderConfigurationToken, sVideoEncoderConfigurationName",
                                    "2, 'thirdStream', '1920*1080', 2048, 'H.264', 'VideoEncoderToken_2', 'VideoEncoder_2'"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sStreamType TEXT DEFAULT 'mainStream'," \
               "sFunction TEXT DEFAULT '',"\
               "sParameters TEXT DEFAULT ''";
    g_free(rkdb_create(TABLE_VIDEO_ADVANCED_ENC, col_para));
    g_free(rkdb_insert(TABLE_VIDEO_ADVANCED_ENC, "id, sStreamType, sFunction, sParameters", \
            "0, 'mainStream', 'qp', '{\"qp_init\":24,\"qp_step\":4,\"qp_min\":12,\"qp_max\":48,\"min_i_qp\":10,\"max_i_qp\":20}'"));
    g_free(rkdb_insert(TABLE_VIDEO_ADVANCED_ENC, "id, sStreamType, sFunction, sParameters", \
            "1, 'mainStream', 'split', '{\"mode\":0,\"size\":1024}'"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sEncodeType TEXT DEFAULT 'MP2'," \
               "iSampleRate INT DEFAULT 16000," \
               "iBitRate INT DEFAULT 32000," \
               "sInput TEXT DEFAULT 'micIn'," \
               "iVolume INT DEFAULT 50," \
               "sANS TEXT DEFAULT 'close'";
    g_free(rkdb_create(TABLE_AUDIO, col_para));
    g_free(rkdb_insert(TABLE_AUDIO, "id", "0"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sStreamProtocol TEXT NOT NULL";
    g_free(rkdb_create(TABLE_STREAM_URL, col_para));
    g_free(rkdb_insert(TABLE_STREAM_URL, "id,sStreamProtocol", "0,'RTSP'"));
    g_free(rkdb_insert(TABLE_STREAM_URL, "id,sStreamProtocol", "1,'RTMP'"));
    g_free(rkdb_insert(TABLE_STREAM_URL, "id,sStreamProtocol", "2,'RTMP'"));
    g_free(rkdb_insert(TABLE_STREAM_URL, "id,sStreamProtocol", "3,'HTTP'"));
    g_free(rkdb_insert(TABLE_STREAM_URL, "id,sStreamProtocol", "4,'HTTP'"));
    g_free(rkdb_insert(TABLE_STREAM_URL, "id,sStreamProtocol", "5,'HTTP'"));
 
    /* image */
    col_para = "id INTEGER PRIMARY KEY," \
               "sScenario TEXT DEFAULT 'normal'";
    g_free(rkdb_create(TABLE_IMAGE_SCENARIO, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_SCENARIO, "id", "0"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "iBrightness INT DEFAULT 50," \
               "iContrast INT DEFAULT 50," \
               "iSaturation INT DEFAULT 50," \
               "iSharpness INT DEFAULT 50," \
               "iFPS INT DEFAULT 30," \
          "sGridWeight TEXT DEFAULT ''," \
               "iEvbias INT DEFAULT 50," \
               "iHue INT DEFAULT 50";
    g_free(rkdb_create(TABLE_IMAGE_ADJUSTMENT, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_ADJUSTMENT, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_ADJUSTMENT, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_ADJUSTMENT, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_ADJUSTMENT, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_ADJUSTMENT, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_ADJUSTMENT, "id", "5"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sIrisType TEXT DEFAULT 'auto'," \
               "sExposureMode TEXT DEFAULT 'auto'," \
               "sGainMode TEXT DEFAULT 'auto'," \
               "iAutoIrisLevel INT DEFAULT 5," \
               "iAutoExposureEnabled INT DEFAULT 1," \
               "iAutoGainEnabled INT DEFAULT 1," \
               "sExposureTime TEXT DEFAULT '1/6'," \
               "iExposureGain INT DEFAULT 1";
    g_free(rkdb_create(TABLE_IMAGE_EXPOSURE, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_EXPOSURE, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_EXPOSURE, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_EXPOSURE, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_EXPOSURE, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_EXPOSURE, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_EXPOSURE, "id", "5"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sNightToDay TEXT DEFAULT 'auto'," \
               "iNightToDayFilterLevel INT DEFAULT 5," \
               "iNightToDayFilterTime INT DEFAULT 5," \
               "sDawnTime TEXT DEFAULT '07:00:00'," \
               "sDuskTime TEXT DEFAULT '18:00:00'," \
               "sIrcutFilterAction TEXT DEFAULT 'day'," \
               "sOverexposeSuppress TEXT DEFAULT 'open'," \
               "sOverexposeSuppressType TEXT DEFAULT 'auto'," \
               "sFillLightMode TEXT DEFAULT 'IR'," \
               "sBrightnessAdjustmentMode TEXT DEFAULT 'auto'," \
               "iLightBrightness INT DEFAULT 1," \
               "iDistanceLevel INT DEFAULT 1";
    g_free(rkdb_create(TABLE_IMAGE_NIGHT_TO_DAY, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_NIGHT_TO_DAY, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_NIGHT_TO_DAY, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_NIGHT_TO_DAY, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_NIGHT_TO_DAY, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_NIGHT_TO_DAY, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_NIGHT_TO_DAY, "id", "5"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sBLCRegion TEXT DEFAULT 'close'," \
               "iBLCStrength INT DEFAULT 1," \
               "sWDR TEXT DEFAULT 'close'," \
               "iWDRLevel INT DEFAULT 0," \
               "sHDR TEXT DEFAULT 'HDR2'," \
               "iHDRLevel INT DEFAULT 1," \
               "sHLC TEXT DEFAULT 'close'," \
               "iHLCLevel INT DEFAULT 0," \
               "iDarkBoostLevel INT DEFAULT 0," \
               "iPositionX INT DEFAULT 0," \
               "iPositionY INT DEFAULT 0," \
               "iBLCRegionWidth INT DEFAULT 120," \
               "iBLCRegionHeight INT DEFAULT 92";
    g_free(rkdb_create(TABLE_IMAGE_BLC, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_BLC, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_BLC, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_BLC, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_BLC, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_BLC, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_BLC, "id", "5"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sWhiteBlanceStyle TEXT DEFAULT 'autoWhiteBalance'," \
               "iWhiteBalanceRed INT DEFAULT 50," \
               "iWhiteBalanceGreen INT DEFAULT 50," \
               "iWhiteBalanceBlue INT DEFAULT 50";
    g_free(rkdb_create(TABLE_IMAGE_WHITE_BLANCE, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_WHITE_BLANCE, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_WHITE_BLANCE, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_WHITE_BLANCE, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_WHITE_BLANCE, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_WHITE_BLANCE, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_WHITE_BLANCE, "id", "5"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sNoiseReduceMode TEXT DEFAULT 'default'," \
               "iDenoiseLevel INT DEFAULT 50," \
               "iSpatialDenoiseLevel INT DEFAULT 50," \
               "iTemporalDenoiseLevel INT DEFAULT 50," \
               "sDehaze TEXT DEFAULT 'close'," \
               "iDehazeLevel INT DEFAULT 0," \
               "sDIS TEXT DEFAULT 'close'," \
               "sGrayScaleMode TEXT DEFAULT '[0-255]'," \
               "iImageRotation INT DEFAULT 0," \
               "sFEC TEXT DEFAULT 'close'," \
               "sDistortionCorrection TEXT DEFAULT 'close',"
               "iFecLevel INT DEFAULT 100,"
               "iLdchLevel INT DEFAULT 0";
    g_free(rkdb_create(TABLE_IMAGE_ENHANCEMENT, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_ENHANCEMENT, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_ENHANCEMENT, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_ENHANCEMENT, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_ENHANCEMENT, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_ENHANCEMENT, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_ENHANCEMENT, "id", "5"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sImageFlip TEXT DEFAULT 'close'," \
               "sSceneMode TEXT DEFAULT 'indoor'," \
               "sPowerLineFrequencyMode TEXT DEFAULT 'PAL(50HZ)'";
    g_free(rkdb_create(TABLE_IMAGE_VIDEO_ADJUSTMEN, col_para));
    g_free(rkdb_insert(TABLE_IMAGE_VIDEO_ADJUSTMEN, "id", "0"));
    g_free(rkdb_insert(TABLE_IMAGE_VIDEO_ADJUSTMEN, "id", "1"));
    g_free(rkdb_insert(TABLE_IMAGE_VIDEO_ADJUSTMEN, "id", "2"));
    g_free(rkdb_insert(TABLE_IMAGE_VIDEO_ADJUSTMEN, "id", "3"));
    g_free(rkdb_insert(TABLE_IMAGE_VIDEO_ADJUSTMEN, "id", "4"));
    g_free(rkdb_insert(TABLE_IMAGE_VIDEO_ADJUSTMEN, "id", "5"));
 
    /* OSD */
    col_para = "id INTEGER PRIMARY KEY," \
               "iNormalizedScreenWidth INT DEFAULT 704," \
               "iNormalizedScreenHeight INT DEFAULT 480";
    g_free(rkdb_create(TABLE_NORMALIZED_SCREEN_SIZE, col_para));
    g_free(rkdb_insert(TABLE_NORMALIZED_SCREEN_SIZE, "id", "0"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sType TEXT," \
               "iEnabled INT DEFAULT 0," \
               "iPositionX INT DEFAULT 0," \
               "iPositionY INT DEFAULT 0," \
               "iWidth INT DEFAULT 0," \
               "iHeight INT DEFAULT 0," \
               "sIsPersistentText TEXT DEFAULT 'true'," \
               "sDisplayText TEXT DEFAULT ''," \
               "iDisplayWeekEnabled INT DEFAULT 1," \
               "sDateStyle TEXT DEFAULT ''," \
               "sTimeStyle TEXT DEFAULT ''," \
               "iTransparentColorEnabled INT DEFAULT 0," \
               "sOSDAttribute TEXT DEFAULT 'transparent/not-flashing'," \
               "sOSDFontSize TEXT DEFAULT '32*32'," \
               "sOSDFrontColorMode TEXT DEFAULT 'customize'," \
               "sOSDFrontColor TEXT DEFAULT 'fff799'," \
               "sAlignment TEXT DEFAULT 'customize'," \
               "iBoundary INT DEFAULT 0";
    g_free(rkdb_create(TABLE_OSD, col_para));
    g_free(rkdb_insert(TABLE_OSD, "id,sType,iEnabled,sDisplayText,iPositionX,iPositionY", "0,'channelName',1,'Camera 01',540,432"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType,iEnabled,sDateStyle,sTimeStyle,iPositionX,iPositionY", "1,'dateTime',1,'CHR-YYYY-MM-DD','24hour',16,16"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "2,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "3,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "4,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "5,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "6,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "7,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "8,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "9,'character'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "10,'privacyMask'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "11,'privacyMask'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "12,'privacyMask'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType", "13,'privacyMask'"));
    g_free(rkdb_insert(TABLE_OSD, "id,sType,iEnabled,iPositionX,iPositionY", "14,'image',1,16,388"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "sStreamType TEXT," \
               "iStreamEnabled INT DEFAULT 0," \
               "iROIId INT," \
               "iROIEnabled INT DEFAULT 0," \
               "sName TEXT DEFAULT 'test'," \
               "iQualityLevelOfROI INT DEFAULT 3," \
               "iPositionX INT DEFAULT 0," \
               "iPositionY INT DEFAULT 0," \
               "iWidth INT DEFAULT 0," \
               "iHeight INT DEFAULT 0";
    g_free(rkdb_create(TABLE_ROI, col_para));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "0,'mainStream',1"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "1,'mainStream',2"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "2,'mainStream',3"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "3,'mainStream',4"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "4,'subStream',1"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "5,'subStream',2"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "6,'subStream',3"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "7,'subStream',4"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "8,'thirdStream',1"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "9,'thirdStream',2"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "10,'thirdStream',3"));
    g_free(rkdb_insert(TABLE_ROI, "id,sStreamType,iROIId", "11,'thirdStream',4"));
 
    col_para = "id INTEGER PRIMARY KEY," \
               "iRegionClipEnabled INT DEFAULT 0," \
               "iPositionX INT DEFAULT 0," \
               "iPositionY INT DEFAULT 0," \
               "iWidth INT DEFAULT 640," \
               "iHeight INT DEFAULT 480";
    g_free(rkdb_create(TABLE_VIDEO_REGION_CLIP, col_para));
    g_free(rkdb_insert(TABLE_VIDEO_REGION_CLIP, "id", "0"));
 
    col_para = "sToken TEXT PRIMARY KEY," \
               "sName TEXT DEFAULT ''," \
               "iFixed INT DEFAULT 0," \
               "sVideoSourceConfigurationToken TEXT DEFAULT 'VideoSourceConfigurationToken'," \
               "sAudioSourceConfigurationToken TEXT DEFAULT ''," \
               "sVideoEncoderConfigurationToken TEXT DEFAULT ''," \
               "sAudioEncoderConfigurationToken TEXT DEFAULT ''," \
               "sVideoAnalyticsConfigurationToken TEXT DEFAULT ''," \
               "sPTZConfigurationToken TEXT DEFAULT ''," \
               "sMetadataConfigurationToken TEXT DEFAULT ''," \
               "sAudioOutputConfigurationToken TEXT DEFAULT ''," \
               "sAudioDecoderConfigurationToken TEXT DEFAULT ''";
    g_free(rkdb_create(TABLE_PROFILE, col_para));
    g_free(rkdb_insert(TABLE_PROFILE, "sToken, sName, sVideoEncoderConfigurationToken, iFixed",
                       "'Profile_0', 'mainStream', 'VideoEncoderToken_0', 1"));
    g_free(rkdb_insert(TABLE_PROFILE, "sToken, sName, sVideoEncoderConfigurationToken, iFixed",
                       "'Profile_1', 'subStream', 'VideoEncoderToken_1', 1"));
    g_free(rkdb_insert(TABLE_PROFILE, "sToken, sName, sVideoEncoderConfigurationToken, iFixed",
                       "'Profile_2', 'thirdStream', 'VideoEncoderToken_2', 1"));
 
    col_para = "sToken TEXT PRIMARY KEY," \
               "sResolution TEXT DEFAULT '2688*1520'," \
               "sFrameRateIn TEXT DEFAULT '25'";
    g_free(rkdb_create(TABLE_VIDEO_SOURCE, col_para));
    g_free(rkdb_insert(TABLE_VIDEO_SOURCE, "sToken", "'VideoSource_0'"));
 
    col_para = "sToken TEXT PRIMARY KEY," \
               "sName TEXT DEFAULT ''," \
               "sSourceToken TEXT DEFAULT ''," \
               "iBoundsX INT DEFAULT 0," \
               "iBoundsY INT DEFAULT 0," \
               "iBoundsWidth INT DEFAULT 2688," \
               "iBoundsHeight INT DEFAULT 1520";
    g_free(rkdb_create(TABLE_VIDEO_SOURCE_CONFIGURATION, col_para));
    g_free(rkdb_insert(TABLE_VIDEO_SOURCE_CONFIGURATION, "sToken, sName, sSourceToken", "'VideoSourceConfigurationToken', 'VideoSourceConfig', 'VideoSource_0'"));
 
    col_para = "sToken TEXT PRIMARY KEY," \
               "sName TEXT DEFAULT ''";
    g_free(rkdb_create(TABLE_METADATA, col_para));
    g_free(rkdb_insert(TABLE_METADATA, "sToken, sName", "'MetaDataToken0', 'metaData0'"));
}