1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.ruoyi.device.dhsdk.module;
 
import com.ruoyi.device.dhsdk.lib.NetSDKLib;
import com.ruoyi.device.dhsdk.lib.ToolKits;
/**
 * 实时预览接口实现
 * 主要有 :开始拉流、停止拉流功能
 */
public class RealPlayModule {
    /**
     * \if ENGLISH_LANG
     * Start RealPlay
     * \else
     * 开始预览
     * \endif
     */
    public static NetSDKLib.LLong startRealPlay(NetSDKLib.LLong m_hLoginHandle, int channel, int stream) {
        NetSDKLib.LLong m_hPlayHandle = LoginModule.netsdk.CLIENT_RealPlayEx(m_hLoginHandle, channel, null, stream);
        if (m_hPlayHandle.longValue() == 0) {
            System.err.println("开始实时预览失败,错误码" + ToolKits.getErrorCodePrint());
        } else {
            System.out.println("Success to start realplay");
        }
        return m_hPlayHandle;
    }
 
    /**
     * \if ENGLISH_LANG
     * Start RealPlay
     * \else
     * 停止预览
     * \endif
     */
    public static void stopRealPlay(NetSDKLib.LLong m_hPlayHandle) {
        if (m_hPlayHandle.longValue() == 0) {
            return;
        }
 
        boolean bRet = LoginModule.netsdk.CLIENT_StopRealPlayEx(m_hPlayHandle);
        if (bRet) {
            m_hPlayHandle.setValue(0);
        }
    }
}