annotate stream/tv.c @ 24105:9e71e0345c35

Automatic TV channels scanning ability for MPlayer. Code is based on patch from Otvos Attila oattila at chello dot hu
author voroshil
date Thu, 23 Aug 2007 16:09:30 +0000
parents b5cc28c45d73
children 0a82a3b7ac46
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
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
23 #include "mp_msg.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
24 #include "help_mp.h"
98769cea155c added tv subsystem
alex
parents:
diff changeset
25
98769cea155c added tv subsystem
alex
parents:
diff changeset
26 #include "stream.h"
19312
ab8d6b6deb63 proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents: 19271
diff changeset
27 #include "libmpdemux/demuxer.h"
ab8d6b6deb63 proper inclusion of demuxer.h (including libmpdemux in Makefile only was to make previous split easier)
ben
parents: 19271
diff changeset
28 #include "libmpdemux/stheader.h"
2830
596a6ba3520f never include files from public headers...
arpi
parents: 2819
diff changeset
29
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16961
diff changeset
30 #include "libaf/af_format.h"
19431
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 19312
diff changeset
31 #include "libmpcodecs/img_format.h"
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23573
diff changeset
32 #include "libavutil/avstring.h"
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
33 #include "osdep/timer.h"
2830
596a6ba3520f never include files from public headers...
arpi
parents: 2819
diff changeset
34
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
35 #include "tv.h"
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
36
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
37 #include "frequencies.h"
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
38
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
39 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
40 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
41 char *tv_channel_last_real;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
42
22381
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
43 /* enumerating drivers (like in stream.c) */
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
44 extern tvi_info_t tvi_info_dummy;
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
45 #ifdef HAVE_TV_V4L1
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
46 extern tvi_info_t tvi_info_v4l;
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
47 #endif
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
48 #ifdef HAVE_TV_V4L2
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
49 extern tvi_info_t tvi_info_v4l2;
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
50 #endif
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
51 #ifdef HAVE_TV_BSDBT848
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
52 extern tvi_info_t tvi_info_bsdbt848;
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
53 #endif
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
54
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
55 static const tvi_info_t* tvi_driver_list[]={
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
56 &tvi_info_dummy,
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
57 #ifdef HAVE_TV_V4L1
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
58 &tvi_info_v4l,
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
59 #endif
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
60 #ifdef HAVE_TV_V4L2
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
61 &tvi_info_v4l2,
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
62 #endif
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
63 #ifdef HAVE_TV_BSDBT848
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
64 &tvi_info_bsdbt848,
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
65 #endif
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
66 NULL
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
67 };
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
68
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
69 void tv_start_scan(tvi_handle_t *tvh, int start)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
70 {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
71 mp_msg(MSGT_TV,MSGL_INFO,"start scan\n");
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
72 tvh->tv_param->scan=start?1:0;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
73 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
74
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
75 static void tv_scan(tvi_handle_t *tvh)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
76 {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
77 unsigned int now;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
78 struct CHANLIST cl;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
79 tv_channels_t *tv_channel_tmp=NULL;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
80 tv_channels_t *tv_channel_add=NULL;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
81 tv_scan_t* scan;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
82 int found=0, index=1;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
83
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
84 scan = tvh->scan;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
85 now=GetTimer();
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
86 if (!scan) {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
87 scan=calloc(1,sizeof(tv_scan_t));
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
88 tvh->scan=scan;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
89 cl = tvh->chanlist_s[scan->channel_num];
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
90 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
91 scan->scan_timer=now+1e6*tvh->tv_param->scan_period;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
92 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
93 if(scan->scan_timer>now)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
94 return;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
95
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
96 if (tv_get_signal(tvh)>tvh->tv_param->scan_threshold) {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
97 cl = tvh->chanlist_s[scan->channel_num];
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
98 tv_channel_tmp=tv_channel_list;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
99 while (tv_channel_tmp) {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
100 index++;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
101 if (cl.freq==tv_channel_tmp->freq){
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
102 found=1;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
103 break;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
104 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
105 tv_channel_add=tv_channel_tmp;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
106 tv_channel_tmp=tv_channel_tmp->next;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
107 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
108 if (!found) {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
109 mp_msg(MSGT_TV, MSGL_INFO, "Found new channel: %s (#%d). \n",cl.name,index);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
110 scan->new_channels++;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
111 tv_channel_tmp = malloc(sizeof(tv_channels_t));
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
112 tv_channel_tmp->index=index;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
113 tv_channel_tmp->next=NULL;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
114 tv_channel_tmp->prev=tv_channel_add;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
115 tv_channel_tmp->freq=cl.freq;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
116 snprintf(tv_channel_tmp->name,sizeof(tv_channel_tmp->name),"ch%d",index);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
117 strncpy(tv_channel_tmp->number, cl.name, 5);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
118 tv_channel_tmp->number[4]='\0';
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
119 if (!tv_channel_list)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
120 tv_channel_list=tv_channel_tmp;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
121 else {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
122 tv_channel_add->next=tv_channel_tmp;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
123 tv_channel_list->prev=tv_channel_tmp;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
124 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
125 }else
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
126 mp_msg(MSGT_TV, MSGL_INFO, "Found existing channel: %s-%s.\n",
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
127 tv_channel_tmp->number,tv_channel_tmp->name);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
128 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
129 scan->channel_num++;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
130 scan->scan_timer=now+1e6*tvh->tv_param->scan_period;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
131 if (scan->channel_num>=chanlists[tvh->chanlist].count) {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
132 tvh->tv_param->scan=0;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
133 mp_msg(MSGT_TV, MSGL_INFO, "TV scan end. Found %d new channels.\n", scan->new_channels);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
134 tv_channel_tmp=tv_channel_list;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
135 if(tv_channel_tmp){
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
136 mp_msg(MSGT_TV,MSGL_INFO,"channels=");
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
137 while(tv_channel_tmp){
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
138 mp_msg(MSGT_TV,MSGL_INFO,"%s-%s",tv_channel_tmp->number,tv_channel_tmp->name);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
139 if(tv_channel_tmp->next)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
140 mp_msg(MSGT_TV,MSGL_INFO,",");
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
141 tv_channel_tmp=tv_channel_tmp->next;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
142 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
143 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
144 if (!tv_channel_current) tv_channel_current=tv_channel_list;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
145 if (tv_channel_current)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
146 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
147 free(tvh->scan);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
148 tvh->scan=NULL;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
149 }else{
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
150 cl = tvh->chanlist_s[scan->channel_num];
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
151 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
152 mp_msg(MSGT_TV, MSGL_INFO, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq);
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
153 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
154 }
22381
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
155
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
156 /* ================== DEMUX_TV ===================== */
98769cea155c added tv subsystem
alex
parents:
diff changeset
157 /*
98769cea155c added tv subsystem
alex
parents:
diff changeset
158 Return value:
98769cea155c added tv subsystem
alex
parents:
diff changeset
159 0 = EOF(?) or no stream
98769cea155c added tv subsystem
alex
parents:
diff changeset
160 1 = successfully read a packet
98769cea155c added tv subsystem
alex
parents:
diff changeset
161 */
98769cea155c added tv subsystem
alex
parents:
diff changeset
162 /* fill demux->video and demux->audio */
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
163
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
164 static int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
165 {
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
166 tvi_handle_t *tvh=(tvi_handle_t*)(demux->priv);
2813
d6d88771f5ef demuxer fixed
arpi
parents: 2810
diff changeset
167 demux_packet_t* dp;
9927
ea1274e658b4 mingw fix
faust3
parents: 9889
diff changeset
168 unsigned int len=0;
22969
c8ace3e97d73 cosmetics. restore empty line removed in r22985.
voroshil
parents: 22967
diff changeset
169
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
170 /* ================== ADD AUDIO PACKET =================== */
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
171
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
172 if (ds==demux->audio && tvh->tv_param->noaudio == 0 &&
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
173 tvh->functions->control(tvh->priv,
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
174 TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
175 {
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
176 len = tvh->functions->get_audio_framesize(tvh->priv);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
177
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
178 dp=new_demux_packet(len);
12034
90315c910b26 Raw audio and video are always keyframes
ranma
parents: 11986
diff changeset
179 dp->flags|=1; /* Keyframe */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
180 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
181 ds_add_packet(demux->audio,dp);
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
182 }
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
183
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
184 /* ================== ADD VIDEO PACKET =================== */
98769cea155c added tv subsystem
alex
parents:
diff changeset
185
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
186 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
187 TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE)
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
188 {
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
189 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
190 dp=new_demux_packet(len);
12034
90315c910b26 Raw audio and video are always keyframes
ranma
parents: 11986
diff changeset
191 dp->flags|=1; /* Keyframe */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
192 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
193 ds_add_packet(demux->video,dp);
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
194 }
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
195
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
196 if (tvh->tv_param->scan) tv_scan(tvh);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
197 return 1;
98769cea155c added tv subsystem
alex
parents:
diff changeset
198 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
199
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
200 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
201 {
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
202 #ifdef HAVE_TV_V4L2
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
203 if (strcmp(tvh->tv_param->driver, "v4l2") != 0) {
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
204 #endif
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 else {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
220 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_BogusNormParameter, norm, "PAL");
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
221 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
222 }
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
223 #ifdef HAVE_TV_V4L2
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
224 } else {
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
225 tvi_functions_t *funcs = tvh->functions;
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
226 char str[8];
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
227 strncpy(str, norm, sizeof(str)-1);
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
228 str[sizeof(str)-1] = '\0';
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
229 if (funcs->control(tvh->priv, TVI_CONTROL_SPC_GET_NORMID, str) != TVI_CONTROL_TRUE)
22728
5e4a2438a0e2 Add missing bogus norm warning for v4l2
voroshil
parents: 22727
diff changeset
230 {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
231 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_BogusNormParameter, norm,"default");
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
232 return 0;
22728
5e4a2438a0e2 Add missing bogus norm warning for v4l2
voroshil
parents: 22727
diff changeset
233 }
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
234 return *(int *)str;
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
235 }
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
236 #endif
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
237 }
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7905
diff changeset
238
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
239 static int open_tv(tvi_handle_t *tvh)
2931
bce9c945b29c tv interface update
alex
parents: 2842
diff changeset
240 {
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
241 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
242 tvi_functions_t *funcs = tvh->functions;
17862
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
243 int tv_fmt_list[] = {
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
244 IMGFMT_YV12,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
245 IMGFMT_I420,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
246 IMGFMT_UYVY,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
247 IMGFMT_YUY2,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
248 IMGFMT_RGB32,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
249 IMGFMT_RGB24,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
250 IMGFMT_RGB16,
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
251 IMGFMT_RGB15
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
252 };
2932
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 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
255 {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
256 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoVideoInputPresent);
3728
499ce786c30d As nobody fixed this yet:
pl
parents: 3703
diff changeset
257 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
258 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
259
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
260 if (tvh->tv_param->outfmt == -1)
17862
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
261 for (i = 0; i < sizeof (tv_fmt_list) / sizeof (*tv_fmt_list); i++)
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
262 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
263 tvh->tv_param->outfmt = tv_fmt_list[i];
17862
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
264 if (funcs->control (tvh->priv, TVI_CONTROL_VID_SET_FORMAT,
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
265 &tvh->tv_param->outfmt) == TVI_CONTROL_TRUE)
17862
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
266 break;
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
267 }
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
268 else
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
269 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
270 switch(tvh->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
271 {
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
272 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
273 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
274 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
275 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
276 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
277 case IMGFMT_RGB24:
15419
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
278 case IMGFMT_BGR32:
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
279 case IMGFMT_BGR24:
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
280 case IMGFMT_BGR16:
da39fe11c872 BGR formats are ok, too
henry
parents: 14607
diff changeset
281 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
282 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
283 default:
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
284 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnknownImageFormat,tvh->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
285 }
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
286 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &tvh->tv_param->outfmt);
17862
ecb2023ee4b6 Try several formats instead of only YV12 if no format was explicitly
albeu
parents: 17174
diff changeset
287 }
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
288
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
289 /* set some params got from cmdline */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
290 funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tvh->tv_param->input);
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
291
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
292 #ifdef HAVE_TV_V4L2
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
293 if (!strcmp(tvh->tv_param->driver, "v4l2") && tvh->tv_param->normid >= 0) {
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
294 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedNormId, tvh->tv_param->normid);
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
295 if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->tv_param->normid) != TVI_CONTROL_TRUE) {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
296 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
297 }
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
298 } else {
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
299 #endif
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
300 /* select video norm */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
301 tvh->norm = norm_from_string(tvh, tvh->tv_param->norm);
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
302
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
303 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedNorm, tvh->tv_param->norm);
8486
c268bbb804d9 handle bogus norm parameter; check for errors when setting norm
henry
parents: 8477
diff changeset
304 if (funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
305 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
8486
c268bbb804d9 handle bogus norm parameter; check for errors when setting norm
henry
parents: 8477
diff changeset
306 }
10537
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
307 #ifdef HAVE_TV_V4L2
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
308 }
31f12f99118b v4l2 support
henry
parents: 10521
diff changeset
309 #endif
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
310
19187
97ea9a6616df Rename *v4l variable to *v4l1.
diego
parents: 19062
diff changeset
311 #ifdef HAVE_TV_V4L1
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
312 if ( tvh->tv_param->mjpeg )
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
313 {
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
314 /* set width to expected value */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
315 if (tvh->tv_param->width == -1)
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
316 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
317 tvh->tv_param->width = 704/tvh->tv_param->decimation;
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
318 }
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
319 if (tvh->tv_param->height == -1)
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
320 {
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
321 if ( tvh->norm != TV_NORM_NTSC )
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
322 tvh->tv_param->height = 576/tvh->tv_param->decimation;
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
323 else
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
324 tvh->tv_param->height = 480/tvh->tv_param->decimation;
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
325 }
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
326 mp_msg(MSGT_TV, MSGL_INFO,
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
327 MSGTR_TV_MJP_WidthHeight, tvh->tv_param->width, tvh->tv_param->height);
9620
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
328 }
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
329 #endif
ce4cd85498f3 hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents: 9519
diff changeset
330
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
331 /* 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
332 /* set width */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
333 if (tvh->tv_param->width != -1)
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
334 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
335 if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tvh->tv_param->width) == TVI_CONTROL_TRUE)
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
336 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tvh->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
337 else
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
338 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
339 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnableToSetWidth, tvh->tv_param->width);
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
340 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tvh->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
341 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
342 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
343
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
344 /* set height */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
345 if (tvh->tv_param->height != -1)
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
346 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
347 if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tvh->tv_param->height) == TVI_CONTROL_TRUE)
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
348 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tvh->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
349 else
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
350 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
351 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnableToSetHeight, tvh->tv_param->height);
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
352 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tvh->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
353 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
354 }
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
355
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
356 if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
357 {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
358 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_NoTuner);
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
359 goto done;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
360 }
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
361
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
362 /* select channel list */
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
363 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
364 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
365 if (!strcasecmp(chanlists[i].name, tvh->tv_param->chanlist))
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
366 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
367 tvh->chanlist = i;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
368 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
369 break;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
370 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
371 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
372
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
373 if (tvh->chanlist == -1)
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
374 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnableFindChanlist,
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
375 tvh->tv_param->chanlist);
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
376 else
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
377 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedChanlist,
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
378 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
379
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
380 if (tvh->tv_param->freq && tvh->tv_param->channel)
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
381 {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
382 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_ChannelFreqParamConflict);
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
383 goto done;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
384 }
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
385
10771
2f213f786e41 spelling fixes
diego
parents: 10598
diff changeset
386 /* Handle channel names */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
387 if (tvh->tv_param->channels) {
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
388 char** channels = tvh->tv_param->channels;
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
389 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_ChannelNamesDetected);
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
390 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
391 tv_channel_list->index=1;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
392 tv_channel_list->next=NULL;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
393 tv_channel_list->prev=NULL;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
394 tv_channel_current = tv_channel_list;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
395
9519
34b636d19268 10L never blowup an option pointer !!!!
albeu
parents: 9501
diff changeset
396 while (*channels) {
34b636d19268 10L never blowup an option pointer !!!!
albeu
parents: 9501
diff changeset
397 char* tmp = *(channels++);
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
398 char* sep = strchr(tmp,'-');
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
399 int i;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
400 struct CHANLIST cl;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
401
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
402 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
403
23703
9fb716ab06a3 Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
reimar
parents: 23573
diff changeset
404 av_strlcpy(tv_channel_current->name, sep + 1,
18761
4168044c1be4 fix a buffer overflow causing a segfault
aurel
parents: 18366
diff changeset
405 sizeof(tv_channel_current->name));
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
406 sep[0] = '\0';
8820
56fc9c8a8692 10l? :)
arpi
parents: 8799
diff changeset
407 strncpy(tv_channel_current->number, tmp, 5);
22619
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
408 tv_channel_current->number[4]='\0';
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
409
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
410 while ((sep=strchr(tv_channel_current->name, '_')))
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
411 sep[0] = ' ';
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
412
22619
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
413 // if channel number is a number and larger than 1000 threat it as frequency
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
414 // tmp still contain pointer to null-terminated string with channel number here
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
415 if (atoi(tmp)>1000){
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
416 tv_channel_current->freq=atoi(tmp);
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
417 }else{
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
418 tv_channel_current->freq = 0;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
419 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
420 cl = tvh->chanlist_s[i];
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
421 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
422 tv_channel_current->freq=cl.freq;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
423 break;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
424 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
425 }
22619
86edaa8501c1 Allow to specify frequencies in channels option.
voroshil
parents: 22381
diff changeset
426 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
427 if (tv_channel_current->freq == 0)
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
428 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoFreqForChannel,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
429 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
430 else {
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
431 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
432 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
433
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
434 if ( sep ) {
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
435 i = atoi (sep+1);
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
436 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
437 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
438 sep[0] = '\0';
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
439 }
9dc39697e3b3 channel finetuning cmdline support, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9663
diff changeset
440 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
441
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
442 /*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
443 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
444 (float)tv_channel_current->freq/1000);*/
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
445
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
446 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
447 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
448 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
449 tv_channel_current->next->next = NULL;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
450 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
451 }
8955
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
452 if (tv_channel_current->prev)
2454bcd4c3f3 sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
arpi
parents: 8820
diff changeset
453 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
454 free(tv_channel_current);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
455 } else
18366
d18fc000093d 100000l to the fools who don't know C
rfelker
parents: 18172
diff changeset
456 tv_channel_last_real = malloc(5);
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
457
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
458 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
459 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
460 int channel = 0;
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
461 if (tvh->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
462 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
463 if (isdigit(*tvh->tv_param->channel))
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
464 /* if tvh->tv_param->channel begins with a digit interpret it as a number */
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
465 channel = atoi(tvh->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
466 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
467 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
468 /* if tvh->tv_param->channel does not begin with a digit
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
469 set the first channel that contains tvh->tv_param->channel in its name */
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
470
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
471 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
472 while ( tv_channel_current ) {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
473 if ( strstr(tv_channel_current->name, tvh->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
474 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
475 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
476 }
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
477 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
478 }
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
479 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
480 else
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
481 channel = 1;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
482
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
483 if ( channel ) {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
484 tv_channel_current = tv_channel_list;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
485 for (i = 1; i < channel; i++)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
486 if (tv_channel_current->next)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
487 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
488 }
736ca83d609f abilty to set tv channel by name on commandline, patch by Ivan Szanto <szivan@duticai.TWI.TUDelft.NL>
alex
parents: 9927
diff changeset
489
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
490 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
491 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
492 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
493 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
494 } else {
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
495 /* we need to set frequency */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
496 if (tvh->tv_param->freq)
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
497 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
498 unsigned long freq = atof(tvh->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
499
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
500 /* set freq in MHz */
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
501 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
502
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
503 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
504 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedFrequency,
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
505 freq, (float)freq/16);
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
506 }
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
507
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
508 if (tvh->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
509 struct CHANLIST cl;
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
510
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
511 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_RequestedChannel, tvh->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
512 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
513 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
514 cl = tvh->chanlist_s[i];
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
515 // 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
516 // i, cl.name, cl.freq);
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
517 if (!strcasecmp(cl.name, tvh->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
518 {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
519 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
520 tvh->channel = i;
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
521 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
522 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
523 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
524 break;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
525 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
526 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
527 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
528 }
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
529
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
530 /* 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
531 {
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
532 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
533 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
534
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
535 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
536
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
537 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
538
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
539 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
540 {
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
541 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
542 {
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
543 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
544 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
545 }
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
546 }
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
547 }
3284
702e399a4b3e update (audio support is coming:)
alex
parents: 3249
diff changeset
548
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
549 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
550 /* also start device! */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
551 return 1;
2931
bce9c945b29c tv interface update
alex
parents: 2842
diff changeset
552 }
bce9c945b29c tv interface update
alex
parents: 2842
diff changeset
553
23883
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
554 static tvi_handle_t *tv_begin(tv_param_t* tv_param)
23879
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
555 {
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
556 int i;
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
557 tvi_handle_t* h;
23883
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
558 if(!strcmp(tv_param->driver,"help")){
23879
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
559 mp_msg(MSGT_TV,MSGL_INFO,MSGTR_TV_AvailableDrivers);
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
560 for(i=0;tvi_driver_list[i];i++){
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
561 mp_msg(MSGT_TV,MSGL_INFO," %s\t%s",tvi_driver_list[i]->short_name,tvi_driver_list[i]->name);
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
562 if(tvi_driver_list[i]->comment)
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
563 mp_msg(MSGT_TV,MSGL_INFO," (%s)",tvi_driver_list[i]->comment);
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
564 mp_msg(MSGT_TV,MSGL_INFO,"\n");
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
565 }
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
566 return NULL;
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
567 }
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
568
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
569 for(i=0;tvi_driver_list[i];i++){
23883
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
570 if (!strcmp(tvi_driver_list[i]->short_name, tv_param->driver)){
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
571 h=tvi_driver_list[i]->tvi_init(tv_param);
23879
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
572 if(!h) return NULL;
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
573
23883
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
574 h->tv_param=tv_param;
23879
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
575 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_DriverInfo, tvi_driver_list[i]->short_name,
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
576 tvi_driver_list[i]->name,
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
577 tvi_driver_list[i]->author,
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
578 tvi_driver_list[i]->comment?tvi_driver_list[i]->comment:"");
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
579 return h;
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
580 }
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
581 }
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
582
23883
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
583 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_NoSuchDriver, tv_param->driver);
23879
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
584 return(NULL);
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
585 }
26a32eda1603 Cosmetics: move two routines up
voroshil
parents: 23703
diff changeset
586
23881
5a5c7866921f Removing forward declarations of routines used only in tv.c
voroshil
parents: 23880
diff changeset
587 static int tv_uninit(tvi_handle_t *tvh)
23880
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
588 {
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
589 int res;
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
590 if(!tvh) return 1;
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
591 if (!tvh->priv) return 1;
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
592 res=tvh->functions->uninit(tvh->priv);
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
593 if(res) tvh->priv=NULL;
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
594 return res;
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
595 }
1c888cc4ebbb Cosmetics.
voroshil
parents: 23879
diff changeset
596
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
597 static demuxer_t* demux_open_tv(demuxer_t *demuxer)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
598 {
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
599 tvi_handle_t *tvh;
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
600 sh_video_t *sh_video;
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
601 sh_audio_t *sh_audio = NULL;
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
602 tvi_functions_t *funcs;
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
603
21837
922c0072a2bf Two crash issues fixed:
voroshil
parents: 19431
diff changeset
604 demuxer->priv=NULL;
23883
d65439444b75 Removing global variables from tv://
voroshil
parents: 23881
diff changeset
605 if(!(tvh=tv_begin(demuxer->stream->priv))) return NULL;
22381
6cabac4d35b5 tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents: 21837
diff changeset
606 if (!tvh->functions->init(tvh->priv)) return NULL;
23900
b5cc28c45d73 Teletext support.
voroshil
parents: 23889
diff changeset
607
b5cc28c45d73 Teletext support.
voroshil
parents: 23889
diff changeset
608 tvh->functions->control(tvh->priv,TVI_CONTROL_VBI_INIT,&(tvh->tv_param->tdevice));
b5cc28c45d73 Teletext support.
voroshil
parents: 23889
diff changeset
609
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
610 if (!open_tv(tvh)){
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
611 tv_uninit(tvh);
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
612 return NULL;
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
613 }
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
614 funcs = tvh->functions;
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
615 demuxer->priv=tvh;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
616
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
617 sh_video = new_sh_video(demuxer, 0);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
618
2932
fa3224774679 splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents: 2931
diff changeset
619 /* get IMAGE FORMAT */
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
620 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format);
2810
1f0bcdb49910 tv update
alex
parents: 2802
diff changeset
621 // 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
622 // sh_video->format = 0x0;
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
623
09d5c9834580 tv update
alex
parents: 2790
diff changeset
624 /* set FPS and FRAMETIME */
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
625
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
626 if(!sh_video->fps)
98769cea155c added tv subsystem
alex
parents:
diff changeset
627 {
10019
0ea7b9c6c27f 1000000000l
rfelker
parents: 10011
diff changeset
628 float tmp;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
629 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
630 sh_video->fps = 25.0f; /* on PAL */
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
631 else sh_video->fps = tmp;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
632 }
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
633
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
634 if (tvh->tv_param->fps != -1.0f)
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
635 sh_video->fps = tvh->tv_param->fps;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
636
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
637 sh_video->frametime = 1.0f/sh_video->fps;
98769cea155c added tv subsystem
alex
parents:
diff changeset
638
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
639 /* If playback only mode, go to immediate mode, fail silently */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
640 if(tvh->tv_param->immediate == 1)
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
641 {
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
642 funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0);
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
643 tvh->tv_param->noaudio = 1;
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
644 }
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
645
8799
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
646 /* disable TV audio if -nosound is present */
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
647 if (!demuxer->audio || demuxer->audio->id == -2) {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
648 tvh->tv_param->noaudio = 1;
8799
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
649 }
f08d507eb683 -nosound fix
henry
parents: 8627
diff changeset
650
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
651 /* 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
652 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
653
98769cea155c added tv subsystem
alex
parents:
diff changeset
654 /* 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
655 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
656
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
657 demuxer->video->sh = sh_video;
98769cea155c added tv subsystem
alex
parents:
diff changeset
658 sh_video->ds = demuxer->video;
98769cea155c added tv subsystem
alex
parents:
diff changeset
659 demuxer->video->id = 0;
9501
d64c56172220 make tv non-seekable
henry
parents: 8955
diff changeset
660 demuxer->seekable = 0;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
661
98769cea155c added tv subsystem
alex
parents:
diff changeset
662 /* here comes audio init */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
663 if (tvh->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
664 {
09d5c9834580 tv update
alex
parents: 2790
diff changeset
665 int audio_format;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
666 int sh_audio_format;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
667 char buf[128];
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
668
09d5c9834580 tv update
alex
parents: 2790
diff changeset
669 /* yeah, audio is present */
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
670
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
671 funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE,
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
672 &tvh->tv_param->audiorate);
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
673
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
674 if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE)
09d5c9834580 tv update
alex
parents: 2790
diff changeset
675 goto no_audio;
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
676
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
677 switch(audio_format)
09d5c9834580 tv update
alex
parents: 2790
diff changeset
678 {
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
679 case AF_FORMAT_U8:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
680 case AF_FORMAT_S8:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
681 case AF_FORMAT_U16_LE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
682 case AF_FORMAT_U16_BE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
683 case AF_FORMAT_S16_LE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
684 case AF_FORMAT_S16_BE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
685 case AF_FORMAT_S32_LE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
686 case AF_FORMAT_S32_BE:
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
687 sh_audio_format = 0x1; /* PCM */
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
688 break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
689 case AF_FORMAT_IMA_ADPCM:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
690 case AF_FORMAT_MU_LAW:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
691 case AF_FORMAT_A_LAW:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
692 case AF_FORMAT_MPEG2:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13978
diff changeset
693 case AF_FORMAT_AC3:
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
694 default:
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
695 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_UnsupportedAudioType,
14255
137896e25c24 100l, buf etc. in af_fmt2str call are already pointers...
reimar
parents: 14245
diff changeset
696 af_fmt2str(audio_format, buf, 128), audio_format);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
697 goto no_audio;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
698 }
09d5c9834580 tv update
alex
parents: 2790
diff changeset
699
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
700 sh_audio = new_sh_audio(demuxer, 0);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
701
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
702 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
703 &sh_audio->samplerate);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
704 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
705 &sh_audio->samplesize);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
706 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
707 &sh_audio->channels);
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
708
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
709 sh_audio->format = sh_audio_format;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
710 sh_audio->sample_format = audio_format;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
711
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
712 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
713 sh_audio->samplerate * sh_audio->samplesize *
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
714 sh_audio->channels;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
715
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
716 // emulate WF for win32 codecs:
19062
83c3afeab35d drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents: 18922
diff changeset
717 sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
5087
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
718 sh_audio->wf->wFormatTag = sh_audio->format;
1d54c3a27093 audio support and pts based packet handling by Charles Henrich
alex
parents: 4350
diff changeset
719 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
720 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
721 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
722 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
723 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
724
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
725 mp_msg(MSGT_DECVIDEO, MSGL_V, MSGTR_TV_AudioFormat,
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 5087
diff changeset
726 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
727 sh_audio->wf->nSamplesPerSec);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
728
09d5c9834580 tv update
alex
parents: 2790
diff changeset
729 demuxer->audio->sh = sh_audio;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
730 sh_audio->ds = demuxer->audio;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
731 demuxer->audio->id = 0;
09d5c9834580 tv update
alex
parents: 2790
diff changeset
732 }
09d5c9834580 tv update
alex
parents: 2790
diff changeset
733 no_audio:
09d5c9834580 tv update
alex
parents: 2790
diff changeset
734
7329
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
735 if(!(funcs->start(tvh->priv))){
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
736 // start failed :(
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
737 tv_uninit(tvh);
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
738 return NULL;
7329
9129781e5939 removed messy global 'tv_handle', use stream->priv for that purpose
arpi
parents: 7318
diff changeset
739 }
10581
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
740
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
741 /* set color eq */
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
742 tv_set_color_options(tvh, TV_COLOR_BRIGHTNESS, tvh->tv_param->brightness);
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
743 tv_set_color_options(tvh, TV_COLOR_HUE, tvh->tv_param->hue);
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
744 tv_set_color_options(tvh, TV_COLOR_SATURATION, tvh->tv_param->saturation);
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
745 tv_set_color_options(tvh, TV_COLOR_CONTRAST, tvh->tv_param->contrast);
10581
4ebff25d9a05 From: Kir Kostuchenko <kir@users.sourceforge.net>
gabucino
parents: 10537
diff changeset
746
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
747 return demuxer;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
748 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
749
17174
83a8c738be89 make demuxer seek and close functions return void, patch by Dominik Mierzejewski
wanderer
parents: 17012
diff changeset
750 static void 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
751 {
7408
0c6948b8100f stream layer cleanup part 2
arpi
parents: 7329
diff changeset
752 tvi_handle_t *tvh=(tvi_handle_t*)(demuxer->priv);
21837
922c0072a2bf Two crash issues fixed:
voroshil
parents: 19431
diff changeset
753 if (!tvh) return;
17174
83a8c738be89 make demuxer seek and close functions return void, patch by Dominik Mierzejewski
wanderer
parents: 17012
diff changeset
754 tvh->functions->uninit(tvh->priv);
21837
922c0072a2bf Two crash issues fixed:
voroshil
parents: 19431
diff changeset
755 demuxer->priv=NULL;
7058
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
756 }
2e5c07262861 new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents: 6161
diff changeset
757
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
758 /* utilities for mplayer (not mencoder!!) */
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
759 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
760 {
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
761 tvi_functions_t *funcs = tvh->functions;
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
762
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
763 switch(opt)
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
764 {
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
765 case TV_COLOR_BRIGHTNESS:
18172
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
766 return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value);
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
767 case TV_COLOR_HUE:
18172
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
768 return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value);
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
769 case TV_COLOR_SATURATION:
18172
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
770 return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value);
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
771 case TV_COLOR_CONTRAST:
18172
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
772 return funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value);
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
773 default:
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
774 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnknownColorOption, opt);
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
775 }
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
776
18172
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
777 return(TVI_CONTROL_UNKNOWN);
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
778 }
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
779
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
780 int tv_get_color_options(tvi_handle_t *tvh, int opt, int* value)
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
781 {
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
782 tvi_functions_t *funcs = tvh->functions;
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
783
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
784 switch(opt)
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
785 {
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
786 case TV_COLOR_BRIGHTNESS:
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
787 return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_BRIGHTNESS, value);
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
788 case TV_COLOR_HUE:
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
789 return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HUE, value);
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
790 case TV_COLOR_SATURATION:
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
791 return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_SATURATION, value);
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
792 case TV_COLOR_CONTRAST:
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
793 return funcs->control(tvh->priv, TVI_CONTROL_VID_GET_CONTRAST, value);
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
794 default:
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
795 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TV_UnknownColorOption, opt);
18172
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
796 }
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
797
90b62d7c0fca Implement tv_get_color_options() and make tv_set_color_options() return
albeu
parents: 18073
diff changeset
798 return(TVI_CONTROL_UNKNOWN);
2937
4307478ad922 added support for setting color values
alex
parents: 2932
diff changeset
799 }
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
800
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
801 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
802 {
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
803 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
804 {
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
805 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq);
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
806 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,
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
807 *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
808 }
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
809 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
810 }
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
811
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
812 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
813 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
814 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
815 {
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
816 // unsigned long freq = atof(tvh->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
817
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
818 /* 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
819 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
820
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
821 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
822 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_CurrentFrequency,
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
823 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
824 }
23900
b5cc28c45d73 Teletext support.
voroshil
parents: 23889
diff changeset
825 tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
826 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
827 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
828
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
829 int tv_get_signal(tvi_handle_t *tvh)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
830 {
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
831 int signal=0;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
832 if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE ||
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
833 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_SIGNAL, &signal)!=TVI_CONTROL_TRUE)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
834 return 0;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
835
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
836 return signal;
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
837 }
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
838
22667
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
839 /*****************************************************************
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
840 * \brief tune current frequency by step_interval value
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
841 * \parameter step_interval increment value in 1/16 MHz
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
842 * \note frequency is rounded to 1/16 MHz value
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
843 * \return 1
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
844 *
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
845 */
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
846 int tv_step_freq(tvi_handle_t* tvh, float step_interval){
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
847 unsigned long frequency;
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
848
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
849 tvh->tv_param->scan=0;
22667
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
850 tv_get_freq(tvh,&frequency);
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
851 frequency+=step_interval;
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
852 return tv_set_freq(tvh,frequency);
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
853 }
e1859558b37d New slave command: tv_step_freq <offset in MHz>
voroshil
parents: 22619
diff changeset
854
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
855 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
856 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
857 struct CHANLIST cl;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
858
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
859 tvh->tv_param->scan=0;
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
860 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
861 {
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
862 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
863 {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
864 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
865 cl = tvh->chanlist_s[--tvh->channel];
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
866 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
867 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
868 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
869 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
870 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
871
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
872 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
873 {
4242
bbfbe9bbb956 fixed channel changing with frequencies.c
alex
parents: 3815
diff changeset
874 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
875 {
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
876 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
877 cl = tvh->chanlist_s[++tvh->channel];
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
878 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
879 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
880 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
881 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
882 }
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
883 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
884 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
885
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
886 int tv_step_channel(tvi_handle_t *tvh, int direction) {
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
887 tvh->tv_param->scan=0;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
888 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
889 if (direction == TV_CHANNEL_HIGHER) {
16469
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
890 tv_channel_last = tv_channel_current;
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
891 if (tv_channel_current->next)
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
892 tv_channel_current = tv_channel_current->next;
16469
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
893 else
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
894 tv_channel_current = tv_channel_list;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
895 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
896 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
897 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
898 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
899 if (direction == TV_CHANNEL_LOWER) {
16469
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
900 tv_channel_last = tv_channel_current;
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
901 if (tv_channel_current->prev)
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
902 tv_channel_current = tv_channel_current->prev;
16469
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
903 else
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
904 while (tv_channel_current->next)
8c1c8d10c163 cycle through tv channels (patch by Andrew Calkin < calkina at geexbox.org >)
aurel
parents: 16175
diff changeset
905 tv_channel_current = tv_channel_current->next;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
906 tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16));
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
907 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
908 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
909 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
910 } 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
911 return(1);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
912 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
913
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
914 int tv_set_channel_real(tvi_handle_t *tvh, char *channel) {
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
915 int i;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
916 struct CHANLIST cl;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
917
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
918 tvh->tv_param->scan=0;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
919 strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name);
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
920 for (i = 0; i < chanlists[tvh->chanlist].count; i++)
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
921 {
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
922 cl = tvh->chanlist_s[i];
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
923 // printf("count%d: name: %s, freq: %d\n",
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
924 // i, cl.name, cl.freq);
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
925 if (!strcasecmp(cl.name, channel))
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
926 {
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
927 tvh->channel = i;
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
928 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
929 cl.name, (float)cl.freq/1000);
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
930 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
931 break;
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
932 }
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
933 }
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
934 return(1);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
935 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
936
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
937 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
938 int i, channel_int;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
939
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
940 tvh->tv_param->scan=0;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
941 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
942 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
943 channel_int = atoi(channel);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
944 tv_channel_current = tv_channel_list;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
945 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
946 if (tv_channel_current->next)
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
947 tv_channel_current = tv_channel_current->next;
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
948 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
949 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
950 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
951 } 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
952 return(1);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
953 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
954
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
955 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
956
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 23900
diff changeset
957 tvh->tv_param->scan=0;
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
958 if (tv_channel_list) {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
959 tv_channels_t *tmp;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
960
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
961 tmp = tv_channel_last;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
962 tv_channel_last = tv_channel_current;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
963 tv_channel_current = tmp;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
964
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
965 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel3, tv_channel_current->number,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
966 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
967 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
968 } else {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
969 int i;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
970 struct CHANLIST cl;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
971
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
972 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
973 {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
974 cl = tvh->chanlist_s[i];
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
975 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
976 {
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
977 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
978 tvh->channel = i;
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
979 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TV_SelectedChannel2,
8627
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
980 cl.name, (float)cl.freq/1000);
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
981 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
982 break;
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
983 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
984 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
985 }
14ab71b47a58 user friendly channel tuning + 10L fix in tvi_v4l (by Stephane Jourdois)
henry
parents: 8494
diff changeset
986 return(1);
8494
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
987 }
47cf94058137 add a TV_SET_CNANNEL command
henry
parents: 8487
diff changeset
988
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
989 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
990 {
16961
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
991 tvh->norm++;
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
992 if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
993 &tvh->norm) != TVI_CONTROL_TRUE) {
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
994 tvh->norm = 0;
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
995 if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM,
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
996 &tvh->norm) != TVI_CONTROL_TRUE) {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
997 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
16961
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
998 return 0;
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
999 }
8b5a4d2dcc2b implement norm switching, which was already documented??
reimar
parents: 16469
diff changeset
1000 }
23900
b5cc28c45d73 Teletext support.
voroshil
parents: 23889
diff changeset
1001 tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
1002 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
1003 }
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
1004
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
1005 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
1006 {
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7408
diff changeset
1007 return(1);
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2937
diff changeset
1008 }
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1009
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1010 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
1011 {
13978
2a9afbfc79d7 setting the norm using text ID instead of numeric
henry
parents: 12034
diff changeset
1012 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
1013
23887
2b431d844608 Removing global variables from tv://
voroshil
parents: 23883
diff changeset
1014 mp_msg(MSGT_TV, MSGL_V, MSGTR_TV_SelectedNorm, tvh->tv_param->norm);
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1015 if (tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm) != TVI_CONTROL_TRUE) {
22967
25704c80d194 Move translatable strings from tv.c to help_mp*
voroshil
parents: 22728
diff changeset
1016 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_CannotSetNorm);
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1017 return 0;
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1018 }
23900
b5cc28c45d73 Teletext support.
voroshil
parents: 23889
diff changeset
1019 tvh->functions->control(tvh->priv,TV_VBI_CONTROL_RESET,tvh->tv_param);
10521
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1020 return(1);
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1021 }
141141fdd250 I'd like to change tv tuner frequency in the slave mode. So this patch
gabucino
parents: 10368
diff changeset
1022
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1023 demuxer_desc_t demuxer_desc_tv = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1024 "Tv card demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1025 "tv",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1026 "TV",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1027 "Alex Beregszaszi, Charles R. Henrich",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1028 "?",
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1029 DEMUXER_TYPE_TV,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1030 0, // no autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1031 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1032 demux_tv_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1033 demux_open_tv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1034 demux_close_tv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1035 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1036 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 15419
diff changeset
1037 };