summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorschmirl <schmirl>2008-11-24 12:10:27 +0000
committerschmirl <schmirl>2008-11-24 12:10:27 +0000
commitcd8d7fbd6c583b81b04d082e100021eedf045283 (patch)
tree9c5122c757a0f6e83ce20c7a153a3270b98f2b12 /server
parent459e41e810cf02e3884d13ee30e773d1400d31ab (diff)
downloadvdr-plugin-streamdev-cd8d7fbd6c583b81b04d082e100021eedf045283.tar.gz
vdr-plugin-streamdev-cd8d7fbd6c583b81b04d082e100021eedf045283.tar.bz2
Compatiblity to Network Media Tank (#496)
- minor fixes of PAT repacker - repack and send every PAT packet we receive
Diffstat (limited to 'server')
-rw-r--r--server/livestreamer.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/server/livestreamer.c b/server/livestreamer.c
index f91f495..d535819 100644
--- a/server/livestreamer.c
+++ b/server/livestreamer.c
@@ -211,7 +211,7 @@ int cStreamdevPatFilter::GetPid(SI::PMT::Stream& stream)
void cStreamdevPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
{
if (Pid == 0x00) {
- if (Tid == 0x00 && !pmtPid) {
+ if (Tid == 0x00) {
SI::PAT pat(Data, false);
if (!pat.CheckCRCAndParse())
return;
@@ -220,6 +220,7 @@ void cStreamdevPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, i
if (!assoc.isNITPid()) {
const cChannel *Channel = Channels.GetByServiceID(Source(), Transponder(), assoc.getServiceId());
if (Channel && (Channel == m_Channel)) {
+ int prevPmtPid = pmtPid;
if (0 != (pmtPid = assoc.getPid())) {
Dprintf("cStreamdevPatFilter: PMT pid for channel %s: %d\n", Channel->Name(), pmtPid);
pmtSid = assoc.getServiceId();
@@ -233,25 +234,27 @@ void cStreamdevPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, i
int ts_id;
unsigned int crc, i, len;
uint8_t *tmp, tspat_buf[TS_SIZE];
+ static uint8_t ccounter = 0;
+ ccounter = (ccounter + 1) % 16;
memset(tspat_buf, 0xff, TS_SIZE);
- memset(tspat_buf, 0x0, 4 + 12 + 5); // TS_HDR_LEN + PAT_TABLE_LEN + 5
ts_id = Channel->Tid(); // Get transport stream id of the channel
tspat_buf[0] = TS_SYNC_BYTE; // Transport packet header sunchronization byte (1000011 = 0x47h)
tspat_buf[1] = 0x40; // Set payload unit start indicator bit
tspat_buf[2] = 0x0; // PID
- tspat_buf[3] = 0x10; // Set payload flag to indicate precence of payload data
- tspat_buf[4] = 0x0; // PSI
+ tspat_buf[3] = 0x10 | ccounter; // Set payload flag, Continuity counter
+ tspat_buf[4] = 0x0; // SI pointer field
tspat_buf[5] = 0x0; // PAT table id
tspat_buf[6] = 0xb0; // Section syntax indicator bit and reserved bits set
tspat_buf[7] = 12 + 1; // Section length (12 bit): PAT_TABLE_LEN + 1
- tspat_buf[8] = (ts_id >> 8) & 0xff; // Transport stream ID (bits 8-15)
+ tspat_buf[8] = (ts_id >> 8); // Transport stream ID (bits 8-15)
tspat_buf[9] = (ts_id & 0xff); // Transport stream ID (bits 0-7)
- tspat_buf[10] = 0x01; // Version number 0, Current next indicator bit set
+ tspat_buf[10] = 0xc0 | ((pat.getVersionNumber() << 1) & 0x3e) |
+ pat.getCurrentNextIndicator();// Version number, Current next indicator
tspat_buf[11] = 0x0; // Section number
tspat_buf[12] = 0x0; // Last section number
- tspat_buf[13] = (pmtSid >> 8) & 0xff; // Program number (bits 8-15)
+ tspat_buf[13] = (pmtSid >> 8); // Program number (bits 8-15)
tspat_buf[14] = (pmtSid & 0xff); // Program number (bits 0-7)
- tspat_buf[15] = (pmtPid >> 8) & 0xff; // Network ID (bits 8-12)
+ tspat_buf[15] = 0xe0 | (pmtPid >> 8); // Network ID (bits 8-12)
tspat_buf[16] = (pmtPid & 0xff); // Network ID (bits 0-7)
crc = 0xffffffff;
len = 12; // PAT_TABLE_LEN
@@ -269,9 +272,11 @@ void cStreamdevPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, i
#endif
} else
isyslog("cStreamdevPatFilter: PAT size %d too large to fit in one TS", Length);
- m_Streamer->SetPids(pmtPid);
- Add(pmtPid, 0x02);
- pmtVersion = -1;
+ if (pmtPid != prevPmtPid) {
+ m_Streamer->SetPids(pmtPid);
+ Add(pmtPid, 0x02);
+ pmtVersion = -1;
+ }
return;
}
}