mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 08:21:12 +02:00
-add record option for teletext & dvbsub pids
This commit is contained in:
committed by
[CST] Focus
parent
cca6d898c8
commit
b2241df43d
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Copyright (c) 2004 gmo18t, Germany. All rights reserved.
|
||||
Copyright (C) 2012 CoolStream International Ltd
|
||||
Copyright (C) 2013 Jacek Jendrzej
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published
|
||||
@@ -124,8 +125,15 @@ CGenPsi::CGenPsi()
|
||||
nba = 0;
|
||||
vpid = 0;
|
||||
vtype = 0;
|
||||
|
||||
vtxtpid = 0;
|
||||
vtxtlang[0] = 'g';
|
||||
vtxtlang[1] = 'e';
|
||||
vtxtlang[2] = 'r';
|
||||
memset(apid, 0, sizeof(apid));
|
||||
memset(atypes, 0, sizeof(atypes));
|
||||
nsub = 0;
|
||||
memset(dvbsubpid, 0, sizeof(dvbsubpid));
|
||||
}
|
||||
|
||||
uint32_t CGenPsi::calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len)
|
||||
@@ -147,7 +155,7 @@ uint32_t CGenPsi::calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len)
|
||||
return crc;
|
||||
}
|
||||
|
||||
void CGenPsi::addPid(uint16_t pid, uint16_t pidtype, short isAC3)
|
||||
void CGenPsi::addPid(uint16_t pid, uint16_t pidtype, short isAC3, const char *data)
|
||||
{
|
||||
switch(pidtype)
|
||||
{
|
||||
@@ -165,8 +173,22 @@ void CGenPsi::addPid(uint16_t pid, uint16_t pidtype, short isAC3)
|
||||
nba++;
|
||||
break;
|
||||
case EN_TYPE_TELTEX:
|
||||
vtxtpid = pid;
|
||||
if(data != NULL){
|
||||
vtxtlang[0] = data[0];
|
||||
vtxtlang[1] = data[1];
|
||||
vtxtlang[2] = data[2];
|
||||
}
|
||||
break;
|
||||
case EN_TYPE_DVBSUB:
|
||||
dvbsubpid[nsub] = pid;
|
||||
if(data != NULL){
|
||||
dvbsublang[nsub][0] = data[0];
|
||||
dvbsublang[nsub][1] = data[1];
|
||||
dvbsublang[nsub][2] = data[2];
|
||||
}
|
||||
nsub++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -232,6 +254,8 @@ int CGenPsi::genpsi(int fd)
|
||||
|
||||
//-- (II) build PAT --
|
||||
data_len = COPY_TEMPLATE(pkt, pkt_pat);
|
||||
// pkt[0xf]= 0xE0 | (pmtpid>>8);
|
||||
// pkt[0x10] = pmtpid & 0xFF;
|
||||
//-- calculate CRC --
|
||||
calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 );
|
||||
//-- write TS packet --
|
||||
@@ -241,6 +265,12 @@ int CGenPsi::genpsi(int fd)
|
||||
data_len = COPY_TEMPLATE(pkt, pkt_pmt);
|
||||
//-- adjust len dependent to count of audio streams --
|
||||
data_len += (SIZE_STREAM_TAB_ROW * (nba-1));
|
||||
if(vtxtpid){
|
||||
data_len += (SIZE_STREAM_TAB_ROW * (1))+10;//add teletext row length
|
||||
}
|
||||
if(nsub){
|
||||
data_len += ((SIZE_STREAM_TAB_ROW+10) * nsub);//add dvbsub row length
|
||||
}
|
||||
patch_len = data_len - OFS_HDR_2 + 1;
|
||||
pkt[OFS_HDR_2+1] |= (patch_len>>8);
|
||||
pkt[OFS_HDR_2+2] = (patch_len & 0xFF);
|
||||
@@ -266,13 +296,61 @@ int CGenPsi::genpsi(int fd)
|
||||
pkt[ofs+3] = 0xF0;
|
||||
pkt[ofs+4] = 0x00;
|
||||
}
|
||||
|
||||
//teletext
|
||||
if(vtxtpid){
|
||||
ofs += SIZE_STREAM_TAB_ROW;
|
||||
pkt[ofs] = 0x06; //teletext stream type;
|
||||
pkt[ofs+1] = 0xE0 | vtxtpid>>8;
|
||||
pkt[ofs+2] = vtxtpid&0xff;
|
||||
pkt[ofs+3] = 0xf0;
|
||||
pkt[ofs+4] = 0x0A; // ES_info_length
|
||||
pkt[ofs+5] = 0x52; //DVB-DescriptorTag: 82 (0x52) [= stream_identifier_descriptor]
|
||||
pkt[ofs+6] = 0x01; // descriptor_length
|
||||
pkt[ofs+7] = 0x03; //component_tag
|
||||
pkt[ofs+8] = 0x56; // DVB teletext tag
|
||||
pkt[ofs+9] = 0x05; // descriptor length
|
||||
pkt[ofs+10] = vtxtlang[0]; //language code[0]
|
||||
pkt[ofs+11] = vtxtlang[1]; //language code[1]
|
||||
pkt[ofs+12] = vtxtlang[2]; //language code[2]
|
||||
pkt[ofs+13] = (/*descriptor_magazine_number*/ 0x01 & 0x06) | ((/*descriptor_type*/ 0x01 << 3) & 0xF8);
|
||||
pkt[ofs+14] = 0x00 ; //Teletext_page_number
|
||||
}
|
||||
|
||||
//dvbsub
|
||||
for (i=0; i<nsub; i++)
|
||||
{
|
||||
ofs += SIZE_STREAM_TAB_ROW;
|
||||
if(i > 0 || vtxtpid)
|
||||
ofs += 10;
|
||||
|
||||
pkt[ofs] = 0x06;//subtitle stream type;
|
||||
pkt[ofs+1] = 0xE0 | dvbsubpid[i]>>8;
|
||||
pkt[ofs+2] = dvbsubpid[i] & 0xFF;
|
||||
pkt[ofs+3] = 0xF0;
|
||||
pkt[ofs+4] = 0x0A; // es info length
|
||||
pkt[ofs+5] = 0x59; // DVB sub tag
|
||||
pkt[ofs+6] = 0x08; // descriptor length
|
||||
pkt[ofs+7] = dvbsublang[i][0]; //language code[0]
|
||||
pkt[ofs+8] = dvbsublang[i][1]; //language code[1]
|
||||
pkt[ofs+9] = dvbsublang[i][2]; //language code[2]
|
||||
pkt[ofs+10] = 0x20; //subtitle_stream.subtitling_type
|
||||
pkt[ofs+11] = 0x01>>8; //composition_page_id
|
||||
pkt[ofs+12] = 0x01&0xff; //composition_page_id
|
||||
pkt[ofs+13] = 0x01>>8; //ancillary_page_id
|
||||
pkt[ofs+14] = 0x01&0xff; //ancillary_page_id
|
||||
}
|
||||
|
||||
//-- calculate CRC --
|
||||
calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 );
|
||||
//-- write TS packet --
|
||||
write(fd, pkt, SIZE_TS_PKT);
|
||||
|
||||
//-- finish --
|
||||
vpid=0;
|
||||
nba=0;
|
||||
nsub = 0;
|
||||
vtxtpid = 0;
|
||||
fdatasync(fd);
|
||||
return 1;
|
||||
}
|
||||
|
@@ -28,21 +28,26 @@
|
||||
#define EN_TYPE_TELTEX 0x02
|
||||
#define EN_TYPE_PCR 0x03
|
||||
#define EN_TYPE_AVC 0x04
|
||||
#define EN_TYPE_DVBSUB 0x06
|
||||
|
||||
class CGenPsi
|
||||
{
|
||||
private:
|
||||
short nba;
|
||||
short nba, nsub;
|
||||
uint16_t vpid;
|
||||
uint8_t vtype;
|
||||
uint16_t vtxtpid;
|
||||
char vtxtlang[3];
|
||||
uint16_t apid[10];
|
||||
short atypes[10];
|
||||
uint16_t dvbsubpid[10];
|
||||
char dvbsublang[10][3];
|
||||
static int copy_template(uint8_t *dst, uint8_t *src, int len);
|
||||
uint32_t calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len);
|
||||
|
||||
public:
|
||||
CGenPsi();
|
||||
void addPid(uint16_t pid,uint16_t pidtype, short isAC3);
|
||||
void addPid(uint16_t pid,uint16_t pidtype, short isAC3, const char *data = NULL);
|
||||
int genpsi(int fd);
|
||||
};
|
||||
#endif
|
||||
|
@@ -72,7 +72,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
CRecordInstance::CRecordInstance(const CTimerd::RecordingInfo * const eventinfo, std::string &dir, bool timeshift, bool stream_vtxt_pid, bool stream_pmt_pid)
|
||||
CRecordInstance::CRecordInstance(const CTimerd::RecordingInfo * const eventinfo, std::string &dir, bool timeshift, bool stream_vtxt_pid, bool stream_pmt_pid, bool stream_subtitle_pids )
|
||||
{
|
||||
channel_id = eventinfo->channel_id;
|
||||
epgid = eventinfo->epgID;
|
||||
@@ -86,6 +86,8 @@ CRecordInstance::CRecordInstance(const CTimerd::RecordingInfo * const eventinfo,
|
||||
|
||||
StreamVTxtPid = stream_vtxt_pid;
|
||||
StreamPmtPid = stream_pmt_pid;
|
||||
StreamSubtitlePids = stream_subtitle_pids;
|
||||
|
||||
Directory = dir;
|
||||
autoshift = timeshift;
|
||||
numpids = 0;
|
||||
@@ -167,10 +169,26 @@ record_error_msg_t CRecordInstance::Start(CZapitChannel * channel)
|
||||
apids[numpids++] = recMovieInfo->audioPids[i].epgAudioPid;
|
||||
psi.addPid(recMovieInfo->audioPids[i].epgAudioPid, EN_TYPE_AUDIO, recMovieInfo->audioPids[i].atype);
|
||||
}
|
||||
if ((StreamVTxtPid) && (allpids.PIDs.vtxtpid != 0)){
|
||||
apids[numpids++] = allpids.PIDs.vtxtpid;
|
||||
psi.addPid(allpids.PIDs.vtxtpid, EN_TYPE_TELTEX, 0, channel->getTeletextLang());
|
||||
}
|
||||
if (StreamSubtitlePids){
|
||||
for (int i = 0 ; i < (int)channel->getSubtitleCount() ; ++i) {
|
||||
CZapitAbsSub* s = channel->getChannelSub(i);
|
||||
if (s->thisSubType == CZapitAbsSub::DVB) {
|
||||
if(i>9)//max sub pids
|
||||
break;
|
||||
|
||||
CZapitDVBSub* sd = reinterpret_cast<CZapitDVBSub*>(s);
|
||||
apids[numpids++] = sd->pId;
|
||||
psi.addPid( sd->pId, EN_TYPE_DVBSUB, 0, sd->ISO639_language_code.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
psi.genpsi(fd);
|
||||
|
||||
if ((StreamVTxtPid) && (allpids.PIDs.vtxtpid != 0))
|
||||
apids[numpids++] = allpids.PIDs.vtxtpid;
|
||||
|
||||
if ((StreamPmtPid) && (allpids.PIDs.pmtpid != 0))
|
||||
apids[numpids++] = allpids.PIDs.pmtpid;
|
||||
@@ -669,6 +687,7 @@ CRecordManager::CRecordManager()
|
||||
{
|
||||
StreamVTxtPid = false;
|
||||
StreamPmtPid = false;
|
||||
StreamSubtitlePids = false;
|
||||
StopSectionsd = false;
|
||||
//recordingstatus = 0;
|
||||
recmap.clear();
|
||||
@@ -882,7 +901,7 @@ bool CRecordManager::Record(const CTimerd::RecordingInfo * const eventinfo, cons
|
||||
else
|
||||
newdir = Directory;
|
||||
|
||||
inst = new CRecordInstance(eventinfo, newdir, timeshift, StreamVTxtPid, StreamPmtPid);
|
||||
inst = new CRecordInstance(eventinfo, newdir, timeshift, StreamVTxtPid, StreamPmtPid, StreamSubtitlePids);
|
||||
|
||||
inst->frontend = frontend;
|
||||
error_msg = inst->Record();
|
||||
|
@@ -83,6 +83,7 @@ class CRecordInstance
|
||||
time_t epg_time;
|
||||
time_t start_time;
|
||||
bool StreamVTxtPid;
|
||||
bool StreamSubtitlePids;
|
||||
bool StreamPmtPid;
|
||||
unsigned short apids[REC_MAX_APIDS];
|
||||
unsigned int numpids;
|
||||
@@ -107,7 +108,7 @@ class CRecordInstance
|
||||
record_error_msg_t Start(CZapitChannel * channel);
|
||||
void WaitRecMsg(time_t StartTime, time_t WaitTime);
|
||||
public:
|
||||
CRecordInstance(const CTimerd::RecordingInfo * const eventinfo, std::string &dir, bool timeshift = false, bool stream_vtxt_pid = false, bool stream_pmt_pid = false);
|
||||
CRecordInstance(const CTimerd::RecordingInfo * const eventinfo, std::string &dir, bool timeshift = false, bool stream_vtxt_pid = false, bool stream_pmt_pid = false, bool stream_subtitle_pids = false);
|
||||
~CRecordInstance();
|
||||
|
||||
record_error_msg_t Record();
|
||||
@@ -146,6 +147,7 @@ class CRecordManager : public CMenuTarget /*, public CChangeObserver*/
|
||||
std::string Directory;
|
||||
std::string TimeshiftDirectory;
|
||||
bool StreamVTxtPid;
|
||||
bool StreamSubtitlePids;
|
||||
bool StreamPmtPid;
|
||||
bool StopSectionsd;
|
||||
int last_mode;
|
||||
@@ -201,11 +203,12 @@ class CRecordManager : public CMenuTarget /*, public CChangeObserver*/
|
||||
bool RunStartScript(void);
|
||||
bool RunStopScript(void);
|
||||
|
||||
void Config(const bool stopsectionsd, const bool stream_vtxt_pid, const bool stream_pmt_pid)
|
||||
void Config(const bool stopsectionsd, const bool stream_vtxt_pid, const bool stream_pmt_pid, bool stream_subtitle_pids )
|
||||
{
|
||||
StopSectionsd = stopsectionsd;
|
||||
StreamVTxtPid = stream_vtxt_pid;
|
||||
StreamPmtPid = stream_pmt_pid;
|
||||
StopSectionsd = stopsectionsd;
|
||||
StreamVTxtPid = stream_vtxt_pid;
|
||||
StreamSubtitlePids = stream_subtitle_pids;
|
||||
StreamPmtPid = stream_pmt_pid;
|
||||
};
|
||||
void SetDirectory(const char * const directory) { Directory = directory; };
|
||||
void SetTimeshiftDirectory(const char * const directory) { TimeshiftDirectory = directory; };
|
||||
|
Reference in New Issue
Block a user