/** * 视频流管理 API(通过后端代理) * * 推荐使用这个封装,通过后端代理调用 Cloudflare API * 避免在前端暴露 API Token */ import { get, post, put, del } from '@/utils/request' import type { ApiResponse } from '@/types' import type { CloudflareVideo, CloudflareLiveInput, CreateLiveInputParams, CreateUploadUrlParams, VideoPlaybackInfo } from '@/types/cloudflare' // ==================== 视频管理 ==================== /** * 获取视频列表 */ export function listVideos(params?: { pageNum?: number pageSize?: number search?: string status?: string }): Promise> { return get('/stream/video/list', params) } /** * 获取视频详情 */ export function getVideo(videoId: string): Promise> { return get(`/stream/video/${videoId}`) } /** * 删除视频 */ export function deleteVideo(videoId: string): Promise> { return del(`/stream/video/${videoId}`) } /** * 从 URL 导入视频 */ export function importVideoFromUrl(data: { url: string name?: string meta?: Record }): Promise> { return post('/stream/video/import', data) } /** * 获取上传 URL */ export function getUploadUrl(params?: CreateUploadUrlParams): Promise> { return post('/stream/video/upload-url', params) } /** * 获取视频播放信息 */ export function getVideoPlayback(videoId: string): Promise> { return get(`/stream/video/${videoId}/playback`) } // ==================== 直播管理 ==================== /** * 获取直播输入列表 */ export function listLiveInputs(params?: { pageNum?: number pageSize?: number }): Promise> { return get('/stream/live/list', params) } /** * 创建直播输入 */ export function createLiveInput(data?: CreateLiveInputParams): Promise> { return post('/stream/live', data) } /** * 获取直播输入详情 */ export function getLiveInput(liveInputId: string): Promise> { return get(`/stream/live/${liveInputId}`) } /** * 更新直播输入 */ export function updateLiveInput(liveInputId: string, data: CreateLiveInputParams): Promise> { return put(`/stream/live/${liveInputId}`, data) } /** * 删除直播输入 */ export function deleteLiveInput(liveInputId: string): Promise> { return del(`/stream/live/${liveInputId}`) } /** * 获取直播播放信息 */ export function getLivePlayback(liveInputId: string): Promise> { return get(`/stream/live/${liveInputId}/playback`) } /** * 获取直播录像列表 */ export function listLiveRecordings(liveInputId: string, params?: { pageNum?: number pageSize?: number }): Promise> { return get(`/stream/live/${liveInputId}/recordings`, params) } // ==================== 转推管理 ==================== /** * 获取转推输出列表 */ export function listLiveOutputs(liveInputId: string): Promise> { return get(`/stream/live/${liveInputId}/outputs`) } /** * 创建转推输出 */ export function createLiveOutput(liveInputId: string, data: { url: string streamKey: string enabled?: boolean }): Promise> { return post(`/stream/live/${liveInputId}/outputs`, data) } /** * 删除转推输出 */ export function deleteLiveOutput(liveInputId: string, outputId: string): Promise> { return del(`/stream/live/${liveInputId}/outputs/${outputId}`) }