|
""" |
|
BackgroundFX Pro API Module. |
|
Provides high-level interfaces for processing, streaming, and serving. |
|
""" |
|
|
|
from .pipeline import ( |
|
ProcessingPipeline, |
|
PipelineConfig, |
|
PipelineResult, |
|
ProcessingMode, |
|
PipelineStage |
|
) |
|
|
|
from .video_processor import ( |
|
VideoProcessorAPI, |
|
VideoStats, |
|
StreamConfig, |
|
VideoStreamMode, |
|
OutputFormat |
|
) |
|
|
|
from .batch_processor import ( |
|
BatchProcessor, |
|
BatchConfig, |
|
BatchItem, |
|
BatchReport, |
|
BatchPriority, |
|
FileType |
|
) |
|
|
|
from .api_server import ( |
|
app, |
|
ServerConfig, |
|
ProcessingRequest, |
|
ImageProcessingRequest, |
|
VideoProcessingRequest, |
|
BatchProcessingRequest, |
|
StreamingRequest, |
|
ProcessingResponse, |
|
JobStatus, |
|
JobManager |
|
) |
|
|
|
from .websocket import ( |
|
WebSocketHandler, |
|
WebSocketServer, |
|
WSMessage, |
|
MessageType, |
|
ClientSession, |
|
SessionManager, |
|
FrameProcessor, |
|
start_standalone_server |
|
) |
|
|
|
__all__ = [ |
|
|
|
'ProcessingPipeline', |
|
'PipelineConfig', |
|
'PipelineResult', |
|
'ProcessingMode', |
|
'PipelineStage', |
|
|
|
|
|
'VideoProcessorAPI', |
|
'VideoStats', |
|
'StreamConfig', |
|
'VideoStreamMode', |
|
'OutputFormat', |
|
|
|
|
|
'BatchProcessor', |
|
'BatchConfig', |
|
'BatchItem', |
|
'BatchReport', |
|
'BatchPriority', |
|
'FileType', |
|
|
|
|
|
'app', |
|
'ServerConfig', |
|
'ProcessingRequest', |
|
'ImageProcessingRequest', |
|
'VideoProcessingRequest', |
|
'BatchProcessingRequest', |
|
'StreamingRequest', |
|
'ProcessingResponse', |
|
'JobStatus', |
|
'JobManager', |
|
|
|
|
|
'WebSocketHandler', |
|
'WebSocketServer', |
|
'WSMessage', |
|
'MessageType', |
|
'ClientSession', |
|
'SessionManager', |
|
'FrameProcessor', |
|
'start_standalone_server' |
|
] |
|
|
|
|
|
__version__ = '1.0.0' |
|
|
|
|
|
def start_api_server(host: str = "0.0.0.0", port: int = 8000, **kwargs): |
|
"""Quick start the REST API server.""" |
|
import uvicorn |
|
from .api_server import app, config |
|
|
|
config.HOST = host |
|
config.PORT = port |
|
|
|
for key, value in kwargs.items(): |
|
if hasattr(config, key.upper()): |
|
setattr(config, key.upper(), value) |
|
|
|
uvicorn.run(app, host=host, port=port) |
|
|
|
|
|
def start_websocket_server(host: str = "0.0.0.0", port: int = 8001): |
|
"""Quick start the WebSocket server.""" |
|
import asyncio |
|
asyncio.run(start_standalone_server(host, port)) |
|
|
|
|
|
def create_pipeline(**kwargs) -> ProcessingPipeline: |
|
"""Create a configured processing pipeline.""" |
|
config = PipelineConfig(**kwargs) |
|
return ProcessingPipeline(config) |
|
|
|
|
|
def create_batch_processor(**kwargs) -> BatchProcessor: |
|
"""Create a configured batch processor.""" |
|
config = BatchConfig(**kwargs) |
|
return BatchProcessor(config) |