summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-10 12:06:45 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-10 12:06:45 +0200
commit5c3c6d734ff0c57fd3d45746df23b96e0e7fc99e (patch)
tree598b2a21bdfe8823f4f61fd5c54f8363130c757d /src
parent2e71bf974f42cfe9edf9c8289602eec0c7ecadf9 (diff)
downloaddabmux-5c3c6d734ff0c57fd3d45746df23b96e0e7fc99e.tar.gz
dabmux-5c3c6d734ff0c57fd3d45746df23b96e0e7fc99e.tar.bz2
dabmux-5c3c6d734ff0c57fd3d45746df23b96e0e7fc99e.zip
Add FIG0/6 CEI
Diffstat (limited to 'src')
-rw-r--r--src/MuxElements.h4
-rw-r--r--src/fig/FIG0_6.cpp87
-rw-r--r--src/fig/FIG0_6.h8
-rw-r--r--src/fig/FIGCarousel.cpp2
-rw-r--r--src/fig/FIGCarousel.h1
5 files changed, 95 insertions, 7 deletions
diff --git a/src/MuxElements.h b/src/MuxElements.h
index 8efc2cb..79100a9 100644
--- a/src/MuxElements.h
+++ b/src/MuxElements.h
@@ -229,7 +229,7 @@ class dabEnsemble : public RemoteControllable {
std::vector<DabSubchannel*> subchannels;
std::vector<std::shared_ptr<AnnouncementCluster> > clusters;
- std::list<std::shared_ptr<LinkageSet> > linkagesets;
+ std::vector<std::shared_ptr<LinkageSet> > linkagesets;
};
@@ -463,6 +463,8 @@ class LinkageSet : public RemoteControllable {
LinkageSet(std::string name, uint16_t lsn, bool hard, bool international);
LinkageSetData data;
+
+ bool is_active(void) const { return data.active; }
private:
/* Remote control */
virtual void set_parameter(const std::string& parameter,
diff --git a/src/fig/FIG0_6.cpp b/src/fig/FIG0_6.cpp
index 401606e..411d47c 100644
--- a/src/fig/FIG0_6.cpp
+++ b/src/fig/FIG0_6.cpp
@@ -57,9 +57,9 @@ FillStatus FIG0_6::fill(uint8_t *buf, size_t max_size)
const size_t num_ids = 1 + linkageSetFIG0_6->id_list.size();
const size_t headersize = sizeof(struct FIGtype0_6_header);
- const int required_size = sizeof(struct FIGtype0_6) +
+ const int required_size = sizeof(struct FIGtype0_6) + headersize +
(num_ids > 0 ?
- headersize + (PD == 0 ? (ILS == 0 ? 2*num_ids : 3*num_ids) : 4*num_ids) :
+ (PD == 0 ? (ILS == 0 ? 2*num_ids : 3*num_ids) : 4*num_ids) :
0);
if (fig0 == NULL) {
@@ -266,5 +266,88 @@ void FIG0_6::update()
#endif
}
+
+FIG0_6_CEI::FIG0_6_CEI(FIGRuntimeInformation *rti) :
+ m_rti(rti)
+{
+}
+
+FillStatus FIG0_6_CEI::fill(uint8_t *buf, size_t max_size)
+{
+ using namespace std;
+
+ auto ensemble = m_rti->ensemble;
+
+ // We are called every 24ms, and must timeout after 5s
+ const int timeout = 5000/24;
+
+ m_transition.update_state(timeout, ensemble->linkagesets);
+
+ FillStatus fs;
+ ssize_t remaining = max_size;
+
+ FIGtype0* fig0 = NULL;
+
+ // Combine all links into one list
+ set<LinkageSet*> alllinks;
+ for (const auto& l : m_transition.new_entries) {
+ alllinks.insert(l.first.get());
+ }
+ for (const auto& l : m_transition.repeated_entries) {
+ alllinks.insert(l.get());
+ }
+ for (const auto& l : m_transition.disabled_entries) {
+ alllinks.insert(l.first.get());
+ }
+
+ for (auto& link : alllinks) {
+ const bool PD = false;
+ const bool ILS = link->data.international;
+
+ // The CEI does not send list contents
+ const size_t num_ids = 0;
+
+ const size_t headersize = sizeof(struct FIGtype0_6_header);
+ const int required_size = sizeof(struct FIGtype0_6) + headersize +
+ (num_ids > 0 ?
+ (PD == 0 ? (ILS == 0 ? 2*num_ids : 3*num_ids) : 4*num_ids) :
+ 0);
+
+ if (fig0 == NULL) {
+ if (remaining < 2 + required_size) {
+ break;
+ }
+ fig0 = (FIGtype0*)buf;
+ fig0->FIGtypeNumber = 0;
+ fig0->Length = 1;
+ fig0->CN = 1; // This is a CEI
+ fig0->OE = 0;
+ fig0->PD = PD;
+ fig0->Extension = 6;
+
+ buf += 2;
+ remaining -= 2;
+ }
+ else if (remaining < required_size) {
+ break;
+ }
+
+ FIGtype0_6 *fig0_6 = (FIGtype0_6*)buf;
+
+ fig0_6->IdListFlag = (num_ids > 0);
+ fig0_6->LA = link->data.active;
+ fig0_6->SH = link->data.hard;
+ fig0_6->ILS = ILS;
+ fig0_6->setLSN(link->data.lsn);
+
+ fig0->Length += sizeof(struct FIGtype0_6);
+ buf += sizeof(struct FIGtype0_6);
+ remaining -= sizeof(struct FIGtype0_6);
+ }
+
+ fs.complete_fig_transmitted = true;
+ return fs;
+}
+
}
diff --git a/src/fig/FIG0_6.h b/src/fig/FIG0_6.h
index 1af396f..e970102 100644
--- a/src/fig/FIG0_6.h
+++ b/src/fig/FIG0_6.h
@@ -70,8 +70,8 @@ class FIG0_6 : public IFIG
* We reorganise all LinkageSets into subsets that have
* the same type.
*/
- std::list<LinkageSetData> linkageSubsets;
- std::list<LinkageSetData>::iterator linkageSetFIG0_6;
+ std::vector<LinkageSetData> linkageSubsets;
+ std::vector<LinkageSetData>::iterator linkageSetFIG0_6;
};
// FIG0/6 needs a change indicator, which is a short-form FIG (i.e. without the list)
@@ -91,8 +91,8 @@ class FIG0_6_CEI : public IFIG
private:
FIGRuntimeInformation *m_rti;
- bool m_initialised;
- std::vector<std::shared_ptr<LinkageSet> >::iterator linkageSetFIG0_6;
+
+ TransitionHandler<LinkageSet> m_transition;
};
}
diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp
index ac2a80b..2fc6718 100644
--- a/src/fig/FIGCarousel.cpp
+++ b/src/fig/FIGCarousel.cpp
@@ -65,6 +65,7 @@ FIGCarousel::FIGCarousel(std::shared_ptr<dabEnsemble> ensemble) :
m_fig0_3(&m_rti),
m_fig0_5(&m_rti),
m_fig0_6(&m_rti),
+ m_fig0_6_cei(&m_rti),
m_fig0_17(&m_rti),
m_fig0_8(&m_rti),
m_fig1_0(&m_rti),
@@ -96,6 +97,7 @@ FIGCarousel::FIGCarousel(std::shared_ptr<dabEnsemble> ensemble) :
load_and_allocate(m_fig0_3, FIBAllocation::FIB_ANY);
load_and_allocate(m_fig0_5, FIBAllocation::FIB_ANY);
load_and_allocate(m_fig0_6, FIBAllocation::FIB_ANY);
+ load_and_allocate(m_fig0_6_cei, FIBAllocation::FIB_ANY);
load_and_allocate(m_fig0_8, FIBAllocation::FIB_ANY);
load_and_allocate(m_fig0_13, FIBAllocation::FIB_ANY);
diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h
index f52f266..209fe19 100644
--- a/src/fig/FIGCarousel.h
+++ b/src/fig/FIGCarousel.h
@@ -90,6 +90,7 @@ class FIGCarousel {
FIG0_3 m_fig0_3;
FIG0_5 m_fig0_5;
FIG0_6 m_fig0_6;
+ FIG0_6_CEI m_fig0_6_cei;
FIG0_17 m_fig0_17;
FIG0_8 m_fig0_8;
FIG1_0 m_fig1_0;