zapit: remove obsolete files

This commit is contained in:
[CST] Focus
2012-06-13 18:54:20 +04:00
parent 200570ec73
commit 0261495e16
15 changed files with 0 additions and 3351 deletions

View File

@@ -1,27 +0,0 @@
/*
* $Id: bat.h,v 1.3 2003/01/30 17:21:16 obi Exp $
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __zapit_bat_h__
#define __zapit_bat_h__
int parse_bat(t_satellite_position satellitePosition, freq_id_t freq);
#endif /* __zapit_bat_h__ */

View File

@@ -1,84 +0,0 @@
/*
* $Id: cam.h,v 1.25 2003/02/09 19:22:08 thegoodguy Exp $
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>,
* thegoodguy <thegoodguy@berlios.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __zapit_cam_h__
#define __zapit_cam_h__
#include <map>
#include "ci.h"
#include <basicclient.h>
#include "types.h"
#include <OpenThreads/Mutex>
#define DEMUX_DECODE_0 1
#define DEMUX_DECODE_1 2
#define DEMUX_DECODE_2 4
#define DEMUX_SOURCE_0 0
#define DEMUX_SOURCE_1 1
#define DEMUX_SOURCE_2 2
#define LIVE_DEMUX 0
#define STREAM_DEMUX 1
#define RECORD_DEMUX 2
class CCam : public CBasicClient
{
private:
virtual unsigned char getVersion(void) const;
virtual const char *getSocketName(void) const;
int camask, demuxes[3];
public:
CCam();
bool sendMessage(const char * const data, const size_t length, bool update = false);
bool setCaPmt(CCaPmt * const caPmt, int _demux = 0, int _camask = 1, bool update = false);
int getCaMask(void) { return camask; };
int makeMask(int demux, bool add);
};
typedef std::map<t_channel_id, CCam*> cammap_t;
typedef cammap_t::iterator cammap_iterator_t;
class CCamManager
{
public:
enum runmode {
PLAY,
RECORD,
STREAM
};
private:
cammap_t channel_map;
OpenThreads::Mutex mutex;
static CCamManager * manager;
bool SetMode(t_channel_id id, enum runmode mode, bool enable, bool force_update = false);
public:
CCamManager();
~CCamManager();
static CCamManager * getInstance(void);
bool Start(t_channel_id id, enum runmode mode, bool force_update = false) { return SetMode(id, mode, true, force_update); };
bool Stop(t_channel_id id, enum runmode mode) { return SetMode(id, mode, false); };
};
#endif /* __cam_h__ */

View File

@@ -1,102 +0,0 @@
/*
* $Id: ci.h,v 1.6 2003/01/30 17:21:16 obi Exp $
*
* (C) 2002 by Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __ci_h__
#define __ci_h__
#include <vector>
class CCaDescriptor
{
private:
unsigned descriptor_tag : 8;
unsigned descriptor_length : 8;
unsigned CA_system_ID : 16;
unsigned reserved1 : 3;
unsigned CA_PID : 13;
std::vector <unsigned char> private_data_byte;
public:
CCaDescriptor(const unsigned char * const buffer);
unsigned writeToBuffer(unsigned char * const buffer);
unsigned getLength(void) { return descriptor_length + 2; }
};
/*
* children of this class need to delete all
* CCaDescriptors in their destructors
*/
class CCaTable
{
private:
std::vector <CCaDescriptor *> ca_descriptor;
protected:
CCaTable(void) { info_length = 0; };
~CCaTable(void);
unsigned getLength(void) { return info_length + 2; }
unsigned writeToBuffer(unsigned char * const buffer);
public:
unsigned reserved2 : 4;
unsigned info_length : 12;
void addCaDescriptor(const unsigned char * const buffer);
};
class CEsInfo : public CCaTable
{
protected:
unsigned getLength(void) { return CCaTable::getLength() + 3; }
unsigned writeToBuffer(unsigned char * const buffer);
public:
unsigned stream_type : 8;
unsigned reserved1 : 3;
unsigned elementary_PID : 13;
friend class CCaPmt;
};
class CCaPmt : public CCaTable
{
protected:
unsigned ca_pmt_length;
public:
CCaPmt();
CCaPmt(const unsigned char * const buffer);
~CCaPmt(void);
unsigned getLength(void);
unsigned writeToBuffer(unsigned char * const buffer, int demux = 1, int camask = 3);
unsigned ca_pmt_list_management : 8;
unsigned program_number : 16;
unsigned reserved1 : 2;
unsigned version_number : 5;
unsigned current_next_indicator : 1;
unsigned short ca_pmt_pid;
std::vector<CEsInfo *> es_info;
};
#endif /* __ci_h__ */

View File

@@ -1,104 +0,0 @@
/*
* $Id: descriptors.h,v 1.19 2004/02/17 16:26:04 thegoodguy Exp $
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __zapit_descriptors_h__
#define __zapit_descriptors_h__
#include "types.h"
void generic_descriptor(const unsigned char * const buffer);
void video_stream_descriptor(const unsigned char * const buffer);
void audio_stream_descriptor(const unsigned char * const buffer);
void hierarchy_descriptor(const unsigned char * const buffer);
void registration_descriptor(const unsigned char * const buffer);
void data_stream_alignment_descriptor(const unsigned char * const buffer);
void target_background_grid_descriptor(const unsigned char * const buffer);
void Video_window_descriptor(const unsigned char * const buffer);
void CA_descriptor(const unsigned char * const buffer, uint16_t ca_system_id, uint16_t* ca_pid);
void ISO_639_language_descriptor(const unsigned char * const buffer);
void System_clock_descriptor(const unsigned char * const buffer);
void Multiplex_buffer_utilization_descriptor(const unsigned char * const buffer);
void Copyright_descriptor(const unsigned char * const buffer);
void Maximum_bitrate_descriptor(const unsigned char * const buffer);
void Private_data_indicator_descriptor(const unsigned char * const buffer);
void Smoothing_buffer_descriptor(const unsigned char * const buffer);
void STD_descriptor(const unsigned char * const buffer);
void IBP_descriptor(const unsigned char * const buffer);
void MPEG4_video_descriptor(const unsigned char * const buffer);
void MPEG4_audio_descriptor(const unsigned char * const buffer);
void IOD_descriptor(const unsigned char * const buffer);
void SL_descriptor(const unsigned char * const buffer);
void FMC_descriptor(const unsigned char * const buffer);
void External_ES_ID_descriptor(const unsigned char * const buffer);
void MuxCode_descriptor(const unsigned char * const buffer);
void FmxBufferSize_descriptor(const unsigned char * const buffer);
void MultiplexBuffer_descriptor(const unsigned char * const buffer);
void FlexMuxTiming_descriptor(const unsigned char * const buffer);
void network_name_descriptor(const unsigned char * const buffer);
void service_list_descriptor(const unsigned char * const buffer, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq);
void stuffing_descriptor(const unsigned char * const buffer);
int satellite_delivery_system_descriptor(const unsigned char * const buffer, t_transport_stream_id transport_stream_id, t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq);
int cable_delivery_system_descriptor(const unsigned char * const buffer, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq);
void VBI_data_descriptor(const unsigned char * const buffer);
void VBI_teletext_descriptor(const unsigned char * const buffer);
void bouquet_name_descriptor(const unsigned char * const buffer);
void service_descriptor(const unsigned char * const buffer, const t_service_id service_id, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq, bool free_ca);
void current_service_descriptor(const unsigned char * const buffer, const t_service_id service_id, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq, bool free_ca);
void country_availability_descriptor(const unsigned char * const buffer);
void linkage_descriptor(const unsigned char * const buffer);
int NVOD_reference_descriptor(const unsigned char * const buffer, const unsigned int num, t_transport_stream_id * const, t_original_network_id * const, t_service_id * const);
void time_shifted_service_descriptor(const unsigned char * const buffer);
void short_event_descriptor(const unsigned char * const buffer);
void extended_event_descriptor(const unsigned char * const buffer);
void time_shifted_event_descriptor(const unsigned char * const buffer);
void component_descriptor(const unsigned char * const buffer);
void mosaic_descriptor(const unsigned char * const buffer);
void stream_identifier_descriptor(const unsigned char * const buffer);
void CA_identifier_descriptor(const unsigned char * const buffer);
void content_descriptor(const unsigned char * const buffer);
void parental_rating_descriptor(const unsigned char * const buffer);
void teletext_descriptor(const unsigned char * const buffer);
void telephone_descriptor(const unsigned char * const buffer);
void local_time_offset_descriptor(const unsigned char * const buffer);
void subtitling_descriptor(const unsigned char * const buffer);
int terrestrial_delivery_system_descriptor(const unsigned char * const buffer);
void multilingual_network_name_descriptor(const unsigned char * const buffer);
void multilingual_bouquet_name_descriptor(const unsigned char * const buffer);
void multilingual_service_name_descriptor(const unsigned char * const buffer);
void multilingual_component_descriptor(const unsigned char * const buffer);
void private_data_specifier_descriptor(const unsigned char * const buffer);
void service_move_descriptor(const unsigned char * const buffer);
void short_smoothing_buffer_descriptor(const unsigned char * const buffer);
void frequency_list_descriptor(const unsigned char * const buffer);
void partial_transport_stream_descriptor(const unsigned char * const buffer);
void data_broadcast_descriptor(const unsigned char * const buffer);
void CA_system_descriptor(const unsigned char * const buffer);
void data_broadcast_id_descriptor(const unsigned char * const buffer);
void transport_stream_descriptor(const unsigned char * const buffer);
void DSNG_descriptor(const unsigned char * const buffer);
void PDC_descriptor(const unsigned char * const buffer);
void AC3_descriptor(const unsigned char * const buffer);
void ancillary_data_descriptor(const unsigned char * const buffer);
void cell_list_descriptor(const unsigned char * const buffer);
void cell_frequency_link_descriptor(const unsigned char * const buffer);
void announcement_support_descriptor(const unsigned char * const buffer);
#endif /* __zapit_descriptors_h__ */

View File

@@ -1,27 +0,0 @@
/*
* $Id: nit.h,v 1.6 2003/01/30 17:21:16 obi Exp $
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __zapit_nit_h__
#define __zapit_nit_h__
int parse_nit(t_satellite_position satellitePosition, freq_id_t freq);
#endif /* __zapit_nit_h__ */

View File

@@ -1,33 +0,0 @@
/*
* $Id: pmt.h,v 1.10 2003/08/15 23:34:09 obi Exp $
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __zapit_pmt_h__
#define __zapit_pmt_h__
#include "channel.h"
#include "ci.h"
int parse_pmt(CZapitChannel * const channel);
int pmt_set_update_filter(CZapitChannel * const channel, int * fd);
int pmt_stop_update_filter(int * fd);
int scan_parse_pmt(int pmtpid, int service_id );
#endif /* __zapit_pmt_h__ */

View File

@@ -1,33 +0,0 @@
/*
* $Id: sdt.h,v 1.17 2003/03/14 07:31:50 obi Exp $
*
* (C) 2002, 2003 by Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __zapit_sdt_h__
#define __zapit_sdt_h__
#include "types.h"
transponder_id_t get_sdt_TsidOnid(t_satellite_position satellitePosition, freq_id_t freq);
int nvod_service_ids(const t_transport_stream_id, const t_original_network_id, const t_service_id, const unsigned int num, t_transport_stream_id * const, t_original_network_id * const, t_service_id * const);
int parse_sdt(t_transport_stream_id* , t_original_network_id*, t_satellite_position satellitePosition, freq_id_t freq);
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);
#endif /* __zapit_sdt_h__ */

