mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 11:50:56 +00:00
use huly stream instedof cf stream (#8245)
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
This commit is contained in:
parent
419a3ddfdb
commit
e092c3ae80
@ -1,12 +1,13 @@
|
|||||||
services:
|
services:
|
||||||
stream:
|
stream:
|
||||||
image: 'hardcoreeng/huly-stream'
|
image: 'hardcoreeng/stream'
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- 'huly.local:host-gateway'
|
- 'huly.local:host-gateway'
|
||||||
container_name: stream
|
container_name: stream
|
||||||
environment:
|
environment:
|
||||||
- STREAM_ENDPOINT_URL=s3://huly.local:9000
|
- STREAM_ENDPOINT_URL=s3://huly.local:9000
|
||||||
- STREAM_INSECURE=true
|
- STREAM_INSECURE=true
|
||||||
|
- STREAM_SERVER_SECRET=secret
|
||||||
- AWS_ACCESS_KEY_ID=minioadmin
|
- AWS_ACCESS_KEY_ID=minioadmin
|
||||||
- AWS_SECRET_ACCESS_KEY=minioadmin
|
- AWS_SECRET_ACCESS_KEY=minioadmin
|
||||||
ports:
|
ports:
|
||||||
|
@ -11,9 +11,12 @@ export interface PreviewConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface VideoMeta {
|
export interface VideoMeta {
|
||||||
status: 'ready' | 'error' | 'inprogress' | 'queued' | 'downloading' | 'pendingupload'
|
hls?: HLSMeta
|
||||||
thumbnail: string
|
}
|
||||||
hls: string
|
|
||||||
|
export interface HLSMeta {
|
||||||
|
thumbnail?: string
|
||||||
|
source?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultImagePreview = (): string => `/files/${getCurrentWorkspaceUuid()}?file=:blobId&size=:size`
|
const defaultImagePreview = (): string => `/files/${getCurrentWorkspaceUuid()}?file=:blobId&size=:size`
|
||||||
|
@ -64,8 +64,8 @@
|
|||||||
{#await getVideoMeta(value.file, value.name) then meta}
|
{#await getVideoMeta(value.file, value.name) then meta}
|
||||||
{@const src = getFileUrl(value.file, value.name)}
|
{@const src = getFileUrl(value.file, value.name)}
|
||||||
|
|
||||||
{#if meta && meta.status === 'ready'}
|
{#if meta?.hls?.source !== undefined}
|
||||||
<HlsVideo {src} {preload} hlsSrc={meta.hls} hlsThumbnail={meta.thumbnail} name={value.name} />
|
<HlsVideo {src} {preload} hlsSrc={meta.hls.source} hlsThumbnail={meta.hls.thumbnail} name={value.name} />
|
||||||
{:else}
|
{:else}
|
||||||
<Video {src} {preload} name={value.name} />
|
<Video {src} {preload} name={value.name} />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -41,9 +41,9 @@
|
|||||||
<HlsVideo {src} hlsSrc={src} preload={true} />
|
<HlsVideo {src} hlsSrc={src} preload={true} />
|
||||||
{:else}
|
{:else}
|
||||||
{#await getVideoMeta(value, name) then meta}
|
{#await getVideoMeta(value, name) then meta}
|
||||||
{#if meta !== undefined && meta.status === 'ready'}
|
{#if meta?.hls?.source !== undefined}
|
||||||
{@const src = getFileUrl(value, name)}
|
{@const src = getFileUrl(value, name)}
|
||||||
<HlsVideo {src} {name} hlsSrc={meta.hls} hlsThumbnail={meta.thumbnail} preload={false} />
|
<HlsVideo {src} {name} hlsSrc={meta.hls.source} hlsThumbnail={meta.hls.thumbnail} preload={false} />
|
||||||
{:else}
|
{:else}
|
||||||
{@const src = getFileUrl(value, name)}
|
{@const src = getFileUrl(value, name)}
|
||||||
<Video {src} {name} />
|
<Video {src} {name} />
|
||||||
|
@ -26,6 +26,7 @@ export interface Config {
|
|||||||
Port: number
|
Port: number
|
||||||
Secret: string
|
Secret: string
|
||||||
AccountsUrl: string
|
AccountsUrl: string
|
||||||
|
StreamUrl?: string
|
||||||
DbUrl: string
|
DbUrl: string
|
||||||
Buckets: BucketConfig[]
|
Buckets: BucketConfig[]
|
||||||
}
|
}
|
||||||
@ -75,6 +76,7 @@ const config: Config = (() => {
|
|||||||
Secret: process.env.SECRET,
|
Secret: process.env.SECRET,
|
||||||
AccountsUrl: process.env.ACCOUNTS_URL,
|
AccountsUrl: process.env.ACCOUNTS_URL,
|
||||||
DbUrl: process.env.DB_URL,
|
DbUrl: process.env.DB_URL,
|
||||||
|
StreamUrl: process.env.STREAM_URL,
|
||||||
Buckets: parseBucketsConfig(process.env.BUCKETS)
|
Buckets: parseBucketsConfig(process.env.BUCKETS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import { type Request, type Response } from 'express'
|
|||||||
import { UploadedFile } from 'express-fileupload'
|
import { UploadedFile } from 'express-fileupload'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
|
import { requestHLS } from './video'
|
||||||
import { cacheControl } from '../const'
|
import { cacheControl } from '../const'
|
||||||
import { type Datalake } from '../datalake'
|
import { type Datalake } from '../datalake'
|
||||||
import { getBufferSha256, getStreamSha256 } from '../hash'
|
import { getBufferSha256, getStreamSha256 } from '../hash'
|
||||||
@ -223,6 +224,10 @@ export async function handleUploadFormData (
|
|||||||
lastModified: Date.now()
|
lastModified: Date.now()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (contentType.startsWith('video/')) {
|
||||||
|
void requestHLS(ctx, workspace, name)
|
||||||
|
}
|
||||||
|
|
||||||
return { key, metadata }
|
return { key, metadata }
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
const error = err instanceof Error ? err.message : String(err)
|
const error = err instanceof Error ? err.message : String(err)
|
||||||
|
@ -17,6 +17,7 @@ import { MeasureContext } from '@hcengineering/core'
|
|||||||
import { type Request, type Response } from 'express'
|
import { type Request, type Response } from 'express'
|
||||||
import { cacheControl } from '../const'
|
import { cacheControl } from '../const'
|
||||||
import { Datalake } from '../datalake'
|
import { Datalake } from '../datalake'
|
||||||
|
import { requestHLS } from './video'
|
||||||
|
|
||||||
export interface MultipartUpload {
|
export interface MultipartUpload {
|
||||||
key: string
|
key: string
|
||||||
@ -120,5 +121,10 @@ export async function handleMultipartUploadAbort (
|
|||||||
const { bucket } = await datalake.selectStorage(ctx, workspace)
|
const { bucket } = await datalake.selectStorage(ctx, workspace)
|
||||||
await bucket.abortMultipartUpload(ctx, name, { uploadId })
|
await bucket.abortMultipartUpload(ctx, name, { uploadId })
|
||||||
|
|
||||||
|
const contentType = req.headers['content-type'] ?? 'application/octet-stream'
|
||||||
|
if (contentType.startsWith('video/')) {
|
||||||
|
void requestHLS(ctx, workspace, name)
|
||||||
|
}
|
||||||
|
|
||||||
res.status(204).send()
|
res.status(204).send()
|
||||||
}
|
}
|
||||||
|
44
services/datalake/pod-datalake/src/handlers/video.ts
Normal file
44
services/datalake/pod-datalake/src/handlers/video.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// Copyright © 2025 Hardcore Engineering Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License. You may
|
||||||
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
//
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
|
||||||
|
import { MeasureContext } from '@hcengineering/core'
|
||||||
|
import config from '../config'
|
||||||
|
|
||||||
|
interface StreamRequest {
|
||||||
|
source: string
|
||||||
|
format: string
|
||||||
|
workspace: string
|
||||||
|
metadata?: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function requestHLS (ctx: MeasureContext, workspace: string, name: string): Promise<void> {
|
||||||
|
if (config.StreamUrl === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const streamReq: StreamRequest = { format: 'hls', source: name, workspace }
|
||||||
|
|
||||||
|
const request = new Request(config.StreamUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(streamReq)
|
||||||
|
})
|
||||||
|
|
||||||
|
const resp = await fetch(request)
|
||||||
|
if (!resp.ok) {
|
||||||
|
ctx.error(resp.statusText)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user