mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
-add pmt parse to scanSDT
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@860 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -21,9 +21,8 @@
|
|||||||
|
|
||||||
#ifndef __zapit_pat_h__
|
#ifndef __zapit_pat_h__
|
||||||
#define __zapit_pat_h__
|
#define __zapit_pat_h__
|
||||||
|
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
|
||||||
int parse_pat(CZapitChannel * const channel);
|
int parse_pat(CZapitChannel * const channel);
|
||||||
|
int scan_parse_pat( std::vector<std::pair<int,int> > &sidpmt );
|
||||||
|
|
||||||
#endif /* __zapit_pat_h__ */
|
#endif /* __zapit_pat_h__ */
|
||||||
|
@@ -28,5 +28,6 @@
|
|||||||
int parse_pmt(CZapitChannel * const channel);
|
int parse_pmt(CZapitChannel * const channel);
|
||||||
int pmt_set_update_filter(CZapitChannel * const channel, int * fd);
|
int pmt_set_update_filter(CZapitChannel * const channel, int * fd);
|
||||||
int pmt_stop_update_filter(int * fd);
|
int pmt_stop_update_filter(int * fd);
|
||||||
|
int scan_parse_pmt(int pmtpid, int service_id );
|
||||||
|
|
||||||
#endif /* __zapit_pmt_h__ */
|
#endif /* __zapit_pmt_h__ */
|
||||||
|
@@ -76,6 +76,47 @@ if(buffer[7]) printf("[PAT] ****************************************************
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int scan_parse_pat( std::vector<std::pair<int,int> > &sidpmt )
|
||||||
|
{
|
||||||
|
|
||||||
|
cDemux * dmx = new cDemux();
|
||||||
|
dmx->Open(DMX_PSI_CHANNEL);
|
||||||
|
|
||||||
|
/* buffer for program association table */
|
||||||
|
unsigned char buffer[PAT_SIZE];
|
||||||
|
|
||||||
|
/* current positon in buffer */
|
||||||
|
unsigned short i;
|
||||||
|
|
||||||
|
unsigned char filter[DMX_FILTER_SIZE];
|
||||||
|
unsigned char mask[DMX_FILTER_SIZE];
|
||||||
|
|
||||||
|
memset(filter, 0x00, DMX_FILTER_SIZE);
|
||||||
|
memset(mask, 0x00, DMX_FILTER_SIZE);
|
||||||
|
|
||||||
|
mask[0] = 0xFF;
|
||||||
|
mask[4] = 0xFF;
|
||||||
|
|
||||||
|
do {
|
||||||
|
/* set filter for program association section */
|
||||||
|
/* read section */
|
||||||
|
if ((dmx->sectionFilter(0, filter, mask, 5) < 0) || (i = dmx->Read(buffer, PAT_SIZE) < 0))
|
||||||
|
{
|
||||||
|
delete dmx;
|
||||||
|
printf("[%s] dmx read failed\n",__FILE__);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
dmx->Stop();
|
||||||
|
for (i = 8; i < (((buffer[1] & 0x0F) << 8) | buffer[2]) + 3; i += 4) {
|
||||||
|
int service_id = ((buffer[i] << 8) | buffer[i+1]);
|
||||||
|
if (service_id != 0)
|
||||||
|
sidpmt.push_back(std::make_pair( service_id , (((buffer[i+2] & 0x1F) << 8) | buffer[i+3]) ) );
|
||||||
|
}
|
||||||
|
} while (filter[4]++ != buffer[7]);
|
||||||
|
delete dmx;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned char pbuffer[PAT_SIZE];
|
static unsigned char pbuffer[PAT_SIZE];
|
||||||
int parse_pat()
|
int parse_pat()
|
||||||
{
|
{
|
||||||
|
@@ -589,6 +589,83 @@ int parse_pmt(CZapitChannel * const channel)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int scan_parse_pmt(int pmtpid, int service_id )
|
||||||
|
{
|
||||||
|
if(pmtpid < 1 )
|
||||||
|
return -1;
|
||||||
|
if(curpmtpid == pmtpid ){
|
||||||
|
for(int i=0;i<11;i++){
|
||||||
|
if(pmt_caids[0][i] > 0)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pmtlen;
|
||||||
|
int ia, dpmtlen, pos;
|
||||||
|
unsigned char descriptor_length=0;
|
||||||
|
const short pmt_size = 1024;
|
||||||
|
|
||||||
|
unsigned char buffer[pmt_size];
|
||||||
|
|
||||||
|
unsigned char filter[DMX_FILTER_SIZE];
|
||||||
|
unsigned char mask[DMX_FILTER_SIZE];
|
||||||
|
|
||||||
|
cDemux * dmx = new cDemux();
|
||||||
|
dmx->Open(DMX_PSI_CHANNEL);
|
||||||
|
|
||||||
|
memset(filter, 0x00, DMX_FILTER_SIZE);
|
||||||
|
memset(mask, 0x00, DMX_FILTER_SIZE);
|
||||||
|
|
||||||
|
filter[0] = 0x02; /* table_id */
|
||||||
|
filter[1] = service_id >> 8;
|
||||||
|
filter[2] = service_id;
|
||||||
|
filter[3] = 0x01; /* current_next_indicator */
|
||||||
|
filter[4] = 0x00; /* section_number */
|
||||||
|
mask[0] = 0xFF;
|
||||||
|
mask[1] = 0xFF;
|
||||||
|
mask[2] = 0xFF;
|
||||||
|
mask[3] = 0x01;
|
||||||
|
mask[4] = 0xFF;
|
||||||
|
|
||||||
|
if ((dmx->sectionFilter(pmtpid, filter, mask, 5) < 0) || (dmx->Read(buffer, pmt_size) < 0)) {
|
||||||
|
delete dmx;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
delete dmx;
|
||||||
|
pmtlen= ((buffer[1]&0xf)<<8) + buffer[2] +3;
|
||||||
|
|
||||||
|
dpmtlen=0;
|
||||||
|
pos=10;
|
||||||
|
|
||||||
|
while(pos+2<pmtlen) {
|
||||||
|
dpmtlen=((buffer[pos] & 0x0f) << 8) | buffer[pos+1];
|
||||||
|
for ( ia=pos+2;ia<(dpmtlen+pos+2);ia +=descriptor_length+2 ) {
|
||||||
|
descriptor_length = buffer[ia+1];
|
||||||
|
if ( ia < pmtlen - 4 )
|
||||||
|
if(buffer[ia]==0x09 && buffer[ia+1]>0) {
|
||||||
|
switch(buffer[ia+2]) {
|
||||||
|
case 0x06:
|
||||||
|
case 0x17:
|
||||||
|
case 0x01:
|
||||||
|
case 0x05:
|
||||||
|
case 0x18:
|
||||||
|
case 0x0B:
|
||||||
|
case 0x0D:
|
||||||
|
case 0x09:
|
||||||
|
case 0x26:
|
||||||
|
case 0x4a:
|
||||||
|
case 0x0E:
|
||||||
|
return 1;
|
||||||
|
} //switch
|
||||||
|
} // if
|
||||||
|
} // for
|
||||||
|
pos+=dpmtlen+5;
|
||||||
|
} // while
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
#ifndef DMX_SET_NEGFILTER_MASK
|
#ifndef DMX_SET_NEGFILTER_MASK
|
||||||
#define DMX_SET_NEGFILTER_MASK _IOW('o',48,uint8_t *)
|
#define DMX_SET_NEGFILTER_MASK _IOW('o',48,uint8_t *)
|
||||||
#endif
|
#endif
|
||||||
|
@@ -26,6 +26,9 @@
|
|||||||
#include <zapit/descriptors.h>
|
#include <zapit/descriptors.h>
|
||||||
#include <zapit/debug.h>
|
#include <zapit/debug.h>
|
||||||
#include <zapit/sdt.h>
|
#include <zapit/sdt.h>
|
||||||
|
#include <zapit/pmt.h>
|
||||||
|
#include <zapit/pat.h>
|
||||||
|
|
||||||
#include <zapit/settings.h> // DEMUX_DEVICE
|
#include <zapit/settings.h> // DEMUX_DEVICE
|
||||||
#include <zapit/types.h>
|
#include <zapit/types.h>
|
||||||
#include <zapit/bouquets.h>
|
#include <zapit/bouquets.h>
|
||||||
@@ -367,7 +370,6 @@ _repeat:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern tallchans curchans;
|
|
||||||
int parse_current_sdt( const t_transport_stream_id p_transport_stream_id, const t_original_network_id p_original_network_id,
|
int parse_current_sdt( const t_transport_stream_id p_transport_stream_id, const t_original_network_id p_original_network_id,
|
||||||
t_satellite_position satellitePosition, freq_id_t freq)
|
t_satellite_position satellitePosition, freq_id_t freq)
|
||||||
{
|
{
|
||||||
@@ -392,11 +394,10 @@ int parse_current_sdt( const t_transport_stream_id p_transport_stream_id, const
|
|||||||
bool EIT_schedule_flag;
|
bool EIT_schedule_flag;
|
||||||
bool EIT_present_following_flag;
|
bool EIT_present_following_flag;
|
||||||
bool free_CA_mode;
|
bool free_CA_mode;
|
||||||
|
int tmp_free_CA_mode = -1;
|
||||||
unsigned char filter[DMX_FILTER_SIZE];
|
unsigned char filter[DMX_FILTER_SIZE];
|
||||||
unsigned char mask[DMX_FILTER_SIZE];
|
unsigned char mask[DMX_FILTER_SIZE];
|
||||||
|
|
||||||
curchans.clear();
|
|
||||||
filter[0] = 0x42;
|
filter[0] = 0x42;
|
||||||
filter[1] = (p_transport_stream_id >> 8) & 0xff;
|
filter[1] = (p_transport_stream_id >> 8) & 0xff;
|
||||||
filter[2] = p_transport_stream_id & 0xff;
|
filter[2] = p_transport_stream_id & 0xff;
|
||||||
@@ -417,6 +418,9 @@ int parse_current_sdt( const t_transport_stream_id p_transport_stream_id, const
|
|||||||
mask[7] = 0xFF;
|
mask[7] = 0xFF;
|
||||||
memset(&mask[8], 0x00, 8);
|
memset(&mask[8], 0x00, 8);
|
||||||
|
|
||||||
|
std::vector<std::pair<int,int> > sidpmt;
|
||||||
|
scan_parse_pat( sidpmt );
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if ((dmx->sectionFilter(0x11, filter, mask, 8) < 0) || (dmx->Read(buffer, SDT_SIZE) < 0)) {
|
if ((dmx->sectionFilter(0x11, filter, mask, 8) < 0) || (dmx->Read(buffer, SDT_SIZE) < 0)) {
|
||||||
delete dmx;
|
delete dmx;
|
||||||
@@ -433,7 +437,16 @@ int parse_current_sdt( const t_transport_stream_id p_transport_stream_id, const
|
|||||||
EIT_schedule_flag = buffer[pos + 2] & 0x02;
|
EIT_schedule_flag = buffer[pos + 2] & 0x02;
|
||||||
EIT_present_following_flag = buffer[pos + 2] & 0x01;
|
EIT_present_following_flag = buffer[pos + 2] & 0x01;
|
||||||
running_status = buffer [pos + 3] & 0xE0;
|
running_status = buffer [pos + 3] & 0xE0;
|
||||||
free_CA_mode = buffer [pos + 3] & 0x10;
|
for (unsigned short i=0; i<sidpmt.size(); i++){
|
||||||
|
if(sidpmt[i].first == service_id){
|
||||||
|
tmp_free_CA_mode = scan_parse_pmt( sidpmt[i].second, sidpmt[i].first );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(tmp_free_CA_mode == -1)
|
||||||
|
free_CA_mode = buffer [pos + 3] & 0x10;
|
||||||
|
else
|
||||||
|
free_CA_mode = tmp_free_CA_mode;
|
||||||
|
|
||||||
descriptors_loop_length = ((buffer[pos + 3] & 0x0F) << 8) | buffer[pos + 4];
|
descriptors_loop_length = ((buffer[pos + 3] & 0x0F) << 8) | buffer[pos + 4];
|
||||||
|
|
||||||
for (pos2 = pos + 5; pos2 < pos + descriptors_loop_length + 5; pos2 += buffer[pos2 + 1] + 2) {
|
for (pos2 = pos + 5; pos2 < pos + descriptors_loop_length + 5; pos2 += buffer[pos2 + 1] + 2) {
|
||||||
@@ -452,6 +465,7 @@ int parse_current_sdt( const t_transport_stream_id p_transport_stream_id, const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free_CA_mode = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (filter[4]++ != buffer[7]);
|
while (filter[4]++ != buffer[7]);
|
||||||
|
@@ -2413,7 +2413,7 @@ printf("[zapit] sdt monitor started\n");
|
|||||||
printf("[sdt monitor] wakeup...\n");
|
printf("[sdt monitor] wakeup...\n");
|
||||||
wtime = 0;
|
wtime = 0;
|
||||||
|
|
||||||
if(scan_runs)
|
if(scan_runs || (currentMode & RECORD_MODE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
updated = 0;
|
updated = 0;
|
||||||
@@ -2437,6 +2437,7 @@ printf("[sdt monitor] wakeup...\n");
|
|||||||
printf("[sdt monitor] TP already updated.\n");
|
printf("[sdt monitor] TP already updated.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
curchans.clear();
|
||||||
ret = parse_current_sdt(transport_stream_id, original_network_id, satellitePosition, freq);
|
ret = parse_current_sdt(transport_stream_id, original_network_id, satellitePosition, freq);
|
||||||
if(ret)
|
if(ret)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user