diff options
author | Tuomas Virtanen <katajakasa@gmail.com> | 2016-01-08 01:29:36 +0200 |
---|---|---|
committer | Tuomas Virtanen <katajakasa@gmail.com> | 2016-01-08 01:29:36 +0200 |
commit | cce3ee047e712f48059ed28b284cf5c194c34de8 (patch) | |
tree | b13dd1a2bb2eb1094d597d30c70002a166caf3ac /include | |
parent | d843d120ae3d87548e10f7ee0ded71a301d5d4b3 (diff) |
Code dump. Playback & decoding works, but no sync yet.
Diffstat (limited to 'include')
-rw-r--r-- | include/kitchensink/internal/kitbuffer.h | 20 | ||||
-rw-r--r-- | include/kitchensink/internal/kitringbuffer.h | 22 | ||||
-rw-r--r-- | include/kitchensink/kitchensink.h | 19 | ||||
-rw-r--r-- | include/kitchensink/kitconfig.h | 26 | ||||
-rw-r--r-- | include/kitchensink/kiterror.h | 8 | ||||
-rw-r--r-- | include/kitchensink/kitplayer.h | 56 | ||||
-rw-r--r-- | include/kitchensink/kitsource.h | 23 |
7 files changed, 142 insertions, 32 deletions
diff --git a/include/kitchensink/internal/kitbuffer.h b/include/kitchensink/internal/kitbuffer.h new file mode 100644 index 0000000..772edf1 --- /dev/null +++ b/include/kitchensink/internal/kitbuffer.h @@ -0,0 +1,20 @@ +#ifndef KITBUFFER_H +#define KITBUFFER_H + +#include "kitchensink/kitconfig.h" + +typedef struct Kit_Buffer { + unsigned int read_p; + unsigned int write_p; + unsigned int size; + void **data; +} Kit_Buffer; + +KIT_LOCAL Kit_Buffer* Kit_CreateBuffer(unsigned int size); +KIT_LOCAL void Kit_DestroyBuffer(Kit_Buffer *buffer); + +KIT_LOCAL void* Kit_ReadBuffer(Kit_Buffer *buffer); +KIT_LOCAL int Kit_WriteBuffer(Kit_Buffer *buffer, void *ptr); +KIT_LOCAL int Kit_IsBufferFull(const Kit_Buffer *buffer); + +#endif // KITBUFFER_H diff --git a/include/kitchensink/internal/kitringbuffer.h b/include/kitchensink/internal/kitringbuffer.h new file mode 100644 index 0000000..773ba29 --- /dev/null +++ b/include/kitchensink/internal/kitringbuffer.h @@ -0,0 +1,22 @@ +#ifndef KITRINGBUFFER_H +#define KITRINGBUFFER_H + +#include "kitchensink/kitconfig.h" + +typedef struct Kit_RingBuffer { + int size; + int len; + int wpos, rpos; + char* data; +} Kit_RingBuffer; + +KIT_LOCAL Kit_RingBuffer* Kit_CreateRingBuffer(unsigned int size); +KIT_LOCAL void Kit_DestroyRingBuffer(Kit_RingBuffer* rb); +KIT_LOCAL int Kit_WriteRingBuffer(Kit_RingBuffer *rb, const char* data, int len); +KIT_LOCAL int Kit_ReadRingBuffer(Kit_RingBuffer *rb, char* data, int len); +KIT_LOCAL int Kit_PeekRingBuffer(const Kit_RingBuffer *rb, char* data, int len); +KIT_LOCAL int Kit_AdvanceRingBuffer(Kit_RingBuffer *rb, int len); +KIT_LOCAL int Kit_GetRingBufferLength(const Kit_RingBuffer *rb); +KIT_LOCAL int Kit_GetRingBufferSize(const Kit_RingBuffer *rb); + +#endif // KITRINGBUFFER_H diff --git a/include/kitchensink/kitchensink.h b/include/kitchensink/kitchensink.h index 6ece77c..3120db7 100644 --- a/include/kitchensink/kitchensink.h +++ b/include/kitchensink/kitchensink.h @@ -1,24 +1,19 @@ #ifndef KITCHENSINK_H #define KITCHENSINK_H -#include <SDL2/SDL.h> #include "kitchensink/kiterror.h" #include "kitchensink/kitsource.h" #include "kitchensink/kitplayer.h" +#include "kitchensink/kitconfig.h" #ifdef __cplusplus extern "C" { #endif -#define KIT_VERSION(x) \ - (x)->major = KIT_VERSION_MAJOR; \ - (x)->minor = KIT_VERSION_MINOR; \ - (x)->patch = KIT_VERSION_PATCH - typedef struct Kit_Version { - Uint8 major; - Uint8 minor; - Uint8 patch; + unsigned char major; + unsigned char minor; + unsigned char patch; } Kit_Version; enum { @@ -26,10 +21,10 @@ enum { KIT_INIT_NETWORK = 0x2, }; -int Kit_Init(); -void Kit_Quit(); +KIT_API int Kit_Init(unsigned int flags); +KIT_API void Kit_Quit(); -void Kit_GetVersion(Kit_Version *version); +KIT_API void Kit_GetVersion(Kit_Version *version); #ifdef __cplusplus } diff --git a/include/kitchensink/kitconfig.h b/include/kitchensink/kitconfig.h new file mode 100644 index 0000000..e8b2d01 --- /dev/null +++ b/include/kitchensink/kitconfig.h @@ -0,0 +1,26 @@ +#ifndef KITCONFIG_H +#define KITCONFIG_H + +#if defined _WIN32 || defined __CYGWIN__ + #define KIT_DLL_IMPORT __declspec(dllimport) + #define KIT_DLL_EXPORT __declspec(dllexport) + #define KIT_DLL_LOCAL +#else + #define KIT_DLL_IMPORT __attribute__ ((visibility ("default"))) + #define KIT_DLL_EXPORT __attribute__ ((visibility ("default"))) + #define KIT_DLL_LOCAL __attribute__ ((visibility ("hidden"))) +#endif + +#ifdef KIT_DLL + #ifdef KIT_DLL_EXPORTS + #define KIT_API KIT_DLL_EXPORT + #else + #define KIT_API KIT_DLL_IMPORT + #endif + #define KIT_LOCAL KIT_DLL_LOCAL +#else + #define KIT_API + #define KIT_LOCAL +#endif + +#endif // KITCONFIG_H diff --git a/include/kitchensink/kiterror.h b/include/kitchensink/kiterror.h index 1b88f89..824ea8c 100644 --- a/include/kitchensink/kiterror.h +++ b/include/kitchensink/kiterror.h @@ -1,13 +1,15 @@ #ifndef KITERROR_H #define KITERROR_H +#include "kitchensink/kitconfig.h" + #ifdef __cplusplus extern "C" { #endif -const char* Kit_GetError(); -void Kit_SetError(const char* fmt, ...); -void Kit_ClearError(); +KIT_API const char* Kit_GetError(); +KIT_API void Kit_SetError(const char* fmt, ...); +KIT_API void Kit_ClearError(); #ifdef __cplusplus } diff --git a/include/kitchensink/kitplayer.h b/include/kitchensink/kitplayer.h index 3c88920..a4edb9b 100644 --- a/include/kitchensink/kitplayer.h +++ b/include/kitchensink/kitplayer.h @@ -2,19 +2,69 @@ #define KITPLAYER_H #include "kitchensink/kitsource.h" +#include "kitchensink/kitconfig.h" +#include <stdbool.h> + +#include <SDL2/SDL_render.h> #ifdef __cplusplus extern "C" { #endif -typedef struct Kit_Player { +#define KIT_CODECMAX 16 +#define KIT_CODECNAMEMAX 128 +#define KIT_VBUFFERSIZE 3 +#define KIT_ABUFFERSIZE 65536 + +typedef enum Kit_PlayerState { + KIT_STOPPED = 0, + KIT_PLAYING, + KIT_FINISHED +} Kit_PlayerState; +typedef struct Kit_AudioFormat { + int bytes; + bool is_signed; + int samplerate; + int channels; +} Kit_AudioFormat; + +typedef struct Kit_VideoFormat { + unsigned int format; + int width; + int height; +} Kit_VideoFormat; + +typedef struct Kit_Player { + Kit_PlayerState state; + Kit_VideoFormat vformat; + Kit_AudioFormat aformat; + void *abuffer; + void *vbuffer; + void *vcodec_ctx; + void *acodec_ctx; + void *swr; + void *sws; + const Kit_Source *src; } Kit_Player; -Kit_Player* Kit_CreatePlayer(Kit_Source *src); -void Kit_ClosePlayer(Kit_Player *player); +typedef struct Kit_PlayerInfo { + char acodec[KIT_CODECMAX]; + char acodec_name[KIT_CODECNAMEMAX]; + char vcodec[KIT_CODECMAX]; + char vcodec_name[KIT_CODECNAMEMAX]; + Kit_VideoFormat video; + Kit_AudioFormat audio; +} Kit_PlayerInfo; +KIT_API Kit_Player* Kit_CreatePlayer(const Kit_Source *src); +KIT_API void Kit_ClosePlayer(Kit_Player *player); +KIT_API int Kit_UpdatePlayer(Kit_Player *player); +KIT_API int Kit_RefreshTexture(Kit_Player *player, SDL_Texture *texture); +KIT_API int Kit_GetAudioData(Kit_Player *player, unsigned char *buffer, size_t length); +KIT_API int Kit_GetPlayerState(Kit_Player *player); +KIT_API void Kit_GetPlayerInfo(const Kit_Player *player, Kit_PlayerInfo *info); #ifdef __cplusplus } diff --git a/include/kitchensink/kitsource.h b/include/kitchensink/kitsource.h index 2b72e88..43b9d2b 100644 --- a/include/kitchensink/kitsource.h +++ b/include/kitchensink/kitsource.h @@ -1,6 +1,8 @@ #ifndef KITSOURCE_H #define KITSOURCE_H +#include "kitchensink/kitconfig.h" + #ifdef __cplusplus extern "C" { #endif @@ -21,28 +23,21 @@ typedef struct Kit_Source { int astream_idx; int vstream_idx; void *format_ctx; - void *vcodec_ctx; - void *acodec_ctx; - void *vcodec; - void *acodec; } Kit_Source; typedef struct Kit_Stream { int index; Kit_streamtype type; - int width; - int height; } Kit_StreamInfo; -Kit_Source* Kit_CreateSourceFromUrl(const char *path); -int Kit_InitSourceCodecs(Kit_Source *src); -void Kit_CloseSource(Kit_Source *src); +KIT_API Kit_Source* Kit_CreateSourceFromUrl(const char *path); +KIT_API void Kit_CloseSource(Kit_Source *src); -int Kit_GetSourceStreamInfo(const Kit_Source *src, Kit_StreamInfo *info, int index); -int Kit_GetSourceStreamCount(const Kit_Source *src); -int Kit_GetBestSourceStream(const Kit_Source *src, const Kit_streamtype type); -int Kit_SetSourceStream(Kit_Source *src, const Kit_streamtype type, int index); -int Kit_GetSourceStream(const Kit_Source *src, const Kit_streamtype type); +KIT_API int Kit_GetSourceStreamInfo(const Kit_Source *src, Kit_StreamInfo *info, int index); +KIT_API int Kit_GetSourceStreamCount(const Kit_Source *src); +KIT_API int Kit_GetBestSourceStream(const Kit_Source *src, const Kit_streamtype type); +KIT_API int Kit_SetSourceStream(Kit_Source *src, const Kit_streamtype type, int index); +KIT_API int Kit_GetSourceStream(const Kit_Source *src, const Kit_streamtype type); #ifdef __cplusplus } |