View File

@@ -1,2 +0,0 @@
2005/07/21
setSource setBlank restored in startPlayBack

View File

@@ -1,149 +0,0 @@
/*
* $Id: bat.cpp,v 1.14 2004/02/17 16:26:07 thegoodguy Exp $
*
* (C) 2002 by Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <zapit/debug.h>
#include <zapit/descriptors.h>
#include <zapit/dmx.h>
#include <zapit/getservices.h>
#include <zapit/bat.h>
#define BAT_SIZE 1024
int parse_bat(t_satellite_position satellitePosition, freq_id_t freq)
{
CDemux dmx;
unsigned char buffer[BAT_SIZE];
/* position in buffer */
unsigned short pos;
unsigned short pos2;
unsigned short pos3;
/* bouquet_association_section elements */
unsigned short section_length;
unsigned short bouquet_id;
unsigned short bouquet_descriptors_length;
unsigned short transport_stream_loop_length;
t_transport_stream_id transport_stream_id;
t_original_network_id original_network_id;
unsigned short transport_descriptors_length;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
memset(filter, 0x00, DMX_FILTER_SIZE);
memset(mask, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x4A;
filter[4] = 0x00;
mask[0] = 0xFF;
mask[4] = 0xFF;
do {
if ((dmx.sectionFilter(0x11, filter, mask) < 0) || (dmx.read(buffer, BAT_SIZE) < 0))
return -1;
section_length = ((buffer[1] & 0x0F) << 8) | buffer[2];
bouquet_id = (buffer[3] << 8) | buffer[4];
bouquet_descriptors_length = ((buffer[8] & 0x0F) << 8) | buffer[9];
for (pos = 10; pos < bouquet_descriptors_length + 10; pos += buffer[pos + 1] + 2) {
switch (buffer[pos]) {
case 0x47:
bouquet_name_descriptor(buffer + pos);
break;
case 0x49:
country_availability_descriptor(buffer + pos);
break;
case 0x4A:
linkage_descriptor(buffer + pos);
break;
case 0x53:
CA_identifier_descriptor(buffer + pos);
break;
case 0x5C:
multilingual_bouquet_name_descriptor(buffer + pos);
break;
/* case 0x5F:
private_data_specifier_descriptor(buffer + pos);
break;
case 0x80:
case 0x91:
case 0xF0:
break;
*/
default:
DBG("first_descriptor_tag: %02x\n", buffer[pos]);
generic_descriptor(buffer + pos);
break;
}
}
transport_stream_loop_length = ((buffer[pos] & 0x0F) << 8) | buffer[pos + 1];
for (pos2 = pos + 2; pos2 < pos + 2 + transport_stream_loop_length; pos2 += transport_descriptors_length + 6) {
transport_stream_id = (buffer[pos2] << 8) | buffer[pos2 + 1];
original_network_id = (buffer[pos2 + 2] << 8) | buffer[pos2 + 3];
transport_descriptors_length = ((buffer[pos2 + 4] & 0x0F) << 8) | buffer[pos2 + 5];
for (pos3 = pos2 + 6; pos3 < transport_descriptors_length + pos2 + 6; pos3 += buffer[pos3 + 1] + 2) {
switch (buffer[pos3]) {
case 0x41:
service_list_descriptor(buffer + pos3, transport_stream_id, original_network_id, satellitePosition, freq);
break;
case 0x42:
stuffing_descriptor(buffer + pos3);
break;
case 0x5F:
private_data_specifier_descriptor(buffer + pos3);
break;
/* case 0x80:
case 0x81:
case 0x83:
case 0x93:
case 0xC9:
case 0xD3:
break;
*/
default:
DBG("second_descriptor_tag: %02x\n", buffer[pos3]);
generic_descriptor(buffer + pos3);
break;
}
}
}
} while (filter[4]++ != buffer[7]);
return 0;
}

View File

@@ -1,199 +0,0 @@
/*
* $Id: cam.cpp,v 1.33 2004/04/04 20:20:45 obi Exp $
*
* (C) 2002 by Andreas Oberritter <obi@tuxbox.org>,
* thegoodguy <thegoodguy@berlios.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdio.h>
/* zapit */
#include <zapit/cam.h>
#include <zapit/settings.h> /* CAMD_UDS_NAME */
#include <messagetools.h> /* get_length_field_size */
#include <zapit/bouquets.h>
#include <zapit/satconfig.h>
#include <zapit/getservices.h>
CCam::CCam()
{
camask = 0;
demuxes[0] = demuxes[1] = demuxes[2] = 0;
}
unsigned char CCam::getVersion(void) const
{
return 0x9F;
}
const char *CCam::getSocketName(void) const
{
return CAMD_UDS_NAME;
}
bool CCam::sendMessage(const char * const data, const size_t length, bool update)
{
/* send_data return false without trying, if no opened connection */
if(update) {
if(!send_data(data, length)) {
if (!open_connection())
return false;
return send_data(data, length);
}
return true;
}
close_connection();
if(!data || !length) {
camask = 1;
return false;
}
if (!open_connection())
return false;
return send_data(data, length);
}
bool CCam::setCaPmt(CCaPmt * const caPmt, int _demux, int _camask, bool update)
{
camask = _camask;
printf("CCam::setCaPmt cam %x source %d camask %d update %s\n", (int) this, _demux, camask, update ? "yes" : "no" );
if(camask == 0) {
close_connection();
return true;
}
if (!caPmt)
return true;
unsigned int size = caPmt->getLength();
unsigned char buffer[3 + get_length_field_size(size) + size];
size_t pos = caPmt->writeToBuffer(buffer, _demux, camask);
return sendMessage((char *)buffer, pos, update);
}
int CCam::makeMask(int demux, bool add)
{
int mask = 0;
if(add)
demuxes[demux]++;
else if(demuxes[demux] > 0)
demuxes[demux]--;
for(int i = 0; i < 3; i++) {
if(demuxes[i] > 0)
mask |= 1 << i;
}
printf("CCam::MakeMask: demuxes %d:%d:%d old mask %d new mask %d\n", demuxes[0], demuxes[1], demuxes[2], camask, mask);
return mask;
}
CCamManager * CCamManager::manager = NULL;
CCamManager::CCamManager()
{
channel_map.clear();
}
CCamManager::~CCamManager()
{
for(cammap_iterator_t it = channel_map.begin(); it != channel_map.end(); it++)
delete it->second;
channel_map.clear();
}
CCamManager * CCamManager::getInstance(void)
{
if(manager == NULL)
manager = new CCamManager();
return manager;
}
bool CCamManager::SetMode(t_channel_id channel_id, enum runmode mode, bool start, bool force_update)
{
CCam * cam;
int oldmask, newmask;
int demux = DEMUX_SOURCE_0;
int source = DEMUX_SOURCE_0;
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
if(channel == NULL) {
printf("CCamManager: channel %llx not found\n", channel_id);
return false;
}
mutex.lock();
if(channel->getCaPmt() == NULL) {
printf("CCamManager: channel %llx dont have caPmt\n", channel_id);
mutex.unlock();
return false;
}
sat_iterator_t sit = satellitePositions.find(channel->getSatellitePosition());
cammap_iterator_t it = channel_map.find(channel_id);
if(it != channel_map.end()) {
cam = it->second;
} else if(start) {
cam = new CCam();
channel_map.insert(std::pair<t_channel_id, CCam*>(channel_id, cam));
} else {
mutex.unlock();
return false;
}
switch(mode) {
case PLAY:
source = DEMUX_SOURCE_0;
demux = LIVE_DEMUX;
break;
case RECORD:
source = DEMUX_SOURCE_0;
demux = RECORD_DEMUX;//FIXME
break;
case STREAM:
source = DEMUX_SOURCE_0;
demux = STREAM_DEMUX;//FIXME
break;
}
oldmask = cam->getCaMask();
if(force_update)
newmask = oldmask;
else
newmask = cam->makeMask(demux, start);
if((oldmask != newmask) || force_update)
cam->setCaPmt(channel->getCaPmt(), source, newmask, true);
if(newmask == 0) {
/* FIXME: back to live channel from playback dont parse pmt and call setCaPmt
* (see CMD_SB_LOCK / UNLOCK PLAYBACK */
//channel->setCaPmt(NULL);
channel->setRawPmt(NULL);
channel_map.erase(channel_id);
delete cam;
}
mutex.unlock();
return true;
}

View File

@@ -1,195 +0,0 @@
/*
* $Id: ci.cpp,v 1.12 2003/02/09 19:22:08 thegoodguy Exp $
*
* (C) 2002 by Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <cstring>
#include <zapit/ci.h>
#include <messagetools.h>
extern int curpmtpid;
/*
* conditional access descriptors
*/
CCaDescriptor::CCaDescriptor(const unsigned char * const buffer)
{
descriptor_tag = buffer[0];
descriptor_length = buffer[1];
CA_system_ID = (buffer[2] << 8) | buffer[3];
reserved1 = buffer[4] >> 5;
CA_PID = ((buffer[4] & 0x1F) << 8) | buffer[5];
private_data_byte = std::vector<unsigned char>(&(buffer[6]), &(buffer[descriptor_length + 2]));
}
unsigned int CCaDescriptor::writeToBuffer(unsigned char * const buffer) // returns number of bytes written
{
buffer[0] = descriptor_tag;
buffer[1] = descriptor_length;
buffer[2] = CA_system_ID >> 8;
buffer[3] = CA_system_ID;
buffer[4] = (reserved1 << 5) | (CA_PID >> 8);
buffer[5] = CA_PID;
std::copy(private_data_byte.begin(), private_data_byte.end(), &(buffer[6]));
return descriptor_length + 2;
}
/*
* generic table containing conditional access descriptors
*/
void CCaTable::addCaDescriptor(const unsigned char * const buffer)
{
CCaDescriptor* dummy = new CCaDescriptor(buffer);
ca_descriptor.push_back(dummy);
if (info_length == 0)
info_length = 1;
info_length += dummy->getLength();
}
unsigned int CCaTable::writeToBuffer(unsigned char * const buffer) // returns number of bytes written
{
#ifdef notdef
buffer[0] = (reserved2 << 4) | (info_length >> 8);
buffer[1] = info_length;
if (info_length == 0)
return 2;
buffer[2] = 1; // ca_pmt_cmd_id: ok_descrambling= 1;
#endif
unsigned int pos = 0;
for (unsigned int i = 0; i < ca_descriptor.size(); i++)
pos += ca_descriptor[i]->writeToBuffer(&(buffer[pos]));
return pos;
}
CCaTable::~CCaTable(void)
{
for (unsigned int i = 0; i < ca_descriptor.size(); i++)
delete ca_descriptor[i];
}
/*
* elementary stream information
*/
unsigned int CEsInfo::writeToBuffer(unsigned char * const buffer) // returns number of bytes written
{
int len = 0;
buffer[0] = stream_type;
buffer[1] = ((reserved1 << 5) | (elementary_PID >> 8)) & 0xff;
buffer[2] = elementary_PID & 0xff;
/* len! */
len = CCaTable::writeToBuffer(&(buffer[6]));
if(len) {
buffer[5] = 0x1; // ca_pmt_cmd_id: ok_descrambling= 1;
len++;
}
buffer[3] = ((len & 0xf00)>>8);
buffer[4] = (len & 0xff);
return len + 5;
//return 3 + CCaTable::writeToBuffer(&(buffer[3]));
}
/*
* contitional access program map table
*/
CCaPmt::~CCaPmt(void)
{
for (unsigned int i = 0; i < es_info.size(); i++)
delete es_info[i];
}
unsigned int CCaPmt::writeToBuffer(unsigned char * const buffer, int demux, int camask) // returns number of bytes written
{
unsigned int i;
memmove(buffer, "\x9f\x80\x32\x82\x00\x00", 6);
buffer[6] = ca_pmt_list_management; //6
buffer[7] = program_number >> 8; //7
buffer[8] = program_number; // 8
buffer[9] = (reserved1 << 6) | (version_number << 1) | current_next_indicator;
buffer[10] = 0x00; // //reserved - prg-info len
buffer[11] = 0x00; // prg-info len
buffer[12] = 0x01; // ca pmt command id
buffer[13] = 0x81; // private descr.. dvbnamespace
buffer[14] = 0x08; //14
buffer[15] = 0x00;
buffer[16] = 0x00;
buffer[17] = 0x00;
buffer[18] = 0x00;
buffer[19] = 0x00;
buffer[20] = 0x00;
buffer[21] = 0x00;
buffer[22] = 0x00; //22
buffer[23] = 0x82; // demuxer kram..
buffer[24] = 0x02;
buffer[25] = camask; // descramble on demux0 and demux1
buffer[26] = demux; // get section data from demux1
buffer[27] = 0x84; // pmt pid
buffer[28] = 0x02;
buffer[29] = (curpmtpid >> 8) & 0xFF;
buffer[30] = curpmtpid & 0xFF; // 30
int lenpos=10;
int len=19;
int wp=31;
i = CCaTable::writeToBuffer(&(buffer[wp]));
wp += i;
len += i;
buffer[lenpos]=((len & 0xf00)>>8);
buffer[lenpos+1]=(len & 0xff);
for (i = 0; i < es_info.size(); i++) {
wp += es_info[i]->writeToBuffer(&(buffer[wp]));
}
buffer[4] = ((wp-6)>>8) & 0xff;
buffer[5]=(wp-6) & 0xff;
#if 0
for(i = 0; i < (unsigned int) wp; i++)
printf("%02X ", buffer[i]);
printf("\n");
#endif
return wp;
}
unsigned int CCaPmt::getLength(void) // the (3 + length_field()) initial bytes are not counted !
{
unsigned int size = 25 + CCaTable::getLength();
//unsigned int size = 19 + CCaTable::getLength();
for (unsigned int i = 0; i < es_info.size(); i++)
size += es_info[i]->getLength();
return size;
}

