正在显示
3 个修改的文件
包含
33 行增加
和
12 行删除
| @@ -2,6 +2,7 @@ const router = require('koa-router')() | @@ -2,6 +2,7 @@ const router = require('koa-router')() | ||
| 2 | var userContoller = require('../controller/userController') | 2 | var userContoller = require('../controller/userController') |
| 3 | var status = require('../util/resTemplate') | 3 | var status = require('../util/resTemplate') |
| 4 | const inspectMediaChannelKey = require('../util/inspectMediaChannelKey') | 4 | const inspectMediaChannelKey = require('../util/inspectMediaChannelKey') |
| 5 | +const shellUtil = require('../util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil') | ||
| 5 | 6 | ||
| 6 | 7 | ||
| 7 | router.prefix('/users') | 8 | router.prefix('/users') |
| @@ -125,4 +126,21 @@ router.post('/encryptionToken',async (ctx, next) => { | @@ -125,4 +126,21 @@ router.post('/encryptionToken',async (ctx, next) => { | ||
| 125 | }) | 126 | }) |
| 126 | 127 | ||
| 127 | 128 | ||
| 129 | +/** | ||
| 130 | + * | ||
| 131 | + */ | ||
| 132 | +router.post('/Recording',async (ctx, next) => { | ||
| 133 | + try{ | ||
| 134 | + let body = ctx.request.body; | ||
| 135 | + console.log() | ||
| 136 | + let Recording = await shellUtil.Recording(body.appID,body.uid,body.channel,body.channelKey) | ||
| 137 | + ctx.response.status= 200; | ||
| 138 | + ctx.response.body= {msg:Recording}; | ||
| 139 | + }catch(e){ | ||
| 140 | + console.log(e) | ||
| 141 | + status.catchError(ctx,400,e.message); | ||
| 142 | + } | ||
| 143 | +}) | ||
| 144 | + | ||
| 145 | + | ||
| 128 | module.exports = router | 146 | module.exports = router |
| @@ -5,19 +5,22 @@ function shell(){ | @@ -5,19 +5,22 @@ function shell(){ | ||
| 5 | 5 | ||
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | -shell.prototype.Recording =async(appId,uid,channel)=>{ | ||
| 9 | - try { | 8 | +shell.prototype.Recording =async(appId,uid,channel,channelKey)=>{ |
| 9 | + return new Promise((resolve, reject) =>{ | ||
| 10 | let shell =`./RECORD_APP`+ | 10 | let shell =`./RECORD_APP`+ |
| 11 | - ` --appId ` +appId | ||
| 12 | - ` --uid ` +uid | ||
| 13 | - ` --channel ` + channel | 11 | + ` --appId ` +appId + |
| 12 | + ` --uid ` +uid + | ||
| 13 | + ` --channel ` + channel + | ||
| 14 | + ` --channelKey ` + channelKey + | ||
| 14 | " --appliteDir \`pwd\`/../bin"; | 15 | " --appliteDir \`pwd\`/../bin"; |
| 15 | - | ||
| 16 | - let backShell =callfile.exec(shell); | ||
| 17 | - return backShell; | ||
| 18 | - } catch (error) { | ||
| 19 | - throw error | ||
| 20 | - } | 16 | + callfile.exec(shell,function(err, stdout, stderr){ |
| 17 | + console.log(arguments); | ||
| 18 | + if(err){ | ||
| 19 | + reject(err); | ||
| 20 | + } | ||
| 21 | + resolve(arguments); | ||
| 22 | + }) | ||
| 23 | + }) | ||
| 21 | 24 | ||
| 22 | } | 25 | } |
| 23 | 26 |
-
请 注册 或 登录 后发表评论