From 2186386cca113506791583cb07d6ccacba7af4e0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Jun 2018 20:04:58 +0200 Subject: Add concept of video state, and add ability to wait transcoding before publishing a video --- server/helpers/utils.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'server/helpers/utils.ts') diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index e4556fa12..8fa861281 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -1,6 +1,5 @@ import { Model } from 'sequelize-typescript' import * as ipaddr from 'ipaddr.js' -const isCidr = require('is-cidr') import { ResultList } from '../../shared' import { VideoResolution } from '../../shared/models/videos' import { CONFIG } from '../initializers' @@ -10,6 +9,8 @@ import { ApplicationModel } from '../models/application/application' import { pseudoRandomBytesPromise } from './core-utils' import { logger } from './logger' +const isCidr = require('is-cidr') + async function generateRandomString (size: number) { const raw = await pseudoRandomBytesPromise(size) @@ -17,22 +18,20 @@ async function generateRandomString (size: number) { } interface FormattableToJSON { - toFormattedJSON () + toFormattedJSON (args?: any) } -function getFormattedObjects (objects: T[], objectsTotal: number) { +function getFormattedObjects (objects: T[], objectsTotal: number, formattedArg?: any) { const formattedObjects: U[] = [] objects.forEach(object => { - formattedObjects.push(object.toFormattedJSON()) + formattedObjects.push(object.toFormattedJSON(formattedArg)) }) - const res: ResultList = { + return { total: objectsTotal, data: formattedObjects - } - - return res + } as ResultList } async function isSignupAllowed () { @@ -87,16 +86,17 @@ function computeResolutionsToTranscode (videoFileHeight: number) { const resolutionsEnabled: number[] = [] const configResolutions = CONFIG.TRANSCODING.RESOLUTIONS + // Put in the order we want to proceed jobs const resolutions = [ - VideoResolution.H_240P, - VideoResolution.H_360P, VideoResolution.H_480P, + VideoResolution.H_360P, VideoResolution.H_720P, + VideoResolution.H_240P, VideoResolution.H_1080P ] for (const resolution of resolutions) { - if (configResolutions[resolution + 'p'] === true && videoFileHeight > resolution) { + if (configResolutions[ resolution + 'p' ] === true && videoFileHeight > resolution) { resolutionsEnabled.push(resolution) } } -- cgit v1.2.3