提交录像
This commit is contained in:
parent
4e2fd2fee2
commit
b1e74b6a18
@ -106,14 +106,8 @@ def init_app():
|
|||||||
# 初始化设备管理器
|
# 初始化设备管理器
|
||||||
device_manager = DeviceManager(db_manager)
|
device_manager = DeviceManager(db_manager)
|
||||||
device_manager.set_socketio(socketio) # 设置WebSocket连接
|
device_manager.set_socketio(socketio) # 设置WebSocket连接
|
||||||
|
|
||||||
# 自动启动推流以填充帧缓存
|
|
||||||
if device_manager.device_status['camera']:
|
|
||||||
streaming_result = device_manager.start_streaming()
|
|
||||||
logger.info(f'自动启动推流结果: {streaming_result}')
|
|
||||||
|
|
||||||
# 初始化视频流管理器
|
# 初始化视频流管理器
|
||||||
video_stream_manager = VideoStreamManager(socketio)
|
video_stream_manager = VideoStreamManager(socketio, device_manager)
|
||||||
|
|
||||||
logger.info('应用初始化完成')
|
logger.info('应用初始化完成')
|
||||||
|
|
||||||
@ -141,31 +135,6 @@ def api_health_check():
|
|||||||
'version': '1.0.0'
|
'version': '1.0.0'
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.route('/api/frame-cache/status', methods=['GET'])
|
|
||||||
def get_frame_cache_status():
|
|
||||||
"""获取帧缓存状态"""
|
|
||||||
try:
|
|
||||||
if device_manager:
|
|
||||||
cache_info = device_manager.get_frame_cache_info()
|
|
||||||
return jsonify({
|
|
||||||
'success': True,
|
|
||||||
'data': cache_info,
|
|
||||||
'timestamp': datetime.now().isoformat()
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
return jsonify({
|
|
||||||
'success': False,
|
|
||||||
'error': '设备管理器未初始化',
|
|
||||||
'timestamp': datetime.now().isoformat()
|
|
||||||
}), 500
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f'获取帧缓存状态失败: {e}')
|
|
||||||
return jsonify({
|
|
||||||
'success': False,
|
|
||||||
'error': str(e),
|
|
||||||
'timestamp': datetime.now().isoformat()
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
# ==================== 认证API ====================
|
# ==================== 认证API ====================
|
||||||
|
|
||||||
@app.route('/api/auth/login', methods=['POST'])
|
@app.route('/api/auth/login', methods=['POST'])
|
||||||
@ -719,7 +688,7 @@ def stop_detection(session_id):
|
|||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
data = flask_request.get_json()
|
data = flask_request.get_json()
|
||||||
logger.debug(f'接收到停止检测请求,session_id: {session_id}, 请求数据: {data}')
|
# logger.debug(f'接收到停止检测请求,session_id: {session_id}, 请求数据: {data}')
|
||||||
# video_data = data.get('videoData') if data else None
|
# video_data = data.get('videoData') if data else None
|
||||||
video_data = data['videoData']
|
video_data = data['videoData']
|
||||||
mime_type = data.get('mimeType', 'video/webm;codecs=vp9') # 默认webm格式
|
mime_type = data.get('mimeType', 'video/webm;codecs=vp9') # 默认webm格式
|
||||||
@ -742,11 +711,11 @@ def stop_detection(session_id):
|
|||||||
}), 400
|
}), 400
|
||||||
# 停止同步录制,传递视频数据
|
# 停止同步录制,传递视频数据
|
||||||
try:
|
try:
|
||||||
logger.debug(f'调用device_manager.stop_recording,session_id: {session_id}, video_data长度: {len(video_data) if video_data else 0}')
|
# logger.debug(f'调用device_manager.stop_recording,session_id: {session_id}, video_data长度: {len(video_data) if video_data else 0}')
|
||||||
if video_data is None:
|
# if video_data is None:
|
||||||
logger.warning(f'视频数据为空,session_id: {session_id}')
|
# logger.warning(f'视频数据为空,session_id: {session_id}')
|
||||||
else:
|
# else:
|
||||||
logger.debug(f'视频数据长度: {len(video_data)} 字符,约 {len(video_data)*3/4/1024:.2f} KB, session_id: {session_id}')
|
# logger.debug(f'视频数据长度: {len(video_data)} 字符,约 {len(video_data)*3/4/1024:.2f} KB, session_id: {session_id}')
|
||||||
restrt=device_manager.stop_recording(session_id, video_data_base64=video_bytes)
|
restrt=device_manager.stop_recording(session_id, video_data_base64=video_bytes)
|
||||||
logger.error(restrt)
|
logger.error(restrt)
|
||||||
except Exception as rec_e:
|
except Exception as rec_e:
|
||||||
|
@ -79,7 +79,7 @@ def init_app():
|
|||||||
logger.info("设备管理器初始化成功")
|
logger.info("设备管理器初始化成功")
|
||||||
|
|
||||||
# 初始化视频流管理器
|
# 初始化视频流管理器
|
||||||
video_stream_manager = VideoStreamManager()
|
video_stream_manager = VideoStreamManager(device_manager=device_manager)
|
||||||
logger.info("视频流管理器初始化成功")
|
logger.info("视频流管理器初始化成功")
|
||||||
|
|
||||||
logger.info("应用初始化完成")
|
logger.info("应用初始化完成")
|
||||||
|
@ -658,8 +658,12 @@ class DatabaseManager:
|
|||||||
logger.error(f'创建检测会话失败: {e}')
|
logger.error(f'创建检测会话失败: {e}')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def update_session_status(self, session_id: str, status: str):
|
def update_session_status(self, session_id: str, status: str) -> bool:
|
||||||
"""更新会话状态"""
|
"""更新会话状态
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: 更新成功返回True,失败返回False
|
||||||
|
"""
|
||||||
conn = self.get_connection()
|
conn = self.get_connection()
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
@ -681,11 +685,12 @@ class DatabaseManager:
|
|||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
logger.info(f'更新会话状态: {session_id} -> {status}')
|
logger.info(f'更新会话状态: {session_id} -> {status}')
|
||||||
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
conn.rollback()
|
conn.rollback()
|
||||||
logger.error(f'更新会话状态失败: {e}')
|
logger.error(f'更新会话状态失败: {e}')
|
||||||
raise
|
return False
|
||||||
|
|
||||||
def update_session_duration(self, session_id: str, duration: int):
|
def update_session_duration(self, session_id: str, duration: int):
|
||||||
"""更新会话持续时间"""
|
"""更新会话持续时间"""
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user