zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
alffmpeg.h
Go to the documentation of this file.
1 #ifndef ALFFMPEG_H
2 #define ALFFMPEG_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif /* __cplusplus */
7 
8 #include <libavcodec/avcodec.h>
9 #include <libavformat/avformat.h>
10 
11 /* Opaque handles to files and streams. Apps don't need to concern themselves
12  * with the internals */
13 typedef struct MyFile *FilePtr;
14 typedef struct MyStream *StreamPtr;
15 
16 /* Opens a file with ffmpeg and sets up the streams' information */
17 FilePtr openAVFile(const char *fname);
18 
19 /* Opens a named file image with ffmpeg and sets up the streams' information */
20 FilePtr openAVData(const char *name, char *buffer, size_t buffer_len);
21 
22 /* Opens a named data stream with ffmpeg, using the specified data pointer and
23  * callbacks, and sets up the streams' information */
24 FilePtr openAVCustom(const char *name, void *user_data,
25  int (*read_packet)(void *user_data, uint8_t *buf, int buf_size),
26  int (*write_packet)(void *user_data, uint8_t *buf, int buf_size),
27  int64_t (*seek)(void *user_data, int64_t offset, int whence));
28 
29 /* Closes/frees an opened file and any of its streams */
30 void closeAVFile(FilePtr file);
31 
32 /* Reports certain information from the file, eg, the number of audio
33  * streams. Returns 0 on success. */
34 int getAVFileInfo(FilePtr file, int *numaudiostreams);
35 
36 /* Retrieves a handle for the given audio stream number (generally 0, but some
37  * files can have multiple audio streams in one file). */
38 StreamPtr getAVAudioStream(FilePtr file, int streamnum);
39 
40 /* Returns information about the given audio stream. Returns 0 on success. */
41 int getAVAudioInfo(StreamPtr stream, ALuint *rate, ALenum *channels, ALenum *type);
42 
43 /* Returns a pointer to the next available packet of decoded audio. Any data
44  * from a previously-decoded packet is dropped. The size (in bytes) of the
45  * returned data buffer is stored in 'length', and the returned pointer is only
46  * valid until the next call to getAVAudioData or readAVAudioData. */
47 uint8_t *getAVAudioData(StreamPtr stream, size_t *length);
48 
49 /* The "meat" function. Decodes audio and writes, at most, length bytes into
50  * the provided data buffer. Will only return less for end-of-stream or error
51  * conditions. Returns the number of bytes written. */
52 size_t readAVAudioData(StreamPtr stream, void *data, size_t length);
53 
54 /* Decodes all remaining data from the stream and returns a buffer containing
55  * the audio data, with the size stored in 'length'. The returned pointer must
56  * be freed with a call to free(). Note that since this decodes the whole
57  * stream, using it on lengthy streams (eg, music) will use a lot of memory.
58  * Such streams are better handled using getAVAudioData or readAVAudioData to
59  * keep smaller chunks in memory at any given time. */
60 void *decodeAVAudioStream(StreamPtr stream, size_t *length);
61 
62 #ifdef __cplusplus
63 }
64 #endif /* __cplusplus */
65 
66 #endif /* ALFFMPEG_H */
struct MyFile * FilePtr
Definition: alffmpeg.h:13
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
long long int64_t
Definition: types.h:10
FilePtr openAVFile(const char *fname)
Definition: alffmpeg.c:161
GLuint GLuint stream
Definition: glew.h:6573
void * decodeAVAudioStream(StreamPtr stream, size_t *length)
Definition: alffmpeg.c:611
FilePtr openAVData(const char *name, char *buffer, size_t buffer_len)
Definition: alffmpeg.c:185
FILE * file
Definition: visualinfo.c:88
EGLImageKHR EGLint * name
Definition: eglext.h:284
FilePtr openAVCustom(const char *name, void *user_data, int(*read_packet)(void *user_data, uint8_t *buf, int buf_size), int(*write_packet)(void *user_data, uint8_t *buf, int buf_size), int64_t(*seek)(void *user_data, int64_t offset, int whence))
Definition: alffmpeg.c:221
size_t readAVAudioData(StreamPtr stream, void *data, size_t length)
Definition: alffmpeg.c:567
StreamPtr getAVAudioStream(FilePtr file, int streamnum)
Definition: alffmpeg.c:318
EGLContext EGLenum EGLClientBuffer buffer
Definition: eglext.h:87
GLsizei GLsizei * length
Definition: gl2ext.h:792
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
struct MyStream * StreamPtr
Definition: alffmpeg.h:14
int ALenum
Definition: al.h:65
unsigned int ALuint
Definition: al.h:59
unsigned char uint8_t
int getAVFileInfo(FilePtr file, int *numaudiostreams)
Definition: alffmpeg.c:303
GLintptr offset
Definition: glew.h:1668
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2539
uint8_t * getAVAudioData(StreamPtr stream, size_t *length)
Definition: alffmpeg.c:503
void closeAVFile(FilePtr file)
Definition: alffmpeg.c:271
int getAVAudioInfo(StreamPtr stream, ALuint *rate, ALenum *channels, ALenum *type)
Definition: alffmpeg.c:392