|
SDL_kitchensink
|
Video/Audio source file handling. More...
Go to the source code of this file.
Data Structures | |
| struct | Kit_Source |
| Audio/video source. More... | |
| struct | Kit_SourceStreamInfo |
| Information for a source stream. More... | |
Typedefs | |
| typedef enum Kit_StreamType | Kit_StreamType |
| Type of the stream. | |
| typedef struct Kit_Source | Kit_Source |
| Audio/video source. | |
| typedef struct Kit_SourceStreamInfo | Kit_SourceStreamInfo |
| Information for a source stream. | |
| typedef int(* | Kit_ReadCallback) (void *userdata, uint8_t *buf, int size) |
| Callback function type for reading data stream. | |
| typedef int64_t(* | Kit_SeekCallback) (void *userdata, int64_t offset, int whence) |
| Callback function type for seeking data stream. | |
Enumerations | |
| enum | Kit_StreamType { KIT_STREAMTYPE_UNKNOWN , KIT_STREAMTYPE_VIDEO , KIT_STREAMTYPE_AUDIO , KIT_STREAMTYPE_DATA , KIT_STREAMTYPE_SUBTITLE , KIT_STREAMTYPE_ATTACHMENT } |
| Type of the stream. More... | |
Functions | |
| KIT_API Kit_Source * | Kit_CreateSourceFromUrl (const char *url) |
| Create a new source from a given url. | |
| KIT_API Kit_Source * | Kit_CreateSourceFromCustom (Kit_ReadCallback read_cb, Kit_SeekCallback seek_cb, void *userdata) |
| Create a new source from custom data. | |
| KIT_API Kit_Source * | Kit_CreateSourceFromRW (SDL_RWops *rw_ops) |
| Create a new source from SDL RWops struct. | |
| KIT_API void | Kit_CloseSource (Kit_Source *src) |
| Closes a previously initialized source. | |
| KIT_API int | Kit_GetSourceStreamInfo (const Kit_Source *src, Kit_SourceStreamInfo *info, int index) |
| Fetches stream information for a given stream index. | |
| KIT_API int | Kit_GetSourceStreamCount (const Kit_Source *src) |
| Gets the amount of streams in source. | |
| KIT_API int | Kit_GetBestSourceStream (const Kit_Source *src, const Kit_StreamType type) |
| Gets the best stream index for a given stream type. | |
Video/Audio source file handling.
| typedef int(* Kit_ReadCallback) (void *userdata, uint8_t *buf, int size) |
Callback function type for reading data stream.
Used by Kit_CreateSourceFromCustom() for reading data from user defined source.
A custom reader function must accept three arguments:
The function must return the amount of bytes copied to the buffer or <0 on error.
Note that this callback is passed directly to ffmpeg avio, so please refer to ffmpeg documentation for any further details.
| typedef int64_t(* Kit_SeekCallback) (void *userdata, int64_t offset, int whence) |
Callback function type for seeking data stream.
Used by Kit_CreateSourceFromCustom() for seeking a user defined source.
A custom seeking function must accept three arguments:
Whence parameter can be one of the standard fseek values or optionally AVSEEK_SIZE.
The function must return the position (in bytes) we seeked to or <0 on error or on unsupported operation.
Note that this callback is passed directly to ffmpeg avio, so please refer to ffmpeg documentation for any further details.
| typedef struct Kit_Source Kit_Source |
Audio/video source.
Should be created using Kit_CreateSourceFromUrl() or Kit_CreateSourceFromCustom(), and closed with Kit_CloseSource().
Source must exist for the whole duration of using a player. You must take care of closing the source yourself after you are done with it!
| typedef struct Kit_SourceStreamInfo Kit_SourceStreamInfo |
Information for a source stream.
Fetch information by using Kit_GetSourceStreamInfo().
| typedef enum Kit_StreamType Kit_StreamType |
Type of the stream.
This is used by Kit_SourceStreamInfo and Kit_GetSourceStreamInfo().
| enum Kit_StreamType |
Type of the stream.
This is used by Kit_SourceStreamInfo and Kit_GetSourceStreamInfo().
| KIT_API void Kit_CloseSource | ( | Kit_Source * | src | ) |
Closes a previously initialized source.
Closes a Kit_Source that was previously created by Kit_CreateSourceFromUrl() or Kit_CreateSourceFromCustom() and frees up all memory and resources used by it. Using the source for anything after this will lead to undefined behaviour.
Passing NULL as argument is valid, and will do nothing.
| src | Previously initialized Kit_Source to close |
| KIT_API Kit_Source * Kit_CreateSourceFromCustom | ( | Kit_ReadCallback | read_cb, |
| Kit_SeekCallback | seek_cb, | ||
| void * | userdata | ||
| ) |
Create a new source from custom data.
This can be used to load data from any resource via the given read and seek functions.
This function will return an initialized Kit_Source on success. Note that you need to manually free the source when it's no longer needed by calling Kit_CloseSource().
On failure, this function will return NULL, and further error data is available via Kit_GetError().
For example:
| read_cb | Read function callback |
| seek_cb | Seek function callback |
| userdata | Any data (or NULL). Will be passed to read_cb and/or seek_cb functions as-is. |
| KIT_API Kit_Source * Kit_CreateSourceFromRW | ( | SDL_RWops * | rw_ops | ) |
Create a new source from SDL RWops struct.
Can be used to read data from SDL compatible sources.
This function will return an initialized Kit_Source on success. Note that you need to manually free the source when it's no longer needed by calling Kit_CloseSource().
On failure, this function will return NULL, and further error data is available via Kit_GetError().
Note that the RWops struct must exist during the whole lifetime of the source, and you must take care of freeing the rwops after it's no longer needed.
For example:
| rw_ops | Initialized RWOps |
| KIT_API Kit_Source * Kit_CreateSourceFromUrl | ( | const char * | url | ) |
Create a new source from a given url.
This can be used to load video/audio from a file or network resource. If you wish to use network resources, make sure the library has been initialized using KIT_INIT_NETWORK flag.
This function will return an initialized Kit_Source on success. Note that you need to manually free the source when it's no longer needed by calling Kit_CloseSource().
On failure, this function will return NULL, and further error data is available via Kit_GetError().
For example:
| url | File path or URL to a video/audio resource |
| KIT_API int Kit_GetBestSourceStream | ( | const Kit_Source * | src, |
| const Kit_StreamType | type | ||
| ) |
Gets the best stream index for a given stream type.
Find the best stream index for a given stream type, if one exists. If there is no stream for the wanted type, will return -1.
| src | Source to query from |
| type | Stream type |
| KIT_API int Kit_GetSourceStreamCount | ( | const Kit_Source * | src | ) |
Gets the amount of streams in source.
| src | Source to query from |
| KIT_API int Kit_GetSourceStreamInfo | ( | const Kit_Source * | src, |
| Kit_SourceStreamInfo * | info, | ||
| int | index | ||
| ) |
Fetches stream information for a given stream index.
Sets fields for given Kit_SourceStreamInfo with information about the stream.
For example:
| src | Source to query from |
| info | A previously allocated Kit_SourceStreamInfo to fill out |
| index | Stream index (starting from 0) |