付智勇

录制信息

... ... @@ -20,6 +20,8 @@ const meeting = require('./routes/meeting')
const studentMeeting = require('./routes/studentMeeting')
const upload = require('./routes/upload')
const email = require('./routes/email')
const RecordInfo = require('./routes/RecordInfo')
... ... @@ -51,7 +53,6 @@ app.use(async (ctx, next) => {
try{
const start = new Date();
const url = ctx.request.url.split('?');
console.log(url);
if(filterUrl.indexOf(url[0]) != -1){
await next();
... ... @@ -78,6 +79,7 @@ app.use(meeting.routes(), meeting.allowedMethods())
app.use(studentMeeting.routes(), studentMeeting.allowedMethods())
app.use(upload.routes(), upload.allowedMethods())
app.use(email.routes(), email.allowedMethods())
app.use(RecordInfo.routes(), RecordInfo.allowedMethods())
... ...
const recordInfoService = require('../services/recordInfoService')
const moment = require('moment')
const uuid = require('../util/UuidUtil');
const recordStatus =require( '../model/RecordStatusModel')
const recordInfo =require( '../model/RecordInfoModel');
function recordInfoController(){
};
recordInfoController.prototype.updaterecordInfo = async(ctx,next)=>{
try {
const channel = ctx.params.channel;
let updaterecordInfo = await recordInfoService.updaterecordInfo(channel)
return updaterecordInfo
} catch (error) {
console.error(error);
throw error;
}
}
recordInfoController.prototype.getRecordInfo = async(ctx,next)=>{
try {
const channel = ctx.params.channel;
let channelinfo = await recordInfoService.getRecordInfo(channel);
return channelinfo;
} catch (error) {
console.error(error);
throw error;
}
}
recordInfoController.prototype.addRecordInfo = async(ctx,next)=>{
try {
let params = ctx.request.body;
let recordInfo = await recordInfoService.addRecordInfo(params)
return recordInfo
} catch (error) {
console.error(error);
throw error;
}
}
recordInfoController.prototype.addRecordInfo = async(ctx,next)=>{
try {
let params = ctx.request.body;
let recordInfo = await recordInfoService.addRecordInfo(params)
return recordInfo
} catch (error) {
console.error(error);
throw error;
}
}
recordInfoController.prototype.stopRecording = async(ctx,next)=>{
try {
const channel = ctx.request.body.channel;
const body = ctx.request.body;
body.id = uuid.db32()
body.createTime = new Date().getTime();
let old = await recordStatus.findOne({where:{channel:channel,status:0}})
if(old){
throw new Error('没有正在录制的课堂')
}
let r = await recordInfo.create(body);
let recording = await recordStatus.update({status:0},{where:{channel:channel}});
return recording;
} catch (error) {
console.error(error);
throw error;
}
}
module.exports = new recordInfoController()
\ No newline at end of file
... ...
var sequelize = require('../config');
var Sequelize = require('sequelize');
var uuid = require('../util/UuidUtil')
var recordInfo = sequelize.define('3m_record_info', {
id: {
type: Sequelize.STRING(32),
defaultValue:uuid.db32(),
allowNull: false,
unique: true,
primaryKey: true,
field: "id"
},
appId: {
allowNull: false,
type:Sequelize.STRING(50),
field: "app_id"
},
channel: {
allowNull: false,
type:Sequelize.STRING(50),
field: "channel"
},
channelKey:{
type:Sequelize.STRING(50),
field: "channel_key"
},
uid:{
type:Sequelize.STRING(50),
field: "uid"
},
userId:{
type:Sequelize.STRING(50),
field: "user_id"
},
userRole:{
type:Sequelize.STRING(50),
field: "user_role"
},
userName:{
type:Sequelize.STRING(50),
field: "user_name"
},
timestamp:{
type:Sequelize.STRING(50),
field: "timestamp"
},
recordTimestamp:{
type:Sequelize.STRING(50),
field: "recordTimestamp"
},
createTime:{
type:Sequelize.STRING(50),
field: "create_time"
},
status:{
type:Sequelize.INTEGER(1),
field:'status',
},
type:{
type:Sequelize.INTEGER(1),
field:'type',
}
}, {
timestamps: false,
freezeTableName: true
});
module.exports = recordInfo;
\ No newline at end of file
... ...
var sequelize = require('../config');
var Sequelize = require('sequelize');
var uuid = require('../util/UuidUtil')
var recordStatus = sequelize.define('3m_record_status', {
id: {
type: Sequelize.STRING(32),
defaultValue:uuid.db32(),
allowNull: false,
unique: true,
primaryKey: true,
field: "id"
},
channel:{
type:Sequelize.STRING(50),
field: "channel"
},
status:{
type:Sequelize.INTEGER(1),
field:'status',
},
}, {
timestamps: false,
freezeTableName: true
});
module.exports = recordStatus;
\ No newline at end of file
... ...
const router = require('koa-router')()
var meetingContoller = require('../controller/recordInfoController')
var status = require('../util/resTemplate')
router.prefix('/recordInfo');
router.put('/updaterecordInfo/:channel', async (ctx, next) => {
try{
var data = await meetingContoller.updaterecordInfo(ctx, next);
status.successTemp(ctx,200,data);
}catch(e){
console.error(e)
status.catchError(ctx,400,e.message);
}
})
router.get('/getRecordInfo/:channel', async (ctx, next) => {
try{
var data = await meetingContoller.getRecordInfo(ctx, next);
status.successTemp(ctx,200,data);
}catch(e){
console.error(e)
status.catchError(ctx,400,e.message);
}
})
router.post('/addRecordInfo', async (ctx, next) => {
try{
var data = await meetingContoller.addRecordInfo(ctx, next);
status.successTemp(ctx,200,data);
}catch(e){
console.error(e)
status.catchError(ctx,400,e.message);
}
})
router.post('/stopRecording', async (ctx, next) => {
try{
var data = await meetingContoller.stopRecording(ctx, next);
status.successTemp(ctx,200,data);
}catch(e){
console.error(e)
status.catchError(ctx,400,e.message);
}
})
module.exports = router
\ No newline at end of file
... ...
... ... @@ -146,12 +146,12 @@ 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)
let Recording = await shellUtil.Recording(body.appId,body.uid,body.channel,body.channelKey,body)
ctx.response.status= 200;
ctx.response.body= {msg:Recording};
}catch(e){
console.log(e)
status.catchError(ctx,400,e.message);
ctx.response.status= 200;
ctx.response.body= {msg:e};
}
})
... ...
const recordInfo =require( '../model/RecordInfoModel')
function recordInfoService(){
}
recordInfoService.prototype.updaterecordInfo = async(channel)=>{
try {
let channelupdate = await recordInfo.update(
{status:0},
{where:
{channel:channel}})
return channelupdate;
} catch (error) {
throw error;
}
}
recordInfoService.prototype.addRecordInfo = async(body) =>{
try {
let addrecord = await recordInfo.create(body);
return addrecord;
} catch (error) {
throw error;
}
}
recordInfoService.prototype.getRecordInfo = async(channel) =>{
try {
let addrecord = await recordInfo.findAll({where:{channel:channel}});
return addrecord;
} catch (error) {
throw error;
}
}
module.exports = new recordInfoService();
\ No newline at end of file
... ...
const callfile = require('child_process');
const recordInfo =require( '../../../model/RecordInfoModel');
const recordStatus =require( '../../../model/RecordStatusModel')
const uuid = require('../../UuidUtil');
const moment = require('moment')
function shell(){
}
shell.prototype.Recording =async(appId,uid,channel,channelKey)=>{
return new Promise((resolve, reject) =>{
let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+
` --appId ` +appId +
//` --uid ` +uid +
` --channel ` + channel +
//` --channelKey ` + channelKey +
" --appliteDir \`pwd\`/../bin";
console.log(shell)
callfile.exec(shell,function(err, stdout, stderr){
console.log(arguments);
if(err){
reject(err);
shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{
// return new Promise((resolve, reject) =>{
try {
body.id = uuid.db32()
body.createTime = new Date().getTime();
var channelInfo = await recordStatus.findOne({where:{channel:channel}});
let r = await recordInfo.create(body);
if(channelInfo){
if(channelInfo.status == 0){
var channelInfo = await recordStatus.update({status:1},{where:{channel:channel}});
}else if(channelInfo.status == 1){
throw false ;
}
}else{
var channelInfo = await recordStatus.create({id:uuid.db32(),channel:channel,status:1});
}
resolve(arguments);
})
resolve(true)
})
let shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+
` --appId ` +appId +
//` --uid ` +uid +
` --channel ` + channel +
//` --channelKey ` + channelKey +
" --appliteDir \`pwd\`/../bin";
await callfile.exec(shell)
return true
} catch (error) {
throw error
}
// })
}
... ...
... ... @@ -30,7 +30,6 @@ module.exports = {
};
},
successTemp: (ctx,code,data)=>{
console.log(code)
ctx.response.status= 200;
ctx.response.body= {
code:!data.code ? 200:data.code,
... ...