pre-release 0.4.2
[Fobs.git] / test / decode_loop.cpp
blob384f0bc643fa9b89f818b76942cf192341464cc9
1 /******************************************************************************
2 * FOBS Video API test application
3 * Copyright (c) 2004 Omnividea Multimedia S.L
4 * Coded by JosŽ San Pedro Wandelmer
6 * This file is part of FOBS.
8 * FOBS is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
13 * FOBS is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FOBS; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ******************************************************************************/
23 #include "Decoder.h"
24 #include <time.h>
25 #include <iostream>
26 #include <stdio.h>
28 using namespace omnividea::fobs;
29 using namespace std;
32 int main(int argc, char *argv[])
34 if(argc < 2) {
35 cout << "Syntax: " << argv[0] << " inputfile" << endl;
36 return -1;
38 Decoder d(argv[1]);
40 clock_t time0 = clock();
42 int iteration = 0;
43 int max_iterations = 10;
44 for(;iteration<max_iterations;iteration++)
46 ReturnCode error = d.open();
47 if(!iteration)
49 cout << "Video info: Width=" << d.getWidth() << " Height=" << d.getHeight() << " BitRate=" << d.getBitRate() << " FrameRate="<< d.getFrameRate() << endl;
50 if(d.isAudioPresent())
51 cout << "Audio info: SampleRate=" << d.getAudioSampleRate() << " BitRate=" << d.getAudioBitRate() << " Channels=" << d.getAudioChannelNumber() << endl;
52 error = d.nextFrame();
53 cout << "First frame time: " << d.getFrameTime() << endl;
55 for(;isOk(error);)
57 error = d.nextFrame();
59 if(isError(error)) cout << "Error: " << getErrorMessage(error)<< endl;
60 d.close();
63 clock_t timef = clock();
65 cout << "loop end...Time spent = " << ((timef-time0)/(double)CLOCKS_PER_SEC) << endl;
66 return 0;