Skip to content

Commit

Permalink
Merge pull request #383 from ksooo/rds-dyn-fix
Browse files Browse the repository at this point in the history
Fix RDS stream support.
  • Loading branch information
ksooo authored Oct 27, 2018
2 parents 5ed5a07 + a86a672 commit 1675b60
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="4.4.1"
version="4.4.2"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
3 changes: 3 additions & 0 deletions pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
4.4.2
- Fix RDS stream support. Only mpeg2 audio streams can contain embedded RDS data and there can be at most one RDS stream at a time.

4.4.1
- Fix creation of RDS streams. Must only be done if audio stream actually contains RDS data.

Expand Down
16 changes: 14 additions & 2 deletions src/tvheadend/HTSPDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ HTSPDemuxer::HTSPDemuxer ( HTSPConnection &conn )
m_seekTime(INVALID_SEEKTIME),
m_seeking(false), m_speedChange(false),
m_subscription(conn), m_lastUse(0),
m_startTime(0)
m_startTime(0), m_rdsIdx(0)
{
}

Expand Down Expand Up @@ -89,6 +89,7 @@ void HTSPDemuxer::Abort0 ( void )
CLockObject lock(m_mutex);
m_streams.clear();
m_streamStat.clear();
m_rdsIdx = 0;
m_seeking = false;
m_speedChange = false;
}
Expand Down Expand Up @@ -392,6 +393,9 @@ bool HTSPDemuxer::ProcessMessage ( const char *method, htsmsg_t *m )

void HTSPDemuxer::ProcessRDS(uint32_t idx, const void* bin, size_t binlen)
{
if (idx != m_rdsIdx)
return;

const uint8_t* data = static_cast<const uint8_t*>(bin);
const size_t offset = binlen - 1;

Expand Down Expand Up @@ -553,7 +557,7 @@ bool HTSPDemuxer::AddRDSStream(uint32_t audioIdx, uint32_t rdsIdx)
// We can only use PVR_STREAM_MAX_STREAMS streams
if (m_streams.size() < PVR_STREAM_MAX_STREAMS)
{
Logger::Log(LogLevel::LEVEL_DEBUG, " id: %d, type rds, codec: %u", rdsIdx, rdsStream.iCodecId);
Logger::Log(LogLevel::LEVEL_DEBUG, "Adding rds stream. id: %d", rdsIdx);
m_streams.emplace_back(rdsStream);
return true;
}
Expand Down Expand Up @@ -608,6 +612,13 @@ bool HTSPDemuxer::AddTVHStream(uint32_t idx, const char* type, htsmsg_field_t *f
{
stream.iChannels = htsmsg_get_u32_or_default(&f->hmf_msg, "channels", 2);
stream.iSampleRate = htsmsg_get_u32_or_default(&f->hmf_msg, "rate", 48000);

if (strcmp("MPEG2AUDIO", type) == 0)
{
// mpeg2 audio streams may contain embedded RDS data.
// We will find out when the first stream packet arrives.
m_rdsIdx = idx;
}
}

/* Video */
Expand Down Expand Up @@ -666,6 +677,7 @@ void HTSPDemuxer::ParseSubscriptionStart ( htsmsg_t *m )

m_streamStat.clear();
m_streams.clear();
m_rdsIdx = 0;

Logger::Log(LogLevel::LEVEL_DEBUG, "demux subscription start");

Expand Down
1 change: 1 addition & 0 deletions src/tvheadend/HTSPDemuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class HTSPDemuxer
tvheadend::Subscription m_subscription;
std::atomic<time_t> m_lastUse;
std::atomic<time_t> m_startTime;
uint32_t m_rdsIdx;
};

} // namespace tvheadend

0 comments on commit 1675b60

Please sign in to comment.