annotate libmpdemux/tv.c @ 16431:1220e74f3335

Remove useless space
author reimar
date Fri, 09 Sep 2005 11:19:27 +0000
parents 6b86089c2edd
children 8c1c8d10c163
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
1 /*
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
2 TV Interface for MPlayer
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
3
10368
6fb8a6a4a071 removing my (nonworking) email address
alex
parents: 10242
diff changeset
4 (C) Alex Beregszaszi
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
5
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
6 API idea based on libvo2
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
7
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
8 Feb 19, 2002: Significant rewrites by Charles R. Henrich (henrich@msu.edu)
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
9 to add support for audio, and bktr *BSD support.
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
10
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
11 */
98769cea155c added tv subsystem
alex
parents:
diff changeset
12
98769cea155c added tv subsystem
alex
parents:
diff changeset
13 #include <stdio.h>
98769cea155c added tv subsystem
alex
parents:
diff changeset
14 #include <stdlib.h>
98769cea155c added tv subsystem
alex
parents:
diff changeset
15 #include <unistd.h>
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
16 #include <string.h>
10242
4e34d468f549 warning fixes by Dominik
alex
parents: 10019
diff changeset
17 #include <ctype.h>
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
18 #include <sys/time.h>
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
19
98769cea155c added tv subsystem
alex
parents:
diff changeset
20 #include "config.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
21
2819
2e58962dc9fe cleaned up some warnings, and tv_param_on moved out from #ifdef USE_TV
alex
parents: 2818
diff changeset
22 int tv_param_on = 0;
2e58962dc9fe cleaned up some warnings, and tv_param_on moved out from #ifdef USE_TV
alex
parents: 2818
diff changeset
23
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
24 #ifdef USE_TV
98769cea155c added tv subsystem
alex
parents:
diff changeset
25 #include "mp_msg.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
26 #include "help_mp.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
27
98769cea155c added tv subsystem
alex
parents:
diff changeset
28 #include "stream.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
29 #include "demuxer.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
30 #include "stheader.h"
2830
596a6ba3520f never include files from public headers...
arpi
parents: 2819
diff changeset
31
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
32 #include "../libaf/af_format.h"
2830
596a6ba3520f never include files from public headers...
arpi
parents: 2819
diff changeset
33 #include "../libvo/img_format.h"
596a6ba3520f never include files from public headers...
arpi
parents: 2819
diff changeset
34 #include "../libvo/fastmemcpy.h"
596a6ba3520f never include files from public headers...
arpi
parents: 2819
diff changeset
35
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
36 #include "tv.h"
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
37
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
38 #include "frequencies.h"
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
39
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
40 /* some default values */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
41 int tv_param_audiorate = 44100;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
42 int tv_param_noaudio = 0;
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
43 int tv_param_immediate = 0;
2837
c63562f5f56f tuning worx (can set frequency)
alex
parents: 2830
diff changeset
44 char *tv_param_freq = NULL;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
45 char *tv_param_channel = NULL;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
46 char *tv_param_norm = "pal";
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
47 #ifdef HAVE_TV_V4L2
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
48 int tv_param_normid = -1;
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
49 #endif
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
50 char *tv_param_chanlist = "europe-east";
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
51 char *tv_param_device = NULL;
98769cea155c added tv subsystem
alex
parents:
diff changeset
52 char *tv_param_driver = "dummy";
98769cea155c added tv subsystem
alex
parents:
diff changeset
53 int tv_param_width = -1;
98769cea155c added tv subsystem
alex
parents:
diff changeset
54 int tv_param_height = -1;
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
55 int tv_param_input = 0; /* used in v4l and bttv */
10598
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
56 int tv_param_outfmt = IMGFMT_YV12;
3285
bd7bff4cb453 add tv fps support
alex
parents: 3284
diff changeset
57 float tv_param_fps = -1.0;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
58 char **tv_param_channels = NULL;
10822
6377c7d0459e audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents: 10771
diff changeset
59 int tv_param_audio_id = 0;
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
60 #if defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2)
7163
a193df8b275b v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents: 7058
diff changeset
61 int tv_param_amode = -1;
11986
80f8c8cffa31 dont mess up v4l volumes
attila
parents: 11775
diff changeset
62 int tv_param_volume = -1;
7163
a193df8b275b v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents: 7058
diff changeset
63 int tv_param_bass = -1;
a193df8b275b v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents: 7058
diff changeset
64 int tv_param_treble = -1;
a193df8b275b v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents: 7058
diff changeset
65 int tv_param_balance = -1;
a193df8b275b v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents: 7058
diff changeset
66 int tv_param_forcechan = -1;
7835
d489890c59d3 add an option to force audio recording when a tv card reports no audio sources
henry
parents: 7807
diff changeset
67 int tv_param_force_audio = 0;
7905
b062996d9794 added an option for specifying the size of capture buffer
henry
parents: 7835
diff changeset
68 int tv_param_buffer_size = -1;
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
69 int tv_param_mjpeg = 0;
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
70 int tv_param_decimation = 2;
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
71 int tv_param_quality = 90;
11775
66e491c35dc8 ALSA 1.x audio out driver
henry
parents: 10822
diff changeset
72 #if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
73 int tv_param_alsa = 0;
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
74 #endif
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
75 char* tv_param_adevice = NULL;
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
76 #endif
9663
596ad944a65e color equalizer for tv input
henry
parents: 9620
diff changeset
77 int tv_param_brightness = 0;
596ad944a65e color equalizer for tv input
henry
parents: 9620
diff changeset
78 int tv_param_contrast = 0;
596ad944a65e color equalizer for tv input
henry
parents: 9620
diff changeset
79 int tv_param_hue = 0;
596ad944a65e color equalizer for tv input
henry
parents: 9620
diff changeset
80 int tv_param_saturation = 0;
14607
7a80c6ac5058 several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents: 14255
diff changeset
81 tv_channels_t *tv_channel_list;
7a80c6ac5058 several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents: 14255
diff changeset
82 tv_channels_t *tv_channel_current, *tv_channel_last;
7a80c6ac5058 several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents: 14255
diff changeset
83 char *tv_channel_last_real;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
84
98769cea155c added tv subsystem
alex
parents:
diff changeset
85 /* ================== DEMUX_TV ===================== */
98769cea155c added tv subsystem
alex
parents:
diff changeset
86 /*
98769cea155c added tv subsystem
alex
parents:
diff changeset
87 Return value:
98769cea155c added tv subsystem
alex
parents:
diff changeset
88 0 = EOF(?) or no stream
98769cea155c added tv subsystem
alex
parents:
diff changeset
89 1 = successfully read a packet
98769cea155c added tv subsystem
alex
parents:
diff changeset
90 */
98769cea155c added tv subsystem
alex
parents:
diff changeset
91 /* fill demux->video and demux->audio */
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
92
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
93 static int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
94 {
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
95 tvi_handle_t *tvh=(tvi_handle_t*)(demux->priv);
2813
d6d88771f5ef demuxer fixed
arpi
parents: 2810
diff changeset
96 demux_packet_t* dp;
9927
ea1274e658b4 mingw fix
faust3
parents: 9889
diff changeset
97 unsigned int len=0;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
98
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
99 /* ================== ADD AUDIO PACKET =================== */
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
100
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
101 if (ds==demux->audio && tv_param_noaudio == 0 &&
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
102 tvh->functions->control(tvh->priv,
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
103 TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
104 {
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
105 len = tvh->functions->get_audio_framesize(tvh->priv);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
106
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
107 dp=new_demux_packet(len);
12034
90315c910b26 Raw audio and video are always keyframes
ranma
parents: 11986
diff changeset
108 dp->flags|=1; /* Keyframe */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
109 dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
110 ds_add_packet(demux->audio,dp);
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
111 }
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
112
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
113 /* ================== ADD VIDEO PACKET =================== */
98769cea155c added tv subsystem
alex
parents:
diff changeset
114
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
115 if (ds==demux->video && tvh->functions->control(tvh->priv,
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
116 TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE)
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
117 {
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
118 len = tvh->functions->get_video_framesize(tvh->priv);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
119 dp=new_demux_packet(len);
12034
90315c910b26 Raw audio and video are always keyframes
ranma
parents: 11986
diff changeset
120 dp->flags|=1; /* Keyframe */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
121 dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
122 ds_add_packet(demux->video,dp);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
123 }
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
124
98769cea155c added tv subsystem
alex
parents:
diff changeset
125 return 1;
98769cea155c added tv subsystem
alex
parents:
diff changeset
126 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
127
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
128 static int norm_from_string(tvi_handle_t *tvh, char* norm)
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
129 {
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
130 #ifdef HAVE_TV_V4L2
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
131 if (strcmp(tv_param_driver, "v4l2") != 0) {
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
132 #endif
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
133 if (!strcasecmp(norm, "pal"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
134 return TV_NORM_PAL;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
135 else if (!strcasecmp(norm, "ntsc"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
136 return TV_NORM_NTSC;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
137 else if (!strcasecmp(norm, "secam"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
138 return TV_NORM_SECAM;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
139 else if (!strcasecmp(norm, "palnc"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
140 return TV_NORM_PALNC;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
141 else if (!strcasecmp(norm, "palm"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
142 return TV_NORM_PALM;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
143 else if (!strcasecmp(norm, "paln"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
144 return TV_NORM_PALN;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
145 else if (!strcasecmp(norm, "ntscjp"))
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
146 return TV_NORM_NTSCJP;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
147 else {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
148 mp_msg(MSGT_TV, MSGL_V, "tv.c: norm_from_string(%s): Bogus norm parameter, setting PAL.\n", norm);
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
149 return TV_NORM_PAL;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
150 }
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
151 #ifdef HAVE_TV_V4L2
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
152 } else {
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
153 tvi_functions_t *funcs = tvh->functions;
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
154 char str[8];
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
155 strncpy(str, norm, sizeof(str)-1);
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
156 str[sizeof(str)-1] = '\0';
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
157 if (funcs->control(tvh->priv, TVI_CONTROL_SPC_GET_NORMID, str) != TVI_CONTROL_TRUE)
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
158 return 0;
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
159 return *(int *)str;
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
160 }
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
161 #endif
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
162 }
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7905
diff changeset
163
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
164 static int open_tv(tvi_handle_t *tvh)
2931
bce9c945b29c tv interface update
alex
parents: 2842
diff changeset
165 {
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
166 int i;
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
167 tvi_functions_t *funcs = tvh->functions;
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
168
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
169 if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
170 {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
171 mp_msg(MSGT_TV, MSGL_ERR, "Error: No video input present!\n");
3728
499ce786c30d As nobody fixed this yet:
pl
parents: 3703
diff changeset
172 return 0;
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
173 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
174
10598
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
175 switch(tv_param_outfmt)
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
176 {
10598
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
177 case IMGFMT_YV12:
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
178 case IMGFMT_I420:
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
179 case IMGFMT_UYVY:
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
180 case IMGFMT_YUY2:
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
181 case IMGFMT_RGB32:
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
182 case IMGFMT_RGB24:
15419
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
183 case IMGFMT_BGR32:
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
184 case IMGFMT_BGR24:
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
185 case IMGFMT_BGR16:
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
186 case IMGFMT_BGR15:
10598
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
187 break;
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
188 default:
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
189 mp_msg(MSGT_TV, MSGL_ERR, "==================================================================\n");
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
190 mp_msg(MSGT_TV, MSGL_ERR, " WARNING: UNTESTED OR UNKNOWN OUTPUT IMAGE FORMAT REQUESTED (0x%x)\n", tv_param_outfmt);
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
191 mp_msg(MSGT_TV, MSGL_ERR, " This may cause buggy playback or program crash! Bug reports will\n");
10598
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
192 mp_msg(MSGT_TV, MSGL_ERR, " be ignored! You should try again with YV12 (which is the default\n");
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
193 mp_msg(MSGT_TV, MSGL_ERR, " colorspace) and read the documentation!\n");
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
194 mp_msg(MSGT_TV, MSGL_ERR, "==================================================================\n");
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
195 }
10598
2b88c28a3cfe Settled to CONF_TYPE_IMGFMT which simplified lot of things. Now there's no need to add new img formats to the source, instead you can try it out by providing it in hexa format, and if it isn't supported by the card, you get a nice error message. That's all.
alex
parents: 10581
diff changeset
196 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &tv_param_outfmt);
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
197
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
198 /* set some params got from cmdline */
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
199 funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
200
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
201 #ifdef HAVE_TV_V4L2
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
202 if (!strcmp(tv_param_driver, "v4l2") && tv_param_normid >= 0) {
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
203 mp_msg(MSGT_TV, MSGL_V, "Selected norm id: %d\n", tv_param_normid);
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
204 if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tv_param_normid) != TVI_CONTROL_TRUE) {
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
205 mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
206 return 0;
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
207 }
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
208 } else {
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
209 #endif
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
210 /* select video norm */
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
211 tvh->norm = norm_from_string(tvh, tv_param_norm);
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
212
7318
85897ab199a4 changed message leveles (too many non-sense info messages)
alex
parents: 7163
diff changeset
213 mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm);
8486
c268bbb804d9 handle bogus norm parameter; check for errors when setting norm
henry
parents: 8477
diff changeset
214 if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
215 mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
8486
c268bbb804d9 handle bogus norm parameter; check for errors when setting norm
henry
parents: 8477
diff changeset
216 return 0;
c268bbb804d9 handle bogus norm parameter; check for errors when setting norm
henry
parents: 8477
diff changeset
217 }
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
218 #ifdef HAVE_TV_V4L2
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
219 }
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
220 #endif
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
221
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
222 #ifdef HAVE_TV_V4L
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
223 if ( tv_param_mjpeg )
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
224 {
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
225 /* set width to expected value */
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
226 if (tv_param_width == -1)
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
227 {
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
228 tv_param_width = 704/tv_param_decimation;
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
229 }
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
230 if (tv_param_height == -1)
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
231 {
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
232 if ( tvh->norm != TV_NORM_NTSC )
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
233 tv_param_height = 576/tv_param_decimation;
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
234 else
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
235 tv_param_height = 480/tv_param_decimation;
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
236 }
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
237 mp_msg(MSGT_TV, MSGL_INFO,
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
238 " MJP: width %d height %d\n", tv_param_width, tv_param_height);
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
239 }
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
240 #endif
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«”n Sz«”nt«Ń <szivan@freemail.hu>
henry
parents: 9519
diff changeset
241
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
242 /* limits on w&h are norm-dependent -- JM */
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
243 /* set width */
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
244 if (tv_param_width != -1)
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
245 {
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
246 if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tv_param_width) == TVI_CONTROL_TRUE)
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
247 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tv_param_width);
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
248 else
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
249 {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
250 mp_msg(MSGT_TV, MSGL_ERR, "Unable to set requested width: %d\n", tv_param_width);
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
251 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tv_param_width);
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
252 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
253 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
254
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
255 /* set height */
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
256 if (tv_param_height != -1)
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
257 {
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
258 if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tv_param_height) == TVI_CONTROL_TRUE)
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
259 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tv_param_height);
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
260 else
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
261 {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
262 mp_msg(MSGT_TV, MSGL_ERR, "Unable to set requested height: %d\n", tv_param_height);
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
263 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tv_param_height);
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
264 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
265 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
266
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
267 if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
268 {
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
269 mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
270 goto done;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
271 }
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
272
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
273 /* select channel list */
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
274 for (i = 0; chanlists[i].name != NULL; i++)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
275 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
276 if (!strcasecmp(chanlists[i].name, tv_param_chanlist))
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
277 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
278 tvh->chanlist = i;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
279 tvh->chanlist_s = chanlists[i].list;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
280 break;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
281 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
282 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
283
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
284 if (tvh->chanlist == -1)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
285 mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
286 tv_param_chanlist);
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
287 else
7318
85897ab199a4 changed message leveles (too many non-sense info messages)
alex
parents: 7163
diff changeset
288 mp_msg(MSGT_TV, MSGL_V, "Selected channel list: %s (including %d channels)\n",
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
289 chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
290
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
291 if (tv_param_freq && tv_param_channel)
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
292 {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
293 mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultaneously!\n");
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
294 goto done;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
295 }
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
296
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
297 /* Handle channel names */
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
298 if (tv_param_channels) {
9519
34b636d19268 10L never blowup an option pointer !!!!
albeu
parents: 9501
diff changeset
299 char** channels = tv_param_channels;
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
300 mp_msg(MSGT_TV, MSGL_INFO, "TV channel names detected.\n");
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
301 tv_channel_list = malloc(sizeof(tv_channels_t));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
302 tv_channel_list->index=1;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
303 tv_channel_list->next=NULL;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
304 tv_channel_list->prev=NULL;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
305 tv_channel_current = tv_channel_list;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
306
9519
34b636d19268 10L never blowup an option pointer !!!!
albeu
parents: 9501
diff changeset
307 while (*channels) {
34b636d19268 10L never blowup an option pointer !!!!
albeu
parents: 9501
diff changeset
308 char* tmp = *(channels++);
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
309 char* sep = strchr(tmp,'-');
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
310 int i;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
311 struct CHANLIST cl;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
312
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
313 if (!sep) continue; // Wrong syntax, but mplayer should not crash
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
314
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
315 strcpy(tv_channel_current->name, sep + 1);
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
316 sep[0] = '\0';
8820
56fc9c8a8692 10l? :)
arpi
parents: 8799
diff changeset
317 strncpy(tv_channel_current->number, tmp, 5);
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
318
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
319 while ((sep=strchr(tv_channel_current->name, '_')))
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
320 sep[0] = ' ';
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
321
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
322 tv_channel_current->freq = 0;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
323 for (i = 0; i < chanlists[tvh->chanlist].count; i++) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
324 cl = tvh->chanlist_s[i];
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
325 if (!strcasecmp(cl.name, tv_channel_current->number)) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
326 tv_channel_current->freq=cl.freq;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
327 break;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
328 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
329 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
330 if (tv_channel_current->freq == 0)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
331 mp_msg(MSGT_TV, MSGL_ERR, "Couldn't find frequency for channel %s (%s)\n",
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
332 tv_channel_current->number, tv_channel_current->name);
9889
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
333 else {
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
334 sep = strchr(tv_channel_current->name, '-');
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
335 if ( !sep ) sep = strchr(tv_channel_current->name, '+');
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
336
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
337 if ( sep ) {
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
338 i = atoi (sep+1);
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
339 if ( sep[0] == '+' ) tv_channel_current->freq += i * 100;
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
340 if ( sep[0] == '-' ) tv_channel_current->freq -= i * 100;
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
341 sep[0] = '\0';
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
342 }
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
343 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
344
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
345 /*mp_msg(MSGT_TV, MSGL_INFO, "-- Detected channel %s - %s (%5.3f)\n",
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
346 tv_channel_current->number, tv_channel_current->name,
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
347 (float)tv_channel_current->freq/1000);*/
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
348
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
349 tv_channel_current->next = malloc(sizeof(tv_channels_t));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
350 tv_channel_current->next->index = tv_channel_current->index + 1;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
351 tv_channel_current->next->prev = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
352 tv_channel_current->next->next = NULL;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
353 tv_channel_current = tv_channel_current->next;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
354 }
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
355 if (tv_channel_current->prev)
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
356 tv_channel_current->prev->next = NULL;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
357 free(tv_channel_current);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
358 } else
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
359 tv_channel_last_real = malloc(sizeof(char)*5);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
360
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
361 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
362 int i;
10011
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
363 int channel = 0;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
364 if (tv_param_channel)
10011
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
365 {
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
366 if (isdigit(*tv_param_channel))
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
367 /* if tv_param_channel begins with a digit interpret it as a number */
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
368 channel = atoi(tv_param_channel);
10011
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
369 else
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
370 {
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
371 /* if tv_param_channel does not begin with a digit
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
372 set the first channel that contains tv_param_channel in its name */
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
373
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
374 tv_channel_current = tv_channel_list;
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
375 while ( tv_channel_current ) {
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
376 if ( strstr(tv_channel_current->name, tv_param_channel) )
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
377 break;
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
378 tv_channel_current = tv_channel_current->next;
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
379 }
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
380 if ( !tv_channel_current ) tv_channel_current = tv_channel_list;
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
381 }
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
382 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
383 else
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
384 channel = 1;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
385
10011
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
386 if ( channel ) {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
387 tv_channel_current = tv_channel_list;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
388 for (i = 1; i < channel; i++)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
389 if (tv_channel_current->next)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
390 tv_channel_current = tv_channel_current->next;
10011
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
391 }
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
392
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
393 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
394 tv_channel_current->name, (float)tv_channel_current->freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
395 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
396 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
397 } else {
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
398 /* we need to set frequency */
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
399 if (tv_param_freq)
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
400 {
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
401 unsigned long freq = atof(tv_param_freq)*16;
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
402
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
403 /* set freq in MHz */
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
404 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
405
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
406 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
7318
85897ab199a4 changed message leveles (too many non-sense info messages)
alex
parents: 7163
diff changeset
407 mp_msg(MSGT_TV, MSGL_V, "Selected frequency: %lu (%.3f)\n",
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
408 freq, (float)freq/16);
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
409 }
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
410
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
411 if (tv_param_channel) {
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
412 struct CHANLIST cl;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
413
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
414 mp_msg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tv_param_channel);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
415 for (i = 0; i < chanlists[tvh->chanlist].count; i++)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
416 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
417 cl = tvh->chanlist_s[i];
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
418 // printf("count%d: name: %s, freq: %d\n",
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
419 // i, cl.name, cl.freq);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
420 if (!strcasecmp(cl.name, tv_param_channel))
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
421 {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
422 strcpy(tv_channel_last_real, cl.name);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
423 tvh->channel = i;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
424 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
425 cl.name, (float)cl.freq/1000);
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
426 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
427 break;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
428 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
429 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
430 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
431 }
7806
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
432
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
433 /* grep frequency in chanlist */
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
434 {
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
435 unsigned long i2;
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
436 int freq;
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
437
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
438 tv_get_freq(tvh, &i2);
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
439
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
440 freq = (int) (((float)(i2/16))*1000)+250;
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
441
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
442 for (i = 0; i < chanlists[tvh->chanlist].count; i++)
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
443 {
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
444 if (tvh->chanlist_s[i].freq == freq)
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
445 {
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
446 tvh->channel = i+1;
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
447 break;
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
448 }
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
449 }
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
450 }
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
451
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
452 done:
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
453 /* also start device! */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
454 return 1;
2931
bce9c945b29c tv interface update
alex
parents: 2842
diff changeset
455 }
bce9c945b29c tv interface update
alex
parents: 2842
diff changeset
456
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
457 static demuxer_t* demux_open_tv(demuxer_t *demuxer)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
458 {
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
459 tvi_handle_t *tvh;
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
460 sh_video_t *sh_video;
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
461 sh_audio_t *sh_audio = NULL;
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
462 tvi_functions_t *funcs;
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
463
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
464 if(!(tvh=tv_begin())) return NULL;
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
465 if (!tv_init(tvh)) return NULL;
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
466 if (!open_tv(tvh)){
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
467 tv_uninit(tvh);
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
468 return NULL;
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
469 }
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
470 funcs = tvh->functions;
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
471 demuxer->priv=tvh;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
472
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
473 sh_video = new_sh_video(demuxer, 0);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
474
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
475 /* get IMAGE FORMAT */
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
476 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
2810
1f0bcdb49910 tv update
alex
parents: 2802
diff changeset
477 // if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format))
3398
a73b02e35e70 give the IMGFMT_ for sh_video->format not 0x0
alex
parents: 3285
diff changeset
478 // sh_video->format = 0x0;
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
479
09d5c9834580 tv update
alex
parents: 2790
diff changeset
480 /* set FPS and FRAMETIME */
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
481
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
482 if(!sh_video->fps)
98769cea155c added tv subsystem
alex
parents:
diff changeset
483 {
10019
0ea7b9c6c27f 1000000000l
rfelker
parents: 10011
diff changeset
484 float tmp;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
485 if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &tmp) != TVI_CONTROL_TRUE)
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
486 sh_video->fps = 25.0f; /* on PAL */
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
487 else sh_video->fps = tmp;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
488 }
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
489
3285
bd7bff4cb453 add tv fps support
alex
parents: 3284
diff changeset
490 if (tv_param_fps != -1.0f)
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
491 sh_video->fps = tv_param_fps;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
492
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
493 sh_video->frametime = 1.0f/sh_video->fps;
98769cea155c added tv subsystem
alex
parents:
diff changeset
494
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
495 /* If playback only mode, go to immediate mode, fail silently */
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
496 if(tv_param_immediate == 1)
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
497 {
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
498 funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
499 tv_param_noaudio = 1;
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
500 }
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
501
8799
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
502 /* disable TV audio if -nosound is present */
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
503 if (!demuxer->audio || demuxer->audio->id == -2) {
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
504 tv_param_noaudio = 1;
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
505 }
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
506
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
507 /* set width */
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
508 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
509
98769cea155c added tv subsystem
alex
parents:
diff changeset
510 /* set height */
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
511 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
512
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
513 demuxer->video->sh = sh_video;
98769cea155c added tv subsystem
alex
parents:
diff changeset
514 sh_video->ds = demuxer->video;
98769cea155c added tv subsystem
alex
parents:
diff changeset
515 demuxer->video->id = 0;
9501
d64c56172220 make tv non-seekable
henry
parents: 8955
diff changeset
516 demuxer->seekable = 0;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
517
98769cea155c added tv subsystem
alex
parents:
diff changeset
518 /* here comes audio init */
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
519 if (tv_param_noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
520 {
09d5c9834580 tv update
alex
parents: 2790
diff changeset
521 int audio_format;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
522 int sh_audio_format;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
523 char buf[128];
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
524
09d5c9834580 tv update
alex
parents: 2790
diff changeset
525 /* yeah, audio is present */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
526
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
527 funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE,
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
528 &tv_param_audiorate);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
529
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
530 if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE)
09d5c9834580 tv update
alex
parents: 2790
diff changeset
531 goto no_audio;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
532
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
533 switch(audio_format)
09d5c9834580 tv update
alex
parents: 2790
diff changeset
534 {
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
535 case AF_FORMAT_U8:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
536 case AF_FORMAT_S8:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
537 case AF_FORMAT_U16_LE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
538 case AF_FORMAT_U16_BE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
539 case AF_FORMAT_S16_LE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
540 case AF_FORMAT_S16_BE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
541 case AF_FORMAT_S32_LE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
542 case AF_FORMAT_S32_BE:
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
543 sh_audio_format = 0x1; /* PCM */
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
544 break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
545 case AF_FORMAT_IMA_ADPCM:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
546 case AF_FORMAT_MU_LAW:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
547 case AF_FORMAT_A_LAW:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
548 case AF_FORMAT_MPEG2:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
549 case AF_FORMAT_AC3:
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
550 default:
6161
c50ea0721e78 applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents: 5923
diff changeset
551 mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s (%x)' unsupported!\n",
14255
137896e25c24 100l, buf etc. in af_fmt2str call are already pointers...
reimar
parents: 14245
diff changeset
552 af_fmt2str(audio_format, buf, 128), audio_format);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
553 goto no_audio;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
554 }
09d5c9834580 tv update
alex
parents: 2790
diff changeset
555
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
556 sh_audio = new_sh_audio(demuxer, 0);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
557
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
558 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
559 &sh_audio->samplerate);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
560 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE,
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
561 &sh_audio->samplesize);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
562 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS,
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
563 &sh_audio->channels);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
564
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
565 sh_audio->format = sh_audio_format;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
566 sh_audio->sample_format = audio_format;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
567
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
568 sh_audio->i_bps = sh_audio->o_bps =
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
569 sh_audio->samplerate * sh_audio->samplesize *
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
570 sh_audio->channels;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
571
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
572 // emulate WF for win32 codecs:
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
573 sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX));
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
574 sh_audio->wf->wFormatTag = sh_audio->format;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
575 sh_audio->wf->nChannels = sh_audio->channels;
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
576 sh_audio->wf->wBitsPerSample = sh_audio->samplesize * 8;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
577 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
578 sh_audio->wf->nBlockAlign = sh_audio->samplesize * sh_audio->channels;
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
579 sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps;
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
580
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
581 mp_msg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
582 sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
583 sh_audio->wf->nSamplesPerSec);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
584
09d5c9834580 tv update
alex
parents: 2790
diff changeset
585 demuxer->audio->sh = sh_audio;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
586 sh_audio->ds = demuxer->audio;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
587 demuxer->audio->id = 0;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
588 }
09d5c9834580 tv update
alex
parents: 2790
diff changeset
589 no_audio:
09d5c9834580 tv update
alex
parents: 2790
diff changeset
590
7329
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
591 if(!(funcs->start(tvh->priv))){
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
592 // start failed :(
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
593 tv_uninit(tvh);
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
594 return NULL;
7329
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
595 }
10581
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
596
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
597 /* set color eq */
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
598 tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tv_param_brightness);
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
599 tv_set_color_options(tvh, TV_COLOR_HUE, tv_param_hue);
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
600 tv_set_color_options(tvh, TV_COLOR_SATURATION, tv_param_saturation);
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
601 tv_set_color_options(tvh, TV_COLOR_CONTRAST, tv_param_contrast);
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
602
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
603 return demuxer;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
604 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
605
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
606 static int demux_close_tv(demuxer_t *demuxer)
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
607 {
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
608 tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv);
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
609 return(tvh->functions->uninit(tvh->priv));
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
610 }
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
611
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
612 /* ================== STREAM_TV ===================== */
6161
c50ea0721e78 applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents: 5923
diff changeset
613 tvi_handle_t *tvi_init_dummy(char *device);
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
614 tvi_handle_t *tvi_init_v4l(char *device, char *adevice);
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
615 tvi_handle_t *tvi_init_v4l2(char *device, char *adevice);
6161
c50ea0721e78 applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents: 5923
diff changeset
616 tvi_handle_t *tvi_init_bsdbt848(char *device);
c50ea0721e78 applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents: 5923
diff changeset
617
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
618 tvi_handle_t *tv_begin(void)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
619 {
98769cea155c added tv subsystem
alex
parents:
diff changeset
620 if (!strcmp(tv_param_driver, "dummy"))
6161
c50ea0721e78 applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents: 5923
diff changeset
621 return tvi_init_dummy(tv_param_device);
3249
49a0d462dffe init_v4l only present if HAVE_TV_V4L
alex
parents: 2941
diff changeset
622 #ifdef HAVE_TV_V4L
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
623 if (!strcmp(tv_param_driver, "v4l"))
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
624 return tvi_init_v4l(tv_param_device, tv_param_adevice);
3249
49a0d462dffe init_v4l only present if HAVE_TV_V4L
alex
parents: 2941
diff changeset
625 #endif
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
626 #ifdef HAVE_TV_V4L2
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
627 if (!strcmp(tv_param_driver, "v4l2"))
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
628 return tvi_init_v4l2(tv_param_device, tv_param_adevice);
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
629 #endif
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
630 #ifdef HAVE_TV_BSDBT848
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
631 if (!strcmp(tv_param_driver, "bsdbt848"))
6161
c50ea0721e78 applied 64bit patch from Ulrich Hecht <uli at suse dot de>
alex
parents: 5923
diff changeset
632 return tvi_init_bsdbt848(tv_param_device);
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
633 #endif
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
634
98769cea155c added tv subsystem
alex
parents:
diff changeset
635 mp_msg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param_driver);
98769cea155c added tv subsystem
alex
parents:
diff changeset
636 return(NULL);
98769cea155c added tv subsystem
alex
parents:
diff changeset
637 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
638
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
639 int tv_init(tvi_handle_t *tvh)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
640 {
2818
9f68d309f8cb printf's changed into mp_msg
alex
parents: 2817
diff changeset
641 mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n", tvh->info->short_name);
9f68d309f8cb printf's changed into mp_msg
alex
parents: 2817
diff changeset
642 mp_msg(MSGT_TV, MSGL_INFO, " name: %s\n", tvh->info->name);
9f68d309f8cb printf's changed into mp_msg
alex
parents: 2817
diff changeset
643 mp_msg(MSGT_TV, MSGL_INFO, " author: %s\n", tvh->info->author);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
644 if (tvh->info->comment)
2818
9f68d309f8cb printf's changed into mp_msg
alex
parents: 2817
diff changeset
645 mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
646
3815
622a9ade4517 updated
alex
parents: 3728
diff changeset
647 return(tvh->functions->init(tvh->priv));
2837
c63562f5f56f tuning worx (can set frequency)
alex
parents: 2830
diff changeset
648 }
c63562f5f56f tuning worx (can set frequency)
alex
parents: 2830
diff changeset
649
c63562f5f56f tuning worx (can set frequency)
alex
parents: 2830
diff changeset
650 int tv_uninit(tvi_handle_t *tvh)
c63562f5f56f tuning worx (can set frequency)
alex
parents: 2830
diff changeset
651 {
c63562f5f56f tuning worx (can set frequency)
alex
parents: 2830
diff changeset
652 return(tvh->functions->uninit(tvh->priv));
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
653 }
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
654
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
655 /* utilities for mplayer (not mencoder!!) */
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
656 int tv_set_color_options(tvi_handle_t *tvh, int opt, int value)
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
657 {
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
658 tvi_functions_t *funcs = tvh->functions;
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
659
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
660 switch(opt)
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
661 {
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
662 case TV_COLOR_BRIGHTNESS:
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
663 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
664 break;
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
665 case TV_COLOR_HUE:
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
666 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
667 break;
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
668 case TV_COLOR_SATURATION:
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
669 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
670 break;
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
671 case TV_COLOR_CONTRAST:
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
672 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
673 break;
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
674 default:
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
675 mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
676 }
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
677
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
678 return(1);
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
679 }
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
680
7806
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
681 int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq)
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
682 {
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
683 if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
684 {
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
685 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
686 mp_msg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
687 *freq, (float)*freq/16);
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
688 }
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
689 return(1);
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
690 }
6a6f6b8b2ac7 set position in channel list on startup. note: hope one day we will get cleaned the int->float->int sutff ;)
alex
parents: 7472
diff changeset
691
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
692 int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
693 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
694 if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
695 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
696 // unsigned long freq = atof(tv_param_freq)*16;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
697
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
698 /* set freq in MHz */
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
699 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
700
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
701 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
7318
85897ab199a4 changed message leveles (too many non-sense info messages)
alex
parents: 7163
diff changeset
702 mp_msg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n",
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
703 freq, (float)freq/16);
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
704 }
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
705 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
706 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
707
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
708 int tv_step_channel_real(tvi_handle_t *tvh, int direction)
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
709 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
710 struct CHANLIST cl;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
711
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
712 if (direction == TV_CHANNEL_LOWER)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
713 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
714 if (tvh->channel-1 >= 0)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
715 {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
716 strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
5923
4241047fb315 patch by J«ärgen Appel <jappel@linux01.gwdg.de>:
pl
parents: 5572
diff changeset
717 cl = tvh->chanlist_s[--tvh->channel];
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
718 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
719 cl.name, (float)cl.freq/1000);
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
720 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
721 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
722 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
723
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
724 if (direction == TV_CHANNEL_HIGHER)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
725 {
4242
bbfbe9bbb956 fixed channel changing with frequencies.c
alex
parents: 3815
diff changeset
726 if (tvh->channel+1 < chanlists[tvh->chanlist].count)
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
727 {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
728 strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
5923
4241047fb315 patch by J«ärgen Appel <jappel@linux01.gwdg.de>:
pl
parents: 5572
diff changeset
729 cl = tvh->chanlist_s[++tvh->channel];
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
730 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
731 cl.name, (float)cl.freq/1000);
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
732 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
733 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
734 }
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
735 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
736 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
737
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
738 int tv_step_channel(tvi_handle_t *tvh, int direction) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
739 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
740 if (direction == TV_CHANNEL_HIGHER) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
741 if (tv_channel_current->next) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
742 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
743 tv_channel_current = tv_channel_current->next;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
744 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
745 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
746 tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
747 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
748 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
749 if (direction == TV_CHANNEL_LOWER) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
750 if (tv_channel_current->prev) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
751 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
752 tv_channel_current = tv_channel_current->prev;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
753 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
754 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n",
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
755 tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
756 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
757 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
758 } else tv_step_channel_real(tvh, direction);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
759 return(1);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
760 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
761
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
762 int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
763 int i;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
764 struct CHANLIST cl;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
765
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
766 strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
767 for (i = 0; i < chanlists[tvh->chanlist].count; i++)
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
768 {
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
769 cl = tvh->chanlist_s[i];
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
770 // printf("count%d: name: %s, freq: %d\n",
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
771 // i, cl.name, cl.freq);
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
772 if (!strcasecmp(cl.name, channel))
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
773 {
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
774 tvh->channel = i;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
775 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
776 cl.name, (float)cl.freq/1000);
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
777 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
778 break;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
779 }
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
780 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
781 return(1);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
782 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
783
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
784 int tv_set_channel(tvi_handle_t *tvh, char *channel) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
785 int i, channel_int;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
786
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
787 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
788 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
789 channel_int = atoi(channel);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
790 tv_channel_current = tv_channel_list;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
791 for (i = 1; i < channel_int; i++)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
792 if (tv_channel_current->next)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
793 tv_channel_current = tv_channel_current->next;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
794 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
795 tv_channel_current->name, (float)tv_channel_current->freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
796 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
797 } else tv_set_channel_real(tvh, channel);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
798 return(1);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
799 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
800
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
801 int tv_last_channel(tvi_handle_t *tvh) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
802
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
803 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
804 tv_channels_t *tmp;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
805
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
806 tmp = tv_channel_last;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
807 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
808 tv_channel_current = tmp;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
809
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
810 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number,
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
811 tv_channel_current->name, (float)tv_channel_current->freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
812 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
813 } else {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
814 int i;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
815 struct CHANLIST cl;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
816
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
817 for (i = 0; i < chanlists[tvh->chanlist].count; i++)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
818 {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
819 cl = tvh->chanlist_s[i];
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
820 if (!strcasecmp(cl.name, tv_channel_last_real))
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
821 {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
822 strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
823 tvh->channel = i;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
824 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
825 cl.name, (float)cl.freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
826 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
827 break;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
828 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
829 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
830 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
831 return(1);
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
832 }
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
833
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
834 int tv_step_norm(tvi_handle_t *tvh)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
835 {
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
836 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
837 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
838
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
839 int tv_step_chanlist(tvi_handle_t *tvh)
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
840 {
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
841 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
842 }
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
843
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
844 int tv_set_norm(tvi_handle_t *tvh, char* norm)
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
845 {
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
846 tvh->norm = norm_from_string(tvh, norm);
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
847
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
848 mp_msg(MSGT_TV, MSGL_V, "Selected norm: %s\n", tv_param_norm);
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
849 if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
850 mp_msg(MSGT_TV, MSGL_ERR, "Error: Cannot set norm!\n");
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
851 return 0;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
852 }
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
853 return(1);
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
854 }
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
855
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
856 demuxer_desc_t demuxer_desc_tv = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
857 "Tv card demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
858 "tv",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
859 "TV",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
860 "Alex Beregszaszi, Charles R. Henrich",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
861 "?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
862 DEMUXER_TYPE_TV,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
863 0, // no autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
864 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
865 demux_tv_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
866 demux_open_tv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
867 demux_close_tv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
868 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
869 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
870 };
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
871
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
872 #endif /* USE_TV */