Subversion Repositories Kolibri OS

Rev

Rev 6133 | Rev 6136 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6133 Rev 6135
1
#include 
1
#include 
2
#include 
2
#include 
3
#include "list.h"
3
#include "list.h"
4
 
4
 
5
#define BLACK_MAGIC_SOUND
5
#define BLACK_MAGIC_SOUND
6
#define BLACK_MAGIC_VIDEO
6
#define BLACK_MAGIC_VIDEO
7
 
7
 
8
typedef unsigned int color_t;
8
typedef unsigned int color_t;
9
typedef unsigned int count_t;
9
typedef unsigned int count_t;
10
 
10
 
11
typedef struct render  render_t;
11
typedef struct render  render_t;
12
typedef struct vstate vst_t;
12
typedef struct vstate vst_t;
13
 
13
 
14
#define HAS_LEFT        (1<<0)
14
#define HAS_LEFT        (1<<0)
15
#define HAS_TOP         (1<<1)
15
#define HAS_TOP         (1<<1)
16
#define HAS_RIGHT       (1<<2)
16
#define HAS_RIGHT       (1<<2)
17
#define HAS_BOTTOM      (1<<3)
17
#define HAS_BOTTOM      (1<<3)
18
 
18
 
19
typedef struct
19
typedef struct
20
{
20
{
21
    struct list_head list;
21
    struct list_head list;
22
    enum AVPixelFormat format;
22
    enum AVPixelFormat format;
23
    AVPicture     picture;
23
    AVPicture     picture;
24
    planar_t*     planar;
24
    planar_t*     planar;
25
    int           is_hw_pic;
25
    int           is_hw_pic;
26
    int           index;
26
    int           index;
27
    double        pts;
27
    double        pts;
28
    double        pkt_pts;
28
    double        pkt_pts;
29
    double        pkt_dts;
29
    double        pkt_dts;
30
    volatile int  ready;
30
    volatile int  ready;
31
}vframe_t;
31
}vframe_t;
32
 
32
 
33
struct render
33
struct render
34
{
34
{
35
    vst_t     *vst;
35
    vst_t     *vst;
36
    uint32_t   caps;
36
    uint32_t   caps;
37
    uint32_t   ctx_width;
37
    uint32_t   ctx_width;
38
    uint32_t   ctx_height;
38
    uint32_t   ctx_height;
39
    uint32_t   win_width;
39
    uint32_t   win_width;
40
    uint32_t   win_height;
40
    uint32_t   win_height;
41
 
41
 
42
    rect_t     rc_client;
42
    rect_t     rc_client;
43
    rect_t     rcvideo;
43
    rect_t     rcvideo;
44
    rect_t     rcleft;
44
    rect_t     rcleft;
45
    rect_t     rctop;
45
    rect_t     rctop;
46
    rect_t     rcright;
46
    rect_t     rcright;
47
    rect_t     rcbottom;
47
    rect_t     rcbottom;
48
 
48
 
49
    uint32_t   layout;
49
    uint32_t   layout;
50
    bitmap_t  *bitmap[4];
50
    bitmap_t  *bitmap[4];
51
    bitmap_t  *last_bitmap;
51
    bitmap_t  *last_bitmap;
52
 
52
 
53
    uint32_t   ctx_format;
53
    uint32_t   ctx_format;
54
    int        target;
54
    int        target;
55
 
55
 
56
    window_t   *win;
56
    window_t   *win;
57
    enum{
57
    enum{
58
      EMPTY, INIT }state;
58
      EMPTY, INIT }state;
59
    enum win_state win_state;
59
    enum win_state win_state;
60
 
60
 
61
    void (*draw)(render_t *render, vframe_t *vframe);
61
    void (*draw)(render_t *render, vframe_t *vframe);
62
};
62
};
63
 
63
 
