Răsfoiți Sursa

推流回调

x1ongzhu 7 ani în urmă
părinte
comite
fb913c4d08

+ 123 - 0
src/main/java/com/izouma/awesomeadmin/dto/VideoNotifyParam.java

@@ -0,0 +1,123 @@
+package com.izouma.awesomeadmin.dto;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import net.sf.json.JSONObject;
+
+@JsonAutoDetect
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class VideoNotifyParam {
+    private String call;
+    private String addr;
+    private String app;
+    private String flashVer;
+    private String swfUrl;
+    private String tcUrl;
+    private String pageUrl;
+    private String name;
+    private String recorder;
+    private String path;
+    private Long   time;
+    private Long   timestamp;
+
+    public String getCall() {
+        return call;
+    }
+
+    public void setCall(String call) {
+        this.call = call;
+    }
+
+    public String getAddr() {
+        return addr;
+    }
+
+    public void setAddr(String addr) {
+        this.addr = addr;
+    }
+
+    public String getApp() {
+        return app;
+    }
+
+    public void setApp(String app) {
+        this.app = app;
+    }
+
+    public String getFlashVer() {
+        return flashVer;
+    }
+
+    public void setFlashVer(String flashVer) {
+        this.flashVer = flashVer;
+    }
+
+    public String getSwfUrl() {
+        return swfUrl;
+    }
+
+    public void setSwfUrl(String swfUrl) {
+        this.swfUrl = swfUrl;
+    }
+
+    public String getTcUrl() {
+        return tcUrl;
+    }
+
+    public void setTcUrl(String tcUrl) {
+        this.tcUrl = tcUrl;
+    }
+
+    public String getPageUrl() {
+        return pageUrl;
+    }
+
+    public void setPageUrl(String pageUrl) {
+        this.pageUrl = pageUrl;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRecorder() {
+        return recorder;
+    }
+
+    public void setRecorder(String recorder) {
+        this.recorder = recorder;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public Long getTime() {
+        return time;
+    }
+
+    public void setTime(Long time) {
+        this.time = time;
+    }
+
+    public Long getTimestamp() {
+        return timestamp;
+    }
+
+    public void setTimestamp(Long timestamp) {
+        this.timestamp = timestamp;
+    }
+
+    @Override
+    public String toString() {
+        return JSONObject.fromObject(this).toString(4);
+    }
+}

+ 24 - 0
src/main/java/com/izouma/awesomeadmin/service/VideoNotifyService.java

@@ -0,0 +1,24 @@
+package com.izouma.awesomeadmin.service;
+
+import com.izouma.awesomeadmin.dto.VideoNotifyParam;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public interface VideoNotifyService {
+    void onConnect(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onPlay(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onPublish(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onPlayDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onPublishDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onRecodDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+
+    void onUpdate(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response);
+}

+ 51 - 0
src/main/java/com/izouma/awesomeadmin/service/impl/VideoNotifyServiceImpl.java

@@ -0,0 +1,51 @@
+package com.izouma.awesomeadmin.service.impl;
+
+import com.izouma.awesomeadmin.dto.VideoNotifyParam;
+import com.izouma.awesomeadmin.service.VideoNotifyService;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Service
+public class VideoNotifyServiceImpl implements VideoNotifyService {
+    @Override
+    public void onConnect(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onPlay(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onPublish(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onPlayDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onPublishDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onRecodDone(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    @Override
+    public void onUpdate(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+
+    }
+}

+ 1 - 2
src/main/java/com/izouma/awesomeadmin/service/impl/VideoRecognitionServiceImpl.java

@@ -50,8 +50,7 @@ public class VideoRecognitionServiceImpl implements VideoRecognitionService {
         CLibrary.INSTANCE.setlocale(CLibrary.LC_ALL, "C");
         CLibrary.INSTANCE.setlocale(CLibrary.LC_NUMERIC, "C");
         CLibrary.INSTANCE.setlocale(CLibrary.LC_CTYPE, "C");
-        System.out.println(System.getProperty("java.library.path"));
-        System.loadLibrary("opencv_java401");
+        System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
         System.loadLibrary("tesseract");
     }
 

+ 46 - 0
src/main/java/com/izouma/awesomeadmin/web/VideoNotifyController.java

@@ -0,0 +1,46 @@
+package com.izouma.awesomeadmin.web;
+
+import com.izouma.awesomeadmin.dto.VideoNotifyParam;
+import com.izouma.awesomeadmin.service.VideoNotifyService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@Controller
+@RequestMapping("/videoNotify")
+public class VideoNotifyController {
+    @Autowired
+    private VideoNotifyService videoNotifyService;
+
+    @RequestMapping(method = RequestMethod.POST)
+    public void videoNotify(VideoNotifyParam param, HttpServletRequest request, HttpServletResponse response) {
+        System.out.println(param);
+        switch (param.getCall()) {
+            case "connect":
+                videoNotifyService.onConnect(param, request, response);
+                break;
+            case "play":
+                videoNotifyService.onPlay(param, request, response);
+                break;
+            case "publish":
+                videoNotifyService.onPublish(param, request, response);
+                break;
+            case "done":
+                videoNotifyService.onDone(param, request, response);
+                break;
+            case "playDone":
+                videoNotifyService.onPlayDone(param, request, response);
+                break;
+            case "publishDone":
+                videoNotifyService.onPublishDone(param, request, response);
+                break;
+            case "recordDone":
+                videoNotifyService.onRecodDone(param, request, response);
+                break;
+        }
+    }
+}

+ 20 - 5
src/main/vue/src/pages/VideoTest.vue

@@ -6,12 +6,12 @@
         </div>
         <br>
         <video ref="video" style="position: relative"></video>
-        <el-dialog :visible.sync="result" width="50%">
+        <el-dialog :visible.sync="showResultDialog" width="50%">
             <span style="font-size: 30px;">{{result?result.rank:''}} / {{result?result.time:''}}</span>
             <img :src="result?result.frame:''" style="width: 100%;">
             <span slot="footer" class="dialog-footer">
-                <el-button @click="dialogVisible = false">取 消</el-button>
-                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
+                <el-button @click="showResultDialog = false" size="small">取消</el-button>
+                <el-button type="primary" @click="saveResult" size="small">保存图片</el-button>
             </span>
         </el-dialog>
     </div>
@@ -28,7 +28,8 @@
                 src: 'rtmp://49.4.66.233:1935/myapp/test',
                 result: null,
                 player: null,
-                starting: false
+                starting: false,
+                showResultDialog: false
             }
         },
         mounted() {
@@ -48,7 +49,7 @@
                 if (this.player.techName_ !== 'Flash') {
                     this.player.pause && this.player.pause()
                 }
-                this.player.dispose()
+                this.player.dispose();
                 this.player = null
             }
         },
@@ -84,6 +85,20 @@
                         }
                     })
                 }
+            },
+            saveResult() {
+                const a = document.createElement('a');
+                const event = new MouseEvent('click');
+                a.download = 'result.png';
+                a.href = this.result.frame;
+                a.dispatchEvent(event)
+            }
+        },
+        watch: {
+            result(val) {
+                if (val) {
+                    this.showResultDialog = true;
+                }
             }
         }
     }