|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- # -*- coding: utf-8 -*-
- # 编码格式
- UTF_8 = "utf-8"
-
- # 文件读模式
- R = 'r'
- ON_OR = "_on_or_"
- ON_AI = "_on_ai_"
- MP4 = ".mp4"
- # 初始化进度
- init_progess = "0.0000"
- # 进度100%
- success_progess = "1.0000"
-
- # 拉流每帧图片缩小宽度大小限制, 大于1400像素缩小一半, 小于1400像素不变
- width = 1400
-
- COLOR = (
- [0, 0, 255],
- [255, 0, 0],
- [211, 0, 148],
- [0, 127, 0],
- [0, 69, 255],
- [0, 255, 0],
- [255, 0, 255],
- [0, 0, 127],
- [127, 0, 255],
- [255, 129, 0],
- [139, 139, 0],
- [255, 255, 0],
- [127, 255, 0],
- [0, 127, 255],
- [0, 255, 127],
- [255, 127, 255],
- [8, 101, 139],
- [171, 130, 255],
- [139, 112, 74],
- [205, 205, 180])
-
- ONLINE = "online"
- OFFLINE = "offline"
- PHOTO = "photo"
- RECORDING = "recording"
-
- ONLINE_START_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["start"]
- },
- "pull_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'maxlength': 255
- },
- "push_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'maxlength': 255
- },
- "logo_url": {
- 'type': 'string',
- 'required': False,
- 'nullable': True,
- 'maxlength': 255
- },
- "models": {
- 'type': 'list',
- 'required': True,
- 'nullable': False,
- 'minlength': 1,
- 'maxlength': 3,
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "code": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "categories",
- 'regex': r'^[a-zA-Z0-9]{1,255}$'
- },
- "is_video": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "code",
- 'allowed': ["0", "1"]
- },
- "is_image": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "code",
- 'allowed': ["0", "1"]
- },
- "categories": {
- 'type': 'list',
- 'required': True,
- 'dependencies': "code",
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{0,255}$'},
- "config": {
- 'type': 'dict',
- 'required': False,
- 'dependencies': "id",
- }
- }
- }
- }
- }
- }
- }
- }
-
- ONLINE_STOP_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["stop"]
- }
- }
-
- OFFLINE_START_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["start"]
- },
- "push_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'maxlength': 255
- },
- "pull_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'maxlength': 255
- },
- "logo_url": {
- 'type': 'string',
- 'required': False,
- 'nullable': True,
- 'maxlength': 255
- },
- "models": {
- 'type': 'list',
- 'required': True,
- 'maxlength': 3,
- 'minlength': 1,
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "code": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "categories",
- 'regex': r'^[a-zA-Z0-9]{1,255}$'
- },
- "is_video": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "code",
- 'allowed': ["0", "1"]
- },
- "is_image": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "code",
- 'allowed': ["0", "1"]
- },
- "categories": {
- 'type': 'list',
- 'required': True,
- 'dependencies': "code",
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{0,255}$'},
- "config": {
- 'type': 'dict',
- 'required': False,
- 'dependencies': "id",
- }
- }
- }
- }
- }
- }
- }
- }
-
- OFFLINE_STOP_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["stop"]
- }
- }
-
- IMAGE_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["start"]
- },
- "logo_url": {
- 'type': 'string',
- 'required': False,
- 'nullable': True,
- 'maxlength': 255
- },
- "image_urls": {
- 'type': 'list',
- 'required': True,
- 'minlength': 1,
- 'schema': {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'maxlength': 5000
- }
- },
- "models": {
- 'type': 'list',
- 'required': True,
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "code": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "categories",
- 'regex': r'^[a-zA-Z0-9]{1,255}$'
- },
- "is_video": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "code",
- 'allowed': ["0", "1"]
- },
- "is_image": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "code",
- 'allowed': ["0", "1"]
- },
- "categories": {
- 'type': 'list',
- 'required': True,
- 'dependencies': "code",
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{0,255}$'},
- "config": {
- 'type': 'dict',
- 'required': False,
- 'dependencies': "id",
- }
- }
- }
- }
- }
- }
- }
- }
-
- RECORDING_START_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["start"]
- },
- "pull_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'maxlength': 255
- },
- "push_url": {
- 'type': 'string',
- 'required': False,
- 'empty': True,
- 'maxlength': 255
- },
- "logo_url": {
- 'type': 'string',
- 'required': False,
- 'nullable': True,
- 'maxlength': 255
- }
- }
-
- RECORDING_STOP_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["stop"]
- }
- }
-
- PULL2PUSH_START_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["start"]
- },
- "video_urls": {
- 'type': 'list',
- 'required': True,
- 'nullable': False,
- 'schema': {
- 'type': 'dict',
- 'required': True,
- 'schema': {
- "id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "pull_url",
- 'regex': r'^[a-zA-Z0-9]{1,255}$'
- },
- "pull_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "push_url",
- 'regex': r'^(https|http|rtsp|rtmp|artc|webrtc|ws)://\w.+$'
- },
- "push_url": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'dependencies': "id",
- 'regex': r'^(https|http|rtsp|rtmp|artc|webrtc|ws)://\w.+$'
- }
- }
- }
- }
- }
- PULL2PUSH_STOP_SCHEMA = {
- "request_id": {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,36}$'
- },
- "command": {
- 'type': 'string',
- 'required': True,
- 'allowed': ["start", "stop"]
- },
- "video_ids": {
- 'type': 'list',
- 'required': False,
- 'nullable': True,
- 'schema': {
- 'type': 'string',
- 'required': True,
- 'empty': False,
- 'regex': r'^[a-zA-Z0-9]{1,255}$'
- }
- }
- }
|