From 7a3b584920c1ef16bf4d899b3bd7c9e2dbc5af26 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Thu, 1 Aug 2013 17:54:51 +0200 Subject: [PATCH] genpsi: add pcr pid handling --- src/driver/genpsi.cpp | 17 +++++++++++------ src/driver/genpsi.h | 3 ++- src/driver/record.cpp | 10 +++++++--- src/driver/streamts.cpp | 5 +++++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/driver/genpsi.cpp b/src/driver/genpsi.cpp index cd350cf22..3c7fb6719 100644 --- a/src/driver/genpsi.cpp +++ b/src/driver/genpsi.cpp @@ -126,6 +126,7 @@ CGenPsi::CGenPsi() vpid = 0; vtype = 0; + pcrpid=0; vtxtpid = 0; vtxtlang[0] = 'g'; vtxtlang[1] = 'e'; @@ -160,9 +161,12 @@ void CGenPsi::addPid(uint16_t pid, uint16_t pidtype, short isAC3, const char *da switch(pidtype) { case EN_TYPE_VIDEO: - vpid=pid; + pcrpid=vpid=pid; vtype = ES_TYPE_MPEG12; break; + case EN_TYPE_PCR: + pcrpid=pid; + break; case EN_TYPE_AVC: vpid=pid; vtype = ES_TYPE_AVC; @@ -243,9 +247,9 @@ int CGenPsi::genpsi(int fd) } //-- write row with desc. for pcr stream (eq. video) -- pkt[ofs] = EN_TYPE_PCR; - pkt[ofs+1] = 0x02; - pkt[ofs+2] = (vpid>>8); - pkt[ofs+3] = (vpid & 0xFF); + pkt[ofs+1] = 0x02;//vtype ??? + pkt[ofs+2] = (pcrpid>>8); + pkt[ofs+3] = (pcrpid & 0xFF); //-- calculate CRC -- calc_crc32psi(&pkt[data_len], &pkt[OFS_HDR_2], data_len-OFS_HDR_2 ); @@ -276,8 +280,8 @@ int CGenPsi::genpsi(int fd) pkt[OFS_HDR_2+2] = (patch_len & 0xFF); //-- patch pcr PID -- ofs = OFS_PMT_DATA; - pkt[ofs] |= (vpid>>8); - pkt[ofs+1] = (vpid & 0xFF); + pkt[ofs] |= (pcrpid>>8); + pkt[ofs+1] = (pcrpid & 0xFF); //-- write row with desc. for ES video stream -- ofs = OFS_STREAM_TAB; pkt[ofs] = vtype; @@ -348,6 +352,7 @@ int CGenPsi::genpsi(int fd) //-- finish -- vpid=0; + pcrpid=0; nba=0; nsub = 0; vtxtpid = 0; diff --git a/src/driver/genpsi.h b/src/driver/genpsi.h index 1fce949d6..bc39991aa 100644 --- a/src/driver/genpsi.h +++ b/src/driver/genpsi.h @@ -27,7 +27,7 @@ #define EN_TYPE_AUDIO 0x01 #define EN_TYPE_TELTEX 0x02 #define EN_TYPE_PCR 0x03 -#define EN_TYPE_AVC 0x04 +#define EN_TYPE_AVC 0x04 #define EN_TYPE_DVBSUB 0x06 class CGenPsi @@ -36,6 +36,7 @@ class CGenPsi short nba, nsub; uint16_t vpid; uint8_t vtype; + uint16_t pcrpid; uint16_t vtxtpid; char vtxtlang[3]; uint16_t apid[10]; diff --git a/src/driver/record.cpp b/src/driver/record.cpp index ed3b6a5ed..d74a78cf0 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -161,10 +161,14 @@ record_error_msg_t CRecordInstance::Start(CZapitChannel * channel) } CGenPsi psi; - if (allpids.PIDs.vpid != 0) - psi.addPid(allpids.PIDs.vpid, recMovieInfo->VideoType ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0); - numpids = 0; + if (allpids.PIDs.vpid != 0){ + psi.addPid(allpids.PIDs.vpid, recMovieInfo->VideoType ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0); + if(allpids.PIDs.pcrpid != allpids.PIDs.vpid){ + psi.addPid(allpids.PIDs.pcrpid, EN_TYPE_PCR, 0); + apids[numpids++]=allpids.PIDs.pcrpid; + } + } for (unsigned int i = 0; i < recMovieInfo->audioPids.size(); i++) { apids[numpids++] = recMovieInfo->audioPids[i].epgAudioPid; psi.addPid(recMovieInfo->audioPids[i].epgAudioPid, EN_TYPE_AUDIO, recMovieInfo->audioPids[i].atype); diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index 1448061eb..2df37b569 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -389,6 +389,11 @@ bool CStreamManager::Parse(int fd, stream_pids_t &pids, t_channel_id &chid) } } } + //add pcr pid + if(channel->getPcrPid() != channel->getVideoPid()){ + pids.insert(channel->getPcrPid()); + psi.addPid(channel->getPcrPid(), EN_TYPE_PCR, 0); + } psi.genpsi(fd); return !pids.empty();