liuyu 4 năm trước cách đây
mục cha
commit
420f2e443d
5 tập tin đã thay đổi với 73 bổ sung2 xóa
  1. 2 2
      app/controller/.room.js
  2. 66 0
      app/controller/room.js
  3. 1 0
      app/model/room.js
  4. 2 0
      app/router.js
  5. 2 0
      app/service/room.js

+ 2 - 2
app/controller/.room.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis"],
+    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis"],
+    requestBody: ["title","name", "type", "filedir", "url", "anchorid","username","status","content","starttime","endtime","adverts","isadvert","stream_id","ishis","file_id"],
   },
   show: {
     parameters: {

+ 66 - 0
app/controller/room.js

@@ -84,6 +84,72 @@ class RoomController extends Controller {
     });
     this.ctx.ok({ });
   }
+
+  async stoptranscode() {
+    // 调用录制接口
+    // 取得公共参数头
+    const SecretId = 'AKIDCAtWu3GhY9VbQzJgfOq4QVJq8AxWi3Sa';
+    const SecretKey = '3sRknnwoOhlY4JH2Wjf6VeYCdnhKr88z';
+    // 导入对应产品模块的client models。
+    const TrtcClient = tencentcloud.trtc.v20190722.Client;
+    const models = tencentcloud.trtc.v20190722.Models;
+
+    const Credential = tencentcloud.common.Credential;
+    const ClientProfile = tencentcloud.common.ClientProfile;
+    const HttpProfile = tencentcloud.common.HttpProfile;
+
+    const cred = new Credential(SecretId, SecretKey);
+    const httpProfile = new HttpProfile();
+    httpProfile.endpoint = 'trtc.tencentcloudapi.com';
+    const clientProfile = new ClientProfile();
+    clientProfile.httpProfile = httpProfile;
+    const client = new TrtcClient(cred, 'ap-shanghai', clientProfile);
+    const req = new models.StopMCUMixTranscodeRequest();
+    const params = {};
+    params.SdkAppId = this.app.config.sdkappid;
+    params.RoomId = this.ctx.query.roomname;
+    req.from_json_string(JSON.stringify(params));
+    client.StartMCUMixTranscode(req, function(errMsg, response) {
+      if (errMsg) {
+        console.log(errMsg);
+        return;
+      }
+      console.log(response.to_json_string());
+    });
+    this.ctx.ok({ });
+  }
+
+  async deletefile() {
+    // 调用录制接口
+    // 取得公共参数头
+    const SecretId = 'AKIDCAtWu3GhY9VbQzJgfOq4QVJq8AxWi3Sa';
+    const SecretKey = '3sRknnwoOhlY4JH2Wjf6VeYCdnhKr88z';
+    // 导入对应产品模块的client models。
+    const VodClient = tencentcloud.vod.v20180717.Client;
+    const models = tencentcloud.vod.v20180717.Models;
+
+    const Credential = tencentcloud.common.Credential;
+    const ClientProfile = tencentcloud.common.ClientProfile;
+    const HttpProfile = tencentcloud.common.HttpProfile;
+
+    const cred = new Credential(SecretId, SecretKey);
+    const httpProfile = new HttpProfile();
+    httpProfile.endpoint = 'vod.tencentcloudapi.com';
+    const clientProfile = new ClientProfile();
+    clientProfile.httpProfile = httpProfile;
+    const client = new VodClient(cred, 'ap-shanghai', clientProfile);
+    const req = new models.DeleteMediaRequest();
+    const params = { FileId: this.ctx.query.fileid };
+    req.from_json_string(JSON.stringify(params));
+    client.StartMCUMixTranscode(req, function(errMsg, response) {
+      if (errMsg) {
+        console.log(errMsg);
+        return;
+      }
+      console.log(response.to_json_string());
+    });
+    this.ctx.ok({ });
+  }
 }
 
 module.exports = CrudController(RoomController, meta);

+ 1 - 0
app/model/room.js

@@ -18,6 +18,7 @@ const RoomSchema = {
   stream_id: { type: String, required: false }, // 视频回放文件id
   ishis: { type: String, required: false, maxLength: 64, default: '0' }, // 状态0、正常1、历史
   requestId: { type: String, required: false }, // 请求id
+  file_id: { type: String, required: false }, // 文件id
   content: { type: String, required: false }, // 直播简介
   anchorid: { type: String, required: false, maxLength: 200 }, // 主播id
   username: { type: String, required: false, maxLength: 200 }, // 主播名称

+ 2 - 0
app/router.js

@@ -20,6 +20,8 @@ module.exports = app => {
 
   // 房间表设置路由
   router.get('/api/onlive/room/starttranscode', controller.room.starttranscode);
+  router.get('/api/onlive/room/stoptranscode', controller.room.stoptranscode);
+  router.get('/api/onlive/room/deletefile', controller.room.deletefile);
   router.get('/api/onlive/room/roomname', controller.room.findroomname);
   router.resources('room', '/api/onlive/room', controller.room); // index、create、show、destroy
   router.post('room', '/api/onlive/room/update/:id', controller.room.update);

+ 2 - 0
app/service/room.js

@@ -63,6 +63,7 @@ class RoomService extends CrudService {
     if (res) {
       res.stream_id = stream_id;
       res.url = data.video_url;
+      res.file_id = data.file_id;
       res.ishis = '1';
       await res.save();
     }
@@ -77,6 +78,7 @@ class RoomService extends CrudService {
     }
     return res;
   }
+
 }
 
 module.exports = RoomService;