2014-01-10 14:47:21 +01:00
|
|
|
|
2015-07-23 12:13:34 +02:00
|
|
|
#include <libsync.h>
|
2016-02-04 00:55:46 +01:00
|
|
|
#include <pixlib3.h>
|
|
|
|
#include "list.h"
|
2014-01-10 14:47:21 +01:00
|
|
|
|
|
|
|
#define BLACK_MAGIC_SOUND
|
|
|
|
#define BLACK_MAGIC_VIDEO
|
|
|
|
|
|
|
|
typedef unsigned int color_t;
|
|
|
|
typedef unsigned int count_t;
|
|
|
|
|
|
|
|
typedef struct render render_t;
|
2016-02-01 16:10:02 +01:00
|
|
|
typedef struct vstate vst_t;
|
2014-01-10 14:47:21 +01:00
|
|
|
|
|
|
|
#define HAS_LEFT (1<<0)
|
|
|
|
#define HAS_TOP (1<<1)
|
|
|
|
#define HAS_RIGHT (1<<2)
|
|
|
|
#define HAS_BOTTOM (1<<3)
|
|
|
|
|
2016-02-01 20:27:17 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-02-04 00:55:46 +01:00
|
|
|
struct list_head list;
|
2016-02-01 20:27:17 +01:00
|
|
|
enum AVPixelFormat format;
|
|
|
|
AVPicture picture;
|
2016-02-04 00:55:46 +01:00
|
|
|
planar_t* planar;
|
|
|
|
int is_hw_pic;
|
|
|
|
int index;
|
2016-02-01 20:27:17 +01:00
|
|
|
double pts;
|
2016-02-04 00:55:46 +01:00
|
|
|
double pkt_pts;
|
2016-02-01 20:27:17 +01:00
|
|
|
volatile int ready;
|
|
|
|
}vframe_t;
|
|
|
|
|
2014-01-10 14:47:21 +01:00
|
|
|
struct render
|
|
|
|
{
|
2016-02-01 16:10:02 +01:00
|
|
|
vst_t *vst;
|
2014-01-10 14:47:21 +01:00
|
|
|
uint32_t caps;
|
|
|
|
uint32_t ctx_width;
|
|
|
|
uint32_t ctx_height;
|
|
|
|
uint32_t win_width;
|
|
|
|
uint32_t win_height;
|
|
|
|
|
|
|
|
rect_t rc_client;
|
|
|
|
rect_t rcvideo;
|
|
|
|
rect_t rcleft;
|
|
|
|
rect_t rctop;
|
|
|
|
rect_t rcright;
|
|
|
|
rect_t rcbottom;
|
|
|
|
|
|
|
|
uint32_t layout;
|
2015-01-15 06:51:37 +01:00
|
|
|
bitmap_t *bitmap[4];
|
2014-01-10 14:47:21 +01:00
|
|
|
bitmap_t *last_bitmap;
|
|
|
|
|
|
|
|
uint32_t ctx_format;
|
|
|
|
int target;
|
|
|
|
|
|
|
|
window_t *win;
|
|
|
|
enum{
|
|
|
|
EMPTY, INIT }state;
|
|
|
|
enum win_state win_state;
|
|
|
|
|
2016-02-04 00:55:46 +01:00
|
|
|
void (*draw)(render_t *render, vframe_t *vframe);
|
2014-01-10 14:47:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum player_state
|
|
|
|
{
|
|
|
|
CLOSED = 0,
|
|
|
|
PREPARE,
|
|
|
|
STOP,
|
|
|
|
PAUSE,
|
|
|
|
PLAY,
|
|
|
|
REWIND,
|
|
|
|
PLAY_2_STOP,
|
|
|
|
PLAY_2_PAUSE,
|
|
|
|
PAUSE_2_PLAY,
|
|
|
|
REWIND_2_PLAY,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ID_PLAY 100
|
|
|
|
#define ID_STOP 101
|
|
|
|
#define ID_PROGRESS 102
|
|
|
|
#define ID_VOL_LEVEL 103
|
|
|
|
#define ID_VOL_CTRL 104
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2015-07-23 12:13:34 +02:00
|
|
|
mutex_t lock;
|
|
|
|
char *buffer;
|
|
|
|
int count;
|
2014-01-10 14:47:21 +01:00
|
|
|
}astream_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned int code;
|
|
|
|
unsigned int sender;
|
|
|
|
unsigned int stream;
|
|
|
|
unsigned int offset;
|
|
|
|
unsigned int size;
|
|
|
|
unsigned int unused[2];
|
|
|
|
}SND_EVENT;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
AVPacketList *first_pkt;
|
|
|
|
AVPacketList *last_pkt;
|
|
|
|
int size;
|
|
|
|
int count;
|
2016-02-01 16:10:02 +01:00
|
|
|
mutex_t lock;
|
2014-01-10 14:47:21 +01:00
|
|
|
} queue_t;
|
|
|
|
|
|
|
|
int put_packet(queue_t *q, AVPacket *pkt);
|
|
|
|
int get_packet(queue_t *q, AVPacket *pkt);
|
|
|
|
|
2016-02-01 16:10:02 +01:00
|
|
|
struct vstate
|
|
|
|
{
|
2016-02-04 20:25:52 +01:00
|
|
|
AVFormatContext *fCtx; /* format context */
|
|
|
|
AVCodecContext *vCtx; /* video decoder context */
|
|
|
|
AVCodecContext *aCtx; /* audio decoder context */
|
|
|
|
AVCodec *vCodec; /* video codec */
|
|
|
|
AVCodec *aCodec; /* audio codec */
|
|
|
|
char *input_file;
|
|
|
|
char *input_name;
|
|
|
|
int vStream; /* video stream index */
|
|
|
|
int aStream; /* audio stream index */
|
|
|
|
AVRational video_time_base;
|
|
|
|
AVRational audio_time_base;
|
|
|
|
|
|
|
|
queue_t q_video; /* video packets queue */
|
|
|
|
queue_t q_audio; /* audio packets queue */
|
|
|
|
|
|
|
|
mutex_t gpu_lock; /* gpu access lock. libdrm not yet thread safe :( */
|
2016-02-04 00:55:46 +01:00
|
|
|
mutex_t decoder_lock;
|
|
|
|
|
|
|
|
mutex_t input_lock;
|
|
|
|
mutex_t output_lock;
|
|
|
|
struct list_head input_list;
|
|
|
|
struct list_head output_list;
|
|
|
|
|
2016-02-04 20:25:52 +01:00
|
|
|
AVFrame *Frame;
|
|
|
|
|
2016-02-04 00:55:46 +01:00
|
|
|
vframe_t *decoder_frame;
|
2016-02-04 20:25:52 +01:00
|
|
|
volatile int frames_count;
|
|
|
|
void *hwCtx; /* hardware context */
|
|
|
|
int hwdec:1; /* hardware decoder */
|
|
|
|
int blit_bitmap:1; /* hardware RGBA blitter */
|
|
|
|
int blit_texture:1; /* hardware RGBA blit and scale */
|
|
|
|
int blit_planar:1; /* hardbare YUV blit and scale */
|
2016-02-04 15:44:22 +01:00
|
|
|
int frame_reorder:1;
|
2016-02-04 20:25:52 +01:00
|
|
|
int nframes;
|
|
|
|
vframe_t vframes[16];
|
2016-02-01 16:10:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-07-23 12:13:34 +02:00
|
|
|
#define DECODER_THREAD 1
|
|
|
|
#define AUDIO_THREAD 2
|
|
|
|
#define VIDEO_THREAD 4
|
|
|
|
|
|
|
|
extern int threads_running;
|
2014-01-10 14:47:21 +01:00
|
|
|
extern astream_t astream;
|
|
|
|
|
2016-02-01 16:10:02 +01:00
|
|
|
render_t *create_render(vst_t *vst, window_t *win, uint32_t flags);
|
2014-01-10 14:47:21 +01:00
|
|
|
void destroy_render(render_t *render);
|
|
|
|
int init_render(render_t *render, int width, int height);
|
|
|
|
void render_adjust_size(render_t *render, window_t *win);
|
|
|
|
void render_set_size(render_t *render, int width, int height);
|
|
|
|
void render_draw_client(render_t *render);
|
|
|
|
|
2016-02-01 17:55:10 +01:00
|
|
|
int fplay_init_context(vst_t *vst);
|
2014-01-10 14:47:21 +01:00
|
|
|
|
|
|
|
int init_audio(int format);
|
|
|
|
int audio_thread(void *param);
|
|
|
|
void set_audio_volume(int left, int right);
|
|
|
|
|
|
|
|
int video_thread(void *param);
|
2016-02-04 20:25:52 +01:00
|
|
|
void flush_video(vst_t* vst);
|
2014-01-10 14:47:21 +01:00
|
|
|
|
2016-02-01 16:10:02 +01:00
|
|
|
void decoder(vst_t *vst);
|
|
|
|
int decode_video(vst_t* vst);
|
2014-01-10 14:47:21 +01:00
|
|
|
int decode_audio(AVCodecContext *ctx, queue_t *qa);
|
|
|
|
|
|
|
|
double get_master_clock(void);
|
|
|
|
|
|
|
|
static inline void GetNotify(void *event)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(68),"b"(14),"c"(event));
|
|
|
|
}
|
|
|
|
|
2016-02-04 20:25:52 +01:00
|
|
|
static inline double get_audio_base(vst_t* vst)
|
|
|
|
{
|
|
|
|
return (double)av_q2d(vst->fCtx->streams[vst->aStream]->time_base)*1000;
|
|
|
|
};
|
|
|
|
|
2016-02-04 00:55:46 +01:00
|
|
|
void va_create_planar(vst_t *vst, vframe_t *vframe);
|
2016-02-01 17:55:10 +01:00
|
|
|
|
2014-01-10 14:47:21 +01:00
|
|
|
int init_fontlib();
|
|
|
|
char *get_moviefile();
|
|
|
|
|