Skip to contentSkip to conversation

app: kaffeine: Fix missing PCR on live streams.

RFC PATCH In review Malcolm Priestley 2 participants 5 messages Jul 9, 2017 – Jul 10, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/2 app: kaffeine: Fix missing PCR on live streams.

The ISO/IEC standard 13818-1 or ITU-T Rec. H.222.0 standard allow transport vendors to place PCR (Program Clock Reference) on a different PID.

If the PCR is unset the value is 0x1fff, most vendors appear to set it the same as video pid in which case it need not be set.

The PCR PID is at an offset of 8 in pmtSection structure.

---
 src/dvb/dvbliveview.cpp | 8 ++++++++
 src/dvb/dvbsi.h         | 5 +++++
 2 files changed, 13 insertions(+)
src/dvb/dvbliveview.cpp +8 -0
index cfad892..3e92fa6 100644
@@ -518,6 +518,7 @@ void DvbLiveView::updatePids(bool forcePatPmtUpdate)
 	DvbPmtSection pmtSection(internal->pmtSectionData);
 	DvbPmtParser pmtParser(pmtSection);
 	QSet<int> newPids;
+	int pcr_pid = pmtSection.pcr_pid();
 	bool updatePatPmt = forcePatPmtUpdate;
 	bool isTimeShifting = internal->timeShiftFile.isOpen();
 
@@ -543,6 +544,13 @@ void DvbLiveView::updatePids(bool forcePatPmtUpdate)
 		newPids.insert(pmtParser.teletextPid);
 	}
 
+	/* check PCR PID is set */
+	if (pcr_pid != 0x1fff) {
+		/* Check not already in list */
+		if (!newPids.contains(pcr_pid))
+			newPids.insert(pcr_pid);
+	}
+
 	for (int i = 0; i < pids.size(); ++i) {
 		int pid = pids.at(i);
 
src/dvb/dvbsi.h +5 -0
index 4d27252..9b4bbe0 100644
@@ -1098,6 +1098,11 @@ public:
 		return (at(3) << 8) | at(4);
 	}
 
+	int pcr_pid() const
+	{
+		return ((at(8) & 0x1f) << 8) | at(9);
+	}
+
 	DvbDescriptor descriptors() const
 	{
 		return DvbDescriptor(getData() + 12, descriptorsLength);
Signature · 1 line
2.13.2
#1 lore raw

RFC PATCH 2/2 app: kaffeine: Fix missing PCR on stream recordings.

The ISO/IEC standard 13818-1 or ITU-T Rec. H.222.0 standard allow transport vendors to place PCR (Program Clock Reference) on a different PID.

This patch adds it recording to file.

---
 src/dvb/dvbrecording.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)
src/dvb/dvbrecording.cpp +8 -0
index ecb4777..12a57dc 100644
@@ -961,6 +961,7 @@ void DvbRecordingFile::pmtSectionChanged(const QByteArray &pmtSectionData_)
 	pmtSectionData = pmtSectionData_;
 	DvbPmtSection pmtSection(pmtSectionData);
 	DvbPmtParser pmtParser(pmtSection);
+	int pcr_pid = pmtSection.pcr_pid();
 	QSet<int> newPids;
 
 	if (pmtParser.videoPid != -1) {
@@ -979,6 +980,13 @@ void DvbRecordingFile::pmtSectionChanged(const QByteArray &pmtSectionData_)
 		newPids.insert(pmtParser.teletextPid);
 	}
 
+	/* check PCR PID is set */
+	if (pcr_pid != 0x1fff) {
+		/* Check not already in list */
+		if (!newPids.contains(pcr_pid))
+			newPids.insert(pcr_pid);
+	}
+
 	for (int i = 0; i < pids.size(); ++i) {
 		int pid = pids.at(i);
 
Signature · 1 line
2.13.2
#2 lore raw
In reply to Malcolm Priestley

Hi Malcolm,

Em Sun, 9 Jul 2017 10:43:50 +0100
Malcolm Priestley <[email protected]> escreveu:

Quoted 7 lines

The ISO/IEC standard 13818-1 or ITU-T Rec. H.222.0 standard allow transport vendors to place PCR (Program Clock Reference) on a different PID.

If the PCR is unset the value is 0x1fff, most vendors appear to set it the same as video pid in which case it need not be set.

The PCR PID is at an offset of 8 in pmtSection structure.

Thanks for the patches!

Patches look good, except for two things:

- we use camelCase at Kaffeine. So, the new field should be pcrPid ;)

- you didn't use dvbsi.xml. The way we usually update dvbsi.h and part of dvbsi.cpp is to add a field at dvbsi.xml and then run:

	$ tools/update_dvbsi.sh

Kaffeine should be built with the optional BUILD_TOOLS feature, in order for it to build the tool that parses dvbsi.xml.

Anyway, I applied your patchset and added a few pathes afterwards adjusting it.

Regards,
Mauro

