annotate libmpdemux/dvdnav_stream.c @ 8514:a1ff87c254ff

I have rewritten the gif89a vo in order to solve some problems I had with it. These are: 1) current code is messy 2) poor comments, if any 3) inaccurate frame dropping and delay code 4) output filename hardcoded 5) output framerate as integer You may specify the output filename and framerate like so: -vo gif89a:4.33 4.33 fps output -vo gif89a:some.gif output to some.gif -vo gif89a:5.02:new.gif output to new.gif at 5.02 fps The filename defaults to out.gif, and the framerate defaults to 5 fps. by Joey Parrish <joey@nicewarrior.org>
author arpi
date Sat, 21 Dec 2002 21:07:16 +0000
parents 6c4eafe5b079
children edfe34c5405d
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"
6133
6c4eafe5b079 new spudec.h requires libvo headers, patch by Daniel Hottinger <TheHotti@gmx.ch>
arpi
parents: 5471
diff changeset
14 #include "../libvo/video_out.h"
5471
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
15 #include "../spudec.h"
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
16
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
17 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
18 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
19 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
20 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
21 int osd_show_dvd_nav_sx; /* start x .... */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
22 int osd_show_dvd_nav_ex;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
23 int osd_show_dvd_nav_sy;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
24 int osd_show_dvd_nav_ey;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
25 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
26
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
27 dvdnav_priv_t * new_dvdnav_stream(char * filename) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
28 char * title_str;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
29 dvdnav_priv_t *dvdnav_priv;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
30
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
31 if (!filename)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
32 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
33
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
34 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
35 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
36
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
37 if (!(dvdnav_priv->filename=strdup(filename))) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
38 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
39 return NULL;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
42 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
43 {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
44 free(dvdnav_priv->filename);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
45 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
46 return NULL;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
49 if (!dvdnav_priv->dvdnav) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
50 free(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
51 return NULL;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
54 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
55
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
56 /* turn on dvdnav caching */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
57 dvdnav_set_readahead_flag(dvdnav_priv->dvdnav,1);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
58
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
59 /* report the title?! */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
60 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
61 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
62 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
63
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
64 return dvdnav_priv;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
67 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
68 if (!dvdnav_priv) return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
69
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
70 // 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
71 return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
72
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
73 dvdnav_priv->started=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
74
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
75 return 1;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
78 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
79 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
80
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
81 dvdnav_close(dvdnav_priv->dvdnav);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
82 dvdnav_priv->dvdnav=NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
83 free(dvdnav_priv);
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
86 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
87 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
88
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
89 dvdnav_priv->ignore_timers=ignore;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
92 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
93 unsigned int now;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
94
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
95 if (!dvdnav_priv) return 0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
96
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
97 if(dvdnav_priv->sleeping)
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
98 {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
99 now=GetTimer();
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
100 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
101 // 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
102 // usec_sleep(1000); /* 1ms granularity */
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
103 return 1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
104 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
105 dvdnav_still_skip(dvdnav_priv->dvdnav); // continue past...
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
106 dvdnav_priv->sleeping=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
107 printf("%s: woke up!\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
108 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
109 dvd_nav_still=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
110 printf("%s: active\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
111 return 0;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
114 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
115 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
116
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
117 if (!dvdnav_priv->started) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
118
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
119 dvdnav_priv->sleeping=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
120 switch (seconds) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
121 case 0:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
122 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
123 case 0xff:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
124 printf( "Sleeping indefinately\n" );
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
125 dvdnav_priv->sleeping=2;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
126 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
127 default:
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
128 printf( "Sleeping %d sec(s)\n", seconds );
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
129 dvdnav_priv->sleep_until = GetTimer();// + seconds*1000000;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
130 dvdnav_priv->sleeping=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
131 break;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
132 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
133 //if (dvdnav_priv->started) dvd_nav_still=1;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
136 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
137 //printf("%s: %d\n",__FUNCTION__,event);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
138
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
139 dvdnav_event_t * dvdnav_event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
140 mp_cmd_t * cmd;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
141
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
142 if (!dvdnav_priv->started) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
143
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
144 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
145 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
146 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
147 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
148 dvdnav_event->event=event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
149 dvdnav_event->details=calloc(1,len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
150 memcpy(dvdnav_event->details,buf,len);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
151 dvdnav_event->len=len;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
152
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
153 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
154 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
155 free(dvdnav_event->details);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
156 free(dvdnav_event);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
157 return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
158 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
159 cmd->id=MP_CMD_DVDNAV_EVENT; // S+event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
160 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
161 cmd->nargs=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
162 cmd->args[0].v.v=dvdnav_event;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
163
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
164 mp_input_queue_cmd(cmd);
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
167 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
168 int event = DVDNAV_NOP;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
169
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
170 if (!len) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
171 *len=-1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
172 if (!dvdnav_priv) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
173 if (!buf) return;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
174
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
175 if (dvd_nav_still) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
176 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
177 *len=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
178 return;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
181 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
182 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
183 *len=-1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
184 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
185 else if (event!=DVDNAV_BLOCK_OK) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
186
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
187 // 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
188 switch (event) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
189 case DVDNAV_STILL_FRAME: {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
190 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
191
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
192 printf("************************************************************ STILL \n");
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
193
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
194 //if (dvdnav_priv->started) dvd_nav_still=1;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
195 //else
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
196 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
197
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
198 break;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
202 // got an event, repeat the read
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
203 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
204 *len=0;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
205 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
206 // printf("%s: got %d\n",__FUNCTION__,*len);
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
209 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
210 if (dvdnav_priv && !dvdnav_priv->started) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
211 dvdnav_stream_reset(dvdnav_priv);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
212 dvdnav_priv->started=1;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
216 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
217 if (!dvdnav_priv) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
218 printf("%s: NULL dvdnav_priv\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
219 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
220 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
221 if (!dvdnav_priv->dvdnav) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
222 printf("%s: NULL dvdnav_priv->dvdnav\n",__FUNCTION__);
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
223 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
224 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
225 if (!dvdnav_priv->dvdnav->vm) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
226 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
227 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
228 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
229 if (!dvdnav_priv->dvdnav->vm->state.pgc) {
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
230 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
231 return NULL;
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
232 }
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
233 return dvdnav_priv->dvdnav->vm->state.pgc->palette;
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
348c7d83e710 dvdnav_stream functions - dvdnav patch by Kees Cook <mplayer@outflux.net>
arpi
parents:
diff changeset
236 #endif /* USE_DVDNAV */