mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
stream_dvb: Move out PID-parsing, disable TPID parsing.
Move PID-string parsing into a separate function, reduces code-duplication. Drop TPID-parsing again since teletext-stream seems not really correctly identified (ffmpeg guessed mp3 in my test...). Parsing now done using strtok + sscanf instead of sscanfs with fixed numbers of expected fields - gives more correct checking of PID-overflow, will allow VDR-style PID-field parsing.
This commit is contained in:
parent
2c6ce12b3c
commit
02e6cf7a0a
@ -138,6 +138,33 @@ static void parse_vdr_par_string(const char* vdr_par_str, dvb_channel_t* ptr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool parse_pid_string(struct mp_log *log, char* pid_string, dvb_channel_t* ptr) {
|
||||||
|
if (pid_string[0]) {
|
||||||
|
int pcnt = 0;
|
||||||
|
const char* tokens = "+";
|
||||||
|
char* pidPart;
|
||||||
|
pidPart = strtok(pid_string, tokens);
|
||||||
|
while (pidPart != NULL) {
|
||||||
|
if (ptr->pids_cnt >= DMX_FILTER_SIZE-1) {
|
||||||
|
mp_verbose(log, "Maximum number of PIDs for one channel reached, ignoring further ones!\n");
|
||||||
|
return (pcnt > 0);
|
||||||
|
}
|
||||||
|
int numChars = 0;
|
||||||
|
int pid = 0;
|
||||||
|
pcnt += sscanf(pidPart, "%d%n", &pid, &numChars);
|
||||||
|
if (numChars > 0) {
|
||||||
|
ptr->pids[ptr->pids_cnt] = pid;
|
||||||
|
ptr->pids_cnt++;
|
||||||
|
}
|
||||||
|
pidPart = strtok(NULL, tokens);
|
||||||
|
}
|
||||||
|
if (pcnt > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, int type)
|
static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, int type)
|
||||||
{
|
{
|
||||||
dvb_channels_list *list;
|
dvb_channels_list *list;
|
||||||
@ -147,7 +174,7 @@ static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, i
|
|||||||
if (!filename)
|
if (!filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
int fields, cnt, pcnt, k;
|
int fields, cnt, k;
|
||||||
int has8192, has0;
|
int has8192, has0;
|
||||||
dvb_channel_t *ptr, *tmp, chn;
|
dvb_channel_t *ptr, *tmp, chn;
|
||||||
char tmp_lcr[256], tmp_hier[256], inv[256], bw[256], cr[256], mod[256], transm[256], gi[256], vpid_str[256], apid_str[256], tpid_str[256],
|
char tmp_lcr[256], tmp_hier[256], inv[256], bw[256], cr[256], mod[256], transm[256], gi[256], vpid_str[256], apid_str[256], tpid_str[256],
|
||||||
@ -292,33 +319,18 @@ static dvb_channels_list *dvb_get_channels(struct mp_log *log, char *filename, i
|
|||||||
list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc);
|
list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vpid_str[0]) {
|
if (parse_pid_string(log, vpid_str, ptr)) {
|
||||||
pcnt = sscanf(vpid_str, "%d+%d+%d+%d+%d+%d+%d", &ptr->pids[0], &ptr->pids[1], &ptr->pids[2], &ptr->pids[3],
|
fields++;
|
||||||
&ptr->pids[4], &ptr->pids[5], &ptr->pids[6]);
|
|
||||||
if (pcnt > 0) {
|
|
||||||
ptr->pids_cnt = pcnt;
|
|
||||||
fields++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (parse_pid_string(log, apid_str, ptr)) {
|
||||||
if (apid_str[0]) {
|
fields++;
|
||||||
cnt = ptr->pids_cnt;
|
|
||||||
pcnt = sscanf(apid_str, "%d+%d+%d+%d+%d+%d+%d+%d", &ptr->pids[cnt], &ptr->pids[cnt+1], &ptr->pids[cnt+2],
|
|
||||||
&ptr->pids[cnt+3], &ptr->pids[cnt+4], &ptr->pids[cnt+5], &ptr->pids[cnt+6], &ptr->pids[cnt+7]);
|
|
||||||
if (pcnt > 0) {
|
|
||||||
ptr->pids_cnt += pcnt;
|
|
||||||
fields++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (tpid_str[0]) {
|
// FIXME: Teletext PID excluded for now, seems misdetected as mp3.
|
||||||
cnt = ptr->pids_cnt;
|
if (parse_pid_string(log, tpid_str, ptr)) {
|
||||||
pcnt = sscanf(tpid_str, "%d+%d+%d", &ptr->pids[cnt], &ptr->pids[cnt+1], &ptr->pids[cnt+2]);
|
fields++;
|
||||||
if (pcnt > 0) {
|
|
||||||
ptr->pids_cnt += pcnt;
|
|
||||||
fields++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if((fields < 2) || (ptr->pids_cnt <= 0) || (ptr->freq == 0) || (strlen(ptr->name) == 0))
|
if((fields < 2) || (ptr->pids_cnt <= 0) || (ptr->freq == 0) || (strlen(ptr->name) == 0))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user