Quoted 39 lines
---
 src/dvb/dvbliveview.cpp | 8 ++++++++
 src/dvb/dvbsi.h         | 5 +++++
 2 files changed, 13 insertions(+)
src/dvb/dvbliveview.cpp +8 -0
index cfad892..3e92fa6 100644
@@ -518,6 +518,7 @@ void DvbLiveView::updatePids(bool forcePatPmtUpdate)
 	DvbPmtSection pmtSection(internal->pmtSectionData);
 	DvbPmtParser pmtParser(pmtSection);
 	QSet<int> newPids;
+	int pcr_pid = pmtSection.pcr_pid();
 	bool updatePatPmt = forcePatPmtUpdate;
 	bool isTimeShifting = internal->timeShiftFile.isOpen();
 
@@ -543,6 +544,13 @@ void DvbLiveView::updatePids(bool forcePatPmtUpdate)
 		newPids.insert(pmtParser.teletextPid);
 	}
 
+	/* check PCR PID is set */
+	if (pcr_pid != 0x1fff) {
+		/* Check not already in list */
+		if (!newPids.contains(pcr_pid))
+			newPids.insert(pcr_pid);
+	}
+
 	for (int i = 0; i < pids.size(); ++i) {
 		int pid = pids.at(i);
 
src/dvb/dvbsi.h +0 -0
index 4d27252..9b4bbe0 100644
@@ -1098,6 +1098,11 @@ public:
 		return (at(3) << 8) | at(4);

src/dvb/dvbsi.h public: · line 1108

Quoted 10 lines
src/dvb/dvbsi.h +5 -0
 	}
 
+	int pcr_pid() const
+	{
+		return ((at(8) & 0x1f) << 8) | at(9);
+	}
+
 	DvbDescriptor descriptors() const
 	{
 		return DvbDescriptor(getData() + 12, descriptorsLength);

Thanks,
Mauro

#3 lore raw
Quoted 11 lines · Mauro Carvalho Chehab

Hi Malcolm,

Em Sun, 9 Jul 2017 10:43:50 +0100
Malcolm Priestley <[email protected]> escreveu:

Quoted 6 lines

The ISO/IEC standard 13818-1 or ITU-T Rec. H.222.0 standard allow transport vendors to place PCR (Program Clock Reference) on a different PID.

If the PCR is unset the value is 0x1fff, most vendors appear to set it the same as video pid in which case it need not be set.

Quoted 7 lines
Quoted 1 line

The PCR PID is at an offset of 8 in pmtSection structure.

Thanks for the patches!

Patches look good, except for two things:

- we use camelCase at Kaffeine. So, the new field should be pcrPid ;)

Ok, Wasn't sure

Quoted 5 lines

- you didn't use dvbsi.xml. The way we usually update dvbsi.h and part of dvbsi.cpp is to add a field at dvbsi.xml and then run:

	$ tools/update_dvbsi.sh

Oh I see.

Quoted 6 lines

Kaffeine should be built with the optional BUILD_TOOLS feature, in order for it to build the tool that parses dvbsi.xml.

Anyway, I applied your patchset and added a few pathes afterwards adjusting it.

Thanks

How do you turn off debug the spam from epg is horrendous.

Regards

Malcolm

#4 lore raw

Em Sun, 9 Jul 2017 13:11:36 +0100
Malcolm Priestley <[email protected]> escreveu:

Quoted 33 lines · Mauro Carvalho Chehab
Quoted 11 lines

Hi Malcolm,

Em Sun, 9 Jul 2017 10:43:50 +0100
Malcolm Priestley <[email protected]> escreveu:

Quoted 6 lines

The ISO/IEC standard 13818-1 or ITU-T Rec. H.222.0 standard allow transport vendors to place PCR (Program Clock Reference) on a different PID.

If the PCR is unset the value is 0x1fff, most vendors appear to set it the same as video pid in which case it need not be set.

Quoted 7 lines
Quoted 1 line

The PCR PID is at an offset of 8 in pmtSection structure.

Thanks for the patches!

Patches look good, except for two things:

- we use camelCase at Kaffeine. So, the new field should be pcrPid ;)

Ok, Wasn't sure

Quoted 5 lines

- you didn't use dvbsi.xml. The way we usually update dvbsi.h and part of dvbsi.cpp is to add a field at dvbsi.xml and then run:

	$ tools/update_dvbsi.sh  

Oh I see.

Quoted 4 lines

Kaffeine should be built with the optional BUILD_TOOLS feature, in order for it to build the tool that parses dvbsi.xml.

Quoted 6 lines
Quoted 2 lines

Anyway, I applied your patchset and added a few pathes afterwards adjusting it.

Thanks

How do you turn off debug the spam from epg is horrendous.

The default should have been to have those debug messages disabled. I'm pretty sure I wrote some patches for it some time ago, but it seems they got lost.

Anyway, I wrote them again. You should now see debug messages only if kaffeine is called with --debug or using
QT_LOGGING_RULES=kaffeine.category.debug=true

as stated on its help message.

Quoted 7 lines

Regards

Malcolm

Thanks,
Mauro