diff options
author | Tuomas Virtanen <katajakasa@gmail.com> | 2016-01-17 04:26:41 +0200 |
---|---|---|
committer | Tuomas Virtanen <katajakasa@gmail.com> | 2016-01-17 04:26:41 +0200 |
commit | 417a6816814e09a26aafc6475b2b9bbc2971dc7d (patch) | |
tree | 6b5f95874f8653b8d3e8e52864a4897f08deac66 /include/kitchensink | |
parent | cd610394c6798884ff416bf9a91a55bae3a6971f (diff) | |
parent | fc53e3f37288e55cfbc6ab4c488107e31017daed (diff) |
Merge pull request #11 from katajakasa/ttv-subtitle-stream
Subtitle support
Diffstat (limited to 'include/kitchensink')
-rw-r--r-- | include/kitchensink/internal/kitbuffer.h | 12 | ||||
-rw-r--r-- | include/kitchensink/internal/kitlist.h | 26 | ||||
-rw-r--r-- | include/kitchensink/kitplayer.h | 21 | ||||
-rw-r--r-- | include/kitchensink/kitsource.h | 5 |
4 files changed, 57 insertions, 7 deletions
diff --git a/include/kitchensink/internal/kitbuffer.h b/include/kitchensink/internal/kitbuffer.h index 19a0c79..4d0f8cc 100644 --- a/include/kitchensink/internal/kitbuffer.h +++ b/include/kitchensink/internal/kitbuffer.h @@ -3,16 +3,22 @@ #include "kitchensink/kitconfig.h" -typedef struct Kit_Buffer { +typedef struct Kit_Buffer Kit_Buffer; + +typedef void (*Kit_BufferFreeCallback)(void*); + +struct Kit_Buffer { unsigned int read_p; unsigned int write_p; unsigned int size; + Kit_BufferFreeCallback free_cb; void **data; -} Kit_Buffer; +}; -KIT_LOCAL Kit_Buffer* Kit_CreateBuffer(unsigned int size); +KIT_LOCAL Kit_Buffer* Kit_CreateBuffer(unsigned int size, Kit_BufferFreeCallback free_cb); KIT_LOCAL void Kit_DestroyBuffer(Kit_Buffer *buffer); +KIT_LOCAL void Kit_ClearBuffer(Kit_Buffer *buffer); KIT_LOCAL void* Kit_ReadBuffer(Kit_Buffer *buffer); KIT_LOCAL void* Kit_PeekBuffer(const Kit_Buffer *buffer); KIT_LOCAL void Kit_AdvanceBuffer(Kit_Buffer *buffer); diff --git a/include/kitchensink/internal/kitlist.h b/include/kitchensink/internal/kitlist.h new file mode 100644 index 0000000..85e3e3f --- /dev/null +++ b/include/kitchensink/internal/kitlist.h @@ -0,0 +1,26 @@ +#ifndef KITLIST_H +#define KITLIST_H + +#include "kitchensink/kitconfig.h" + +typedef struct Kit_List Kit_List; + +typedef void (*Kit_ListFreeCallback)(void*); + +struct Kit_List { + unsigned int size; + unsigned int length; + Kit_ListFreeCallback free_cb; + void **data; +}; + +KIT_LOCAL Kit_List* Kit_CreateList(unsigned int size, Kit_ListFreeCallback free_cb); +KIT_LOCAL void Kit_DestroyList(Kit_List *list); + +KIT_LOCAL void Kit_ClearList(Kit_List *list); +KIT_LOCAL void Kit_RemoveFromList(Kit_List *list, unsigned int iterator); +KIT_LOCAL void* Kit_IterateList(const Kit_List *list, unsigned int *iterator); +KIT_LOCAL int Kit_WriteList(Kit_List *list, void *ptr); +KIT_LOCAL int Kit_GetListLength(const Kit_List *list); + +#endif // KITLIST_H diff --git a/include/kitchensink/kitplayer.h b/include/kitchensink/kitplayer.h index a0f97ad..1d1f5f9 100644 --- a/include/kitchensink/kitplayer.h +++ b/include/kitchensink/kitplayer.h @@ -6,6 +6,7 @@ #include <SDL2/SDL_render.h> #include <SDL2/SDL_thread.h> +#include <SDL2/SDL_surface.h> #include <stdbool.h> @@ -24,6 +25,7 @@ typedef enum Kit_PlayerState { } Kit_PlayerState; typedef struct Kit_AudioFormat { + int stream_idx; ///< Stream index bool is_enabled; ///< Is stream enabled unsigned int format; ///< SDL Audio Format bool is_signed; ///< Signedness @@ -33,17 +35,24 @@ typedef struct Kit_AudioFormat { } Kit_AudioFormat; typedef struct Kit_VideoFormat { - bool is_enabled; ///<Is stream enabled + int stream_idx; ///< Stream index + bool is_enabled; ///< Is stream enabled unsigned int format; ///< SDL Pixel Format int width; ///< Width in pixels int height; ///< Height in pixels } Kit_VideoFormat; +typedef struct Kit_SubtitleFormat { + int stream_idx; ///< Stream index + bool is_enabled; ///< Is stream enabled +} Kit_SubtitleFormat; + typedef struct Kit_Player { // Local state Kit_PlayerState state; ///< Playback state Kit_VideoFormat vformat; ///< Video format information Kit_AudioFormat aformat; ///< Audio format information + Kit_SubtitleFormat sformat; ///< Subtitle format information // Synchronization double clock_sync; ///< Clock sync point @@ -54,18 +63,22 @@ typedef struct Kit_Player { SDL_Thread *dec_thread; ///< Decoder thread SDL_mutex *vmutex; ///< Video stream buffer lock SDL_mutex *amutex; ///< Audio stream buffer lock + SDL_mutex *smutex; ///< Subtitle stream buffer lock SDL_mutex *cmutex; ///< Control stream buffer lock // Buffers void *abuffer; ///<Audio stream buffer void *vbuffer; ///< Video stream buffer + void *sbuffer; ///< Subtitle stream buffer void *cbuffer; ///< Control stream buffer // FFmpeg internal state void *vcodec_ctx; ///< FFmpeg: Video codec context void *acodec_ctx; ///< FFmpeg: Audio codec context + void *scodec_ctx; ///< FFmpeg: Subtitle codec context void *tmp_vframe; ///< FFmpeg: Preallocated temporary video frame void *tmp_aframe; ///< FFmpeg: Preallocated temporary audio frame + void *tmp_sframe; ///< FFmpeg: Preallocated temporary subtitle frame void *swr; ///< FFmpeg: Audio resampler void *sws; ///< FFmpeg: Video converter @@ -79,15 +92,19 @@ typedef struct Kit_PlayerInfo { char acodec_name[KIT_CODECNAMEMAX]; ///< Audio codec long, more descriptive name char vcodec[KIT_CODECMAX]; ///< Video codec short name, eg. "x264" char vcodec_name[KIT_CODECNAMEMAX]; ///< Video codec long, more descriptive name + char scodec[KIT_CODECMAX]; ///< Subtitle codec short name, eg. "ass" + char scodec_name[KIT_CODECNAMEMAX]; ///< Subtitle codec long, more descriptive name Kit_VideoFormat video; ///< Video format information Kit_AudioFormat audio; ///< Audio format information + Kit_SubtitleFormat subtitle; ///< Subtitle format information } 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_GetVideoData(Kit_Player *player, SDL_Texture *texture); +KIT_API int Kit_GetSubtitleData(Kit_Player *player, SDL_Renderer *renderer); KIT_API int Kit_GetAudioData(Kit_Player *player, unsigned char *buffer, int length, int cur_buf_len); KIT_API void Kit_GetPlayerInfo(const Kit_Player *player, Kit_PlayerInfo *info); diff --git a/include/kitchensink/kitsource.h b/include/kitchensink/kitsource.h index aef9764..ed1711f 100644 --- a/include/kitchensink/kitsource.h +++ b/include/kitchensink/kitsource.h @@ -20,8 +20,9 @@ typedef enum Kit_StreamType { } Kit_StreamType; typedef struct Kit_Source { - int astream_idx; ///< Audiostream index - int vstream_idx; ///< Videostream index + int astream_idx; ///< Audio stream index + int vstream_idx; ///< Video stream index + int sstream_idx; ///< Subtitle stream index void *format_ctx; ///< FFmpeg: Videostream format context } Kit_Source; |