annotate libmpdemux/dvdnav_stream.c @ 5718:82af351fff02

more tajpo
author gabucino
date Sat, 20 Apr 2002 06:25:49 +0000
parents 348c7d83e710
children 6c4eafe5b079
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
1 #include "config.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
2
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
3 #ifdef USE_DVDNAV
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
4 #include <dvdnav_internal.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
5 #include <stdlib.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
6 #include <stdio.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
7 #include <unistd.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
8 #include <string.h>
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
9 #include "mp_msg.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
10 #include "../linux/timer.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
11 #include "../input/input.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
12 #include "stream.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
13 #include "dvdnav_stream.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
14 #include "../spudec.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
15
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
16 int dvd_nav_skip_opening=0; /* skip opening stalls? */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
17 int osd_show_dvd_nav_delay=0; /* count down for dvd nav text on OSD */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
18 char dvd_nav_text[50]; /* for reporting stuff to OSD */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
19 int osd_show_dvd_nav_highlight; /* show highlight area */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
20 int osd_show_dvd_nav_sx; /* start x .... */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
21 int osd_show_dvd_nav_ex;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
22 int osd_show_dvd_nav_sy;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
23 int osd_show_dvd_nav_ey;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
24 int dvd_nav_still=0; /* are we on a still picture? */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
25
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
26 dvdnav_priv_t * new_dvdnav_stream(char * filename) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
27 char * title_str;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
28 dvdnav_priv_t *dvdnav_priv;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
29
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
30 if (!filename)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
31 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
32
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
33 if (!(dvdnav_priv=(dvdnav_priv_t*)calloc(1,sizeof(*dvdnav_priv))))
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
34 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
35
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
36 if (!(dvdnav_priv->filename=strdup(filename))) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
37 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
38 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
39 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
40
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
41 if(dvdnav_open(&(dvdnav_priv->dvdnav),dvdnav_priv->filename)!=DVDNAV_STATUS_OK)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
42 {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
43 free(dvdnav_priv->filename);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
44 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
45 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
46 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
47
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
48 if (!dvdnav_priv->dvdnav) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
49 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
50 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
51 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
52
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
53 dvdnav_stream_ignore_timers(dvdnav_priv,dvd_nav_skip_opening);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
54
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
55 /* turn on dvdnav caching */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
56 dvdnav_set_readahead_flag(dvdnav_priv->dvdnav,1);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
57
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
58 /* report the title?! */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
59 if (dvdnav_get_title_string(dvdnav_priv->dvdnav,&title_str)==DVDNAV_STATUS_OK) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
60 mp_msg(MSGT_OPEN,MSGL_INFO,"Title: '%s'\n",title_str);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
61 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
62
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
63 return dvdnav_priv;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
64 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
65
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
66 int dvdnav_stream_reset(dvdnav_priv_t * dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
67 if (!dvdnav_priv) return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
68
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
69 // if (dvdnav_reset(dvdnav_priv->dvdnav)!=DVDNAV_STATUS_OK)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
70 return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
71
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
72 dvdnav_priv->started=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
73
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
74 return 1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
75 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
76
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
77 void free_dvdnav_stream(dvdnav_priv_t * dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
78 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
79
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
80 dvdnav_close(dvdnav_priv->dvdnav);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
81 dvdnav_priv->dvdnav=NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
82 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
83 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
84
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
85 void dvdnav_stream_ignore_timers(dvdnav_priv_t * dvdnav_priv, int ignore) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
86 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
87
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
88 dvdnav_priv->ignore_timers=ignore;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
89 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
90
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
91 int dvdnav_stream_sleeping(dvdnav_priv_t * dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
92 unsigned int now;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
93
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
94 if (!dvdnav_priv) return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
95
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
96 if(dvdnav_priv->sleeping)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
97 {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
98 now=GetTimer();
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
99 while(dvdnav_priv->sleeping>1 || now<dvdnav_priv->sleep_until) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
100 // printf("%s %u<%u\n",__FUNCTION__,now,dvdnav_priv->sleep_until);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
101 // usec_sleep(1000); /* 1ms granularity */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
102 return 1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
103 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
104 dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past...
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
105 dvdnav_priv->sleeping=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
106 printf("%s: woke up!\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
107 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
108 dvd_nav_still=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
109 printf("%s: active\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
110 return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
111 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
112
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
113 void dvdnav_stream_sleep(dvdnav_priv_t * dvdnav_priv, int seconds) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
114 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
115
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
116 if (!dvdnav_priv->started) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
117
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
118 dvdnav_priv->sleeping=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
119 switch (seconds) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
120 case 0:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
121 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
122 case 0xff:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
123 printf( "Sleeping indefinately\n" );
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
124 dvdnav_priv->sleeping=2;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
125 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
126 default:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
127 printf( "Sleeping %d sec(s)\n", seconds );
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
128 dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
129 dvdnav_priv->sleeping=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
130 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
131 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
132 //if (dvdnav_priv->started) dvd_nav_still=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
133 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
134
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
135 void dvdnav_stream_add_event(dvdnav_priv_t* dvdnav_priv, int event, unsigned char *buf, int len) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
136 //printf("%s: %d\n",__FUNCTION__,event);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
137
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
138 dvdnav_event_t * dvdnav_event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
139 mp_cmd_t * cmd;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
140
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
141 if (!dvdnav_priv->started) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
142
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
143 if (!(dvdnav_event=(dvdnav_event_t*)calloc(1,sizeof(*dvdnav_event)))) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
144 printf("%s: dvdnav_event: out of memory!\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
145 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
146 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
147 dvdnav_event->event=event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
148 dvdnav_event->details=calloc(1,len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
149 memcpy(dvdnav_event->details,buf,len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
150 dvdnav_event->len=len;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
151
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
152 if (!(cmd = (mp_cmd_t*)calloc(1,sizeof(*cmd)))) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
153 printf("%s: mp_cmd_t: out of memory!\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
154 free(dvdnav_event->details);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
155 free(dvdnav_event);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
156 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
157 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
158 cmd->id=MP_CMD_DVDNAV_EVENT; // S+event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
159 cmd->name=strdup("dvdnav_event"); // FIXME: do I really need a 'name'?
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
160 cmd->nargs=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
161 cmd->args[0].v.v=dvdnav_event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
162
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
163 mp_input_queue_cmd(cmd);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
164 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
165
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
166 void dvdnav_stream_read(dvdnav_priv_t * dvdnav_priv, unsigned char *buf, int *len) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
167 int event = DVDNAV_NOP;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
168
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
169 if (!len) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
170 *len=-1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
171 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
172 if (!buf) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
173
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
174 if (dvd_nav_still) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
175 printf("%s: got a stream_read while I should be asleep!\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
176 *len=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
177 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
178 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
179
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
180 if (dvdnav_get_next_block(dvdnav_priv->dvdnav,buf,&event,len)!=DVDNAV_STATUS_OK) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
181 printf( "Error getting next block from DVD (%s)\n",dvdnav_err_to_string(dvdnav_priv->dvdnav) );
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
182 *len=-1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
183 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
184 else if (event!=DVDNAV_BLOCK_OK) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
185
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
186 // need to handle certain events internally (like skipping stills)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
187 switch (event) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
188 case DVDNAV_STILL_FRAME: {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
189 dvdnav_still_event_t *still_event = (dvdnav_still_event_t*)(buf);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
190
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
191 printf("************************************************************ STILL \n");
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
192
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
193 //if (dvdnav_priv->started) dvd_nav_still=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
194 //else
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
195 dvdnav_still_skip(dvdnav_priv->dvdnav); // don't let dvdnav stall on this image
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
196
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
197 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
198 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
199 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
200
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
201 // got an event, repeat the read
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
202 dvdnav_stream_add_event(dvdnav_priv,event,buf,*len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
203 *len=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
204 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
205 // printf("%s: got %d\n",__FUNCTION__,*len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
206 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
207
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
208 void dvdnav_stream_fullstart(dvdnav_priv_t * dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
209 if (dvdnav_priv && !dvdnav_priv->started) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
210 dvdnav_stream_reset(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
211 dvdnav_priv->started=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
212 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
213 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
214
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
215 unsigned int * dvdnav_stream_get_palette(dvdnav_priv_t * dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
216 if (!dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
217 printf("%s: NULL dvdnav_priv\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
218 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
219 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
220 if (!dvdnav_priv->dvdnav) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
221 printf("%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
222 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
223 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
224 if (!dvdnav_priv->dvdnav->vm) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
225 printf("%s: NULL dvdnav_priv->dvdnav->vm\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
226 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
227 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
228 if (!dvdnav_priv->dvdnav->vm->state.pgc) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
229 printf("%s: NULL dvdnav_priv->dvdnav->vm->state.pgc\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
230 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
231 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
232 return dvdnav_priv->dvdnav->vm->state.pgc->palette;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
233 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
234
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
235 #endif /* USE_DVDNAV */