Android调用海康威视SDK实现网络实时播放 截图

本文介绍了如何在Android应用中整合海康威视的SDK,实现网络实时视频预览和截图功能。通过导入必要的jar包,设置预览参数并启动预览,同时提供了一个使用Timer进行定时截图的方法。详细步骤和代码参考链接已提供。
摘要由CSDN通过智能技术生成

小编我纠结了好久,各种找资料啊,海康官网上各种反编译apk,扒c语言的文档,整的想吐血

终于在一篇文章上看的了相关内容,现在整理记录一下下!!!

哈哈哈,博客网址现在找不到了,直接看代码吧

1、预览
//一定要把相关jar导入

compile files('libs/AudioEngineSDK.jar')
compile files('libs/HCNetSDK.jar')
compile files('libs/jna.jar')
compile files('libs/PlayerSDK.jar')

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/bg">

    <SurfaceView
        android:id="@+id/sf_VideoMonitor"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center"
        android:layout_marginTop="158px" />
    <ImageView
        android:layout_below="@id/sf_VideoMonitor"
        android:id="@+id/imageview"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center"
        android:layout_marginTop="158px"
        android:background="@mipmap/ic_launcher"/>

</RelativeLayout>

import com.hikvision.netsdk.ExceptionCallBack;
import com.hikvision.netsdk.HCNetSDK;
import com.hikvision.netsdk.INT_PTR;
import com.hikvision.netsdk.NET_DVR_DEVICEINFO_V30;
import com.hikvision.netsdk.NET_DVR_JPEGPARA;
import com.hikvision.netsdk.NET_DVR_PREVIEWINFO;
import com.hikvision.netsdk.PTZCommand;
import com.hikvision.netsdk.RealPlayCallBack;

import org.MediaPlayer.PlayM4.Player;

import static com.hikvision.netsdk.PTZPresetCmd.CLE_PRESET;
import static com.hikvision.netsdk.PTZPresetCmd.SET_PRESET;

/**
 * <pre>
 *  ClassName  DemoActivity Class
 * </pre>
 *
 * @author zhuzhenlei
 * @version V1.0
 * @modificationHistory
 */
public class CameraBaseActivity extends Activity implements Callback, OnTouchListener{
   
    private SurfaceView m_osurfaceView = null;
    private NET_DVR_DEVICEINFO_V30 m_oNetDvrDeviceInfoV30 = null;
    private int m_iLogID = -1; // return by NET_DVR_Login_v30
    private int m_iPlayID = -1; // return by NET_DVR_RealPlay_V30
    private int m_iPlaybackID = -1; // return by NET_DVR_PlayBackByTime
    private int m_iPort = -1; // play port
    private int m_iStartChan = 0; // start channel no  通道开始
    private int m_iChanNum = 0; // channel number 通道个数
    private final String TAG = "DemoActivity";
    private boolean m_bNeedDecode = true;
    private boolean m_bStopPlayback = false;
    private Thread thread;
    private boolean isShow = true;
    private Button btnUp;
    private Button btnDown;
    private Button btnLeft;
    private Button btnRight;
    private Button btnZoomIn;
    private Button btnZoomOut;
    private CameraManager h1;
    private AppData app;

    public final String ADDRESS = "192.168.31.105";
    public final int PORT = 8000;//不需要改变端口号
    public final String USER = "admin";//用户名
    public final String PSD = "123456";//密码
    private ImageView imageView ;

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CrashUtil crashUtil = CrashUtil.getInstance();
        crashUtil.init(this);

        app = (AppData) getApplication();
        setContentView(R.layout.main);
        //初始化sdk
        if (!initeSdk()) {
            this.finish();
            return;
        }

        //
        if (!initeActivity()) {
            this.finish();
            return;
        }
        // login on the device
        m_iLogID = loginDevice();
        if (m_iLogID < 0) {
            Log.e(TAG, "This device logins failed!");
            return;
        } else {
            System.out.println("m_iLogID=" + m_iLogID);
        }
        // get instance of exception callback and set
        ExceptionCallBack oexceptionCbf = getExceptiongCbf();
        if (oexceptionCbf == null) {
            Log.e(TAG, "ExceptionCallBack object is failed!");
            return;
        }

        if (!HCNetSDK.getInstance().NET_DVR_SetExceptionCallBack(
                oexceptionCbf)) {
            Log.e(TAG, "NET_DVR_SetExceptionCallBack is failed!");
            return;
        }

        //预览   NET_DVR_PREVIEWINFO用于设置预览参数。

//        lChannel          通道号,目前设备模拟通道号从 1 开始,数字通道的起始通道号一般从 33 开始,具体取值在登录接口返回
//        dwStreamType      码流类型:0-主码流,1-子码流,2-码流 3,3-虚拟码流,以此类推 dwLinkMode       连接方式:0- TCP 方式,1- UDP 方式ÿ
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值