ocr1.0
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import json
|
||||
import threading
|
||||
import time
|
||||
|
||||
from fastapi import HTTPException, Query, APIRouter, Depends, Request
|
||||
from mysql.connector import Error as MySQLError
|
||||
|
||||
@ -17,7 +19,7 @@ from schema.response_schema import APIResponse
|
||||
from schema.user_schema import UserResponse
|
||||
|
||||
# 导入之前封装的WEBRTC处理函数
|
||||
from rtc.rtc import process_webrtc_stream
|
||||
from core.rtmp import rtmp_pull_video_stream
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/devices",
|
||||
@ -29,7 +31,7 @@ router = APIRouter(
|
||||
def run_webrtc_processing(ip, webrtc_url):
|
||||
try:
|
||||
print(f"开始处理来自设备 {ip} 的WEBRTC流: {webrtc_url}")
|
||||
process_webrtc_stream(ip, webrtc_url)
|
||||
rtmp_pull_video_stream(webrtc_url)
|
||||
except Exception as e:
|
||||
print(f"WEBRTC处理出错: {str(e)}")
|
||||
|
||||
@ -52,7 +54,9 @@ async def create_device(request: Request, device_data: DeviceCreateRequest):
|
||||
# 设备创建成功后,在后台线程启动WEBRTC流处理
|
||||
threading.Thread(
|
||||
target=run_webrtc_processing,
|
||||
args=(device_data.ip, existing_device["live_webrtc_url"]),
|
||||
# args=(device_data.ip, existing_device["live_webrtc_url"]),
|
||||
args=(device_data.ip, existing_device["rtmp_push_url"]),
|
||||
|
||||
daemon=True # 设为守护线程,主程序退出时自动结束
|
||||
).start()
|
||||
# IP已存在时返回该设备信息
|
||||
|
Reference in New Issue
Block a user