64
enum player_state
64
enum player_state
65
{
65
{
66
    CLOSED = 0,
66
    CLOSED = 0,
67
    PREPARE,
67
    PREPARE,
68
    STOP,
68
    STOP,
69
    PAUSE,
69
    PAUSE,
70
    PLAY,
70
    PLAY,
71
    REWIND,
71
    REWIND,
72
    PLAY_2_STOP,
72
    PLAY_2_STOP,
73
    PLAY_2_PAUSE,
73
    PLAY_2_PAUSE,
74
    PAUSE_2_PLAY,
74
    PAUSE_2_PLAY,
75
    REWIND_2_PLAY,
75
    REWIND_2_PLAY,
76
};
76
};
77
 
77
 
78
#define ID_PLAY             100
78
#define ID_PLAY             100
79
#define ID_STOP             101
79
#define ID_STOP             101
80
#define ID_PROGRESS         102
80
#define ID_PROGRESS         102
81
#define ID_VOL_LEVEL        103
81
#define ID_VOL_LEVEL        103
82
#define ID_VOL_CTRL         104
82
#define ID_VOL_CTRL         104
83
 
83
 
84
typedef struct
84
typedef struct
85
{
85
{
86
    mutex_t lock;
86
    mutex_t lock;
87
    char    *buffer;
87
    char    *buffer;
88
    int     count;
88
    int     count;
89
}astream_t;
89
}astream_t;
90
 
90
 
91
typedef struct
91
typedef struct
92
{
92
{
93
  unsigned int  code;
93
  unsigned int  code;
94
  unsigned int  sender;
94
  unsigned int  sender;
95
  unsigned int  stream;
95
  unsigned int  stream;
96
  unsigned int  offset;
96
  unsigned int  offset;
97
  unsigned int  size;
97
  unsigned int  size;
98
  unsigned int  unused[2];
98
  unsigned int  unused[2];
99
}SND_EVENT;
99
}SND_EVENT;
100
 
100
 
101
 
101
 
102
typedef struct {
102
typedef struct {
103
    AVPacketList *first_pkt;
103
    AVPacketList *first_pkt;
104
    AVPacketList *last_pkt;
104
    AVPacketList *last_pkt;
105
    int size;
105
    int size;
106
    int count;
106
    int count;
107
    mutex_t       lock;
107
    mutex_t       lock;
108
} queue_t;
108
} queue_t;
109
 
109
 
110
int put_packet(queue_t *q, AVPacket *pkt);
110
int put_packet(queue_t *q, AVPacket *pkt);
111
int get_packet(queue_t *q, AVPacket *pkt);
111
int get_packet(queue_t *q, AVPacket *pkt);
112
 
112
 
113
#define HWDEC_NUM_SURFACES  16
113
#define HWDEC_NUM_SURFACES  16
114
struct vstate
114
struct vstate
115
{
115
{
116
    AVFormatContext *fCtx;          /* format context           */
116
    AVFormatContext *fCtx;          /* format context           */
117
    AVCodecContext  *vCtx;          /* video decoder context    */
117
    AVCodecContext  *vCtx;          /* video decoder context    */
118
    AVCodecContext  *aCtx;          /* audio decoder context    */
118
    AVCodecContext  *aCtx;          /* audio decoder context    */
119
    AVCodec         *vCodec;        /* video codec              */
119
    AVCodec         *vCodec;        /* video codec              */
120
    AVCodec         *aCodec;        /* audio codec              */
120
    AVCodec         *aCodec;        /* audio codec              */
121
    int             vStream;        /* video stream index       */
121
    int             vStream;        /* video stream index       */
122
    int             aStream;        /* audio stream index       */
122
    int             aStream;        /* audio stream index       */
123
 
123
 
124
    queue_t         q_video;        /* video packets queue      */
124
    queue_t         q_video;        /* video packets queue      */
125
    queue_t         q_audio;        /* audio packets queue      */
125
    queue_t         q_audio;        /* audio packets queue      */
126
 
126
 
127
    mutex_t         gpu_lock;       /* gpu access lock. libdrm not yet thread safe :( */
127
    mutex_t         gpu_lock;       /* gpu access lock. libdrm not yet thread safe :( */
128
    mutex_t         decoder_lock;
128
    mutex_t         decoder_lock;
129
 
129
 
130
    mutex_t         input_lock;
130
    mutex_t         input_lock;
131
    mutex_t         output_lock;
131
    mutex_t         output_lock;
132
    struct list_head input_list;
132
    struct list_head input_list;
133
    struct list_head output_list;
133
    struct list_head output_list;
134
 
134
 
135
    vframe_t       *decoder_frame;
135
    vframe_t       *decoder_frame;
136
    void           *hwCtx;          /* hardware context         */
136
    void           *hwCtx;          /* hardware context         */
137
    int             hwdec;          /* hardware decoder         */
137
    int             hwdec:1;        /* hardware decoder         */
138
};
138
    int             blit_bitmap:1;  /* hardware RGBA blitter    */
-
 
139
    int             blit_texture:1; /* hardware RGBA blit and scale */
-
 
140
    int             blit_planar:1;  /* hardbare YUV blit and scale */
-
 
141
    int             frame_reorder:1;
-
 
142
};
139
 
