2010-11-10 08:51:05 +03:00
|
|
|
|
2013-02-17 19:27:33 +04:00
|
|
|
#include "pixlib2.h"
|
|
|
|
|
2010-11-10 08:51:05 +03:00
|
|
|
#define BLACK_MAGIC_SOUND
|
|
|
|
#define BLACK_MAGIC_VIDEO
|
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
typedef unsigned int color_t;
|
|
|
|
typedef unsigned int count_t;
|
|
|
|
|
|
|
|
typedef struct render render_t;
|
|
|
|
|
2012-02-28 12:45:00 +04:00
|
|
|
#define HAS_LEFT (1<<0)
|
|
|
|
#define HAS_TOP (1<<1)
|
|
|
|
#define HAS_RIGHT (1<<2)
|
|
|
|
#define HAS_BOTTOM (1<<3)
|
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
struct render
|
|
|
|
{
|
|
|
|
uint32_t caps;
|
|
|
|
uint32_t ctx_width;
|
|
|
|
uint32_t ctx_height;
|
|
|
|
uint32_t win_width;
|
|
|
|
uint32_t win_height;
|
|
|
|
|
2012-02-28 12:45:00 +04:00
|
|
|
rect_t rc_client;
|
|
|
|
rect_t rcvideo;
|
|
|
|
rect_t rcleft;
|
|
|
|
rect_t rctop;
|
|
|
|
rect_t rcright;
|
|
|
|
rect_t rcbottom;
|
|
|
|
|
|
|
|
uint32_t layout;
|
2012-02-14 02:34:36 +04:00
|
|
|
bitmap_t bitmap[4];
|
2012-03-02 14:31:15 +04:00
|
|
|
bitmap_t *last_bitmap;
|
2012-11-28 16:06:34 +04:00
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
uint32_t ctx_format;
|
|
|
|
int target;
|
2012-11-28 16:06:34 +04:00
|
|
|
|
2012-02-28 12:45:00 +04:00
|
|
|
window_t *win;
|
2012-02-14 02:34:36 +04:00
|
|
|
enum{
|
|
|
|
EMPTY, INIT }state;
|
2012-02-28 12:45:00 +04:00
|
|
|
enum win_state win_state;
|
2012-02-14 02:34:36 +04:00
|
|
|
|
|
|
|
void (*draw)(render_t *render, AVPicture *picture);
|
|
|
|
};
|
|
|
|
|
2012-03-02 14:31:15 +04:00
|
|
|
enum player_state
|
2012-11-28 16:06:34 +04:00
|
|
|
{
|
|
|
|
CLOSED = 0,
|
|
|
|
PREPARE,
|
|
|
|
STOP,
|
|
|
|
PAUSE,
|
|
|
|
PLAY,
|
|
|
|
REWIND,
|
|
|
|
PLAY_2_STOP,
|
|
|
|
PLAY_2_PAUSE,
|
|
|
|
PAUSE_2_PLAY,
|
|
|
|
REWIND_2_PLAY,
|
2012-05-27 14:41:27 +04:00
|
|
|
};
|
2012-03-02 14:31:15 +04:00
|
|
|
|
2012-11-28 16:06:34 +04:00
|
|
|
#define ID_PLAY 100
|
|
|
|
#define ID_STOP 101
|
|
|
|
#define ID_PROGRESS 102
|
|
|
|
#define ID_VOL_LEVEL 103
|
|
|
|
#define ID_VOL_CTRL 104
|
|
|
|
|
2010-11-10 08:51:05 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
volatile uint32_t lock;
|
|
|
|
char *buffer;
|
|
|
|
volatile uint32_t count;
|
|
|
|
}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;
|
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned handle;
|
|
|
|
unsigned io_code;
|
|
|
|
void *input;
|
|
|
|
int inp_size;
|
|
|
|
void *output;
|
|
|
|
int out_size;
|
|
|
|
}ioctl_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
AVPacketList *first_pkt;
|
|
|
|
AVPacketList *last_pkt;
|
|
|
|
int size;
|
|
|
|
int count;
|
|
|
|
volatile uint32_t lock;
|
|
|
|
} queue_t;
|
|
|
|
|
|
|
|
int put_packet(queue_t *q, AVPacket *pkt);
|
|
|
|
int get_packet(queue_t *q, AVPacket *pkt);
|
|
|
|
|
|
|
|
|
2010-11-10 08:51:05 +03:00
|
|
|
extern astream_t astream;
|
|
|
|
extern AVRational video_time_base;
|
|
|
|
|
2013-02-28 15:41:51 +04:00
|
|
|
render_t *create_render(window_t *win, AVCodecContext *ctx, uint32_t flags);
|
|
|
|
void destroy_render(render_t *render);
|
2012-02-14 02:34:36 +04:00
|
|
|
int init_render(render_t *render, int width, int height);
|
2012-02-28 12:45:00 +04:00
|
|
|
void render_adjust_size(render_t *render, window_t *win);
|
2013-02-28 15:41:51 +04:00
|
|
|
void render_set_size(render_t *render, int width, int height);
|
2012-02-28 12:45:00 +04:00
|
|
|
void render_draw_client(render_t *render);
|
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
|
2010-11-10 08:51:05 +03:00
|
|
|
int init_audio(int format);
|
2012-02-14 02:34:36 +04:00
|
|
|
int audio_thread(void *param);
|
2013-02-17 19:27:33 +04:00
|
|
|
void set_audio_volume(int left, int right);
|
2012-02-14 02:34:36 +04:00
|
|
|
|
2010-11-10 08:51:05 +03:00
|
|
|
int init_video(AVCodecContext *ctx);
|
2012-02-14 02:34:36 +04:00
|
|
|
int video_thread(void *param);
|
|
|
|
|
|
|
|
int decode_video(AVCodecContext *ctx, queue_t *qv);
|
|
|
|
int decode_audio(AVCodecContext *ctx, queue_t *qa);
|
|
|
|
|
2012-03-02 14:31:15 +04:00
|
|
|
double get_master_clock(void);
|
2010-11-10 08:51:05 +03:00
|
|
|
|
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
int create_thread(int (*proc)(void *param), void *param, int stack_size);
|
2010-11-10 08:51:05 +03:00
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
void mutex_lock(volatile uint32_t *val);
|
2010-11-10 08:51:05 +03:00
|
|
|
|
2012-02-14 02:34:36 +04:00
|
|
|
static inline void mutex_unlock(volatile uint32_t *val)
|
2010-11-10 08:51:05 +03:00
|
|
|
{
|
|
|
|
*val = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void GetNotify(void *event)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(68),"b"(14),"c"(event));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t get_os_button()
|
|
|
|
{
|
|
|
|
uint32_t val;
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:"=a"(val)
|
|
|
|
:"a"(17));
|
|
|
|
return val>>8;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void yield(void)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
::"a"(68), "b"(1));
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void delay(uint32_t time)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
2012-05-27 14:41:27 +04:00
|
|
|
::"a"(5), "b"(time)
|
|
|
|
:"memory");
|
2010-11-10 08:51:05 +03:00
|
|
|
};
|
2012-02-14 02:34:36 +04:00
|
|
|
|
|
|
|
|
2012-11-28 16:06:34 +04:00
|
|
|
int init_fontlib();
|
2013-02-17 19:27:33 +04:00
|
|
|
int draw_text(bitmap_t *winbitmap, int face, char *text, int x, int y, int color);
|
|
|
|
int draw_text_ext(bitmap_t *winbitmap, int face, char *text, rect_t *rc, int color);
|
|
|
|
char *get_moviefile();
|
|
|
|
|