Rev 2427 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2427 | Rev 2693 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | 15 | ||
Line 16... | Line 16... | ||
16 | extern int res_play_btn[]; |
16 | extern int res_play_btn[]; |
17 | extern int res_play_btn_pressed[]; |
17 | extern int res_play_btn_pressed[]; |
Line -... | Line 18... | ||
- | 18 | ||
Line 18... | Line 19... | ||
18 | 19 | extern int64_t stream_duration; |
|
19 | 20 | ||
20 | typedef struct |
21 | typedef struct |
21 | { |
22 | { |
Line 42... | Line 43... | ||
42 | volatile uint32_t driver_lock; |
43 | volatile uint32_t driver_lock; |
Line 43... | Line 44... | ||
43 | 44 | ||
Line -... | Line 45... | ||
- | 45 | void get_client_rect(rect_t *rc); |
|
- | 46 | ||
- | 47 | void flush_video() |
|
- | 48 | { |
|
- | 49 | int i; |
|
- | 50 | ||
- | 51 | for(i = 0; i < 4; i++) |
|
- | 52 | { |
|
- | 53 | frames[i].pts = 0; |
|
- | 54 | frames[i].ready = 0; |
|
- | 55 | }; |
|
- | 56 | vfx = 0; |
|
Line 44... | Line 57... | ||
44 | void get_client_rect(rect_t *rc); |
57 | dfx = 0; |
45 | 58 | }; |
|
46 | 59 | ||
Line 111... | Line 124... | ||
111 | 124 | ||
Line 112... | Line 125... | ||
112 | if( get_packet(qv, &pkt) == 0 ) |
125 | if( get_packet(qv, &pkt) == 0 ) |
113 | return 0; |
126 | return 0; |
Line 114... | Line 127... | ||
114 | 127 | ||
Line 115... | Line 128... | ||
115 | current_clock = -80.0 + get_master_clock(); |
128 | current_clock = -90.0 + get_master_clock(); |
116 | 129 | ||
117 | if( pkt.dts == AV_NOPTS_VALUE && |
130 | if( pkt.dts == AV_NOPTS_VALUE && |
118 | Frame->reordered_opaque != AV_NOPTS_VALUE) |
131 | Frame->reordered_opaque != AV_NOPTS_VALUE) |
119 | pts = Frame->reordered_opaque; |
132 | pts = Frame->reordered_opaque; |
120 | else if(pkt.dts != AV_NOPTS_VALUE) |
133 | else if(pkt.dts != AV_NOPTS_VALUE) |
121 | pts= pkt.dts; |
134 | pts= pkt.dts; |
Line -... | Line 135... | ||
- | 135 | else |
|
122 | else |
136 | pts= 0; |
Line 123... | Line 137... | ||
123 | pts= 0; |
137 | |
124 | 138 | ||
125 | pts *= av_q2d(video_time_base)*1000.0; |
139 | pts *= av_q2d(video_time_base)*1000.0; |
Line 126... | Line 140... | ||
126 | 140 | ||
Line 159... | Line 173... | ||
159 | (const uint8_t**)Frame->data, |
173 | (const uint8_t**)Frame->data, |
160 | Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height); |
174 | Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height); |
161 | 175 | ||
Line 162... | Line 176... | ||
162 | frames[dfx].pts = pts*1000.0; |
176 | frames[dfx].pts = pts*1000.0; |
- | 177 | // printf("pts %f\n", frames[dfx].pts); |
|
- | 178 | ||
163 | frames[dfx].ready = 1; |
179 | frames[dfx].ready = 1; |
Line 164... | Line 180... | ||
164 | 180 | ||
165 | dfx++; |
181 | dfx++; |
166 | dfx&= 3; |
182 | dfx&= 3; |
Line 173... | Line 189... | ||
173 | 189 | ||
Line 174... | Line 190... | ||
174 | extern volatile enum player_state player_state; |
190 | extern volatile enum player_state player_state; |
175 | //rect_t win_rect; |
191 | //rect_t win_rect; |
Line -... | Line 192... | ||
- | 192 | ||
Line 176... | Line 193... | ||
176 | 193 | extern int64_t rewind_pos; |
|
177 | 194 | ||
178 | int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) |
195 | int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) |
Line 194... | Line 211... | ||
194 | 211 | ||
Line 195... | Line 212... | ||
195 | case MSG_LBTNDOWN: |
212 | case MSG_LBTNDOWN: |
196 | if(player_state == PAUSE) |
213 | if(player_state == PAUSE) |
197 | { |
214 | { |
198 | win->panel.play_btn->img_default = res_play_btn; |
215 | win->panel.play_btn->img_default = res_pause_btn; |
199 | win->panel.play_btn->img_hilite = res_play_btn; |
216 | win->panel.play_btn->img_hilite = res_pause_btn; |
200 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
217 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
201 | send_message(win->panel.play_btn, MSG_PAINT, 0, 0); |
218 | send_message(win->panel.play_btn, MSG_PAINT, 0, 0); |
202 | player_state = PLAY_RESTART; |
219 | player_state = PAUSE_2_PLAY; |
Line 203... | Line 220... | ||
203 | 220 | ||
204 | } |
221 | } |
205 | else if(player_state == PLAY) |
222 | else if(player_state == PLAY) |
206 | { |
223 | { |
207 | win->panel.play_btn->img_default = res_pause_btn; |
224 | win->panel.play_btn->img_default = res_play_btn; |
208 | win->panel.play_btn->img_hilite = res_pause_btn; |
225 | win->panel.play_btn->img_hilite = res_play_btn; |
209 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
226 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
210 | send_message(win->panel.play_btn, MSG_PAINT, 0, 0); |
227 | send_message(win->panel.play_btn, MSG_PAINT, 0, 0); |
211 | player_state = PAUSE; |
228 | player_state = PAUSE; |
212 | } |
229 | } |
Line 217... | Line 234... | ||
217 | { |
234 | { |
218 | case ID_PLAY: |
235 | case ID_PLAY: |
219 | if(player_state == PAUSE) |
236 | if(player_state == PAUSE) |
220 | { |
237 | { |
221 | win->panel.play_btn->img_default = res_play_btn; |
238 | win->panel.play_btn->img_default = res_pause_btn; |
222 | win->panel.play_btn->img_hilite = res_play_btn; |
- | |
223 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
- | |
224 | player_state = PLAY_RESTART; |
- | |
225 | } |
- | |
226 | else if(player_state == PLAY) |
- | |
227 | { |
- | |
228 | win->panel.play_btn->img_default = res_pause_btn; |
- | |
229 | win->panel.play_btn->img_hilite = res_pause_btn; |
239 | win->panel.play_btn->img_hilite = res_pause_btn; |
230 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
240 | win->panel.play_btn->img_pressed = res_pause_btn_pressed; |
231 | player_state = PAUSE; |
241 | player_state = PAUSE_2_PLAY; |
- | 242 | } |
|
- | 243 | else if(player_state == PLAY) |
|
- | 244 | { |
|
- | 245 | win->panel.play_btn->img_default = res_play_btn; |
|
- | 246 | win->panel.play_btn->img_hilite = res_play_btn; |
|
- | 247 | win->panel.play_btn->img_pressed = res_play_btn_pressed; |
|
- | 248 | player_state = PAUSE; |
|
232 | } |
249 | } |
233 | break; |
250 | break; |
234 | default: |
251 | |
- | 252 | case 101: //ID_PROGRESS: |
|
- | 253 | if(player_state != REWIND) |
|
- | 254 | { |
|
- | 255 | progress_t *prg = (progress_t*)arg2; |
|
- | 256 | ||
- | 257 | rewind_pos = (int64_t)prg->pos * |
|
- | 258 | (prg->max - prg->min)/prg->ctrl.w; |
|
- | 259 | ||
- | 260 | // printf("progress action %f\n", (double)rewind_pos); |
|
- | 261 | player_state = REWIND; |
|
- | 262 | main_render->win->panel.prg->current = rewind_pos; |
|
- | 263 | send_message(&main_render->win->panel.ctrl, MSG_PAINT, 0, 0); |
|
- | 264 | }; |
|
- | 265 | break; |
|
- | 266 | ||
- | 267 | default: |
|
235 | break; |
268 | break; |
236 | } |
269 | } |
237 | break; |
270 | break; |
238 | 271 | ||
Line 241... | Line 274... | ||
241 | }; |
274 | }; |
242 | return 0; |
275 | return 0; |
243 | }; |
276 | }; |
244 | 277 | ||
Line -... | Line 278... | ||
- | 278 | #define VERSION_A 1 |
|
- | 279 | ||
245 | void render_time(render_t *render) |
280 | void render_time(render_t *render) |
246 | { |
281 | { |
247 | double ctime; /* milliseconds */ |
282 | double ctime; /* milliseconds */ |
248 | double fdelay; /* milliseconds */ |
283 | double fdelay; /* milliseconds */ |
Line 259... | Line 294... | ||
259 | yield(); |
294 | yield(); |
260 | return; |
295 | return; |
261 | }; |
296 | }; |
262 | 297 | ||
Line -... | Line 298... | ||
- | 298 | #ifdef VERSION_A |
|
263 | if(frames[vfx].ready == 1 ) |
299 | if(frames[vfx].ready == 1 ) |
264 | { |
300 | { |
- | 301 | int sys_time; |
|
- | 302 | ||
265 | ctime = get_master_clock(); |
303 | ctime = get_master_clock(); |
266 | fdelay = (frames[vfx].pts - ctime); |
304 | fdelay = (frames[vfx].pts - ctime); |
Line 267... | Line 305... | ||
267 | 305 | ||
268 | // printf("pts %f time %f delay %f\n", |
306 | // printf("pts %f time %f delay %f\n", |
Line 269... | Line 307... | ||
269 | // frames[vfx].pts, ctime, fdelay); |
307 | // frames[vfx].pts, ctime, fdelay); |
270 | 308 | ||
271 | if(fdelay > 20.0) |
309 | if(fdelay > 15.0) |
272 | { |
310 | { |
273 | delay(2); |
311 | delay(1); |
274 | // yield(); |
312 | // yield(); |
Line -... | Line 313... | ||
- | 313 | return; |
|
- | 314 | }; |
|
- | 315 | ||
- | 316 | ctime = get_master_clock(); |
|
- | 317 | fdelay = (frames[vfx].pts - ctime); |
|
- | 318 | ||
- | 319 | sys_time = get_tick_count(); |
|
- | 320 | ||
- | 321 | // if(fdelay < 0) |
|
275 | return; |
322 | // printf("systime %d pts %f time %f delay %f\n", |
- | 323 | // sys_time*10, frames[vfx].pts, ctime, fdelay); |
|
- | 324 | ||
276 | }; |
325 | main_render->draw(main_render, &frames[vfx].picture); |
277 | 326 | main_render->win->panel.prg->current = frames[vfx].pts*1000; |
|
278 | main_render->draw(main_render, &frames[vfx].picture); |
327 | send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); |
279 | frames[vfx].ready = 0; |
328 | frames[vfx].ready = 0; |
280 | vfx++; |
329 | vfx++; |
Line -... | Line 330... | ||
- | 330 | vfx&= 3; |
|
- | 331 | } |
|
- | 332 | else yield(); |
|
- | 333 | ||
- | 334 | #else |
|
- | 335 | ||
- | 336 | if(frames[vfx].ready == 1 ) |
|
- | 337 | { |
|
- | 338 | ctime = get_master_clock(); |
|
- | 339 | fdelay = (frames[vfx].pts - ctime); |
|
- | 340 | ||
- | 341 | // printf("pts %f time %f delay %f\n", |
|
- | 342 | // frames[vfx].pts, ctime, fdelay); |
|
- | 343 | ||
- | 344 | if(fdelay < 0.0 ) |
|
- | 345 | { |
|
- | 346 | int next_vfx; |
|
- | 347 | fdelay = 0; |
|
- | 348 | next_vfx = (vfx+1) & 3; |
|
- | 349 | if( frames[next_vfx].ready == 1 ) |
|
- | 350 | { |
|
- | 351 | if(frames[next_vfx].pts <= ctime) |
|
- | 352 | { |
|
- | 353 | frames[vfx].ready = 0; // skip this frame |
|
- | 354 | vfx++; |
|
- | 355 | vfx&= 3; |
|
- | 356 | } |
|
- | 357 | else |
|
- | 358 | { |
|
- | 359 | if( (frames[next_vfx].pts - ctime) < |
|
- | 360 | ( ctime - frames[vfx].pts) ) |
|
- | 361 | { |
|
- | 362 | frames[vfx].ready = 0; // skip this frame |
|
- | 363 | vfx++; |
|
- | 364 | vfx&= 3; |
|
- | 365 | fdelay = (frames[next_vfx].pts - ctime); |
|
- | 366 | } |
|
- | 367 | } |
|
- | 368 | }; |
|
- | 369 | }; |
|
- | 370 | ||
- | 371 | if(fdelay > 10.0) |
|
- | 372 | { |
|
- | 373 | int val = fdelay; |
|
- | 374 | printf("pts %f time %f delay %d\n", |
|
- | 375 | frames[vfx].pts, ctime, val); |
|
- | 376 | delay(val/10); |
|
- | 377 | }; |
|
- | 378 | ||
- | 379 | ctime = get_master_clock(); |
|
- | 380 | fdelay = (frames[vfx].pts - ctime); |
|
- | 381 | ||
- | 382 | printf("pts %f time %f delay %f\n", |
|
- | 383 | frames[vfx].pts, ctime, fdelay); |
|
- | 384 | ||
- | 385 | main_render->draw(main_render, &frames[vfx].picture); |
|
- | 386 | main_render->win->panel.prg->current = frames[vfx].pts; |
|
- | 387 | // send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); |
|
- | 388 | frames[vfx].ready = 0; |
|
- | 389 | vfx++; |
|
- | 390 | vfx&= 3; |
|
281 | vfx&= 3; |
391 | } |
Line 295... | Line 405... | ||
295 | 405 | ||
Line 296... | Line 406... | ||
296 | init_winlib(); |
406 | init_winlib(); |
Line 297... | Line 407... | ||
297 | 407 | ||
298 | MainWindow = create_window(movie_file,0, |
408 | MainWindow = create_window(movie_file,0, |
Line -... | Line 409... | ||
- | 409 | 10,10,width,height+29+55,MainWindowProc); |
|
299 | 10,10,width,height+29+75,MainWindowProc); |
410 | |
Line 300... | Line 411... | ||
300 | 411 | MainWindow->panel.prg->max = stream_duration; |
|
Line 301... | Line 412... | ||
301 | // printf("MainWindow %x\n", MainWindow); |
412 | // printf("MainWindow %x\n", MainWindow); |
- | 413 | ||
- | 414 | main_render->win = MainWindow; |
|
- | 415 | ||
- | 416 | show_window(MainWindow, NORMAL); |
|
302 | 417 | ||
Line 303... | Line 418... | ||
303 | main_render->win = MainWindow; |
418 | render_draw_client(main_render); |
304 | 419 | player_state = PAUSE_2_PLAY; |
|
305 | show_window(MainWindow, NORMAL); |
420 | |
Line 446... | Line 561... | ||
446 | uint8_t state; |
561 | uint8_t state; |
447 | 562 | ||
Line 448... | Line 563... | ||
448 | 563 | ||
449 | right = win->w; |
564 | right = win->w; |
450 | bottom = win->h-CAPTION_HEIGHT-75; |
565 | bottom = win->h-CAPTION_HEIGHT-55; |
Line 451... | Line 566... | ||
451 | render->win_state = win->win_state; |
566 | render->win_state = win->win_state; |
452 | 567 | ||
Line 480... | Line 595... | ||
480 | new_h = 64*render->ctx_height/render->ctx_width; |
595 | new_h = 64*render->ctx_height/render->ctx_width; |
481 | }; |
596 | }; |
482 | 597 | ||
Line 483... | Line 598... | ||
483 | render->win_width = win->w; |
598 | render->win_width = win->w; |
484 | render->win_height = win->h-CAPTION_HEIGHT-75; |
599 | render->win_height = win->h-CAPTION_HEIGHT-55; |
485 | render_set_size(render, new_w, new_h); |
600 | render_set_size(render, new_w, new_h); |
486 | }; |
601 | }; |
Line 487... | Line 602... | ||
487 | 602 | ||
488 | void draw_hw_picture(render_t *render, AVPicture *picture) |
603 | void draw_hw_picture(render_t *render, AVPicture *picture) |
Line 598... | Line 713... | ||
598 | if(render->win_state == MINIMIZED || |
713 | if(render->win_state == MINIMIZED || |
599 | render->win_state == ROLLED) |
714 | render->win_state == ROLLED) |
600 | return; |
715 | return; |
601 | 716 | ||
Line 602... | Line 717... | ||
602 | if(player_state == PAUSE) |
717 | if((player_state == PAUSE) || |
- | 718 | (player_state == PLAY_INIT) ) |
|
603 | { |
719 | { |
- | 720 | if(frames[vfx].ready == 1 ) |
|
604 | main_render->draw(main_render, &frames[vfx].picture); |
721 | main_render->draw(main_render, &frames[vfx].picture); |
- | 722 | else |
|
- | 723 | draw_bar(0, CAPTION_HEIGHT, render->win_width, |
|
- | 724 | render->rcvideo.b, 0); |
|
605 | }; |
725 | }; |
Line 606... | Line 726... | ||
606 | 726 | ||
607 | if(render->layout & HAS_TOP) |
727 | if(render->layout & HAS_TOP) |
608 | draw_bar(0, CAPTION_HEIGHT, render->win_width, |
728 | draw_bar(0, CAPTION_HEIGHT, render->win_width, |