1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include<windows.h>
time_t now;
struct tm* tm;
time_t now=time(NULL);
struct tm *tm=localtime(&now);
int o2,o1;
time_t s2,s1;
void play() {
// Open the input file as a 'byte-stream file source':
fi_params.nFICardFrameSize = TRANSPORT_PACKETS_PER_NETWORK_PACKET * TRANSPORT_PACKET_SIZE;
fi_params.p_lm_lock_fn = lm_lock_fn;
fi_params.p_lm_unlock_fn = lm_unlock_fn;
DeviceParameters temp;
fileSource = DeviceSourceFICard::createNew(*env, fi_params, temp);
if (fileSource == NULL) {
*env << "Unable to open file \"" << inputFileName
<< "\" as a byte-stream file source\n";
exit(1);
}
FramedSource* videoES = fileSource;
// Create a framer for the Video Elementary Stream:
videoSource = MPEG1or2VideoStreamDiscreteFramer::createNew(*env, videoES);
// Finally, start playing:
*env << "Beginning to read from file...\n";
o1=videoSink->octetCount();
s1=tm->tm_sec;
videoSink->startPlaying(*videoSource, afterPlaying, videoSink);
int Counter=0;
MSG Msg;
UINT TimerId = SetTimer(NULL, 0, 10000, &TimerProc);
cout << "TimerId: " << TimerId << '\n';
//printf("TimerId %s/n",TimerId);
if (!TimerId)
return 16;
while (GetMessage(&Msg, NULL, 0, 0)) {
++Counter;
if (Msg.message == WM_TIMER)
cout << "Counter: " << Counter << "; timer message\n";
/*printf("Counter: %d\n",Counter);*/
else
cout << "Counter: " << Counter << "; message: " << Msg.message << '\n';
/*printf("Counter: %d\n",Counter);
printf(" message: %s\n",Msg.message);*/
DispatchMessage(&Msg);
}
KillTimer(NULL, TimerId);
}
VOID CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime) {
cout << "Time: " << dwTime << '\n';
//printf("Time: %s/n",dwTime);
//getch();
cout.flush();
o2=videoSink->octetCount();
s2=tm->tm_sec;
double mbits_sent = (o2 - o1) / 1024.0 / 1024.0 / (s2 - s1);
printf("mbits_sent %d\n",mbits_sent);
}
|