comparison menus.c @ 1:cfe5048cc182

add my initial changes (use O_APPEND, add "skip title" option)
author paulo@thepaulopc
date Thu, 12 Nov 2009 23:43:47 -0800
parents 7e8d91fad6c7
children 399518436fcf
comparison
equal deleted inserted replaced
0:93749ee354c6 1:f14c340e1864
47 int main(int argc, char **argv) { 47 int main(int argc, char **argv) {
48 dvdnav_t *dvdnav; 48 dvdnav_t *dvdnav;
49 uint8_t mem[DVD_VIDEO_LB_LEN]; 49 uint8_t mem[DVD_VIDEO_LB_LEN];
50 int finished = 0; 50 int finished = 0;
51 int output_fd = 0; 51 int output_fd = 0;
52 int dump = 0, tt_dump = 0; 52 int dump = 0, tt_dump = 0, tt_skip = 0;
53 53
54 /* open dvdnav handle */ 54 /* open dvdnav handle */
55 printf("Opening DVD...\n"); 55 printf("Opening DVD...\n");
56 if (dvdnav_open(&dvdnav, "/dev/dvd") != DVDNAV_STATUS_OK) { 56 if (dvdnav_open(&dvdnav, "/dev/dvd") != DVDNAV_STATUS_OK) {
57 printf("Error on dvdnav_open\n"); 57 printf("Error on dvdnav_open\n");
103 case DVDNAV_BLOCK_OK: 103 case DVDNAV_BLOCK_OK:
104 /* We have received a regular block of the currently playing MPEG stream. 104 /* We have received a regular block of the currently playing MPEG stream.
105 * A real player application would now pass this block through demuxing 105 * A real player application would now pass this block through demuxing
106 * and decoding. We simply write it to disc here. */ 106 * and decoding. We simply write it to disc here. */
107 107
108 if (!output_fd) { 108 if (!output_fd && (dump || tt_dump)) {
109 printf("Opening output...\n"); 109 printf("Opening output...\n");
110 output_fd = open("libdvdnav.mpg", O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG); 110 output_fd = open("libdvdnav.mpg", O_CREAT | O_WRONLY | O_APPEND, S_IRWXU | S_IRWXG);
111 if (output_fd == -1) { 111 if (output_fd == -1) {
112 printf("Error opening output\n"); 112 printf("Error opening output\n");
113 return 4; 113 return 4;
114 } 114 }
115 } 115 }
187 187
188 dump = 0; 188 dump = 0;
189 if (tt_dump && tt != tt_dump) 189 if (tt_dump && tt != tt_dump)
190 tt_dump = 0; 190 tt_dump = 0;
191 191
192 if (!dump && !tt_dump) { 192 if (tt_skip && tt != tt_skip)
193 tt_skip = 0;
194
195 if (output_fd && !tt_dump) {
196 printf("Closing output...\n");
197 output_fd = close(output_fd);
198 }
199
200 if (!dump && !tt_dump && !tt_skip) {
193 fflush(stdin); 201 fflush(stdin);
194 while ((input != 'a') && (input != 's') && (input != 'q') && (input != 't')) { 202 while ((input != 'a') && (input != 's') && (input != 'q') && (input != 't') && (input != 'l')) {
195 printf("(a)ppend cell to output\n(s)kip cell\nappend until end of (t)itle\n(q)uit\n"); 203 printf("(a)ppend cell to output\n(s)kip cell\nappend until end of (t)itle\nskip tit(l)e\n(q)uit\n");
196 scanf("%c", &input); 204 scanf("%c", &input);
197 } 205 }
198 206
199 switch (input) { 207 switch (input) {
200 case 'a': 208 case 'a':
201 dump = 1; 209 dump = 1;
202 break; 210 break;
203 case 't': 211 case 't':
204 tt_dump = tt; 212 tt_dump = tt;
205 break; 213 break;
214 case 'l':
215 tt_skip = tt;
216 break;
206 case 'q': 217 case 'q':
207 finished = 1; 218 finished = 1;
208 } 219 }
209 } 220 }
210 } 221 }