| @@ -38,72 +38,32 @@ int CALLBACK Test_MediaCallBack(XSDK_HANDLE hMedia, const unsigned char *pData, | |||||
| } | } | ||||
| int TestMediaRealPlay() | |||||
| int TestMediaRealPlay(XSDK_HANDLE hDevice,int dPos) | |||||
| { | { | ||||
| printf("MediaRealPlay %s\r\n", __FUNCTION__); | printf("MediaRealPlay %s\r\n", __FUNCTION__); | ||||
| XSDK_HANDLE hPlayer[6] ; | |||||
| XSDK_HANDLE hPlayer ; | |||||
| bool bPause = false; | bool bPause = false; | ||||
| int nSpeed = 0; | int nSpeed = 0; | ||||
| char c = 0; | char c = 0; | ||||
| int size = sizeof(hDeviceArr) / sizeof(hDeviceArr[0]); | |||||
| //while((c = getchar()) != 'q') | |||||
| //{ | |||||
| // switch(c) | |||||
| // { | |||||
| // case 's': | |||||
| if(size==6) | |||||
| if (hDevice) | |||||
| { | { | ||||
| for (int i = 0; i < size; i++) | |||||
| { | |||||
| if (hPlayer[i]) | |||||
| { | |||||
| XSDK_MediaStop(hPlayer[i]); | |||||
| hPlayer[i] = 0; | |||||
| } | |||||
| } | |||||
| for (int i = 0; i < size; i++) | |||||
| { | |||||
| SXMediaRealPlayReq param = { 0 }; | |||||
| param.nChannel = 0; | |||||
| 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("play hMedia:: %x\r\n", hDeviceArr[i]); | |||||
| XSDK_DevSynTime(hDeviceArr[i], "", 1); | |||||
| } | |||||
| XSDK_MediaStop(hDevice); | |||||
| } | } | ||||
| // break; | |||||
| // case 't': | |||||
| // { | |||||
| // for (int i = 0; i < size; i++) | |||||
| // { | |||||
| // if (hPlayer[i]) | |||||
| // { | |||||
| // XSDK_MediaStop(hPlayer[i]); | |||||
| // hPlayer[i] = 0; | |||||
| // } | |||||
| // } | |||||
| // | |||||
| // } | |||||
| // break; | |||||
| // } | |||||
| //} | |||||
| //for (int i = 0; i < size; i++) | |||||
| //{ | |||||
| // if (hPlayer[i]) | |||||
| // { | |||||
| // XSDK_MediaStop(hPlayer[i]); | |||||
| // hPlayer[i] = 0; | |||||
| // } | |||||
| //} | |||||
| SXMediaRealPlayReq param = { 0 }; | |||||
| param.nChannel = 0; | |||||
| param.nStreamType = 0; | |||||
| param.nRequestType = EXSDK_DATA_FORMATE_FRAME; | |||||
| param.pMediaCallback = Test_MediaCallBack; | |||||
| param.pUserData = (void *)DeviceIdArr[dPos]; | |||||
| hPlayer= XSDK_MediaRealPlay(hDevice, ¶m); | |||||
| bPause = false; | |||||
| nSpeed = 0; | |||||
| printf("play hMedia:: %x\r\n", hDevice); | |||||
| XSDK_DevSynTime(hDevice, "", 1); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -73,6 +73,7 @@ int CALLBACK Main_MessageCallBack(XSDK_HANDLE hDevice, int nMsgId, int nParam1, | |||||
| { | { | ||||
| OnDASDeviceReg(hDevice, (SXSDKDASDeviceInfo *)pObject,dPos); | OnDASDeviceReg(hDevice, (SXSDKDASDeviceInfo *)pObject,dPos); | ||||
| dPos++; | dPos++; | ||||
| TestMediaRealPlay(hDevice,dPos); | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -157,7 +158,7 @@ int main(int argc, char *argv[]) | |||||
| //TestDevAlarmCallback(); | //TestDevAlarmCallback(); | ||||
| //// 测试实时视频 | //// 测试实时视频 | ||||
| TestMediaRealPlay(); | |||||
| //TestMediaRealPlay(); | |||||
| //// 设备录像回放 | //// 设备录像回放 | ||||
| // TestMediaRecordPlay(); | // TestMediaRecordPlay(); | ||||
| @@ -42,7 +42,7 @@ int TestDevAlarmCallback(); | |||||
| void OnDevAlarmCallback(XSDK_HANDLE hDevice, const char *szAlarm); | void OnDevAlarmCallback(XSDK_HANDLE hDevice, const char *szAlarm); | ||||
| // 测试实时视频 | // 测试实时视频 | ||||
| int TestMediaRealPlay(); | |||||
| int TestMediaRealPlay(XSDK_HANDLE hDevice,int dPos); | |||||
| // 设备录像回放 | // 设备录像回放 | ||||
| int TestMediaRecordPlay(); | int TestMediaRecordPlay(); | ||||
| @@ -31,29 +31,29 @@ def convert(origin, target): | |||||
| cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target) | cmd = 'ffmpeg -i {0} -c copy {1}'.format(origin, target) | ||||
| print("cmd:: {0}".format(cmd)) | print("cmd:: {0}".format(cmd)) | ||||
| args = shlex.split(cmd) | args = shlex.split(cmd) | ||||
| #status, output = sp.getstatusoutput(cmd) | |||||
| #print("status:: {0}, output {1}".format(status, output)) | |||||
| #if status ==0: | |||||
| # print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| # os.remove(origin) | |||||
| #else: | |||||
| # print("{0} convert fail".format(origin)) | |||||
| proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) | |||||
| answer = b'Overwrite ? [y/N]' | |||||
| try: | |||||
| outs, errs = proc.communicate() | |||||
| print(outs, errs) | |||||
| print("answer in outs : {0}".format(answer in errs)) | |||||
| if answer in errs: | |||||
| print('write y') | |||||
| # proc.stdin.write(b'y') | |||||
| if proc.returncode == 0: | |||||
| print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| os.remove(origin) | |||||
| else: | |||||
| print("{0} convert fail".format(origin)) | |||||
| except sp.TimeoutExpired: | |||||
| proc.kill() | |||||
| status, output = sp.getstatusoutput(cmd) | |||||
| print("status:: {0}, output {1}".format(status, output)) | |||||
| if status ==0: | |||||
| print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| os.remove(origin) | |||||
| else: | |||||
| print("{0} convert fail".format(origin)) | |||||
| # proc = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) | |||||
| # answer = b'Overwrite ? [y/N]' | |||||
| # try: | |||||
| # outs, errs = proc.communicate() | |||||
| # print(outs, errs) | |||||
| # print("answer in outs : {0}".format(answer in errs)) | |||||
| # if answer in errs: | |||||
| # print('write y') | |||||
| # # proc.stdin.write(b'y') | |||||
| # if proc.returncode == 0: | |||||
| # print("{0} convert {1} Success, origin dat will remove!".format(origin, target)) | |||||
| # os.remove(origin) | |||||
| # else: | |||||
| # print("{0} convert fail".format(origin)) | |||||
| # except sp.TimeoutExpired: | |||||
| # proc.kill() | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||