diff --git a/routes/users.js b/routes/users.js index 3140a1f..8b3c182 100644 --- a/routes/users.js +++ b/routes/users.js @@ -2,6 +2,7 @@ const router = require('koa-router')() var userContoller = require('../controller/userController') var status = require('../util/resTemplate') const inspectMediaChannelKey = require('../util/inspectMediaChannelKey') +const shellUtil = require('../util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil') router.prefix('/users') @@ -125,4 +126,21 @@ router.post('/encryptionToken',async (ctx, next) => { }) +/** + * + */ +router.post('/Recording',async (ctx, next) => { + try{ + let body = ctx.request.body; + console.log() + let Recording = await shellUtil.Recording(body.appID,body.uid,body.channel,body.channelKey) + ctx.response.status= 200; + ctx.response.body= {msg:Recording}; + }catch(e){ + console.log(e) + status.catchError(ctx,400,e.message); + } +}) + + module.exports = router diff --git a/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js b/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js index c323868..726632b 100644 --- a/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js +++ b/util/Agora_Recording_SDK_for_Linux_FULL/samples/shellUtil.js @@ -5,19 +5,22 @@ function shell(){ } -shell.prototype.Recording =async(appId,uid,channel)=>{ - try { +shell.prototype.Recording =async(appId,uid,channel,channelKey)=>{ + return new Promise((resolve, reject) =>{ let shell =`./RECORD_APP`+ - ` --appId ` +appId - ` --uid ` +uid - ` --channel ` + channel + ` --appId ` +appId + + ` --uid ` +uid + + ` --channel ` + channel + + ` --channelKey ` + channelKey + " --appliteDir \`pwd\`/../bin"; - - let backShell =callfile.exec(shell); - return backShell; - } catch (error) { - throw error - } + callfile.exec(shell,function(err, stdout, stderr){ + console.log(arguments); + if(err){ + reject(err); + } + resolve(arguments); + }) + }) } diff --git a/util/filterUrl.js b/util/filterUrl.js index e94fa77..ecb1769 100644 --- a/util/filterUrl.js +++ b/util/filterUrl.js @@ -1 +1 @@ -module.exports = ['/',"/users/addUser","/users/login",'/users/addUser?time=1','/users/encryptionToken'] \ No newline at end of file +module.exports = ['/',"/users/addUser","/users/login",'/users/addUser?time=1','/users/encryptionToken','/users/Recording'] \ No newline at end of file