fix mp4 compatibility issues
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, Header, Query
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from app.db import pop_next_health, pop_next_measure
|
||||
from app.db import normalize_client_id, pop_next_health, pop_next_measure
|
||||
from app.settings import Settings, get_settings
|
||||
|
||||
router = APIRouter(prefix="/api/v1/biomass", tags=["biomass"])
|
||||
@@ -16,10 +18,27 @@ def _new_headers(has_new: bool) -> dict[str, str]:
|
||||
return {HEADER_BIOMASS_NEW: "1" if has_new else "0"}
|
||||
|
||||
|
||||
def _resolve_client_id(
|
||||
x_fish_client_id: Optional[str] = Header(None, alias="X-Fish-Client-Id"),
|
||||
client_id: Optional[str] = Query(
|
||||
None,
|
||||
description="客户端标识;与请求头 X-Fish-Client-Id 二选一(优先头)。未带时共用 default 游标",
|
||||
),
|
||||
) -> str:
|
||||
if x_fish_client_id is not None and str(x_fish_client_id).strip():
|
||||
return normalize_client_id(x_fish_client_id)
|
||||
if client_id is not None and str(client_id).strip():
|
||||
return normalize_client_id(client_id)
|
||||
return normalize_client_id(None)
|
||||
|
||||
|
||||
@router.get("/real/camera/")
|
||||
async def get_real_camera(settings: Settings = Depends(get_settings)):
|
||||
"""双目实时结果:每次 GET 投递下一条未消费的 FishMeasure 快照(SQLite 游标)。"""
|
||||
m, has_new, _ = pop_next_measure(settings)
|
||||
async def get_real_camera(
|
||||
settings: Settings = Depends(get_settings),
|
||||
client_id: str = Depends(_resolve_client_id),
|
||||
):
|
||||
"""双目实时结果:每次 GET 投递该客户端下一条未消费的 FishMeasure 快照(按 client_id 独立游标)。"""
|
||||
m, has_new, _ = pop_next_measure(settings, client_id)
|
||||
if not has_new:
|
||||
return JSONResponse(
|
||||
content={
|
||||
@@ -61,9 +80,12 @@ async def get_real_camera(settings: Settings = Depends(get_settings)):
|
||||
|
||||
|
||||
@router.get("/health/result/")
|
||||
async def get_health_result(settings: Settings = Depends(get_settings)):
|
||||
"""行为 / 健康结果:每次 GET 投递下一条未消费的 FishAction 快照(SQLite 游标)。"""
|
||||
h, has_new, _ = pop_next_health(settings)
|
||||
async def get_health_result(
|
||||
settings: Settings = Depends(get_settings),
|
||||
client_id: str = Depends(_resolve_client_id),
|
||||
):
|
||||
"""行为 / 健康结果:每次 GET 投递该客户端下一条未消费的 FishAction 快照(按 client_id 独立游标)。"""
|
||||
h, has_new, _ = pop_next_health(settings, client_id)
|
||||
if not has_new:
|
||||
return JSONResponse(
|
||||
content={
|
||||
|
||||
Reference in New Issue
Block a user