Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Split this up into separate files.
- Loading branch information
Showing
3 changed files
with
116 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* 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> | ||
#include "theoraplay.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
THEORAPLAY_Decoder *decoder; | ||
const THEORAPLAY_YuvVideoItem *video = NULL; | ||
const THEORAPLAY_PcmAudioItem *audio = NULL; | ||
|
||
int i; | ||
for (i = 1; i < argc; i++) | ||
{ | ||
printf("Trying file '%s' ...\n", argv[i]); | ||
decoder = THEORAPLAY_startDecode(argv[i], 20); | ||
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 | ||
|
||
printf("done with this file!\n"); | ||
THEORAPLAY_stopDecode(decoder); | ||
} // for | ||
|
||
printf("done all files!\n"); | ||
return 0; | ||
} // main | ||
|
||
// end of testtheoraplay.c ... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
#ifndef _INCL_THEORAPLAY_H_ | ||
#define _INCL_THEORAPLAY_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct THEORAPLAY_Decoder THEORAPLAY_Decoder; | ||
|
||
typedef struct THEORAPLAY_YuvVideoItem | ||
{ | ||
unsigned int playms; | ||
unsigned int width; | ||
unsigned int height; | ||
unsigned char *yuv; | ||
struct THEORAPLAY_YuvVideoItem *next; | ||
} THEORAPLAY_YuvVideoItem; | ||
|
||
typedef struct THEORAPLAY_PcmAudioItem | ||
{ | ||
unsigned int playms; // playback start time in milliseconds. | ||
int channels; | ||
int frames; | ||
float *samples; // frames * channels float32 samples. | ||
struct THEORAPLAY_PcmAudioItem *next; | ||
} THEORAPLAY_PcmAudioItem; | ||
|
||
THEORAPLAY_Decoder *THEORAPLAY_startDecode(const char *fname, | ||
const unsigned int maxframes); | ||
void THEORAPLAY_stopDecode(THEORAPLAY_Decoder *decoder); | ||
int THEORAPLAY_isDecoding(THEORAPLAY_Decoder *decoder); | ||
|
||
const THEORAPLAY_PcmAudioItem *THEORAPLAY_getAudio(THEORAPLAY_Decoder *decoder); | ||
void THEORAPLAY_freeAudio(const THEORAPLAY_PcmAudioItem *item); | ||
|
||
const THEORAPLAY_YuvVideoItem *THEORAPLAY_getVideo(THEORAPLAY_Decoder *decoder); | ||
void THEORAPLAY_freeVideo(const THEORAPLAY_YuvVideoItem *item); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* include-once blocker. */ | ||
|
||
/* end of theoraplay.h ... */ | ||
|