Skip to content

Latest commit

 

History

History
72 lines (60 loc) · 1.86 KB

testtheoraplay.c

File metadata and controls

72 lines (60 loc) · 1.86 KB
 
Jun 10, 2011
Jun 10, 2011
1
2
3
4
5
6
7
8
9
10
/**
* TheoraPlay; multithreaded Ogg Theora/Ogg Vorbis decoding.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
#include <stdio.h>
#include <unistd.h>
Jun 15, 2011
Jun 15, 2011
11
#include <string.h>
Jun 10, 2011
Jun 10, 2011
12
13
#include "theoraplay.h"
Jun 15, 2011
Jun 15, 2011
14
static void dofile(const char *fname, const THEORAPLAY_VideoFormat vidfmt)
Jun 10, 2011
Jun 10, 2011
15
{
Jun 11, 2011
Jun 11, 2011
16
THEORAPLAY_Decoder *decoder = NULL;
Jun 15, 2011
Jun 15, 2011
17
18
const THEORAPLAY_VideoFrame *video = NULL;
const THEORAPLAY_AudioPacket *audio = NULL;
Jun 10, 2011
Jun 10, 2011
19
Jun 15, 2011
Jun 15, 2011
20
printf("Trying file '%s' ...\n", fname);
Jun 23, 2011
Jun 23, 2011
21
decoder = THEORAPLAY_startDecodeFile(fname, 20, vidfmt);
Jun 15, 2011
Jun 15, 2011
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
while (THEORAPLAY_isDecoding(decoder))
{
video = THEORAPLAY_getVideo(decoder);
if (video)
{
printf("Got video frame (%u ms)!\n", video->playms);
THEORAPLAY_freeVideo(video);
} // if
audio = THEORAPLAY_getAudio(decoder);
if (audio)
{
printf("Got %d frames of audio (%u ms)!\n", audio->frames, audio->playms);
THEORAPLAY_freeAudio(audio);
} // if
if (!video && !audio)
usleep(10000);
} // while
if (THEORAPLAY_decodingError(decoder))
printf("There was an error decoding this file!\n");
else
printf("done with this file!\n");
THEORAPLAY_stopDecode(decoder);
} // dofile
int main(int argc, char **argv)
{
THEORAPLAY_VideoFormat vidfmt = THEORAPLAY_VIDFMT_YV12;
Jun 10, 2011
Jun 10, 2011
53
int i;
Jun 15, 2011
Jun 15, 2011
54
Jun 10, 2011
Jun 10, 2011
55
56
for (i = 1; i < argc; i++)
{
Jun 15, 2011
Jun 15, 2011
57
58
59
60
61
62
if (strcmp(argv[i], "--rgb") == 0)
vidfmt = THEORAPLAY_VIDFMT_RGB;
else if (strcmp(argv[i], "--rgba") == 0)
vidfmt = THEORAPLAY_VIDFMT_RGBA;
else if (strcmp(argv[i], "--yv12") == 0)
vidfmt = THEORAPLAY_VIDFMT_YV12;
Jun 10, 2011
Jun 10, 2011
63
else
Jun 15, 2011
Jun 15, 2011
64
dofile(argv[i], vidfmt);
Jun 10, 2011
Jun 10, 2011
65
66
67
68
69
70
71
} // for
printf("done all files!\n");
return 0;
} // main
// end of testtheoraplay.c ...