小编我纠结了好久,各种找资料啊,海康官网上各种反编译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 方式ÿ