system的config中qiniuLiveConfig类型定义修改;liveStream调用七牛云接口方法调整
This commit is contained in:
parent
bee5848640
commit
246db21ab6
|
|
@ -1,7 +1,7 @@
|
|||
import { Config } from '../../../types/Config';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, false, {
|
||||
config: Config;
|
||||
entity: "platform" | "system";
|
||||
entity: "system" | "platform";
|
||||
name: string;
|
||||
entityId: string;
|
||||
}>) => React.ReactElement;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React from 'react';
|
||||
import { Tabs, Row, Col, Card, Divider, Input, Form, Space } from 'antd';
|
||||
import { Tabs, Row, Col, Card, Divider, Input, Form, Space, Select } from 'antd';
|
||||
import Styles from './web.module.less';
|
||||
function Qiniu(props) {
|
||||
const { live, setValue } = props;
|
||||
|
|
@ -27,6 +27,31 @@ function Qiniu(props) {
|
|||
<Input placeholder="请输入liveHost" type="text" value={live?.liveHost} onChange={(e) => setValue(`liveHost`, e.target.value)}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="publishDomain">
|
||||
<>
|
||||
<Input placeholder="请输入publishDomain(推流域名)" type="text" value={live?.publishDomain} onChange={(e) => setValue(`publishDomain`, e.target.value)}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="playDomainType">
|
||||
<>
|
||||
<Select style={{ width: '100%' }} placeholder="请选择播放域名类型" value={live?.playDomainType} onChange={(value) => {
|
||||
setValue(`playDomainType`, value);
|
||||
}} options={[
|
||||
{
|
||||
label: 'RTMP',
|
||||
value: 'rtmp',
|
||||
},
|
||||
{
|
||||
label: 'HLS',
|
||||
value: 'hls',
|
||||
},
|
||||
{
|
||||
label: 'FLV',
|
||||
value: 'flv',
|
||||
},
|
||||
]}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="playDomain">
|
||||
<>
|
||||
<Input placeholder="请输入playDomain" type="text" value={live?.playDomain} onChange={(e) => setValue(`playDomain`, e.target.value)}/>
|
||||
|
|
@ -37,21 +62,45 @@ function Qiniu(props) {
|
|||
<Input placeholder="请输入playBackDomain" type="text" value={live?.playBackDomain} onChange={(e) => setValue(`playBackDomain`, e.target.value)}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="playKey">
|
||||
<Form.Item label="publishSecurity">
|
||||
<>
|
||||
<Input placeholder="请输入playKey" type="text" value={live?.playKey} onChange={(e) => setValue(`playKey`, e.target.value)}/>
|
||||
<Select style={{ width: '100%' }} placeholder="请选择推流鉴权方式" value={live?.publishSecurity} onChange={(value) => {
|
||||
setValue(`publishSecurity`, value);
|
||||
}} options={[
|
||||
{
|
||||
label: '无校验鉴权',
|
||||
value: 'none:',
|
||||
},
|
||||
{
|
||||
label: '静态鉴权',
|
||||
value: 'static:',
|
||||
},
|
||||
{
|
||||
label: '限时鉴权',
|
||||
value: 'expiry',
|
||||
},
|
||||
{
|
||||
label: '限时鉴权sk',
|
||||
value: 'expiry_sk',
|
||||
},
|
||||
]}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="publishDomain">
|
||||
<>
|
||||
<Input placeholder="请输入publishDomain" type="text" value={live?.publishDomain} onChange={(e) => setValue(`publishDomain`, e.target.value)}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="publishKey">
|
||||
<Form.Item label="publishKey"
|
||||
//name="publishKey"
|
||||
help="静态鉴权或限时鉴权时必填">
|
||||
<>
|
||||
<Input placeholder="请输入publishKey" type="text" value={live?.publishKey} onChange={(e) => setValue(`publishKey`, e.target.value)}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item label="playKey"
|
||||
//name="playKey"
|
||||
help="为空则表示未开启播放防盗链">
|
||||
<>
|
||||
<Input placeholder="请输入playKey" type="text" value={live?.playKey} onChange={(e) => setValue(`playKey`, e.target.value)}/>
|
||||
</>
|
||||
</Form.Item>
|
||||
|
||||
</Form>),
|
||||
},
|
||||
]}></Tabs>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export default function Render(props) {
|
|||
{
|
||||
key: '直播api设置',
|
||||
label: '直播api设置',
|
||||
children: (<Live live={live || {}} setValue={(path, value) => setValue(`Map.${path}`, value)}/>),
|
||||
children: (<Live live={live || {}} setValue={(path, value) => setValue(`Live.${path}`, value)}/>),
|
||||
},
|
||||
{
|
||||
key: '地图api设置',
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@ export type QiniuCloudConfig = {
|
|||
export type QiniuLiveConfig = {
|
||||
accessKey: string;
|
||||
liveHost: string;
|
||||
hub: string;
|
||||
publishDomain: string;
|
||||
playDomainType: 'rtmp' | 'hls' | 'flv';
|
||||
playDomain: string;
|
||||
playBackDomain: string;
|
||||
hub: string;
|
||||
publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk';
|
||||
publishKey: string;
|
||||
playKey: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,8 +12,17 @@ export async function getLivestream(params, context) {
|
|||
// 获取七牛直播云信息
|
||||
const { instance, config, } = getConfig(context.getApplication().system.config, 'Live', origin);
|
||||
assert(origin === 'qiniu');
|
||||
const { hub, liveHost, publishDomain, playDomain, playKey, publishKey } = config;
|
||||
return instance.getLiveStream(hub, 'POST', streamTitle, liveHost, publishDomain, playDomain, publishKey, playKey, expireAt);
|
||||
const { hub, liveHost, publishDomain, playDomainType, playDomain, playKey, publishKey, publishSecurity } = config;
|
||||
const r = await instance.getLiveStream(hub, streamTitle, liveHost, publishDomain, playDomainType, playDomain, expireAt, publishSecurity, publishKey, playKey);
|
||||
return {
|
||||
streamTitle,
|
||||
hub,
|
||||
rtmpPushUrl: r.rtmpPushUrl,
|
||||
rtmpPlayUrl: r.playUrl,
|
||||
pcPushUrl: r.pcPushUrl,
|
||||
streamKey: r.streamKey,
|
||||
expireAt,
|
||||
};
|
||||
}
|
||||
// 获取推拉流地址
|
||||
/**
|
||||
|
|
@ -27,8 +36,17 @@ export async function getStreamObj(params, context) {
|
|||
const { streamTitle, expireAt, origin } = params;
|
||||
const { instance, config, } = getConfig(context.getApplication().system.config, 'Live', origin);
|
||||
assert(origin === 'qiniu');
|
||||
const { publishDomain: publishDomain, publishKey: publishKey, playDomain, playKey, hub } = config;
|
||||
return instance.getStreamObj(publishDomain, playDomain, hub, publishKey, playKey, streamTitle, expireAt);
|
||||
const { playDomainType, publishDomain, publishSecurity, publishKey, playDomain, playKey, hub } = config;
|
||||
const r = instance.getStreamObj(hub, streamTitle, expireAt, publishDomain, playDomainType, playDomain, publishSecurity, publishKey, playKey);
|
||||
return {
|
||||
streamTitle,
|
||||
hub,
|
||||
rtmpPushUrl: r.rtmpPushUrl,
|
||||
rtmpPlayUrl: r.playUrl,
|
||||
pcPushUrl: r.pcPushUrl,
|
||||
streamKey: r.streamKey,
|
||||
expireAt,
|
||||
};
|
||||
}
|
||||
// 生成直播回放
|
||||
export async function getPlayBackUrl(params, context) {
|
||||
|
|
|
|||
|
|
@ -7,10 +7,12 @@ export type QiniuCloudConfig = {
|
|||
export type QiniuLiveConfig = {
|
||||
accessKey: string;
|
||||
liveHost: string;
|
||||
hub: string;
|
||||
publishDomain: string;
|
||||
playDomainType: 'rtmp' | 'hls' | 'flv';
|
||||
playDomain: string;
|
||||
playBackDomain: string;
|
||||
hub: string;
|
||||
publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk';
|
||||
publishKey: string;
|
||||
playKey: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPlayBackUrl = exports.getStreamObj = exports.getLivestream = void 0;
|
||||
exports.getLivestream = getLivestream;
|
||||
exports.getStreamObj = getStreamObj;
|
||||
exports.getPlayBackUrl = getPlayBackUrl;
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const getContextConfig_1 = require("./getContextConfig");
|
||||
/**
|
||||
|
|
@ -15,10 +17,18 @@ async function getLivestream(params, context) {
|
|||
// 获取七牛直播云信息
|
||||
const { instance, config, } = (0, getContextConfig_1.getConfig)(context.getApplication().system.config, 'Live', origin);
|
||||
(0, assert_1.assert)(origin === 'qiniu');
|
||||
const { hub, liveHost, publishDomain, playDomain, playKey, publishKey } = config;
|
||||
return instance.getLiveStream(hub, 'POST', streamTitle, liveHost, publishDomain, playDomain, publishKey, playKey, expireAt);
|
||||
const { hub, liveHost, publishDomain, playDomainType, playDomain, playKey, publishKey, publishSecurity } = config;
|
||||
const r = await instance.getLiveStream(hub, streamTitle, liveHost, publishDomain, playDomainType, playDomain, expireAt, publishSecurity, publishKey, playKey);
|
||||
return {
|
||||
streamTitle,
|
||||
hub,
|
||||
rtmpPushUrl: r.rtmpPushUrl,
|
||||
rtmpPlayUrl: r.playUrl,
|
||||
pcPushUrl: r.pcPushUrl,
|
||||
streamKey: r.streamKey,
|
||||
expireAt,
|
||||
};
|
||||
}
|
||||
exports.getLivestream = getLivestream;
|
||||
// 获取推拉流地址
|
||||
/**
|
||||
* 直播流已存在的情况下,获取推拉流地址
|
||||
|
|
@ -31,10 +41,18 @@ async function getStreamObj(params, context) {
|
|||
const { streamTitle, expireAt, origin } = params;
|
||||
const { instance, config, } = (0, getContextConfig_1.getConfig)(context.getApplication().system.config, 'Live', origin);
|
||||
(0, assert_1.assert)(origin === 'qiniu');
|
||||
const { publishDomain: publishDomain, publishKey: publishKey, playDomain, playKey, hub } = config;
|
||||
return instance.getStreamObj(publishDomain, playDomain, hub, publishKey, playKey, streamTitle, expireAt);
|
||||
const { playDomainType, publishDomain, publishSecurity, publishKey, playDomain, playKey, hub } = config;
|
||||
const r = instance.getStreamObj(hub, streamTitle, expireAt, publishDomain, playDomainType, playDomain, publishSecurity, publishKey, playKey);
|
||||
return {
|
||||
streamTitle,
|
||||
hub,
|
||||
rtmpPushUrl: r.rtmpPushUrl,
|
||||
rtmpPlayUrl: r.playUrl,
|
||||
pcPushUrl: r.pcPushUrl,
|
||||
streamKey: r.streamKey,
|
||||
expireAt,
|
||||
};
|
||||
}
|
||||
exports.getStreamObj = getStreamObj;
|
||||
// 生成直播回放
|
||||
async function getPlayBackUrl(params, context) {
|
||||
const { streamTitle, start, end, origin } = params;
|
||||
|
|
@ -43,4 +61,3 @@ async function getPlayBackUrl(params, context) {
|
|||
const { hub, playBackDomain, liveHost } = config;
|
||||
return instance.getPlayBackUrl(hub, playBackDomain, streamTitle, start, end, 'POST', liveHost);
|
||||
}
|
||||
exports.getPlayBackUrl = getPlayBackUrl;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useState } from 'react';
|
||||
import { Tabs, Row, Col, Card, Divider, Input, Form, Space } from 'antd';
|
||||
import { Tabs, Row, Col, Card, Divider, Input, Form, Space, Select } from 'antd';
|
||||
import Styles from './web.module.less';
|
||||
import { Config, QiniuLiveConfig } from '../../../../types/Config';
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ function Qiniu(props: {
|
|||
>
|
||||
<Form.Item
|
||||
label="accessKey"
|
||||
// name="accessKey"
|
||||
// name="accessKey"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
|
|
@ -48,7 +48,7 @@ function Qiniu(props: {
|
|||
</Form.Item>
|
||||
<Form.Item
|
||||
label="hub"
|
||||
//name="hub"
|
||||
//name="hub"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
|
|
@ -63,7 +63,7 @@ function Qiniu(props: {
|
|||
</Form.Item>
|
||||
<Form.Item
|
||||
label="liveHost"
|
||||
//name="liveHost"
|
||||
//name="liveHost"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
|
|
@ -79,9 +79,55 @@ function Qiniu(props: {
|
|||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="publishDomain"
|
||||
//name="publishDomain"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
placeholder="请输入publishDomain(推流域名)"
|
||||
type="text"
|
||||
value={live?.publishDomain}
|
||||
onChange={(e) =>
|
||||
setValue(
|
||||
`publishDomain`,
|
||||
e.target.value
|
||||
)
|
||||
}
|
||||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="playDomainType"
|
||||
>
|
||||
<>
|
||||
<Select
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请选择播放域名类型"
|
||||
value={live?.playDomainType}
|
||||
onChange={(value: string) => {
|
||||
setValue(`playDomainType`, value);
|
||||
}}
|
||||
options={[
|
||||
{
|
||||
label: 'RTMP',
|
||||
value: 'rtmp',
|
||||
},
|
||||
{
|
||||
label: 'HLS',
|
||||
value: 'hls',
|
||||
},
|
||||
{
|
||||
label: 'FLV',
|
||||
value: 'flv',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="playDomain"
|
||||
//name="playDomain"
|
||||
//name="playDomain"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
|
|
@ -99,7 +145,7 @@ function Qiniu(props: {
|
|||
</Form.Item>
|
||||
<Form.Item
|
||||
label="playBackDomain"
|
||||
//name="playBackDomain"
|
||||
//name="playBackDomain"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
|
|
@ -116,44 +162,41 @@ function Qiniu(props: {
|
|||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="playKey"
|
||||
//name="playKey"
|
||||
label="publishSecurity"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
placeholder="请输入playKey"
|
||||
type="text"
|
||||
value={live?.playKey}
|
||||
onChange={(e) =>
|
||||
setValue(
|
||||
`playKey`,
|
||||
e.target.value
|
||||
)
|
||||
}
|
||||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="publishDomain"
|
||||
//name="publishDomain"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
placeholder="请输入publishDomain"
|
||||
type="text"
|
||||
value={live?.publishDomain}
|
||||
onChange={(e) =>
|
||||
setValue(
|
||||
`publishDomain`,
|
||||
e.target.value
|
||||
)
|
||||
}
|
||||
<Select
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请选择推流鉴权方式"
|
||||
value={live?.publishSecurity}
|
||||
onChange={(value: string) => {
|
||||
setValue(`publishSecurity`, value);
|
||||
}}
|
||||
options={[
|
||||
{
|
||||
label: '无校验鉴权',
|
||||
value: 'none:',
|
||||
},
|
||||
{
|
||||
label: '静态鉴权',
|
||||
value: 'static:',
|
||||
},
|
||||
{
|
||||
label: '限时鉴权',
|
||||
value: 'expiry',
|
||||
},
|
||||
{
|
||||
label: '限时鉴权sk',
|
||||
value: 'expiry_sk',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="publishKey"
|
||||
//name="publishKey"
|
||||
help="静态鉴权或限时鉴权时必填"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
|
|
@ -169,12 +212,32 @@ function Qiniu(props: {
|
|||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="playKey"
|
||||
//name="playKey"
|
||||
help="为空则表示未开启播放防盗链"
|
||||
>
|
||||
<>
|
||||
<Input
|
||||
placeholder="请输入playKey"
|
||||
type="text"
|
||||
value={live?.playKey}
|
||||
onChange={(e) =>
|
||||
setValue(
|
||||
`playKey`,
|
||||
e.target.value
|
||||
)
|
||||
}
|
||||
/>
|
||||
</>
|
||||
</Form.Item>
|
||||
|
||||
</Form>
|
||||
),
|
||||
},
|
||||
]}
|
||||
></Tabs>
|
||||
</Col>
|
||||
></Tabs >
|
||||
</Col >
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export default function Render(
|
|||
<Live
|
||||
live={live || {}}
|
||||
setValue={(path, value) =>
|
||||
setValue(`Map.${path}`, value)
|
||||
setValue(`Live.${path}`, value)
|
||||
}
|
||||
/>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ export type QiniuCloudConfig = {
|
|||
export type QiniuLiveConfig = {
|
||||
accessKey: string;
|
||||
liveHost: string; // 七牛直播云接口域名
|
||||
hub: string; // 直播空间名,
|
||||
publishDomain: string; // 推流域名
|
||||
playDomainType: 'rtmp' | 'hls' | 'flv'; //拉流域名类型
|
||||
playDomain: string; // 拉流域名
|
||||
playBackDomain: string; // 直播回放存储域名
|
||||
hub: string; // 直播空间名,
|
||||
publishKey: string; // 直播空间限时鉴权密钥
|
||||
playKey: string; // 拉流密钥
|
||||
publishSecurity: 'none' | 'static' | 'expiry' | 'expiry_sk'; //推流鉴权方式:'none':无校验鉴权;'static':静态鉴权;'expiry':限时鉴权;'expiry_sk':限时鉴权sk
|
||||
publishKey: string; // 直播空间限时鉴权密钥 用于static和expiry类型的推流鉴权方式 expiry_sk使用accessKey和secretKey
|
||||
playKey: string; // 拉流密钥(防盗链主密钥) 若为空则为未开启防盗链
|
||||
}
|
||||
|
||||
export type QiniuCosConfig = {
|
||||
|
|
@ -69,7 +71,7 @@ export type LocalCosConfig = {
|
|||
domain: string; // 访问域名
|
||||
protocol: Protocol | Protocol[]; // 协议头
|
||||
nginxPath?: string; // nginx映射路径
|
||||
|
||||
|
||||
savePath: string; // 服务器保存路径 绝对路径
|
||||
uploadUrl: string; // 服务器上传地址
|
||||
getUrl: string; // 文件获取地址
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { Origin, QiniuLiveConfig } from '../types/Config';
|
|||
import { getConfig } from './getContextConfig';
|
||||
import { QiniuCloudInstance } from 'oak-external-sdk/es/service/qiniu/QiniuCloud';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { cloneDeep } from 'oak-domain/lib/utils/lodash';
|
||||
|
||||
/**
|
||||
* 创建直播流并生成推拉流地址
|
||||
|
|
@ -37,8 +38,17 @@ export async function getLivestream<ED extends EntityDict & BaseEntityDict, Cxt
|
|||
config,
|
||||
} = getConfig(context.getApplication()!.system!.config!, 'Live', origin);
|
||||
assert(origin === 'qiniu');
|
||||
const { hub, liveHost, publishDomain, playDomain, playKey, publishKey } = config as QiniuLiveConfig;
|
||||
return (instance as QiniuCloudInstance).getLiveStream(hub, 'POST', streamTitle, liveHost, publishDomain, playDomain, publishKey, playKey, expireAt);
|
||||
const { hub, liveHost, publishDomain, playDomainType, playDomain, playKey, publishKey, publishSecurity } = config as QiniuLiveConfig;
|
||||
const r = await (instance as QiniuCloudInstance).getLiveStream(hub, streamTitle, liveHost, publishDomain, playDomainType, playDomain, expireAt, publishSecurity, publishKey, playKey);
|
||||
return {
|
||||
streamTitle,
|
||||
hub,
|
||||
rtmpPushUrl: r.rtmpPushUrl,
|
||||
rtmpPlayUrl: r.playUrl,
|
||||
pcPushUrl: r.pcPushUrl,
|
||||
streamKey: r.streamKey,
|
||||
expireAt,
|
||||
};
|
||||
}
|
||||
|
||||
// 获取推拉流地址
|
||||
|
|
@ -72,8 +82,17 @@ export async function getStreamObj<ED extends EntityDict & BaseEntityDict, Cxt e
|
|||
} = getConfig(context.getApplication()!.system!.config!, 'Live', origin);
|
||||
|
||||
assert(origin === 'qiniu');
|
||||
const { publishDomain: publishDomain, publishKey: publishKey, playDomain, playKey, hub } = config as QiniuLiveConfig;
|
||||
return (instance as QiniuCloudInstance).getStreamObj(publishDomain, playDomain, hub, publishKey, playKey, streamTitle, expireAt);
|
||||
const { playDomainType, publishDomain, publishSecurity, publishKey, playDomain, playKey, hub } = config as QiniuLiveConfig;
|
||||
const r = (instance as QiniuCloudInstance).getStreamObj(hub, streamTitle, expireAt, publishDomain, playDomainType, playDomain, publishSecurity, publishKey, playKey);
|
||||
return {
|
||||
streamTitle,
|
||||
hub,
|
||||
rtmpPushUrl: r.rtmpPushUrl,
|
||||
rtmpPlayUrl: r.playUrl,
|
||||
pcPushUrl: r.pcPushUrl,
|
||||
streamKey: r.streamKey,
|
||||
expireAt,
|
||||
};
|
||||
}
|
||||
|
||||
// 生成直播回放
|
||||
|
|
|
|||
Loading…
Reference in New Issue