annotate libvo/vo_mpegpes.c @ 29922:3991a8fd6a02

Readjust the global number of subs when switching dvdnav track to take into account any change in the number of DVD subtitles available.
author reimar
date Tue, 24 Nov 2009 06:59:21 +0000
parents 0f1b5b68af32
children 358ac046eccc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
1 /*
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
2 * based on: test_av.c - test program for new API
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
3 *
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
4 * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
5 * & Marcus Metzler <marcus@convergence.de>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
6 * for convergence integrated media GmbH
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
7 *
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
8 * MPEG-PS multiplexer, part of FFmpeg
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
9 * Copyright Gerard Lantau (see http://ffmpeg.org)
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
10 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
11 * This file is part of MPlayer.
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
12 *
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
13 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
14 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
15 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
16 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
17 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
18 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
21 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
22 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
23 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
24 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 27431
diff changeset
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
26 */
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
27
6239
22cf38f95151 warning fix (write()/close() require unistd.h)
pl
parents: 5881
diff changeset
28 #include "config.h"
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
29 #include <stdio.h>
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
30 #include <stdlib.h>
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
31 #include <string.h>
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
32 #include <errno.h>
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
33 #include <sys/types.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
34 #include <sys/stat.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
35 #include <fcntl.h>
6239
22cf38f95151 warning fix (write()/close() require unistd.h)
pl
parents: 5881
diff changeset
36 #include <unistd.h>
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
37
5877
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
38 #include "mp_msg.h"
27369
8598536ca4f5 Set HAVE_DVB in configure when HAVE_DVB_HEAD is defined
diego
parents: 27368
diff changeset
39
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
40 #ifdef CONFIG_DVB
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
41 #ifndef CONFIG_DVB_HEAD
27431
bb738b9ea7c4 Use '#include <poll.h>' instead of '#include <sys/poll.h>'.
diego
parents: 27430
diff changeset
42 #include <poll.h>
2066
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
43
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
44 #include <sys/ioctl.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
45 #include <stdio.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
46 #include <time.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
47
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
48 #include <ost/dmx.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
49 #include <ost/frontend.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
50 #include <ost/sec.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
51 #include <ost/video.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
52 #include <ost/audio.h>
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
53
8594
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
54 #else
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
55 #define true 1
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
56 #define false 0
27431
bb738b9ea7c4 Use '#include <poll.h>' instead of '#include <sys/poll.h>'.
diego
parents: 27430
diff changeset
57 #include <poll.h>
8594
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
58
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
59 #include <sys/ioctl.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
60 #include <stdio.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
61 #include <time.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
62
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
63 #include <linux/dvb/dmx.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
64 #include <linux/dvb/frontend.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
65 #include <linux/dvb/video.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
66 #include <linux/dvb/audio.h>
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
67 #endif
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
68 #endif
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
69
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
70 #include "config.h"
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
71 #include "video_out.h"
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
72 #include "video_out_internal.h"
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 16171
diff changeset
73 #include "libmpdemux/mpeg_packetizer.h"
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
74
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
75 int vo_mpegpes_fd=-1;
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 19163
diff changeset
76 extern int vo_mpegpes_fd2;
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
77
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
78 static const vo_info_t info =
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
79 {
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
80 #ifdef CONFIG_DVB
27368
a50cc6945dfd cosmetics: typo fixes
diego
parents: 25558
diff changeset
81 "MPEG-PES to DVB card",
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
82 #else
27368
a50cc6945dfd cosmetics: typo fixes
diego
parents: 25558
diff changeset
83 "MPEG-PES file",
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
84 #endif
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
85 "mpegpes",
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
86 "A'rpi",
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
87 ""
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
88 };
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
89
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
90 const LIBVO_EXTERN (mpegpes)
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7860
diff changeset
91
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
92 static int
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 13048
diff changeset
93 config(uint32_t s_width, uint32_t s_height, uint32_t width, uint32_t height, uint32_t flags, char *title, uint32_t format)
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
94 {
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
95 #ifdef CONFIG_DVB
5877
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
96 switch(s_height){
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
97 case 288:
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
98 case 576:
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
99 case 240:
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
100 case 480:
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
101 break;
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
102 default:
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
103 mp_msg(MSGT_VO,MSGL_ERR,"DVB: height=%d not supported (try 240/480 (ntsc) or 288/576 (pal)\n",s_height);
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
104 return -1;
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
105 }
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
106 #endif
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
107 return 0;
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
108 }
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
109
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
110 static int preinit(const char *arg){
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
111 #ifdef CONFIG_DVB
25558
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
112 int card = -1;
13048
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
113 char vo_file[30], ao_file[30], *tmp;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
114
13048
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
115 if(arg != NULL){
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
116 if((tmp = strstr(arg, "card=")) != NULL) {
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
117 card = atoi(&tmp[5]);
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
118 if((card < 1) || (card > 4)) {
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
119 mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n");
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
120 return -1;
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
121 }
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
122 card--;
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
123 arg = NULL;
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
124 }
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
125 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
126
7672
e6b46875e1b9 - fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents: 7124
diff changeset
127 if(!arg){
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
128 //|O_NONBLOCK
25558
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
129 //search the first usable card
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
130 if(card==-1) {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
131 int n;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
132 for(n=0; n<4; n++) {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
133 sprintf(vo_file, "/dev/dvb/adapter%d/video0", n);
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
134 if(access(vo_file, F_OK | W_OK)==0) {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
135 card = n;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
136 break;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
137 }
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
138 }
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
139 }
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
140 if(card==-1) {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
141 mp_msg(MSGT_VO,MSGL_INFO, "Couldn't find a usable dvb video device, exiting\n");
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
142 return -1;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 25220
diff changeset
143 }
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
144 #ifndef CONFIG_DVB_HEAD
13048
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
145 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/ost/video+audio\n");
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
146 sprintf(vo_file, "/dev/ost/video");
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
147 sprintf(ao_file, "/dev/ost/audio");
8594
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
148 #else
13048
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
149 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/dvb/adapter%d/video0+audio0\n", card);
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
150 sprintf(vo_file, "/dev/dvb/adapter%d/video0", card);
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
151 sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card);
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
152 #endif
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
153 if((vo_mpegpes_fd = open(vo_file,O_RDWR)) < 0){
8594
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
154 perror("DVB VIDEO DEVICE: ");
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
155 return -1;
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 8148
diff changeset
156 }
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
157 if ( (ioctl(vo_mpegpes_fd,VIDEO_SET_BLANK, false) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
158 perror("DVB VIDEO SET BLANK: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
159 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
160 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
161 if ( (ioctl(vo_mpegpes_fd,VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
162 perror("DVB VIDEO SELECT SOURCE: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
163 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
164 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
165 if ( (ioctl(vo_mpegpes_fd,VIDEO_PLAY) < 0)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
166 perror("DVB VIDEO PLAY: ");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
167 return -1;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
168 }
7672
e6b46875e1b9 - fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents: 7124
diff changeset
169 return 0;
e6b46875e1b9 - fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents: 7124
diff changeset
170 }
e6b46875e1b9 - fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents: 7124
diff changeset
171 #endif
13048
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
172 arg = (arg ? arg : "grab.mpg");
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
173 mp_msg(MSGT_VO,MSGL_INFO, "Saving PES stream to %s\n", arg);
2f150c190f7a user can select dvb card number to use (V3 api only)
nicodvb
parents: 8917
diff changeset
174 vo_mpegpes_fd=open(arg,O_WRONLY|O_CREAT,0666);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
175 if(vo_mpegpes_fd<0){
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
176 perror("vo_mpegpes");
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
177 return -1;
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
178 }
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
179 return 0;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
180 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
181
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
182
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
183 static void draw_osd(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
184 {
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
185 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
186
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
187
19150
8f2b737e2a70 my_write() must return the bytes written
nicodvb
parents: 19148
diff changeset
188 static int my_write(unsigned char* data,int len){
19153
8df0a51b0e37 fix compilation if DVB is not defined
ben
parents: 19150
diff changeset
189 int orig_len = len;
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
190 #ifdef CONFIG_DVB
2066
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
191 #define NFD 2
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
192 struct pollfd pfd[NFD];
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
193
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
194 // printf("write %d bytes \n",len);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
195
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
196 pfd[0].fd = vo_mpegpes_fd;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
197 pfd[0].events = POLLOUT;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
198
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
199 pfd[1].fd = vo_mpegpes_fd2;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
200 pfd[1].events = POLLOUT;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
201
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
202 while(len>0){
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
203 if (poll(pfd,NFD,1)){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
204 if (pfd[0].revents & POLLOUT){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
205 int ret=write(vo_mpegpes_fd,data,len);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28446
diff changeset
206 // printf("ret=%d \n",ret);
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
207 if(ret<=0){
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
208 perror("write");
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
209 usleep(0);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
210 } else {
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
211 len-=ret; data+=ret;
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
212 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
213 } else usleep(1000);
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
214 }
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
215 }
2066
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
216
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
217 #else
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
218 write(vo_mpegpes_fd,data,len); // write to file
2b14cad013b7 using poll() only for DVB card - not required for file write
arpi
parents: 1986
diff changeset
219 #endif
19150
8f2b737e2a70 my_write() must return the bytes written
nicodvb
parents: 19148
diff changeset
220 return orig_len;
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
221 }
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
222
2706
3066369adb32 audio packet writting added
arpi
parents: 2496
diff changeset
223 void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 16171
diff changeset
224 send_mpeg_pes_packet (data, len, id, timestamp, 1, my_write);
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
225 }
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
226
4299
8e157167cee5 LPCM write code rewritten, thanks to Marcus at mocm@convergence.de
arpi
parents: 2727
diff changeset
227 void send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id){
19161
049c74156629 reuse send_mpeg_lpcm_packet() instead of the old packetizer
nicodvb
parents: 19153
diff changeset
228 send_mpeg_lpcm_packet(data, len, id, timestamp, freq_id, my_write);
2706
3066369adb32 audio packet writting added
arpi
parents: 2496
diff changeset
229 }
3066369adb32 audio packet writting added
arpi
parents: 2496
diff changeset
230
3066369adb32 audio packet writting added
arpi
parents: 2496
diff changeset
231
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
232 static int draw_frame(uint8_t * src[])
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
233 {
1872
2fe0e11bab3c file writer implemented
arpi
parents: 1871
diff changeset
234 vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
5877
93de400ad48e libfame code removed (use -vop fame/-vop lavc), init code moved to preinit, height checks added to config()
arpi
parents: 5844
diff changeset
235 send_pes_packet(p->data,p->size,p->id,(p->timestamp>0)?p->timestamp:vo_pts); // video data
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
236 return 0;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
237 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
238
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
239 static void flip_page (void)
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
240 {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
241 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
242
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
243 static int draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x0,int y0)
1935
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
244 {
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
245 return 0;
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
246 }
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
247
fcd39f3b13d4 YV12 support (using libavcodec for mpeg1-I encoding)
arpi
parents: 1876
diff changeset
248
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
249 static int
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
250 query_format(uint32_t format)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
251 {
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 13048
diff changeset
252 if(format==IMGFMT_MPEGPES) return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW|VFCAP_TIMER;
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
253 return 0;
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
254 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
255
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
256 static void
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
257 uninit(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
258 {
7672
e6b46875e1b9 - fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents: 7124
diff changeset
259 if(vo_mpegpes_fd2>=0 && vo_mpegpes_fd2!=vo_mpegpes_fd) close(vo_mpegpes_fd2);
e6b46875e1b9 - fixed a 10l bug: setting PTS flag even if no PTS stored
arpi
parents: 7124
diff changeset
260 vo_mpegpes_fd2=-1;
1876
220475b1676a PS multiplexing fixed
arpi
parents: 1872
diff changeset
261 if(vo_mpegpes_fd>=0){ close(vo_mpegpes_fd);vo_mpegpes_fd=-1;}
1871
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
262 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
263
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
264
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
265 static void check_events(void)
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
266 {
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
267 }
cb5dde69354b Mpeg PES added
arpi
parents:
diff changeset
268
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
269 static int control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4341
diff changeset
270 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
271 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
272 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
273 return query_format(*((uint32_t*)data));
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
274 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
275 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4341
diff changeset
276 }