View File

@@ -1,964 +0,0 @@
/*
* $Id: descriptors.cpp,v 1.65 2004/02/17 16:26:07 thegoodguy Exp $
*
* (C) 2002-2003 Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <cstdio>
#include <map>
#include <string>
/* libevent */
#include <eventserver.h>
#include <zapit/bouquets.h>
#include <zapit/client/zapitclient.h>
#include <zapit/descriptors.h>
#include <zapit/dvbstring.h>
#include <zapit/frontend_c.h>
#include <zapit/getservices.h>
#include <zapit/scan.h>
#include <zapit/sdt.h>
#include <zapit/pat.h>
#include <zapit/pmt.h>
#include <zapit/debug.h>
#include <zapit/zapit.h>
#include <dmx.h>
#include <math.h>
extern CBouquetManager *g_bouquetManager;
extern CZapitClient::scanType scanType;
std::string curr_chan_name;
std::string lastProviderName;
//std::string lastServiceName;
//std::map <t_channel_id, uint8_t> service_types;
extern CEventServer *eventServer;
int scan_fta_flag = 0;
void generic_descriptor(const unsigned char * const)
{
#if 0
DBG("generic descriptor dump:");
for (unsigned short i = 0; i < buffer[1] + 2; i++)
printf(" %02x", buffer[i]);
printf("\n");
#endif
}
/* 0x02 */
void video_stream_descriptor(const unsigned char * const)
{
}
/* 0x03 */
void audio_stream_descriptor(const unsigned char * const)
{
}
/* 0x04 */
void hierarchy_descriptor(const unsigned char * const)
{
}
/* 0x05 */
void registration_descriptor(const unsigned char * const)
{
}
/* 0x06 */
void data_stream_alignment_descriptor(const unsigned char * const)
{
}
/* 0x07 */
void target_background_grid_descriptor(const unsigned char * const)
{
}
/* 0x08 */
void Video_window_descriptor(const unsigned char * const)
{
}
/* 0x09 */
void CA_descriptor(const unsigned char * const buffer, uint16_t /*ca_system_id*/, uint16_t* ca_pid)
{
// if ((((buffer[2] & 0x1F) << 8) | buffer[3]) == ca_system_id)
*ca_pid = ((buffer[4] & 0x1F) << 8) | buffer[5];
}
/* 0x0A */
void ISO_639_language_descriptor(const unsigned char * const)
{
}
/* 0x0B */
void System_clock_descriptor(const unsigned char * const)
{
}
/* 0x0C */
void Multiplex_buffer_utilization_descriptor(const unsigned char * const)
{
}
/* 0x0D */
void Copyright_descriptor(const unsigned char * const)
{
}
/* 0x0E */
void Maximum_bitrate_descriptor(const unsigned char * const)
{
}
/* 0x0F */
void Private_data_indicator_descriptor(const unsigned char * const)
{
}
/* 0x10 */
void Smoothing_buffer_descriptor(const unsigned char * const)
{
}
/* 0x11 */
void STD_descriptor(const unsigned char * const)
{
}
/* 0x12 */
void IBP_descriptor(const unsigned char * const)
{
}
/*
* 0x13 ... 0x1A: Defined in ISO/IEC 13818-6
*/
/* 0x1B */
void MPEG4_video_descriptor(const unsigned char * const)
{
}
/* 0x1C */
void MPEG4_audio_descriptor(const unsigned char * const)
{
}
/* 0x1D */
void IOD_descriptor(const unsigned char * const)
{
}
/* 0x1E */
void SL_descriptor(const unsigned char * const)
{
}
/* 0x1F */
void FMC_descriptor(const unsigned char * const)
{
}
/* 0x20 */
void External_ES_ID_descriptor(const unsigned char * const)
{
}
/* 0x21 */
void MuxCode_descriptor(const unsigned char * const)
{
}
/* 0x22 */
void FmxBufferSize_descriptor(const unsigned char * const)
{
}
/* 0x23 */
void MultiplexBuffer_descriptor(const unsigned char * const)
{
}
/* 0x24 */
void FlexMuxTiming_descriptor(const unsigned char * const)
{
}
/*
* 0x25 ... 0x39: ITU-T H.222.0 | ISO/IEC 13818-1 Reserved
*/
/* 0x40 */
void network_name_descriptor(const unsigned char * const /*buffer*/)
{
#if 0
unsigned char tag = buffer[0];
unsigned char len = buffer[1];
char name[255];
int i;
for(i = 0; i < len; i++)
name[i] = buffer[2+i];
name[i] = 0;
printf("[nit] network name: %s\n", name);
#endif
}
/* 0x41 */
void service_list_descriptor(const unsigned char * const buffer, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq)
{
for (int i = 0; i < buffer[1]; i += 3) {
t_service_id service_id = buffer[i + 2] << 8 | buffer[i + 3];
t_channel_id channel_id = CREATE_CHANNEL_ID64;
uint8_t service_type = buffer[i+4];
//printf("[service_list] type %X sid %X\n", service_type, service_id);
if(service_type == 0x9A) service_type = 1;
if(service_type == 0x86) service_type = 1;
//service_types[channel_id] = service_type;
CServiceScan::getInstance()->AddServiceType(channel_id, service_type);
}
}
/* 0x42 */
void stuffing_descriptor(const unsigned char * const)
{
}
/* 0x43 */
int satellite_delivery_system_descriptor(const unsigned char * const buffer, t_transport_stream_id transport_stream_id, t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq)
{
FrontendParameters feparams;
uint8_t polarization;
stiterator tI;
transponder_id_t TsidOnid;
int modulationSystem, modulationType/*, rollOff*/, fec_inner;
if (CFrontend::getInstance()->getInfo()->type != FE_QPSK)
return -1;
feparams.frequency =
(
((buffer[2] >> 4) * 100000000) +
((buffer[2] & 0x0F) * 10000000) +
((buffer[3] >> 4) * 1000000) +
((buffer[3] & 0x0F) * 100000) +
((buffer[4] >> 4) * 10000) +
((buffer[4] & 0x0F) * 1000) +
((buffer[5] >> 4) * 100) +
((buffer[5] & 0x0F) * 10)
);
feparams.inversion = INVERSION_AUTO;
// rollOff = (buffer[8] >> 4) & 0x03; //alpha_0_35, alpha_0_25, alpha_0_20, alpha_auto
modulationSystem = (buffer[8] >> 2) & 0x01; // 1= DVB_S2
modulationType = (buffer[8]) & 0x03; // 1=QPSK, 2=M8PSK
feparams.u.qpsk.symbol_rate =
(
((buffer[9] >> 4) * 100000000) +
((buffer[9] & 0x0F) * 10000000) +
((buffer[10] >> 4) * 1000000) +
((buffer[10] & 0x0F) * 100000) +
((buffer[11] >> 4) * 10000) +
((buffer[11] & 0x0F) * 1000) +
((buffer[12] >> 4) * 100)
);
fec_inner = CFrontend::getCodeRate(buffer[12] & 0x0F, modulationSystem);
if(modulationType == 2)
fec_inner += 9;
feparams.u.qpsk.fec_inner = (fe_code_rate_t) fec_inner;
polarization = (buffer[8] >> 5) & 0x03;
/* workarounds for braindead broadcasters (e.g. on Telstar 12 at 15.0W) */
if (feparams.frequency >= 100000000)
feparams.frequency /= 10;
if (feparams.u.qpsk.symbol_rate >= 50000000)
feparams.u.qpsk.symbol_rate /= 10;
feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000);
freq = feparams.frequency / 1000;
if(feparams.frequency > 15000000) {
printf("[NIT] ******************************************* Bogus TP: freq %d SR %d fec %d pol %d\n", feparams.frequency, feparams.u.qpsk.symbol_rate, fec_inner, polarization);
return 0;
}
TsidOnid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, original_network_id, transport_stream_id);
CServiceScan::getInstance()->AddTransponder(TsidOnid, &feparams, polarization, true);
return 0;
}
/* 0x44 */
int cable_delivery_system_descriptor(const unsigned char * const buffer, t_transport_stream_id transport_stream_id, t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq)
{
transponder_id_t TsidOnid;
if (CFrontend::getInstance()->getInfo()->type != FE_QAM)
return -1;
FrontendParameters feparams;
feparams.frequency =
(
((buffer[2] >> 4) * 1000000000) +
((buffer[2] & 0x0F) * 100000000) +
((buffer[3] >> 4) * 10000000) +
((buffer[3] & 0x0F) * 1000000) +
((buffer[4] >> 4) * 100000) +
((buffer[4] & 0x0F) * 10000) +
((buffer[5] >> 4) * 1000) +
((buffer[5] & 0x0F) * 100)
);
feparams.inversion = INVERSION_AUTO;
feparams.u.qam.symbol_rate =
(
((buffer[9] >> 4) * 100000000) +
((buffer[9] & 0x0F) * 10000000) +
((buffer[10] >> 4) * 1000000) +
((buffer[10] & 0x0F) * 100000) +
((buffer[11] >> 4) * 10000) +
((buffer[11] & 0x0F) * 1000) +
((buffer[12] >> 4) * 100)
);
if(feparams.frequency > 1000*1000)
feparams.frequency /= 1000;
feparams.u.qam.fec_inner = CFrontend::getCodeRate(buffer[12] & 0x0F);
feparams.u.qam.modulation = CFrontend::getModulation(buffer[8]);
//printf("TP:: freq %X Frequency %X ID %llx\n", freq, feparams.frequency, CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, original_network_id, transport_stream_id));
//feparams.frequency = (int) 1000 * (int) round ((double) feparams.frequency / (double) 1000);
freq = feparams.frequency / 100;
TsidOnid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, original_network_id, transport_stream_id);
CServiceScan::getInstance()->AddTransponder(TsidOnid, &feparams, 0, true);
return 0;
}
/* 0x45 */
void VBI_data_descriptor(const unsigned char * const)
{
}
/* 0x46 */
void VBI_teletext_descriptor(const unsigned char * const)
{
}
/* 0x47 */
void bouquet_name_descriptor(const unsigned char * const)
{
}
uint8_t fix_service_type(uint8_t type)
{
if((type == 0x9A) || (type == 0x86) || (type==0xc3)
|| (type==0xc5) || (type==0xc6) ||
(type == 0x11) || (type == 0x16) || (type == 0x19) || (type == 0x82) |
(type == 0x87) || (type == 0xd3) )
return 1;
return type;
}
bool check_blacklisted_digital_plus(const t_original_network_id onid, const t_transport_stream_id tsid)
{
if ( (onid == 0x0001) &&
((tsid == 0x03F0) || (tsid == 0x03F8) || (tsid == 0x0404) || (tsid == 0x0408) || (tsid == 0x040A) || (tsid == 0x040E) ||
(tsid == 0x0412) || (tsid == 0x0416) || (tsid == 0x041A) || (tsid == 0x041E) || (tsid == 0x0420) || (tsid == 0x0422) || (tsid == 0x0424)) )
return true;
else
return false;
}
void removeMultipleWhitespaces (std::string &str)
{
size_t pos = str.find(" ");
if(pos != std::string::npos ){
std::string temp;
for ( unsigned short i = 0 ; i < str.length(); i++)
if (!(str[i] == ' ' && str[i+1] == ' '))
temp += str[i];
str = temp;
}
}
bool check_blacklisted(std::string& providerName)
{
bool in_blacklist = false;
const char *Cyfrowy_Polsat="Cyfrowy Polsat";
if (providerName == "CanalSat\xE9lite") {
providerName = "CanalSat\xC3\xA9lite";
in_blacklist = true;
} else if (providerName == "Chambre des D\xE9" "put\xE9" "es") {
providerName = "Chambre des D\xC3\xA9" "put\xC3\xA9" "es";
in_blacklist = true;
} else if (providerName == "SKY") {
providerName = "Sky"; // well the name PREMIERE itself is not a problem
in_blacklist = true;
} else if(strncasecmp(providerName.c_str(),"TVN ",4)==0) {
providerName = "TVN";
in_blacklist = true;
}else if (providerName == "BetaDigital"){
in_blacklist = true;
}else if (providerName == "Radio Maria <20>sterreich"){
providerName="Radio Maria \xc3\x96sterreich";
in_blacklist = true;
} else if(strncasecmp(providerName.c_str(),Cyfrowy_Polsat,14)==0){
providerName = Cyfrowy_Polsat;
in_blacklist = true;
}
return in_blacklist;
}
/* 0x48 */
void service_descriptor(const unsigned char * const buffer, const t_service_id service_id, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq, bool free_ca)
{
bool service_wr = false;
uint8_t service_type = buffer[2];
CZapitChannel *channel = NULL;
bool tpchange = false;
static transponder_id_t last_tpid = 0;
//scrambled
if(free_ca && scan_fta_flag){
return;
}
service_type = fix_service_type(service_type);
uint8_t real_type = service_type;
switch ( scanType ) {
case CZapitClient::ST_TVRADIO:
if ( (service_type == 1 ) || (service_type == 2) )
service_wr=true;
break;
case CZapitClient::ST_TV:
if ( service_type == 1 )
service_wr=true;
break;
case CZapitClient::ST_RADIO:
if ( service_type == 2 )
service_wr=true;
break;
case CZapitClient::ST_ALL:
service_wr=true;
break;
}
if ( !service_wr )
return;
uint8_t service_provider_name_length = buffer[3];
std::string providerName((const char*)&(buffer[4]), service_provider_name_length);
std::string serviceName;
// std::string satelliteName = "unknown";
bool in_blacklist = false;
if (check_blacklisted(providerName)) {
in_blacklist = true;
}else if((check_blacklisted_digital_plus(original_network_id, transport_stream_id))){
providerName = "Digital+";
in_blacklist = true;
}
if (in_blacklist) {
if (((unsigned char)buffer[4 + service_provider_name_length + 1]) >= 0x20) // no encoding info
serviceName = CDVBString(("\x05" + std::string((const char*)&(buffer[4 + service_provider_name_length + 1]), (2 + buffer[1]) - (4 + service_provider_name_length + 1))).c_str(), (2 + buffer[1]) - (4 + service_provider_name_length + 1) + 1).getContent(); // add artificial encoding info
else
serviceName = CDVBString((const char*)&(buffer[4 + service_provider_name_length + 1]), (2 + buffer[1]) - (4 + service_provider_name_length + 1)).getContent();
}
else
{
providerName = CDVBString((const char*)&(buffer[4]), service_provider_name_length).getContent();
serviceName = CDVBString((const char*)&(buffer[4 + service_provider_name_length + 1]), (2 + buffer[1]) - (4 + service_provider_name_length + 1)).getContent();
}
if(serviceName.empty() || serviceName == "."){
char buf_tmp[16]={0};
snprintf(buf_tmp,sizeof(buf_tmp),"(0x%04X_0x%04X)",transport_stream_id, service_id);
serviceName = buf_tmp;
}
t_channel_id channel_id;
int i = 0;
freq_id_t freq_tmp = freq;
freq -= 2;
for(i = 0; i < 6; i++) {
channel_id = CREATE_CHANNEL_ID64;
channel = CServiceManager::getInstance()->FindChannel(channel_id);
if(channel) {
service_wr = false;
channel->setName(serviceName);
channel->setServiceType(real_type);
channel->scrambled = free_ca;
break;
}
freq++;
}
transponder_id_t tpid = CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID( freq, satellitePosition, original_network_id, transport_stream_id);
if(service_wr) {
freq = freq_tmp;
channel_id = CREATE_CHANNEL_ID64;
DBG("New channel ===== %llx:::%llx %s\n", channel_id, tpid, serviceName.c_str());
channel = new CZapitChannel (
serviceName,
service_id,
transport_stream_id,
original_network_id,
real_type /*service_type*/,
satellitePosition,
freq
);
CServiceManager::getInstance()->AddChannel(channel);
channel->scrambled = free_ca;
//channel = &ret.first->second;
}
//FIXME at this point channel never should be NULL
if(channel == NULL) {
printf("service_descriptor: BUG ? channel %llx:::%llx %s nor found neither created !\n", channel_id, tpid, serviceName.c_str());
return;
}
//printf("[scan] last tp %llx new %llx\n", last_tpid, tpid);
if(last_tpid != tpid) {
last_tpid = tpid;
tpchange = true;
}
if ( providerName.empty() ) {
unsigned char buff[1024];
unsigned short network_descriptors_length=0;
unsigned short pos=0;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
memset(filter, 0x00, DMX_FILTER_SIZE);
memset(mask, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x40;
filter[4] = 0x00;
mask[0] = 0xFF;
mask[4] = 0xFF;
if(tpchange) {
cDemux * dmx = new cDemux(1);
dmx->Open(DMX_PSI_CHANNEL);
if (!((dmx->sectionFilter(0x10, filter, mask, 5) < 0) || (dmx->Read(buff, 1024) < 0))) {
network_descriptors_length = ((buff[8] & 0x0F) << 8) | buff[9];
for (pos = 10; pos < network_descriptors_length + 10; pos += buff[pos + 1] + 2) {
switch (buff[pos]) {
case 0x40:
if (buff[pos+1] > 30)
buff[pos+1] = 30;
providerName = CDVBString((const char*)&(buff[pos+2]), buff[pos+1]).getContent();
break;
default:
DBG("first_descriptor_tag: %02x\n", buff[pos]);
break;
}
}
}
delete dmx;
} else {
providerName=lastProviderName;
}
}
removeMultipleWhitespaces( providerName );
// remove space at ende providerName
if(!providerName.empty()){
i = 1;
while (isspace(providerName[providerName.size()-i])){
i++;
}
i--;
if(i > 0){
providerName.resize(providerName.size()-i);
}
}else{
const char *unknown_provider_name = "Unknown Provider";
providerName = CDVBString(unknown_provider_name, strlen(unknown_provider_name)).getContent();
}
lastProviderName = providerName;
//CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_PROVIDER, (void *) lastProviderName.c_str(), lastProviderName.length() + 1);
CServiceScan::getInstance()->ChannelFound(service_type, lastProviderName, serviceName);
switch (service_type) {
case ST_DIGITAL_TELEVISION_SERVICE:
case ST_DIGITAL_RADIO_SOUND_SERVICE:
case ST_NVOD_REFERENCE_SERVICE:
case ST_NVOD_TIME_SHIFTED_SERVICE:
{
CZapitBouquet* bouquet;
int bouquetId;
char pname[100];
if (CFrontend::getInstance()->getInfo()->type == FE_QPSK)
snprintf(pname, 100, "[%c%03d.%d] %s", satellitePosition > 0? 'E' : 'W', abs(satellitePosition)/10, abs(satellitePosition)%10, providerName.c_str());
else
snprintf(pname, 100, "%s", providerName.c_str());
bouquetId = scanBouquetManager->existsBouquet(pname);
if (bouquetId == -1)
bouquet = scanBouquetManager->addBouquet(std::string(pname), false);
else
bouquet = scanBouquetManager->Bouquets[bouquetId];
#if 0
lastServiceName = serviceName;
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_SERVICENAME, (void *) lastServiceName.c_str(), lastServiceName.length() + 1);
CZapit::getInstance()->SendEvent(CZapitClient::EVT_SCAN_SERVICENAME, (void *) serviceName.c_str(), serviceName.length() + 1);
#endif
#if 0
CZapitChannel* chan = scanBouquetManager->findChannelByChannelID(channel_id);
if(chan)
bouquet->addService(chan);
#endif
bouquet->addService(channel);
break;
}
default:
break;
}
if(CZapit::getInstance()->scanPids()) {
if(tpchange)
parse_pat();
channel->resetPids();
if(!pat_get_pmt_pid(channel)) {
if(!parse_pmt(channel)) {
//if(channel->getPreAudioPid() == 0 && channel->getVideoPid() == 0)
// printf("[scan] Channel %s dont have A/V pids !\n", channel->getName().c_str());
if ((channel->getPreAudioPid() != 0) || (channel->getVideoPid() != 0)) {
channel->setPidsFlag();
}
}
}
}
if(service_type == ST_DIGITAL_TELEVISION_SERVICE && !channel->scrambled) {
CZapit::getInstance()->SetCurrentChannelID(channel->getChannelID());
}
}
void current_service_descriptor(const unsigned char * const buffer, const t_service_id service_id, const t_transport_stream_id transport_stream_id, const t_original_network_id original_network_id, t_satellite_position satellitePosition, freq_id_t freq, bool free_ca)
{
bool service_wr = false;
uint8_t service_type = buffer[2];
service_type = fix_service_type(service_type);
uint8_t real_type = service_type;
#if 0
switch ( scanType ) {
case CZapitClient::ST_TVRADIO:
if ( (service_type == 1 ) || (service_type == 2) )
service_wr=true;
break;
case CZapitClient::ST_TV:
if ( service_type == 1 )
service_wr=true;
break;
case CZapitClient::ST_RADIO:
if ( service_type == 2 )
service_wr=true;
break;
case CZapitClient::ST_ALL:
service_wr=true;
break;
}
#endif
if ( (service_type == 1 ) || (service_type == 2) )
service_wr=true;
if ( !service_wr )
return;
if(CServiceManager::getInstance()->FindCurrentChannel(CREATE_CHANNEL_ID64))
return;
uint8_t service_provider_name_length = buffer[3];
std::string providerName((const char*)&(buffer[4]), service_provider_name_length);
std::string serviceName;
// std::string satelliteName = "unknown";
bool in_blacklist = false;
if (check_blacklisted(providerName)) {
in_blacklist = true;
}else if((check_blacklisted_digital_plus(original_network_id, transport_stream_id))){
providerName = "Digital+";
in_blacklist = true;
}
if (in_blacklist) {
if (((unsigned char)buffer[4 + service_provider_name_length + 1]) >= 0x20) // no encoding info
serviceName = CDVBString(("\x05" + std::string((const char*)&(buffer[4 + service_provider_name_length + 1]), (2 + buffer[1]) - (4 + service_provider_name_length + 1))).c_str(), (2 + buffer[1]) - (4 + service_provider_name_length + 1) + 1).getContent(); // add artificial encoding info
else
serviceName = CDVBString((const char*)&(buffer[4 + service_provider_name_length + 1]), (2 + buffer[1]) - (4 + service_provider_name_length + 1)).getContent();
} else {
serviceName = CDVBString((const char*)&(buffer[4 + service_provider_name_length + 1]), (2 + buffer[1]) - (4 + service_provider_name_length + 1)).getContent();
}
if(serviceName.empty() || serviceName == "." ){
char buf_tmp[16]={0};
snprintf(buf_tmp,sizeof(buf_tmp),"(0x%04X_0x%04X)",transport_stream_id, service_id);
serviceName = buf_tmp;
}
CZapitChannel * channel = new CZapitChannel(serviceName,
service_id,
transport_stream_id,
original_network_id,
real_type /*service_type*/,
satellitePosition,
freq
);
CServiceManager::getInstance()->AddCurrentChannel(channel);
channel->scrambled = free_ca;
}
/* 0x49 */
void country_availability_descriptor(const unsigned char * const)
{
}
/* 0x4A */
void linkage_descriptor(const unsigned char * const)
{
}
/* 0x4B */
int NVOD_reference_descriptor(
const unsigned char * const buffer,
const unsigned int num,
t_transport_stream_id * const tsid,
t_original_network_id * const onid,
t_service_id * const sid)
{
if ((unsigned int)(buffer[1] / 6) + 1 >= num) {
*tsid = (buffer[2 + (6 * num)] << 16) | buffer[3 + (6 * num)];
*onid = (buffer[4 + (6 * num)] << 16) | buffer[5 + (6 * num)];
*sid = (buffer[6 + (6 * num)] << 16) | buffer[7 + (6 * num)];
return 0;
}
return -1;
}
/* 0x4C */
void time_shifted_service_descriptor(const unsigned char * const)
{
}
/* 0x4D */
void short_event_descriptor(const unsigned char * const)
{
}
/* 0x4E */
void extended_event_descriptor(const unsigned char * const)
{
}
/* 0x4F */
void time_shifted_event_descriptor(const unsigned char * const)
{
}
/* 0x50 */
void component_descriptor(const unsigned char * const)
{
}
/* 0x51 */
void mosaic_descriptor(const unsigned char * const)
{
}
/* 0x52 */
void stream_identifier_descriptor(const unsigned char * const)
{
}
/* 0x53 */
void CA_identifier_descriptor(const unsigned char * const)
{
}
/* 0x54 */
void content_descriptor(const unsigned char * const)
{
}
/* 0x55 */
void parental_rating_descriptor(const unsigned char * const)
{
}
/* 0x56 */
void teletext_descriptor(const unsigned char * const)
{
}
/* 0x57 */
void telephone_descriptor(const unsigned char * const)
{
}
/* 0x58 */
void local_time_offset_descriptor(const unsigned char * const)
{
}
/* 0x59 */
void subtitling_descriptor(const unsigned char * const)
{
}
/* 0x5A */
int terrestrial_delivery_system_descriptor(const unsigned char * const)
{
if (CFrontend::getInstance()->getInfo()->type != FE_OFDM)
return -1;
/* TODO */
return 0;
}
/* 0x5B */
void multilingual_network_name_descriptor(const unsigned char * const)
{
}
/* 0x5C */
void multilingual_bouquet_name_descriptor(const unsigned char * const)
{
}
/* 0x5D */
void multilingual_service_name_descriptor(const unsigned char * const)
{
}
/* 0x5E */
void multilingual_component_descriptor(const unsigned char * const)
{
}
/* 0x5F */
void private_data_specifier_descriptor(const unsigned char * const)
{
}
/* 0x60 */
void service_move_descriptor(const unsigned char * const)
{
}
/* 0x61 */
void short_smoothing_buffer_descriptor(const unsigned char * const)
{
}
/* 0x62 */
void frequency_list_descriptor(const unsigned char * const)
{
}
/* 0x63 */
void partial_transport_stream_descriptor(const unsigned char * const)
{
}
/* 0x64 */
void data_broadcast_descriptor(const unsigned char * const)
{
}
/* 0x65 */
void CA_system_descriptor(const unsigned char * const)
{
}
/* 0x66 */
void data_broadcast_id_descriptor(const unsigned char * const)
{
}
/* 0x67 */
void transport_stream_descriptor(const unsigned char * const)
{
}
/* 0x68 */
void DSNG_descriptor(const unsigned char * const)
{
}
/* 0x69 */
void PDC_descriptor(const unsigned char * const)
{
}
/* 0x6A */
void AC3_descriptor(const unsigned char * const)
{
}
/* 0x6B */
void ancillary_data_descriptor(const unsigned char * const)
{
}
/* 0x6C */
void cell_list_descriptor(const unsigned char * const)
{
}
/* 0x6D */
void cell_frequency_link_descriptor(const unsigned char * const)
{
}
/* 0x6E */
void announcement_support_descriptor(const unsigned char * const)
{
}
/* 0x6F ... 0x7F: reserved */
/* 0x80 ... 0xFE: user private */
/* 0xFF: forbidden */

