From cbdd3b9e92d2dc9b4031e78320f9430ea123f83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=B9=BF?= Date: Fri, 7 Apr 2023 19:30:08 +0800 Subject: [PATCH] fix video output callback --- build_test.sh | 5 +++++ src/HkStreamer.cpp | 45 +++++++++++++++++++++++---------------------- src/convert.cpp | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+), 22 deletions(-) create mode 100755 build_test.sh diff --git a/build_test.sh b/build_test.sh new file mode 100755 index 0000000..f613368 --- /dev/null +++ b/build_test.sh @@ -0,0 +1,5 @@ +#!/bin/bash +./build.sh +export LD_LIBRARY_PATH=`pwd`/lib +cd build +./hkstreamer --cmd playback --device 192.168.12.100 --channel 3 -U admin -P Admin123 -S 2023-04-06T00:00:00Z -E 2023-04-06T00:10:00Z >t.ts \ No newline at end of file diff --git a/src/HkStreamer.cpp b/src/HkStreamer.cpp index 6031c3a..c191d1b 100644 --- a/src/HkStreamer.cpp +++ b/src/HkStreamer.cpp @@ -13,7 +13,7 @@ using namespace std; long playHandle = -1; bool is_playback = false; long lUserID; -const int outcache_size=1024; +const int outcache_size=10240; void signalexit(int signal){ if(playHandle!= -1){ @@ -35,22 +35,12 @@ void exitHandler(){ template void CALLBACK fPlayDataCallBack(LONG lPlayHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, T dwUser){ - DWORD remained = dwBufSize; - char cache[outcache_size]={0}; - BYTE *cp; // cp head point - cp = pBuffer; - while(remained>0){ - int cplen = outcache_size; - if(remainedsPassword.c_str(), NAME_LEN); std::cerr << struLoginInfo.sDeviceAddress << " " << struLoginInfo.sUserName << " " << struLoginInfo.sPassword << std::endl; lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40); + cerr<<"UserID:"<start,timezone, &(struVodPara.struBeginTime)); - convert_isotimestr_time(stream->start,timezone, &(struVodPara.struEndTime)); + convert_isotimestr_time(stream->end,timezone, &(struVodPara.struEndTime)); + struVodPara.struIDInfo.dwChannel = stream->lChannel; playHandle = NET_DVR_PlayBackByTime_V40(lUserID, &struVodPara); if(checkResult(playHandle<0,"play back error")){ @@ -186,7 +178,7 @@ void _installExitHandler(){ int playback(LPLoginInfo loginInfo, LPStream stream) { lUserID = login(loginInfo); - if(checkResult(lUserID<1, "device login error")){ + if(checkResult(lUserID<0, "device login error")){ return HPR_ERROR; } // TODO: find timezone cfg @@ -207,7 +199,8 @@ int _getStream(long lUserID,LPStream stream){ NET_DVR_PREVIEWINFO struPlayInfo = {0}; struPlayInfo.hPlayWnd = 0; struPlayInfo.lChannel = stream->lChannel; //channel NO - struPlayInfo.dwLinkMode = 1; // 采用子码流 + struPlayInfo.dwStreamType = 1;// 采用子码流 + struPlayInfo.dwLinkMode = 0; struPlayInfo.bBlocked = 1; struPlayInfo.dwDisplayBufNum = 1; playHandle = NET_DVR_RealPlay_V40(lUserID, &struPlayInfo, NULL, NULL); @@ -215,7 +208,7 @@ int _getStream(long lUserID,LPStream stream){ return HPR_ERROR; } int scRet; - scRet = NET_DVR_SetStandardDataCallBack(playHandle,fPlayDataCallBack,0); + scRet = NET_DVR_SetRealDataCallBack(playHandle,fPlayDataCallBack,0); if(checkResult(scRet<0,"set play callback error")){ return HPR_ERROR; } @@ -226,7 +219,7 @@ int _getStream(long lUserID,LPStream stream){ int play(LPLoginInfo loginInfo, LPStream stream) { lUserID = login(loginInfo); - if(checkResult(lUserID<1, "device login error")){ + if(checkResult(lUserID<0, "device login error")){ return HPR_ERROR; } int fChannelInfo = _readChannelConfig(lUserID, stream); @@ -234,5 +227,13 @@ int play(LPLoginInfo loginInfo, LPStream stream) return fChannelInfo; } - return _getStream(lUserID, stream); + int ret = _getStream(lUserID, stream); + if(ret != 0){ + cerr<<"Get stream error"< #include "../include/HCNetSDK.h" #include "time.h" +#include using namespace std; void convert_str_chararr(string src, char *dst, int dstlen) @@ -17,6 +18,17 @@ void convert_str_chararr(string src, char *dst, int dstlen) strncpy(dst, src.c_str(), cplen); } +void outtm(string msg, struct tm t){ + cerr<dwHour = ltime.tm_hour; time->dwMinute = ltime.tm_min; time->dwSecond = ltime.tm_sec; + if(ts<1680768000){ + outtm("iso", t); + cerr<<"Ts:"<