Browse Source

adjust

master
wenqiurong 5 years ago
parent
commit
8103a72d18
4 changed files with 11 additions and 20 deletions
  1. +2
    -2
      TestDASServer.cpp
  2. +8
    -17
      TestMediaRealPlay.cpp
  3. BIN
      test
  4. +1
    -1
      video.py

+ 2
- 2
TestDASServer.cpp View File

@@ -10,10 +10,10 @@ void OnDASServerStart(XSDK_HANDLE hServer, int nResult)
void OnDASDeviceReg(XSDK_HANDLE hDevice, SXSDKDASDeviceInfo *pDASInfo, int dPos)
{
printf("hDevice::%d, dPos::%d, DeiveID::%s\r\n",hDevice,dPos,pDASInfo->sDevId);
printf("hDevice::%x, dPos::%d, DeiveID::%s\r\n",hDevice,dPos,pDASInfo->sDevId);
hDeviceArr[dPos] = hDevice;
strncpy(DeviceIdArr[dPos], pDASInfo->sDevId, 127);
printf("cachedMedia %d\r\n", hDeviceArr[dPos]);
printf("cachedMedia %x\r\n", hDeviceArr[dPos]);
// hDevice---等同于XSDK_DevLoginSyn/XSDK_DevLogin的返回值
//printf("OnDASDeviceReg-->\r\nIP:%s\r\nPort:%d\r\nDeiveID:%s\r\nUserName:%s\r\nPassword:%s\r\nChannelNum:%d\r\nEncryptyType:%s\r\n",
// pDASInfo->sDevIP, pDASInfo->nDevPort, pDASInfo->sDevId, pDASInfo->sUserName, pDASInfo->sPassword, pDASInfo->nChannelNum, pDASInfo->sEncryptType);


+ 8
- 17
TestMediaRealPlay.cpp View File

@@ -1,17 +1,6 @@
#include "XNetSDKTest.h"
#include <string>
int getPos(XSDK_HANDLE hMedia) {
int size = sizeof(hDeviceArr) / sizeof(hDeviceArr[0]);
for (int i = 0; i < size; i++) {
printf("pos:: %d , cached:: %d,hMedia:: %d\r\n",i,hDeviceArr[i],hMedia);
if (hDeviceArr[i] == hMedia) {
return i;
}
}
return -1;
}
int CALLBACK Test_MediaCallBack(XSDK_HANDLE hMedia, const unsigned char *pData, int nDataLen, int nDataType, void *pDataInfo, int nDataInfoSize, void *pUserData)
{
if (EXSDK_DATA_FORMATE_FRAME == nDataType && nDataInfoSize > 0)
@@ -29,15 +18,16 @@ int CALLBACK Test_MediaCallBack(XSDK_HANDLE hMedia, const unsigned char *pData,
if (pFrame->nType == XSDK_FRAME_TYPE_VIDEO)
{
int pos = getPos(hMedia);
string fmt("/extdisk/origin/%04d-%02d-%02d-%02d.dat");
//int pos = getPos(hMedia);
string fmt("/extdisk/origin/%s/%s-%04d-%02d-%02d-%02d.dat");
char file_name[1024];
snprintf(file_name,sizeof(file_name),fmt.c_str(),pFrame->nYear,pFrame->nMonth,pFrame->nDay,pFrame->nHour) ;
printf("file_path: %d ,%s \r\n", pos,file_name);
char * userData = (char *)pUserData;
snprintf(file_name,sizeof(file_name),fmt.c_str(),userData,userData,pFrame->nYear,pFrame->nMonth,pFrame->nDay,pFrame->nHour) ;
printf("file_path: %s ,%s \r\n", userData,file_name);
// ABFile("video_header.dat", pFrame->pHeader, pFrame->nLength);
ABFile(file_name, pFrame->pContent, pFrame->nFrameLength);
}
//printf("Media[hMedia:%ld][Len:%d][Type:%d/%d][%04d-%02d-%02d %02d:%02d:%02d-%03d]\r\n", hMedia, nDataLen, pFrame->nType, pFrame->nSubType, pFrame->nYear, pFrame->nMonth, pFrame->nDay, pFrame->nHour, pFrame->nMinute, pFrame->nSecond, (int)(pFrame->nTimeStamp % 1000));
printf("Media[hMedia:%ld][Len:%d][Type:%d/%d][%04d-%02d-%02d %02d:%02d:%02d-%03d]\r\n", hMedia, nDataLen, pFrame->nType, pFrame->nSubType, pFrame->nYear, pFrame->nMonth, pFrame->nDay, pFrame->nHour, pFrame->nMinute, pFrame->nSecond, (int)(pFrame->nTimeStamp % 1000));
}
else if (EXSDK_DATA_MEDIA_ON_PLAY_STATE == nDataType)
{
@@ -88,10 +78,11 @@ int TestMediaRealPlay()
param.nStreamType = 0;
param.nRequestType = EXSDK_DATA_FORMATE_FRAME;
param.pMediaCallback = Test_MediaCallBack;
param.pUserData = (void *)DeviceIdArr[i];
hPlayer[i] = XSDK_MediaRealPlay(hDeviceArr[i], &param);
bPause = false;
nSpeed = 0;
printf("paly hMedia:: %d\r\n", hDeviceArr[i]);
printf("play hMedia:: %x\r\n", hDeviceArr[i]);
}
}
break;


BIN
test View File


+ 1
- 1
video.py View File

@@ -20,7 +20,7 @@ def list_folder(org_folder, tar_folder, code):
if current_time + ".dat" == f:
print("{0} ignore".format(os.path.join(root, f)))
continue
convert(os.path.join(root, f), os.path.join(tar_folder, code, f.replace(SUFFIX,"")+TARGET_SUFFIX))
convert(os.path.join(root, f), os.path.join(tar_folder, code, list(root.split("/"))[-1],f.replace(SUFFIX,"")+TARGET_SUFFIX))
def convert(origin, target):


Loading…
Cancel
Save