summaryrefslogtreecommitdiff
path: root/include/kitchensink
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2017-09-12 00:06:31 +0300
committerTuomas Virtanen <katajakasa@gmail.com>2017-09-22 15:15:57 +0300
commitfd7bbceb6321250ed5d80103d13e9d7584b552ac (patch)
treeb8202cd4c110d3e93c1c7a4032252e66c3e11073 /include/kitchensink
parentbf1d1e30ac4062a2f764193a865761161ec7fc6b (diff)
Split kitplayer.c to multiple files
Diffstat (limited to 'include/kitchensink')
-rw-r--r--include/kitchensink/internal/kitaudio.h28
-rw-r--r--include/kitchensink/internal/kitcontrol.h24
-rw-r--r--include/kitchensink/internal/kithelpers.h11
-rw-r--r--include/kitchensink/internal/kitsubtitle.h24
-rw-r--r--include/kitchensink/internal/kitvideo.h22
-rw-r--r--include/kitchensink/kitchensink.h1
-rw-r--r--include/kitchensink/kitformats.h29
-rw-r--r--include/kitchensink/kitplayer.h24
8 files changed, 140 insertions, 23 deletions
diff --git a/include/kitchensink/internal/kitaudio.h b/include/kitchensink/internal/kitaudio.h
new file mode 100644
index 0000000..e1c9ffb
--- /dev/null
+++ b/include/kitchensink/internal/kitaudio.h
@@ -0,0 +1,28 @@
+#ifndef KITAUDIO_H
+#define KITAUDIO_H
+
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+#include <libavformat/avformat.h>
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitformats.h"
+#include "kitchensink/kitplayer.h"
+#include "kitchensink/internal/kitringbuffer.h"
+
+#define KIT_ABUFFERSIZE 64
+
+typedef struct Kit_AudioPacket {
+ double pts;
+ size_t original_size;
+ Kit_RingBuffer *rb;
+} Kit_AudioPacket;
+
+KIT_LOCAL Kit_AudioPacket* _CreateAudioPacket(const char* data, size_t len, double pts);
+KIT_LOCAL void _FreeAudioPacket(void *ptr);
+KIT_LOCAL enum AVSampleFormat _FindAVSampleFormat(int format);
+KIT_LOCAL unsigned int _FindAVChannelLayout(int channels);
+KIT_LOCAL void _FindAudioFormat(enum AVSampleFormat fmt, int *bytes, bool *is_signed, unsigned int *format);
+KIT_LOCAL void _HandleAudioPacket(Kit_Player *player, AVPacket *packet);
+
+#endif // KITAUDIO_H
diff --git a/include/kitchensink/internal/kitcontrol.h b/include/kitchensink/internal/kitcontrol.h
new file mode 100644
index 0000000..eaad484
--- /dev/null
+++ b/include/kitchensink/internal/kitcontrol.h
@@ -0,0 +1,24 @@
+#ifndef KITCONTROL_H
+#define KITCONTROL_H
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitplayer.h"
+
+#define KIT_CBUFFERSIZE 8
+
+typedef enum Kit_ControlPacketType {
+ KIT_CONTROL_SEEK,
+ KIT_CONTROL_FLUSH
+} Kit_ControlPacketType;
+
+typedef struct Kit_ControlPacket {
+ Kit_ControlPacketType type;
+ double value1;
+} Kit_ControlPacket;
+
+KIT_LOCAL Kit_ControlPacket* _CreateControlPacket(Kit_ControlPacketType type, double value1);
+KIT_LOCAL void _FreeControlPacket(void *ptr);
+KIT_LOCAL void _HandleFlushCommand(Kit_Player *player, Kit_ControlPacket *packet);
+KIT_LOCAL void _HandleSeekCommand(Kit_Player *player, Kit_ControlPacket *packet);
+
+#endif // KITCONTROL_H
diff --git a/include/kitchensink/internal/kithelpers.h b/include/kitchensink/internal/kithelpers.h
new file mode 100644
index 0000000..5b94a7a
--- /dev/null
+++ b/include/kitchensink/internal/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/kitsubtitle.h b/include/kitchensink/internal/kitsubtitle.h
new file mode 100644
index 0000000..4582744
--- /dev/null
+++ b/include/kitchensink/internal/kitsubtitle.h
@@ -0,0 +1,24 @@
+#ifndef KITSUBTITLE_H
+#define KITSUBTITLE_H
+
+#include <libavformat/avformat.h>
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitplayer.h"
+
+#define KIT_SBUFFERSIZE 512
+
+typedef struct Kit_SubtitlePacket {
+ double pts_start;
+ double pts_end;
+ SDL_Rect *rect;
+ SDL_Surface *surface;
+ SDL_Texture *texture;
+} Kit_SubtitlePacket;
+
+KIT_LOCAL Kit_SubtitlePacket* _CreateSubtitlePacket(double pts_start, double pts_end, SDL_Rect *rect, SDL_Surface *surface);
+KIT_LOCAL void _FreeSubtitlePacket(void *ptr);
+KIT_LOCAL void _HandleBitmapSubtitle(Kit_SubtitlePacket** spackets, int *n, Kit_Player *player, double pts, AVSubtitle *sub, AVSubtitleRect *rect);
+KIT_LOCAL void _HandleSubtitlePacket(Kit_Player *player, AVPacket *packet);
+
+#endif // KITSUBTITLE_H
diff --git a/include/kitchensink/internal/kitvideo.h b/include/kitchensink/internal/kitvideo.h
new file mode 100644
index 0000000..f1cb4ff
--- /dev/null
+++ b/include/kitchensink/internal/kitvideo.h
@@ -0,0 +1,22 @@
+#ifndef KITVIDEO_H
+#define KITVIDEO_H
+
+#include <libavformat/avformat.h>
+
+#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitplayer.h"
+
+#define KIT_VBUFFERSIZE 3
+
+typedef struct Kit_VideoPacket {
+ double pts;
+ AVFrame *frame;
+} Kit_VideoPacket;
+
+KIT_LOCAL Kit_VideoPacket* _CreateVideoPacket(AVFrame *frame, double pts);
+KIT_LOCAL void _FreeVideoPacket(void *ptr);
+KIT_LOCAL void _FindPixelFormat(enum AVPixelFormat fmt, unsigned int *out_fmt);
+KIT_LOCAL enum AVPixelFormat _FindAVPixelFormat(unsigned int fmt);
+KIT_LOCAL void _HandleVideoPacket(Kit_Player *player, AVPacket *packet);
+
+#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..ef86826
--- /dev/null
+++ b/include/kitchensink/kitformats.h
@@ -0,0 +1,29 @@
+#ifndef KITFORMATS_H
+#define KITFORMATS_H
+
+#include <stdbool.h>
+
+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;
+
+#endif // KITFORMATS_H
diff --git a/include/kitchensink/kitplayer.h b/include/kitchensink/kitplayer.h
index b9ea1c7..9505208 100644
--- a/include/kitchensink/kitplayer.h
+++ b/include/kitchensink/kitplayer.h
@@ -3,6 +3,7 @@
#include "kitchensink/kitsource.h"
#include "kitchensink/kitconfig.h"
+#include "kitchensink/kitformats.h"
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_thread.h>
@@ -24,29 +25,6 @@ typedef enum Kit_PlayerState {
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