summaryrefslogtreecommitdiff
path: root/include/kitchensink
diff options
context:
space:
mode:
Diffstat (limited to 'include/kitchensink')
-rw-r--r--include/kitchensink/internal/audio/kitaudio.h12
-rw-r--r--include/kitchensink/internal/kitdecoder.h56
-rw-r--r--include/kitchensink/internal/kitlibstate.h3
-rw-r--r--include/kitchensink/internal/kitlist.h26
-rw-r--r--include/kitchensink/internal/libass.h57
-rw-r--r--include/kitchensink/internal/subtitle/kitsubtitle.h14
-rw-r--r--include/kitchensink/internal/subtitle/kitsubtitlepacket.h18
-rw-r--r--include/kitchensink/internal/subtitle/renderers/kitsubass.h10
-rw-r--r--include/kitchensink/internal/subtitle/renderers/kitsubimage.h10
-rw-r--r--include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h23
-rw-r--r--include/kitchensink/internal/utils/kitbuffer.h (renamed from include/kitchensink/internal/kitbuffer.h)2
-rw-r--r--include/kitchensink/internal/utils/kithelpers.h11
-rw-r--r--include/kitchensink/internal/utils/kitlog.h11
-rw-r--r--include/kitchensink/internal/utils/kitringbuffer.h (renamed from include/kitchensink/internal/kitringbuffer.h)0
-rw-r--r--include/kitchensink/internal/video/kitvideo.h12
-rw-r--r--include/kitchensink/kitchensink.h1
-rw-r--r--include/kitchensink/kitformats.h30
-rw-r--r--include/kitchensink/kitlib.h4
-rw-r--r--include/kitchensink/kitplayer.h87
-rw-r--r--include/kitchensink/kitsource.h8
20 files changed, 293 insertions, 102 deletions
diff --git a/include/kitchensink/internal/audio/kitaudio.h b/include/kitchensink/internal/audio/kitaudio.h
new file mode 100644
index 0000000..ac6753b
--- /dev/null
+++ b/include/kitchensink/internal/audio/kitaudio.h
@@ -0,0 +1,12 @@
+#ifndef KITAUDIO_H
+#define KITAUDIO_H
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitformats.h"
+#include "kitchensink/kitplayer.h"
+#include "kitchensink/internal/kitdecoder.h"
+
+KIT_LOCAL Kit_Decoder* Kit_CreateAudioDecoder(const Kit_Source *src, Kit_AudioFormat *format);
+KIT_LOCAL int Kit_GetAudioDecoderData(Kit_Decoder *dec, unsigned char *buf, int len);
+
+#endif // KITAUDIO_H
diff --git a/include/kitchensink/internal/kitdecoder.h b/include/kitchensink/internal/kitdecoder.h
new file mode 100644
index 0000000..6ec209e
--- /dev/null
+++ b/include/kitchensink/internal/kitdecoder.h
@@ -0,0 +1,56 @@
+#ifndef KITDECODER_H
+#define KITDECODER_H
+
+#include <stdbool.h>
+
+#include <SDL2/SDL_mutex.h>
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitsource.h"
+#include "kitchensink/internal/utils/kitbuffer.h"
+
+#define KIT_DEC_IN 0
+#define KIT_DEC_OUT 1
+
+typedef struct Kit_Decoder Kit_Decoder;
+
+typedef int (*dec_decode_cb)(Kit_Decoder *dec, AVPacket *in_packet);
+typedef void (*dec_close_cb)(Kit_Decoder *dec);
+typedef void (*dec_free_packet_cb)(void *packet);
+
+KIT_LOCAL struct Kit_Decoder {
+ int stream_index; ///< Source stream index for the current stream
+ double clock_sync; ///< Sync source for current stream
+ double clock_pos; ///< Current pts for the stream
+
+ AVCodecContext *codec_ctx; ///< FFMpeg internal: Codec context
+ AVFormatContext *format_ctx; ///< FFMpeg internal: Format context (owner: Kit_Source)
+
+ SDL_mutex *lock[2]; ///< Threading locks for input and output buffers
+ Kit_Buffer *buffer[2]; ///< Buffers for incoming and decoded packets
+
+ void *userdata; ///< Decoder specific information (Audio, video, subtitle context)
+ dec_decode_cb dec_decode; ///< Decoder decoding function callback
+ dec_close_cb dec_close; ///< Decoder close function callback
+};
+
+KIT_LOCAL Kit_Decoder* Kit_CreateDecoder(const Kit_Source *src, int stream_index,
+ int out_b_size, dec_free_packet_cb free_out_cb);
+KIT_LOCAL void Kit_SetDecoderClockSync(Kit_Decoder *dec, double sync);
+KIT_LOCAL void Kit_ChangeDecoderClockSync(Kit_Decoder *dec, double sync);
+KIT_LOCAL bool Kit_CanWriteDecoderInput(Kit_Decoder *dec);
+KIT_LOCAL int Kit_WriteDecoderInput(Kit_Decoder *dec, AVPacket *packet);
+KIT_LOCAL AVPacket* Kit_ReadDecoderInput(Kit_Decoder *dec);
+KIT_LOCAL int Kit_WriteDecoderOutput(Kit_Decoder *dec, void *packet);
+KIT_LOCAL void* Kit_PeekDecoderOutput(Kit_Decoder *dec);
+KIT_LOCAL void Kit_AdvanceDecoderOutput(Kit_Decoder *dec);
+KIT_LOCAL void Kit_ForEachDecoderOutput(Kit_Decoder *dec, Kit_ForEachItemCallback foreach_cb, void *userdata);
+KIT_LOCAL void Kit_ClearDecoderBuffers(Kit_Decoder *dec);
+KIT_LOCAL int Kit_RunDecoder(Kit_Decoder *dec);
+KIT_LOCAL void Kit_ClearDecoderInput(Kit_Decoder *dec);
+KIT_LOCAL void Kit_ClearDecoderOutput(Kit_Decoder *dec);
+KIT_LOCAL void Kit_CloseDecoder(Kit_Decoder *dec);
+
+#endif // KITDECODER_H
diff --git a/include/kitchensink/internal/kitlibstate.h b/include/kitchensink/internal/kitlibstate.h
index e16a5c9..ad515b9 100644
--- a/include/kitchensink/internal/kitlibstate.h
+++ b/include/kitchensink/internal/kitlibstate.h
@@ -1,12 +1,13 @@
#ifndef KITLIBSTATE_H
#define KITLIBSTATE_H
-#include <ass/ass.h>
+#include "kitchensink/internal/libass.h"
#include "kitchensink/kitconfig.h"
typedef struct Kit_LibraryState {
unsigned int init_flags;
ASS_Library *libass_handle;
+ void *ass_so_handle;
} Kit_LibraryState;
KIT_LOCAL Kit_LibraryState* Kit_GetLibraryState();
diff --git a/include/kitchensink/internal/kitlist.h b/include/kitchensink/internal/kitlist.h
deleted file mode 100644
index 85e3e3f..0000000
--- a/include/kitchensink/internal/kitlist.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#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/internal/libass.h b/include/kitchensink/internal/libass.h
new file mode 100644
index 0000000..0c9730a
--- /dev/null
+++ b/include/kitchensink/internal/libass.h
@@ -0,0 +1,57 @@
+#ifndef KITLIBASS_H
+#define KITLIBASS_H
+
+#ifndef USE_DYNAMIC_LIBASS
+
+#include <ass/ass.h>
+
+#else // USE_DYNAMIC_LIBASS
+
+#include <stdint.h>
+#include <stdarg.h>
+
+typedef struct ass_library ASS_Library;
+typedef struct ass_renderer ASS_Renderer;
+typedef struct ass_track ASS_Track;
+
+typedef struct ass_image {
+ int w, h;
+ int stride;
+ unsigned char *bitmap;
+ uint32_t color;
+ int dst_x, dst_y;
+ struct ass_image *next;
+ enum {
+ IMAGE_TYPE_CHARACTER,
+ IMAGE_TYPE_OUTLINE,
+ IMAGE_TYPE_SHADOW
+ } type;
+} ASS_Image;
+
+typedef enum {
+ ASS_HINTING_NONE = 0,
+ ASS_HINTING_LIGHT,
+ ASS_HINTING_NORMAL,
+ ASS_HINTING_NATIVE
+} ASS_Hinting;
+
+ASS_Library* (*ass_library_init)(void);
+void (*ass_library_done)(ASS_Library *priv);
+void (*ass_process_codec_private)(ASS_Track *track, char *data, int size);
+void (*ass_set_message_cb)(ASS_Library *priv, void (*msg_cb)(int level, const char *fmt, va_list args, void *data), void *data);
+ASS_Renderer* (*ass_renderer_init)(ASS_Library *);
+void (*ass_renderer_done)(ASS_Renderer *priv);
+void (*ass_set_frame_size)(ASS_Renderer *priv, int w, int h);
+void (*ass_set_hinting)(ASS_Renderer *priv, ASS_Hinting ht);
+void (*ass_set_fonts)(ASS_Renderer *priv, const char *default_font, const char *default_family, int dfp, const char *config, int update);
+ASS_Image* (*ass_render_frame)(ASS_Renderer *priv, ASS_Track *track, long long now, int *detect_change);
+ASS_Track* (*ass_new_track)(ASS_Library *);
+void (*ass_free_track)(ASS_Track *track);
+void (*ass_process_data)(ASS_Track *track, char *data, int size);
+void (*ass_add_font)(ASS_Library *library, char *name, char *data, int data_size);
+
+int load_libass(void *handle);
+
+#endif // USE_DYNAMIC_LIBASS
+
+#endif // KITLIBASS_H
diff --git a/include/kitchensink/internal/subtitle/kitsubtitle.h b/include/kitchensink/internal/subtitle/kitsubtitle.h
new file mode 100644
index 0000000..a8b4cc0
--- /dev/null
+++ b/include/kitchensink/internal/subtitle/kitsubtitle.h
@@ -0,0 +1,14 @@
+#ifndef KITSUBTITLE_H
+#define KITSUBTITLE_H
+
+#include <SDL2/SDL_render.h>
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitformats.h"
+#include "kitchensink/kitplayer.h"
+#include "kitchensink/internal/kitdecoder.h"
+
+KIT_LOCAL Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, Kit_SubtitleFormat *format, int w, int h);
+KIT_LOCAL int Kit_GetSubtitleDecoderDataTexture(Kit_Decoder *dec, SDL_Texture *texture);
+
+#endif // KITSUBTITLE_H
diff --git a/include/kitchensink/internal/subtitle/kitsubtitlepacket.h b/include/kitchensink/internal/subtitle/kitsubtitlepacket.h
new file mode 100644
index 0000000..e3ae4e4
--- /dev/null
+++ b/include/kitchensink/internal/subtitle/kitsubtitlepacket.h
@@ -0,0 +1,18 @@
+#ifndef KITSUBTITLEPACKET_H
+#define KITSUBTITLEPACKET_H
+
+#include <SDL2/SDL_surface.h>
+
+typedef struct Kit_SubtitlePacket {
+ double pts_start;
+ double pts_end;
+ int x;
+ int y;
+ SDL_Surface *surface;
+} Kit_SubtitlePacket;
+
+Kit_SubtitlePacket* Kit_CreateSubtitlePacket(
+ double pts_start, double pts_end, int pos_x, int pos_y, SDL_Surface *surface);
+void Kit_FreeSubtitlePacket(Kit_SubtitlePacket *packet);
+
+#endif // KITSUBTITLEPACKET_H
diff --git a/include/kitchensink/internal/subtitle/renderers/kitsubass.h b/include/kitchensink/internal/subtitle/renderers/kitsubass.h
new file mode 100644
index 0000000..39df3ac
--- /dev/null
+++ b/include/kitchensink/internal/subtitle/renderers/kitsubass.h
@@ -0,0 +1,10 @@
+#ifndef KITSUBASS_H
+#define KITSUBASS_H
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/internal/kitdecoder.h"
+#include "kitchensink/internal/subtitle/renderers/kitsubrenderer.h"
+
+KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateASSSubtitleRenderer(const Kit_Decoder *dec, int w, int h);
+
+#endif // KITSUBASS_H
diff --git a/include/kitchensink/internal/subtitle/renderers/kitsubimage.h b/include/kitchensink/internal/subtitle/renderers/kitsubimage.h
new file mode 100644
index 0000000..706f1f0
--- /dev/null
+++ b/include/kitchensink/internal/subtitle/renderers/kitsubimage.h
@@ -0,0 +1,10 @@
+#ifndef KITSUBIMAGE_H
+#define KITSUBIMAGE_H
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/internal/kitdecoder.h"
+#include "kitchensink/internal/subtitle/renderers/kitsubrenderer.h"
+
+KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateImageSubtitleRenderer(const Kit_Decoder *dec, int w, int h);
+
+#endif // KITSUBIMAGE_H
diff --git a/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h b/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h
new file mode 100644
index 0000000..e237546
--- /dev/null
+++ b/include/kitchensink/internal/subtitle/renderers/kitsubrenderer.h
@@ -0,0 +1,23 @@
+#ifndef KITSUBRENDERER_H
+#define KITSUBRENDERER_H
+
+#include "kitchensink/kitsource.h"
+#include "kitchensink/kitformats.h"
+
+typedef struct Kit_SubtitleRenderer Kit_SubtitleRenderer;
+//typedef struct Kit_SubtitlePacket Kit_SubtitlePacket;
+
+typedef Kit_SubtitlePacket* (*ren_render_cb)(Kit_SubtitleRenderer *ren, void *src, double start_pts, double end_pts);
+typedef void (*ren_close_cb)(Kit_SubtitleRenderer *ren);
+
+struct Kit_SubtitleRenderer {
+ void *userdata;
+ ren_render_cb ren_render; ///< Subtitle rendering function callback
+ ren_close_cb ren_close; ///< Subtitle renderer close function callback
+};
+
+KIT_LOCAL Kit_SubtitleRenderer* Kit_CreateSubtitleRenderer();
+KIT_LOCAL Kit_SubtitlePacket* Kit_RunSubtitleRenderer(Kit_SubtitleRenderer *ren, void *src, double start_pts, double end_pts);
+KIT_LOCAL void Kit_CloseSubtitleRenderer(Kit_SubtitleRenderer *ren);
+
+#endif // KITSUBRENDERER_H
diff --git a/include/kitchensink/internal/kitbuffer.h b/include/kitchensink/internal/utils/kitbuffer.h
index 4d0f8cc..67d93c3 100644
--- a/include/kitchensink/internal/kitbuffer.h
+++ b/include/kitchensink/internal/utils/kitbuffer.h
@@ -6,6 +6,7 @@
typedef struct Kit_Buffer Kit_Buffer;
typedef void (*Kit_BufferFreeCallback)(void*);
+typedef void (*Kit_ForEachItemCallback)(void*, void *userdata);
struct Kit_Buffer {
unsigned int read_p;
@@ -23,6 +24,7 @@ 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);
KIT_LOCAL int Kit_WriteBuffer(Kit_Buffer *buffer, void *ptr);
+KIT_LOCAL void Kit_ForEachItemInBuffer(const Kit_Buffer *buffer, Kit_ForEachItemCallback cb, void *userdata);
KIT_LOCAL int Kit_IsBufferFull(const Kit_Buffer *buffer);
#endif // KITBUFFER_H
diff --git a/include/kitchensink/internal/utils/kithelpers.h b/include/kitchensink/internal/utils/kithelpers.h
new file mode 100644
index 0000000..5b94a7a
--- /dev/null
+++ b/include/kitchensink/internal/utils/kithelpers.h
@@ -0,0 +1,11 @@
+#ifndef KITHELPERS_H
+#define KITHELPERS_H
+
+#include <stdbool.h>
+#include <libavformat/avformat.h>
+#include "kitchensink/kitconfig.h"
+
+KIT_LOCAL double _GetSystemTime();
+KIT_LOCAL bool attachment_is_font(AVStream *stream);
+
+#endif // KITHELPERS_H
diff --git a/include/kitchensink/internal/utils/kitlog.h b/include/kitchensink/internal/utils/kitlog.h
new file mode 100644
index 0000000..6b24763
--- /dev/null
+++ b/include/kitchensink/internal/utils/kitlog.h
@@ -0,0 +1,11 @@
+#ifndef KITLOG_H
+#define KITLOG_H
+
+#ifdef NDEBUG
+ #define LOG(...)
+#else
+ #include <stdio.h>
+ #define LOG(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
+#endif
+
+#endif // KITLOG_H
diff --git a/include/kitchensink/internal/kitringbuffer.h b/include/kitchensink/internal/utils/kitringbuffer.h
index 2f67520..2f67520 100644
--- a/include/kitchensink/internal/kitringbuffer.h
+++ b/include/kitchensink/internal/utils/kitringbuffer.h
diff --git a/include/kitchensink/internal/video/kitvideo.h b/include/kitchensink/internal/video/kitvideo.h
new file mode 100644
index 0000000..6978d9f
--- /dev/null
+++ b/include/kitchensink/internal/video/kitvideo.h
@@ -0,0 +1,12 @@
+#ifndef KITVIDEO_H
+#define KITVIDEO_H
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitformats.h"
+#include "kitchensink/kitplayer.h"
+#include "kitchensink/internal/kitdecoder.h"
+
+KIT_LOCAL Kit_Decoder* Kit_CreateVideoDecoder(const Kit_Source *src, Kit_VideoFormat *format);
+KIT_LOCAL int Kit_GetVideoDecoderDataTexture(Kit_Decoder *dec, SDL_Texture *texture);
+
+#endif // KITVIDEO_H
diff --git a/include/kitchensink/kitchensink.h b/include/kitchensink/kitchensink.h
index be318a5..6c5da35 100644
--- a/include/kitchensink/kitchensink.h
+++ b/include/kitchensink/kitchensink.h
@@ -3,6 +3,7 @@
#include "kitchensink/kitlib.h"
#include "kitchensink/kiterror.h"
+#include "kitchensink/kitformats.h"
#include "kitchensink/kitsource.h"
#include "kitchensink/kitplayer.h"
#include "kitchensink/kitutils.h"
diff --git a/include/kitchensink/kitformats.h b/include/kitchensink/kitformats.h
new file mode 100644
index 0000000..129047b
--- /dev/null
+++ b/include/kitchensink/kitformats.h
@@ -0,0 +1,30 @@
+#ifndef KITFORMATS_H
+#define KITFORMATS_H
+
+#include <stdbool.h>
+
+typedef struct Kit_AudioFormat {
+ int stream_index; ///< Stream index
+ bool is_enabled; ///< Is stream enabled
+ unsigned int format; ///< SDL Audio Format
+ bool is_signed; ///< Signedness
+ int bytes; ///< Bytes per sample per channel
+ int samplerate; ///< Sampling rate
+ int channels; ///< Channels
+} Kit_AudioFormat;
+
+typedef struct Kit_VideoFormat {
+ int stream_index; ///< 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_index; ///< Stream index
+ bool is_enabled; ///< Is stream enabled
+ unsigned int format; ///< SDL Pixel Format
+} Kit_SubtitleFormat;
+
+#endif // KITFORMATS_H
diff --git a/include/kitchensink/kitlib.h b/include/kitchensink/kitlib.h
index 9a827be..d8c3bb9 100644
--- a/include/kitchensink/kitlib.h
+++ b/include/kitchensink/kitlib.h
@@ -18,8 +18,8 @@ typedef struct Kit_Version {
} Kit_Version;
enum {
- KIT_INIT_FORMATS = 0x1,
- KIT_INIT_NETWORK = 0x2,
+ KIT_INIT_NETWORK = 0x1,
+ KIT_INIT_ASS = 0x2
};
KIT_API int Kit_Init(unsigned int flags);
diff --git a/include/kitchensink/kitplayer.h b/include/kitchensink/kitplayer.h
index b9ea1c7..4c80e9a 100644
--- a/include/kitchensink/kitplayer.h
+++ b/include/kitchensink/kitplayer.h
@@ -3,10 +3,12 @@
#include "kitchensink/kitsource.h"
#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitformats.h"
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_thread.h>
#include <SDL2/SDL_surface.h>
+#include <SDL2/SDL_mutex.h>
#include <stdbool.h>
@@ -19,76 +21,23 @@ extern "C" {
typedef enum Kit_PlayerState {
KIT_STOPPED = 0, ///< Playback stopped or has not started yet.
- KIT_PLAYING, ///< Playback started & player is actively decoding.
- KIT_PAUSED, ///< Playback paused; player is actively decoding but no new data is given out.
- KIT_CLOSED ///< Playback is stopped and player is closing.
+ KIT_PLAYING, ///< Playback started & player is actively decoding.
+ KIT_PAUSED, ///< Playback paused; player is actively decoding but no new data is given out.
+ KIT_CLOSED ///< Playback is stopped and player is closing.
} 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
- int bytes; ///< Bytes per sample per channel
- int samplerate; ///< Sampling rate
- int channels; ///< Channels
-} Kit_AudioFormat;
-
-typedef struct Kit_VideoFormat {
- 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_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
- double pause_start; ///< Timestamp of pause beginning
- double vclock_pos; ///< Video stream last pts
-
- // Threading
- 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
-
- // libass
- void *ass_renderer;
- void *ass_track;
-
- // Other
- uint8_t seek_flag;
- const Kit_Source *src; ///< Reference to Audio/Video source
+ void *audio_dec; ///< Audio decoder context (or NULL)
+ void *video_dec; ///< Video decoder context (or NULL)
+ void *subtitle_dec; ///< Subtitle decoder context (or NULL)
+ SDL_Thread *dec_thread; ///< Decoder thread
+ SDL_mutex *dec_lock; ///< Decoder lock
+ const Kit_Source *src; ///< Reference to Audio/Video source
+ double pause_started; ///< Temporary flag for handling pauses
} Kit_Player;
typedef struct Kit_PlayerInfo {
@@ -107,9 +56,9 @@ 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_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 int Kit_GetVideoDataTexture(Kit_Player *player, SDL_Texture *texture);
+KIT_API int Kit_GetSubtitleDataTexture(Kit_Player *player, SDL_Texture *texture);
+KIT_API int Kit_GetAudioData(Kit_Player *player, unsigned char *buffer, int length);
KIT_API void Kit_GetPlayerInfo(const Kit_Player *player, Kit_PlayerInfo *info);
KIT_API Kit_PlayerState Kit_GetPlayerState(const Kit_Player *player);
diff --git a/include/kitchensink/kitsource.h b/include/kitchensink/kitsource.h
index ed1711f..ea85d57 100644
--- a/include/kitchensink/kitsource.h
+++ b/include/kitchensink/kitsource.h
@@ -20,10 +20,10 @@ typedef enum Kit_StreamType {
} Kit_StreamType;
typedef struct Kit_Source {
- 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
+ int audio_stream_index; ///< Audio stream index
+ int video_stream_index; ///< Video stream index
+ int subtitle_stream_index; ///< Subtitle stream index
+ void *format_ctx; ///< FFmpeg: Videostream format context
} Kit_Source;
typedef struct Kit_Stream {