143
 
140
 
144
 
141
#define DECODER_THREAD  1
145
#define DECODER_THREAD  1
142
#define AUDIO_THREAD    2
146
#define AUDIO_THREAD    2
143
#define VIDEO_THREAD    4
147
#define VIDEO_THREAD    4
144
 
148
 
145
extern int threads_running;
149
extern int threads_running;
146
extern astream_t astream;
150
extern astream_t astream;
147
extern AVRational video_time_base;
151
extern AVRational video_time_base;
148
 
152
 
149
render_t *create_render(vst_t *vst, window_t *win, uint32_t flags);
153
render_t *create_render(vst_t *vst, window_t *win, uint32_t flags);
150
void destroy_render(render_t *render);
154
void destroy_render(render_t *render);
151
int init_render(render_t *render, int width, int height);
155
int init_render(render_t *render, int width, int height);
152
void render_adjust_size(render_t *render, window_t *win);
156
void render_adjust_size(render_t *render, window_t *win);
153
void render_set_size(render_t *render, int width, int height);
157
void render_set_size(render_t *render, int width, int height);
154
void render_draw_client(render_t *render);
158
void render_draw_client(render_t *render);
155
 
159
 
156
int fplay_init_context(vst_t *vst);
160
int fplay_init_context(vst_t *vst);
157
 
161
 
158
int init_audio(int format);
162
int init_audio(int format);
159
int audio_thread(void *param);
163
int audio_thread(void *param);
160
void set_audio_volume(int left, int right);
164
void set_audio_volume(int left, int right);
161
 
165
 
162
int init_video(vst_t* vst);
166
int init_video(vst_t* vst);
163
int video_thread(void *param);
167
int video_thread(void *param);
164
 
168
 
165
void decoder(vst_t *vst);
169
void decoder(vst_t *vst);
166
int decode_video(vst_t* vst);
170
int decode_video(vst_t* vst);
167
int decode_audio(AVCodecContext  *ctx, queue_t *qa);
171
int decode_audio(AVCodecContext  *ctx, queue_t *qa);
168
 
172
 
169
double get_master_clock(void);
173
double get_master_clock(void);
170
 
174
 
171
static inline void GetNotify(void *event)
175
static inline void GetNotify(void *event)
172
{
176
{
173
    __asm__ __volatile__ (
177
    __asm__ __volatile__ (
174
    "int $0x40"
178
    "int $0x40"
175
    ::"a"(68),"b"(14),"c"(event));
179
    ::"a"(68),"b"(14),"c"(event));
176
}
180
}
177
 
181
 
178
void va_create_planar(vst_t *vst, vframe_t *vframe);
182
void va_create_planar(vst_t *vst, vframe_t *vframe);
179
 
183
 
180
int init_fontlib();
184
int init_fontlib();
181
char *get_moviefile();
185
char *get_moviefile();
182
 
186
 
183
typedef>
187
typedef>
184
 
188
 
185
typedef>
189
typedef>
186
#define>
190
#define>
187
#define>
191
#define>
188
#define>
192
#define>
189
#define>
193
#define>
190
#define>
194
#define>
191
#define>
195
#define>