|
|
@@ -1,43 +1,26 @@ |
|
|
|
#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)
|
|
|
|
{
|
|
|
|
SXSDK_FRAME_INFO *pFrame = (SXSDK_FRAME_INFO *)pDataInfo;
|
|
|
|
//if(pFrame->nType==XSDK_FRAME_TYPE_VIDEO)
|
|
|
|
//{
|
|
|
|
// FILE *file = fopen("real.dat","ab+") ;
|
|
|
|
// if(file)
|
|
|
|
// {
|
|
|
|
// fwrite(pFrame->pContent,1,pFrame->nFrameLength,file);
|
|
|
|
// fclose(file);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (pFrame->nType == XSDK_FRAME_TYPE_VIDEO)
|
|
|
|
int hour = pFrame->nHour ;
|
|
|
|
if(hour>=11 && hour<=22)
|
|
|
|
{
|
|
|
|
int pos = getPos(hMedia);
|
|
|
|
string fmt("/extdisk/origin/%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);
|
|
|
|
// ABFile("video_header.dat", pFrame->pHeader, pFrame->nLength);
|
|
|
|
ABFile(file_name, pFrame->pContent, pFrame->nFrameLength);
|
|
|
|
if (pFrame->nType == XSDK_FRAME_TYPE_VIDEO)
|
|
|
|
{
|
|
|
|
string fmt("/extdisk/origin/%s/%s-%04d-%02d-%02d-%02d.dat");
|
|
|
|
char file_name[1024];
|
|
|
|
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 +71,12 @@ 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], ¶m);
|
|
|
|
bPause = false;
|
|
|
|
nSpeed = 0;
|
|
|
|
printf("paly hMedia:: %d\r\n", hDeviceArr[i]);
|
|
|
|
printf("play hMedia:: %x\r\n", hDeviceArr[i]);
|
|
|
|
XSDK_DevSynTime(hDeviceArr[i], "", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|