View File

@@ -1,224 +0,0 @@
/*
* $Id: nit.cpp,v 1.36 2004/04/17 19:44:04 derget Exp $
*
* (C) 2002 by Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* system c++ */
#include <map>
/* zapit */
#include <zapit/debug.h>
#include <zapit/descriptors.h>
#include <zapit/getservices.h>
#include <dmx.h>
#include <zapit/nit.h>
#include <zapit/scan.h>
#define NIT_SIZE 1024
extern short abort_scan;
void *nit_thread(void * data)
{
int satellitePosition = (int) data;
printf("[scan] trying to parse NIT\n");
int status = parse_nit(satellitePosition, 0);
if(status < 0)
printf("[scan] NIT failed !\n");
else
printf("[scan] NIT finished.\n");
pthread_exit(NULL);
}
int parse_nit(t_satellite_position satellitePosition, freq_id_t freq)
{
int ret = 0;
int secdone[255];
int sectotal = -1;
for(int i = 0; i < 255; i++)
secdone[i] = 0;
cDemux * dmx = new cDemux();;
dmx->Open(DMX_PSI_CHANNEL);
unsigned char buffer[NIT_SIZE];
/* position in buffer */
unsigned short pos;
unsigned short pos2;
/* network_information_section elements */
unsigned short section_length;
unsigned short network_descriptors_length;
unsigned short transport_descriptors_length;
unsigned short transport_stream_loop_length;
t_transport_stream_id transport_stream_id;
t_original_network_id original_network_id;
unsigned short network_id;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
memset(filter, 0x00, DMX_FILTER_SIZE);
memset(mask, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x40;
//filter[4] = 0x00;
mask[0] = 0xFF;
//mask[4] = 0xFF;
//unsigned char sec = 0x00;
if (dmx->sectionFilter(0x10, filter, mask, 5) < 0) {
delete dmx;
return -1;
}
do {
if (dmx->Read(buffer, NIT_SIZE) < 0) {
delete dmx;
return -1;
}
if (CServiceScan::getInstance()->Aborted()) {
ret = -1;
goto _return;
}
if(buffer[0] != 0x40)
printf("[NIT] ******************************************* Bogus section received: 0x%x\n", buffer[0]);
section_length = ((buffer[1] & 0x0F) << 8) + buffer[2];
network_id = ((buffer[3] << 8)| buffer [4]);
network_descriptors_length = ((buffer[8] & 0x0F) << 8) | buffer[9];
unsigned char secnum = buffer[6];
printf("[NIT] section %X last %X network_id 0x%x -> %s\n", secnum, buffer[7], network_id, secdone[secnum] ? "skip" : "use");
if(secdone[secnum]) // mark sec XX done
continue;
secdone[secnum] = 1;
sectotal++;
for (pos = 10; pos < network_descriptors_length + 10; pos += buffer[pos + 1] + 2)
{
switch (buffer[pos])
{
/* case 0x0F:
Private_data_indicator_descriptor(buffer + pos);
break;
*/
case 0x40:
network_name_descriptor(buffer + pos);
break;
case 0x4A:
linkage_descriptor(buffer + pos);
break;
case 0x5B:
multilingual_network_name_descriptor(buffer + pos);
break;
/* case 0x5F:
private_data_specifier_descriptor(buffer + pos);
break;
*/
case 0x80: /* unknown, Eutelsat 13.0E */
break;
case 0x90: /* unknown, Eutelsat 13.0E */
break;
default:
DBG("first_descriptor_tag: %02x\n", buffer[pos]);
break;
}
}
transport_stream_loop_length = ((buffer[pos] & 0x0F) << 8) | buffer[pos + 1];
if (!transport_stream_loop_length)
continue;
for (pos += 2; pos < section_length - 3; pos += transport_descriptors_length + 6)
{
transport_stream_id = (buffer[pos] << 8) | buffer[pos + 1];
original_network_id = (buffer[pos + 2] << 8) | buffer[pos + 3];
transport_descriptors_length = ((buffer[pos + 4] & 0x0F) << 8) | buffer[pos + 5];
//if (transponders.find((transport_stream_id << 16) | original_network_id) == transponders.end())
//if (scantransponders.find(CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, original_network_id, transport_stream_id)) == scantransponders.end())
{
for (pos2 = pos + 6; pos2 < pos + transport_descriptors_length + 6; pos2 += buffer[pos2 + 1] + 2)
{
switch (buffer[pos2])
{
case 0x41:
service_list_descriptor(buffer + pos2, transport_stream_id, original_network_id, satellitePosition, freq);
break;
case 0x42:
stuffing_descriptor(buffer + pos2);
break;
case 0x43:
if (satellite_delivery_system_descriptor(buffer + pos2, transport_stream_id, original_network_id, satellitePosition, freq) < 0)
{
ret = -2;
goto _return;
}
break;
case 0x44:
if (cable_delivery_system_descriptor(buffer + pos2, transport_stream_id, original_network_id, satellitePosition, freq) < 0)
{
ret = -2;
goto _return;
}
break;
case 0x5A:
if (terrestrial_delivery_system_descriptor(buffer + pos2) < 0)
{
ret = -2;
goto _return;
}
break;
case 0x5F:
private_data_specifier_descriptor(buffer + pos2);
break;
case 0x62:
frequency_list_descriptor(buffer + pos2);
break;
case 0x82: /* unknown, Eutelsat 13.0E */
break;
default:
DBG("second_descriptor_tag: %02x\n", buffer[pos2]);
break;
}
}
}
}
} while(sectotal < buffer[7]);
//} while (filter[4]++ != buffer[7]);
_return:
dmx->Stop();
delete dmx;
return ret;
}

View File

@@ -1,722 +0,0 @@
/*
* $Id: pmt.cpp,v 1.40 2004/04/04 20:46:17 obi Exp $
*
* (C) 2002 by Andreas Oberritter <obi@tuxbox.org>
* (C) 2002 by Frank Bormann <happydude@berlios.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
/* zapit */
#include <zapit/settings.h>
#include <zapit/descriptors.h>
#include <zapit/debug.h>
#include <zapit/pmt.h>
#include <zapit/scan.h>
#include <sectionsd/edvbstring.h>
#include <dmx.h>
#include <ca_cs.h>
//#include <linux/dvb/dmx.h>
#define PMT_SIZE 1024
#define RECORD_MODE 0x4
/*
* Stream types
* ------------
* 0x01 ISO/IEC 11172 Video
* 0x02 ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or ISO/IEC 11172-2 constrained parameter video stream
* 0x03 ISO/IEC 11172 Audio
* 0x04 ISO/IEC 13818-3 Audio
* 0x05 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections, e.g. MHP Application signalling stream
* 0x06 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data, e.g. teletext or ac3
* 0x0b ISO/IEC 13818-6 type B
* 0x81 User Private (MTV)
* 0x90 User Private (Premiere Mail, BD_DVB)
* 0xc0 User Private (Canal+)
* 0xc1 User Private (Canal+)
* 0xc6 User Private (Canal+)
*/
unsigned short parse_ES_info(const unsigned char * const buffer, CZapitChannel * const channel, CCaPmt * const caPmt)
{
unsigned short ES_info_length;
unsigned short pos;
unsigned char descriptor_tag;
unsigned char descriptor_length;
unsigned char i;
bool isAc3 = false;
bool isDts = false;
bool isAac = false;
bool descramble = false;
std::string description = "";
unsigned char componentTag = 0xFF;
/* elementary stream info for ca pmt */
CEsInfo *esInfo = new CEsInfo();
esInfo->stream_type = buffer[0];
esInfo->reserved1 = buffer[1] >> 5;
esInfo->elementary_PID = ((buffer[1] & 0x1F) << 8) | buffer[2];
esInfo->reserved2 = buffer[3] >> 4;
ES_info_length = ((buffer[3] & 0x0F) << 8) | buffer[4];
for (pos = 5; pos < ES_info_length + 5; pos += descriptor_length + 2) {
descriptor_tag = buffer[pos];
descriptor_length = buffer[pos + 1];
unsigned char fieldCount = descriptor_length / 5;
switch (descriptor_tag) {
case 0x02:
video_stream_descriptor(buffer + pos);
break;
case 0x03:
audio_stream_descriptor(buffer + pos);
break;
case 0x05:
if (descriptor_length >= 3)
if (!strncmp((const char*)&buffer[pos + 2], "DTS", 3))
isDts = true;
break;
case 0x09:
esInfo->addCaDescriptor(buffer + pos);
descramble = true;
break;
case 0x0A: /* ISO_639_language_descriptor */
#if 0
printf("descr 0x0A: %02X %02X %02X\n", buffer[pos+2], buffer[pos+3], buffer[pos+4]);
#endif
/* FIXME cyfra+ radio -> 41 20 31 ?? */
if (description != "" && buffer[pos + 3] == ' ') {
description += buffer[pos + 3];
description += buffer[pos + 4];
} else {
for (i = 0; i < 3; i++)
description += tolower(buffer[pos + i + 2]);
}
break;
case 0x13: /* Defined in ISO/IEC 13818-6 */
break;
case 0x0E:
Maximum_bitrate_descriptor(buffer + pos);
break;
case 0x0F:
Private_data_indicator_descriptor(buffer + pos);
break;
case 0x11:
STD_descriptor(buffer + pos);
break;
case 0x45:
VBI_data_descriptor(buffer + pos);
break;
case 0x52: /* stream_identifier_descriptor */
componentTag = buffer[pos + 2];
break;
case 0x56: /* teletext descriptor */
char tmp_Lang[4];
//printf("[pmt] teletext pid %x: %s\n", esInfo->elementary_PID, tmp_Lang);
printf("[pmt] teletext pid %x\n", esInfo->elementary_PID);
for (unsigned char fIdx = 0; fIdx < fieldCount; fIdx++) {
memmove(tmp_Lang, &buffer[pos + 5*fIdx + 2], 3);
tmp_Lang[3] = '\0';
unsigned char teletext_type=buffer[pos + 5*fIdx + 5]>> 3;
unsigned char teletext_magazine_number = buffer[pos + 5*fIdx + 5] & 7;
unsigned char teletext_page_number=buffer[pos + 5*fIdx + 6];
printf("[pmt] teletext type %d mag %d page %d lang %s\n", teletext_type, teletext_magazine_number, teletext_page_number, tmp_Lang);
if (teletext_type==0x01)
channel->setTeletextLang(tmp_Lang);
if (teletext_type==0x02){
channel->addTTXSubtitle(esInfo->elementary_PID,tmp_Lang,teletext_magazine_number,teletext_page_number);
} else {
if (teletext_type==0x05){
channel->addTTXSubtitle(esInfo->elementary_PID,tmp_Lang,teletext_magazine_number,teletext_page_number,true);
}
}
}
channel->setTeletextPid(esInfo->elementary_PID);
descramble = true;//FIXME ORF HD scramble txt ?
break;
case 0x59:
if (esInfo->stream_type==0x06) {
unsigned char fieldCount1=descriptor_length/8;
for (unsigned char fIdx=0;fIdx<fieldCount1;fIdx++){
char tmpLang[4];
memmove(tmpLang,&buffer[pos + 8*fIdx + 2],3);
tmpLang[3] = '\0';
unsigned char subtitling_type=buffer[pos+8*fIdx+5];
unsigned short composition_page_id=
*((unsigned short*)(&buffer[pos + 8*fIdx + 6]));
unsigned short ancillary_page_id=
*((unsigned short*)(&buffer[pos + 8*fIdx + 8]));
channel->addDVBSubtitle(esInfo->elementary_PID,tmpLang,subtitling_type,composition_page_id,ancillary_page_id);
}
descramble = true;//FIXME MGM / 10E scrambling subtitles ?
}
subtitling_descriptor(buffer + pos);
break;
case 0x5F:
private_data_specifier_descriptor(buffer + pos);
break;
case 0x66:
data_broadcast_id_descriptor(buffer + pos);
break;
case 0x6A: /* AC3 descriptor */
isAc3 = true;
break;
case 0x6F: /* unknown, Astra 19.2E */
break;
case 0x7B:
isDts = true;
break;
case 0x7C: //FIXME AAC
isAac = true;
break;
case 0x90: /* unknown, Astra 19.2E */
break;
case 0xB1: /* unknown, Astra 19.2E */
break;
case 0xC0: /* unknown, Astra 19.2E */
break;
case 0xC1: /* unknown, Astra 19.2E */
break;
case 0xC2: /* User Private descriptor - Canal+ */
#if 0
DBG("0xC2 dump:");
for (i = 0; i < descriptor_length; i++) {
printf("%c", buffer[pos + 2 + i]);
if (((i+1) % 8) == 0)
printf("\n");
}
#endif
break;
case 0xC5: /* User Private descriptor - Canal+ Radio */
//description = convertDVBUTF8((const char*)&buffer[pos+3], 24, 2, 1);
description = convertDVBUTF8((const char*)&buffer[pos+3], 24, 2, channel->getTransportStreamId() << 16 | channel->getOriginalNetworkId());
#if 0
printf("descr 0xC5\n");
for (i = 0; i < 24; i++) {
printf("%02X ", buffer[pos + i]);
//description += buffer[pos + i + 3];
}
printf("\n");
printf("[pmt] name %s\n", description.c_str());
#endif
break;
case 0xC6: /* unknown, Astra 19.2E */
break;
case 0xFD: /* unknown, Astra 19.2E */
break;
case 0xFE: /* unknown, Astra 19.2E */
break;
default:
DBG("descriptor_tag: %02x\n", descriptor_tag);
break;
}
}
switch (esInfo->stream_type) {
case 0x01:
case 0x02:
case 0x1b: // AVC Video Stream (MPEG4 H264)
channel->setVideoPid(esInfo->elementary_PID);
descramble = true;
channel->type = (esInfo->stream_type == 0x1b); //FIXME
printf("[pmt] vpid %x stream %d type %d\n", esInfo->elementary_PID, esInfo->stream_type, channel->type);
break;
case 0x03:
case 0x04:
if (description == "")
description = " ";
if(CServiceScan::getInstance()->Scanning()) {
if(channel->getPreAudioPid() == 0)
channel->setAudioPid(esInfo->elementary_PID);
} else
channel->addAudioChannel(esInfo->elementary_PID, CZapitAudioChannel::MPEG, description, componentTag);
descramble = true;
printf("[pmt] apid %x: %s\n", esInfo->elementary_PID, description.c_str());
break;
case 0x05:// private section
{
int tmp=0;
// Houdini: shameless stolen from enigma dvbservices.cpp
for (pos = 5; pos < ES_info_length + 5; pos += descriptor_length + 2) {
descriptor_tag = buffer[pos];
descriptor_length = buffer[pos + 1];
switch (descriptor_tag) {
case 0x5F: //DESCR_PRIV_DATA_SPEC:
if ( ((buffer[pos + 2]<<24) | (buffer[pos + 3]<<16) | (buffer[pos + 4]<<8) | (buffer[pos + 5])) == 190 )
tmp |= 1;
break;
case 0x90:
{
if ( descriptor_length == 4 && !buffer[pos + 2] && !buffer[pos + 3] && buffer[pos + 4] == 0xFF && buffer[pos + 5] == 0xFF )
tmp |= 2;
}
//break;??
default:
break;
}
}
if ( tmp == 3 ) {
channel->setPrivatePid(esInfo->elementary_PID);
DBG("channel->setPrivatePid(%x)\n", esInfo->elementary_PID);
}
descramble = true;
break;
}
case 0x81:
esInfo->stream_type = 0x6;
if (description == "")
description = "Unknown";
description += " (AC3)";
isAc3 = true;
descramble = true;
if(!CServiceScan::getInstance()->Scanning())
channel->addAudioChannel(esInfo->elementary_PID, CZapitAudioChannel::AC3, description, componentTag);
break;
case 0x06:
if ((isAc3) || (isDts) || (isAac)) {
if (description == "") {
description = esInfo->elementary_PID;
if (isAc3)
description += " (AC3)";
else if (isDts)
description += " (DTS)";
else if (isAac)
description += " (AAC)";
}
if(!CServiceScan::getInstance()->Scanning()) {
CZapitAudioChannel::ZapitAudioChannelType Type;
if (isAc3)
Type = CZapitAudioChannel::AC3;
else if (isDts)
Type = CZapitAudioChannel::DTS;
else if (isAac)
Type = CZapitAudioChannel::AAC;
else
Type = CZapitAudioChannel::UNKNOWN;
channel->addAudioChannel(esInfo->elementary_PID, Type, description, componentTag);
}
descramble = true;
}
break;
case 0x0F: // AAC ADTS
case 0x11: // AAC LATM
if (description == "")
description = esInfo->elementary_PID;
description += " (AAC)";
isAac = true;
descramble = true;
if(!CServiceScan::getInstance()->Scanning())
channel->addAudioChannel(esInfo->elementary_PID, CZapitAudioChannel::AAC, description, componentTag);
break;
case 0x0B:
break;
case 0x90:
break;
case 0x93:
break;
case 0xC0:
break;
case 0xC1:
break;
case 0xC6:
break;
default:
DBG("stream_type: %02x\n", esInfo->stream_type);
break;
}
if (descramble)
caPmt->es_info.insert(caPmt->es_info.end(), esInfo);
else
delete esInfo;
return ES_info_length;
}
int curpmtpid,curservice_id;
int pmt_caids[4][11] = {{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0}};
int parse_pmt(CZapitChannel * const channel)
{
int pmtlen;
int ia, dpmtlen, pos;
unsigned char descriptor_length=0;
unsigned char buffer[PMT_SIZE];
/* current position in buffer */
unsigned short i,j;
for(j=0;j<4;j++){
for(i=0;i<11;i++)
pmt_caids[j][i] = 0;
}
/* length of elementary stream description */
unsigned short ES_info_length;
/* TS_program_map_section elements */
unsigned short section_length;
unsigned short program_info_length;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
printf("[zapit] parsing pmt pid 0x%X\n", channel->getPmtPid());
if (channel->getPmtPid() == 0){
return -1;
}
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] = channel->getServiceId() >> 8;
filter[2] = channel->getServiceId();
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(channel->getPmtPid(), filter, mask, 5) < 0) || (dmx->Read(buffer, PMT_SIZE) < 0)) {
delete dmx;
return -1;
}
delete dmx;
curservice_id = channel->getServiceId();
curpmtpid = channel->getPmtPid();
pmtlen= ((buffer[1]&0xf)<<8) + buffer[2] +3;
dpmtlen=0;
pos=10;
short int ci0 = 0, ci1 = 0, ci2 = 0, ci3 = 0, ci4 = 0, ci5 = 0, ci6 = 0, ci7 = 0, ci8 = 0, ci9 = 0, ci10 = 0;
if(!CServiceScan::getInstance()->Scanning()) {
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: pmt_caids[ci0][0] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci0 < 3) ci0++;
break;
case 0x17: pmt_caids[ci1][1] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci1 < 3) ci1++;
break;
case 0x01: pmt_caids[ci2][2] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci2 < 3) ci2++;
break;
case 0x05: pmt_caids[ci3][3] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci3 < 3) ci3++;
break;
case 0x18: pmt_caids[ci4][4] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci4 < 3) ci4++;
break;
case 0x0B: pmt_caids[ci5][5] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci5 < 3) ci5++;
break;
case 0x0D: pmt_caids[ci6][6] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci6 < 3) ci6++;
break;
case 0x09: pmt_caids[ci7][7] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci7 < 3) ci7++;
break;
case 0x26: pmt_caids[ci8][8] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci8 < 3) ci8++;
break;
case 0x4a: pmt_caids[ci9][9] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci9 < 3) ci9++;
break;
case 0x0E: pmt_caids[ci10][10] = (buffer[ia+2] & 0x1f) << 8 | buffer[ia+3];
if(ci10 < 3) ci10++;
break;
} //switch
} // if
} // for
pos+=dpmtlen+5;
} // while
#if 0
fout=fopen("/tmp/caids.info","w");
if(fout) {
fprintf(fout, "%d %d %d %d %d %d %d %d %d %d\n", caids[0],caids[1],caids[2],caids[3],caids[4],caids[5], caids[6], caids[7], caids[8], caids[9]);
fclose(fout);
}
#endif
} /* if !CServiceScan::getInstance()->Scanning() */
CCaPmt *caPmt = new CCaPmt();
/* ca pmt */
caPmt->program_number = (buffer[3] << 8) + buffer[4];
caPmt->reserved1 = buffer[5] >> 6;
caPmt->version_number = (buffer[5] >> 1) & 0x1F;
caPmt->current_next_indicator = buffer[5] & 0x01;
caPmt->reserved2 = buffer[10] >> 4;
printf("[pmt] pcr pid: old 0x%x new 0x%x\n", channel->getPcrPid(), ((buffer[8] & 0x1F) << 8) + buffer[9]);
if(channel->getCaPmt() != 0) {
if(channel->getCaPmt()->version_number != caPmt->version_number)
channel->resetPids();
}
/* pmt */
section_length = ((buffer[1] & 0x0F) << 8) + buffer[2];
//if(!channel->getPidsFlag())
channel->setPcrPid(((buffer[8] & 0x1F) << 8) + buffer[9]);
program_info_length = ((buffer[10] & 0x0F) << 8) | buffer[11];
if (program_info_length)
for (i = 12; i < 12 + program_info_length; i += buffer[i + 1] + 2)
switch (buffer[i]) {
case 0x09:
caPmt->addCaDescriptor(buffer + i);
break;
default:
DBG("decriptor_tag: %02x\n", buffer[i]);
break;
}
/* pmt */
for (i = 12 + program_info_length; i < section_length - 1; i += ES_info_length + 5)
ES_info_length = parse_ES_info(buffer + i, channel, caPmt);
if(CServiceScan::getInstance()->Scanning()) {
channel->setCaPmt(NULL);
channel->setRawPmt(NULL);
delete caPmt;
} else {
channel->setCaPmt(caPmt);
unsigned char * p = new unsigned char[pmtlen];
memmove(p, buffer, pmtlen);
channel->setRawPmt(p, pmtlen);
}
#if 0
//Quick&Dirty Hack to support Premiere's EPG not only on the portal but on the subchannels as well
if (channel->getOriginalNetworkId() == 0x0085) {
if (channel->getTransportStreamId() ==0x0003)
channel->setPrivatePid(0x0b12);
if (channel->getTransportStreamId() ==0x0004)
channel->setPrivatePid(0x0b11);
}
#endif
channel->setPidsFlag();
return 0;
}
int scan_parse_pmt(int pmtpid, int service_id )
{
if((pmtpid < 1 ) || (curpmtpid == pmtpid && service_id != curservice_id))
return -1;
if(curpmtpid == pmtpid && service_id == curservice_id){
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;
if(service_id == ((buffer[3] << 8) | buffer[4]) ){
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;
}
return -1;
}
#ifndef DMX_SET_NEGFILTER_MASK
#define DMX_SET_NEGFILTER_MASK _IOW('o',48,uint8_t *)
#endif
cDemux * pmtDemux;
int pmt_set_update_filter(CZapitChannel * const channel, int * fd)
{
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
unsigned char mode[DMX_FILTER_SIZE];
if(pmtDemux == NULL) {
pmtDemux = new cDemux(0);
pmtDemux->Open(DMX_PSI_CHANNEL);
}
if (channel->getPmtPid() == 0)
return -1;
memset(filter, 0x00, DMX_FILTER_SIZE);
memset(mask, 0x00, DMX_FILTER_SIZE);
memset(mode, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x02; /* table_id */
filter[1] = channel->getServiceId() >> 8;
filter[2] = channel->getServiceId();
filter[4] = 0x00; /* section_number */
mask[0] = 0xFF;
mask[1] = 0xFF;
mask[2] = 0xFF;
mask[4] = 0xFF;
printf("[pmt] set update filter, sid 0x%x pid 0x%x version %x\n", channel->getServiceId(), channel->getPmtPid(), channel->getCaPmt()->version_number);
#if HAVE_COOL_HARDWARE
filter[3] = (((channel->getCaPmt()->version_number + 1) & 0x01) << 1) | 0x01;
mask[3] = (0x01 << 1) | 0x01;
pmtDemux->sectionFilter(channel->getPmtPid(), filter, mask, 5);
#else
filter[3] = (channel->getCaPmt()->version_number << 1) | 0x01;
mask[3] = (0x1F << 1) | 0x01;
mode[3] = 0x1F << 1;
pmtDemux->sectionFilter(channel->getPmtPid(), filter, mask, 5, 0, mode);
#endif
*fd = 1;
return 0;
}
int pmt_stop_update_filter(int * fd)
{
printf("[pmt] stop update filter\n");
#if HAVE_TRIPLEDRAGON
if (pmtDemux)
delete pmtDemux;
/* apparently a close/reopen is needed on TD... */
pmtDemux = NULL;
#else
if(pmtDemux)
pmtDemux->Stop();
#endif
*fd = -1;
return 0;
}

View File

@@ -1,486 +0,0 @@
/*
* $Id: sdt.cpp,v 1.44 2003/03/14 08:22:04 obi Exp $
*
* (C) 2002, 2003 by Andreas Oberritter <obi@tuxbox.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <fcntl.h>
#include <unistd.h>
/* zapit */
#include <zapit/descriptors.h>
#include <zapit/debug.h>
#include <zapit/sdt.h>
#include <zapit/pmt.h>
#include <zapit/pat.h>
#include <zapit/settings.h> // DEMUX_DEVICE
#include <zapit/types.h>
#include <zapit/bouquets.h>
#include <zapit/frontend_c.h>
#include <zapit/satconfig.h>
#include <dmx.h>
#define SDT_SIZE 1026
transponder_id_t get_sdt_TsidOnid(t_satellite_position satellitePosition, freq_id_t freq)
{
unsigned char buffer[SDT_SIZE];
cDemux * dmx = new cDemux();
dmx->Open(DMX_PSI_CHANNEL);
/* service_description_section elements */
t_transport_stream_id transport_stream_id;
t_original_network_id original_network_id;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
memset(filter, 0x00, DMX_FILTER_SIZE);
memset(mask, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x42;
mask[0] = 0xFF;
if ((dmx->sectionFilter(0x11, filter, mask, 1) < 0) || (dmx->Read(buffer, SDT_SIZE) < 0)) {
delete dmx;
return 0;
}
transport_stream_id = (buffer[3] << 8) | buffer[4];
original_network_id = (buffer[8] << 8) | buffer[9];
delete dmx;
return CREATE_TRANSPONDER_ID_FROM_SATELLITEPOSITION_ORIGINALNETWORK_TRANSPORTSTREAM_ID(freq, satellitePosition, original_network_id, transport_stream_id);
}
int nvod_service_ids(
const t_transport_stream_id ref_tsid,
const t_original_network_id ref_onid,
const t_service_id ref_sid,
const unsigned int num,
t_transport_stream_id * const tsid,
t_original_network_id * const onid,
t_service_id * const sid)
{
cDemux * dmx = new cDemux();
dmx->Open(DMX_PSI_CHANNEL);
/* position in buffer */
unsigned short pos;
unsigned short pos2;
/* service_description_section elements */
unsigned short section_length;
unsigned short service_id;
unsigned short descriptors_loop_length;
unsigned char buffer[SDT_SIZE];
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
filter[0] = 0x42;
filter[1] = (ref_tsid >> 8) & 0xff;
filter[2] = ref_tsid & 0xff;
filter[3] = 0x00;
filter[4] = 0x00;
filter[5] = 0x00;
filter[6] = (ref_onid >> 8) & 0xff;
filter[7] = ref_onid & 0xff;
memset(&filter[8], 0x00, 8);
mask[0] = 0xFF;
mask[1] = 0xFF;
mask[2] = 0xFF;
mask[3] = 0x00;
mask[4] = 0xFF;
mask[5] = 0x00;
mask[6] = 0xFF;
mask[7] = 0xFF;
memset(&mask[8], 0x00, 8);
do {
if ((dmx->sectionFilter(0x11, filter, mask, 8) < 0) || (dmx->Read(buffer, SDT_SIZE) < 0)) {
delete dmx;
return -1;
}
section_length = ((buffer[1] & 0x0F) << 8) | buffer[2];
for (pos = 11; pos < section_length - 1; pos += descriptors_loop_length + 5) {
service_id = (buffer[pos] << 8) | buffer[pos + 1];
descriptors_loop_length = ((buffer[pos + 3] & 0x0F) << 8) | buffer[pos + 4];
if (service_id == ref_sid)
for (pos2 = pos + 5; pos2 < pos + descriptors_loop_length + 5; pos2 += buffer[pos2 + 1] + 2)
if (buffer[pos2] == 0x4b) {
delete dmx;
return NVOD_reference_descriptor(&buffer[pos2], num, tsid, onid, sid);
}
}
}
while (filter[4]++ != buffer[7]);
delete dmx;
return -1;
}
int parse_sdt(
t_transport_stream_id *p_transport_stream_id,
t_original_network_id *p_original_network_id,
t_satellite_position satellitePosition, freq_id_t freq)
{
int secdone[255];
int sectotal = -1;
memset(secdone, 0, 255);
cDemux * dmx = new cDemux();
dmx->Open(DMX_PSI_CHANNEL);
unsigned char buffer[SDT_SIZE];
/* position in buffer */
unsigned short pos;
unsigned short pos2;
/* service_description_section elements */
unsigned short section_length;
unsigned short transport_stream_id = 0;
unsigned short original_network_id = 0;
unsigned short service_id;
unsigned short descriptors_loop_length;
unsigned short running_status;
bool EIT_schedule_flag;
bool EIT_present_following_flag;
bool free_CA_mode;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
int flen;
bool cable_hack_done = false;
bool cable = (CFrontend::getInstance()->getInfo()->type == FE_QAM);
#if 1
flen = 5;
memset(filter, 0x00, DMX_FILTER_SIZE);
memset(mask, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x42;
//filter[4] = 0x00;
mask[0] = 0xFF;
//mask[4] = 0xFF;
#else // FIXME why we need to know tsid/onid for table 0x42 ??
flen = 8;
filter[0] = 0x42;
filter[1] = (p_transport_stream_id >> 8) & 0xff;
filter[2] = p_transport_stream_id & 0xff;
filter[3] = 0x00;
filter[4] = 0x00;
filter[5] = 0x00;
filter[6] = (p_original_network_id >> 8) & 0xff;
filter[7] = p_original_network_id & 0xff;
memset(&filter[8], 0x00, 8);
mask[0] = 0xFF;
mask[1] = 0xFF;
mask[2] = 0xFF;
mask[3] = 0x00;
mask[4] = 0xFF;
mask[5] = 0x00;
mask[6] = 0xFF;
mask[7] = 0xFF;
memset(&mask[8], 0x00, 8);
#endif
if (dmx->sectionFilter(0x11, filter, mask, flen) < 0) {
delete dmx;
return -1;
}
do {
_repeat:
if (dmx->Read(buffer, SDT_SIZE) < 0) {
delete dmx;
return -1;
}
if(buffer[0] != 0x42)
printf("[SDT] ******************************************* Bogus section received: 0x%x\n", buffer[0]);
section_length = ((buffer[1] & 0x0F) << 8) | buffer[2];
if(cable_hack_done) {
if( (transport_stream_id == ((buffer[3] << 8) | buffer[4])) &&
(original_network_id == ((buffer[8] << 8) | buffer[9])))
break;
} else {
transport_stream_id = (buffer[3] << 8) | buffer[4];
original_network_id = (buffer[8] << 8) | buffer[9];
}
unsigned char secnum = buffer[6];
printf("[SDT] section %X last %X tsid 0x%x onid 0x%x -> %s\n", buffer[6], buffer[7], transport_stream_id, original_network_id, secdone[secnum] ? "skip" : "use");
if(secdone[secnum])
continue;
secdone[secnum] = 1;
sectotal++;
*p_transport_stream_id = transport_stream_id;
*p_original_network_id = original_network_id;
for (pos = 11; pos < section_length - 1; pos += descriptors_loop_length + 5) {
service_id = (buffer[pos] << 8) | buffer[pos + 1];
EIT_schedule_flag = buffer[pos + 2] & 0x02;
EIT_present_following_flag = buffer[pos + 2] & 0x01;
running_status = buffer [pos + 3] & 0xE0;
free_CA_mode = buffer [pos + 3] & 0x10;
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) {
//printf("[sdt] descriptor %X\n", buffer[pos2]);
switch (buffer[pos2]) {
case 0x0A:
ISO_639_language_descriptor(buffer + pos2);
break;
/* case 0x40:
network_name_descriptor(buffer + pos2);
break;
*/
case 0x42:
stuffing_descriptor(buffer + pos2);
break;
case 0x47:
bouquet_name_descriptor(buffer + pos2);
break;
case 0x48:
service_descriptor(buffer + pos2, service_id, transport_stream_id, original_network_id, satellitePosition, freq, free_CA_mode);
break;
case 0x49:
country_availability_descriptor(buffer + pos2);
break;
case 0x4A:
linkage_descriptor(buffer + pos2);
break;
case 0x4B:
//NVOD_reference_descriptor(buffer + pos2);
break;
case 0x4C:
time_shifted_service_descriptor(buffer + pos2);
break;
case 0x51:
mosaic_descriptor(buffer + pos2);
break;
case 0x53:
CA_identifier_descriptor(buffer + pos2);
break;
case 0x5D:
multilingual_service_name_descriptor(buffer + pos2);
break;
case 0x5F:
private_data_specifier_descriptor(buffer + pos2);
break;
case 0x64:
data_broadcast_descriptor(buffer + pos2);
break;
case 0x80: /* unknown, Eutelsat 13.0E */
break;
case 0x84: /* unknown, Eutelsat 13.0E */
break;
case 0x86: /* unknown, Eutelsat 13.0E */
break;
case 0x88: /* unknown, Astra 19.2E */
break;
case 0xB2: /* unknown, Eutelsat 13.0E */
break;
case 0xC0: /* unknown, Eutelsat 13.0E */
break;
case 0xE4: /* unknown, Astra 19.2E */
break;
case 0xE5: /* unknown, Astra 19.2E */
break;
case 0xE7: /* unknown, Eutelsat 13.0E */
break;
case 0xED: /* unknown, Astra 19.2E */
break;
case 0xF8: /* unknown, Astra 19.2E */
break;
case 0xF9: /* unknown, Astra 19.2E */
break;
default:
/*
DBG("descriptor_tag: %02x\n", buffer[pos2]);
generic_descriptor(buffer + pos2);
*/
break;
}
}
}
} while(sectotal < buffer[7]);
//while (filter[4]++ != buffer[7]);
if(cable && !cable_hack_done && sectotal == 0) {
cable_hack_done = true;
secdone[0] = 0;
goto _repeat;
}
delete dmx;
sat_iterator_t sit = satellitePositions.find(satellitePosition);
if(sit != satellitePositions.end())
sit->second.have_channels = true;
return 0;
}
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)
{
//extern bool sdt_wakeup;//zapit.cpp
unsigned char buffer[SDT_SIZE];
/* position in buffer */
unsigned short pos;
unsigned short pos2;
/* service_description_section elements */
unsigned short section_length;
unsigned short transport_stream_id;
unsigned short original_network_id;
unsigned short service_id;
unsigned short descriptors_loop_length;
unsigned short running_status;
bool EIT_schedule_flag;
bool EIT_present_following_flag;
bool free_CA_mode;
int tmp_free_CA_mode = -1;
unsigned char filter[DMX_FILTER_SIZE];
unsigned char mask[DMX_FILTER_SIZE];
transponder_id_t current_tp_id = CFrontend::getInstance()->getTsidOnid();
memset(filter, 0x00, DMX_FILTER_SIZE);
filter[0] = 0x42;
filter[1] = (p_transport_stream_id >> 8) & 0xff;
filter[2] = p_transport_stream_id & 0xff;
filter[4] = 0x00;
filter[6] = (p_original_network_id >> 8) & 0xff;
filter[7] = p_original_network_id & 0xff;
memset(mask, 0x00, DMX_FILTER_SIZE);
mask[0] = 0xFF;
mask[1] = 0xFF;
mask[2] = 0xFF;
mask[4] = 0xFF;
mask[6] = 0xFF;
mask[7] = 0xFF;
std::vector<std::pair<int,int> > sidpmt;
int pat_ok = scan_parse_pat( sidpmt );
cDemux * dmx = new cDemux();
dmx->Open(DMX_PSI_CHANNEL);
int ret = -1;
do {
if ((dmx->sectionFilter(0x11, filter, mask, 8) < 0) || (dmx->Read(buffer, SDT_SIZE) < 0)) {
delete dmx;
return ret;
}
dmx->Stop();
section_length = ((buffer[1] & 0x0F) << 8) | buffer[2];
transport_stream_id = (buffer[3] << 8) | buffer[4];
original_network_id = (buffer[8] << 8) | buffer[9];
for (pos = 11; pos < section_length - 1; pos += descriptors_loop_length + 5) {
tmp_free_CA_mode = -1;
service_id = (buffer[pos] << 8) | buffer[pos + 1];
EIT_schedule_flag = buffer[pos + 2] & 0x02;
EIT_present_following_flag = buffer[pos + 2] & 0x01;
running_status = buffer [pos + 3] & 0xE0;
for (unsigned short i=0; i<sidpmt.size() && pat_ok == 1; i++){
if(sidpmt[i].first == service_id && running_status != 32 ){
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];
for (pos2 = pos + 5; pos2 < pos + descriptors_loop_length + 5; pos2 += buffer[pos2 + 1] + 2) {
//printf("[sdt] descriptor %X\n", buffer[pos2]);
switch (buffer[pos2]) {
case 0x48:
current_service_descriptor(buffer + pos2, service_id, transport_stream_id, original_network_id, satellitePosition, freq, free_CA_mode);
ret = 0;
break;
default:
/*
DBG("descriptor_tag: %02x\n", buffer[pos2]);
generic_descriptor(buffer + pos2);
*/
break;
}
}
free_CA_mode = -1;
#if 0
if(sdt_wakeup){//break scan , transponder change
ret = -2;
break;
}
#endif
if(current_tp_id != CFrontend::getInstance()->getTsidOnid())
break;
}
}
while (filter[4]++ != buffer[7]);
delete dmx;
if(current_tp_id != CFrontend::getInstance()->getTsidOnid())
ret = -2;
return ret;
}