aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fig/FIG2.cpp63
-rw-r--r--src/fig/FIG2.h35
-rw-r--r--src/fig/FIGCarousel.cpp4
-rw-r--r--src/fig/FIGCarousel.h3
4 files changed, 41 insertions, 64 deletions
diff --git a/src/fig/FIG2.cpp b/src/fig/FIG2.cpp
index a5cbe04..fefde6e 100644
--- a/src/fig/FIG2.cpp
+++ b/src/fig/FIG2.cpp
@@ -186,8 +186,8 @@ FillStatus FIG2_0::fill(uint8_t *buf, size_t max_size)
return fs;
}
-// Programme service label
-FillStatus FIG2_1::fill(uint8_t *buf, size_t max_size)
+// Programme service label and data service label
+FillStatus FIG2_1_and_5::fill(uint8_t *buf, size_t max_size)
{
FillStatus fs;
@@ -202,8 +202,9 @@ FillStatus FIG2_1::fill(uint8_t *buf, size_t max_size)
// Rotate through the subchannels until there is no more space
while (service != ensemble->services.end()) {
- if ((*service)->getType(ensemble) == subchannel_type_t::Audio and
- (*service)->label.has_fig2_label()) {
+ const bool is_programme = (*service)->getType(ensemble) == subchannel_type_t::Audio;
+
+ if (not (m_programme xor is_programme) and (*service)->label.has_fig2_label()) {
auto& segments = segment_per_service[(*service)->id];
@@ -215,9 +216,10 @@ FillStatus FIG2_1::fill(uint8_t *buf, size_t max_size)
}
}
- const ssize_t required_bytes = (segments.current_segment_index() == 0) ?
- sizeof(FIGtype2) + 2 + sizeof(FIG2_Extended_Label) + segments.current_segment_length() :
- sizeof(FIGtype2) + 2 + segments.current_segment_length();
+ const size_t id_length = (is_programme ? 2 : 4);
+
+ const ssize_t required_bytes = sizeof(FIGtype2) + id_length + segments.current_segment_length() +
+ ((segments.current_segment_index() == 0) ? sizeof(FIG2_Extended_Label) : 0);
if (remaining < required_bytes) {
break;
@@ -228,7 +230,7 @@ FillStatus FIG2_1::fill(uint8_t *buf, size_t max_size)
fig2->Length = required_bytes - 1;
fig2->FIGtypeNumber = 2;
- fig2->Extension = 1;
+ fig2->Extension = figextension();
fig2->Rfu = 0;
fig2->SegmentIndex = segments.current_segment_index();
fig2->ToggleFlag = segments.toggle_flag();
@@ -237,10 +239,18 @@ FillStatus FIG2_1::fill(uint8_t *buf, size_t max_size)
remaining -= sizeof(FIGtype2);
// Identifier field
- buf[0] = (*service)->id >> 8;
- buf[1] = (*service)->id & 0xFF;
- buf += 2;
- remaining -= 2;
+ if (is_programme) {
+ buf[0] = (*service)->id >> 8;
+ buf[1] = (*service)->id & 0xFF;
+ }
+ else {
+ buf[0] = ((*service)->id >> 24) & 0xFF;
+ buf[1] = ((*service)->id >> 16) & 0xFF;
+ buf[2] = ((*service)->id >> 8) & 0xFF;
+ buf[3] = (*service)->id & 0xFF;
+ }
+ buf += id_length;
+ remaining -= id_length;
if (segments.current_segment_index() == 0) {
auto ext = (FIG2_Extended_Label*)buf;
@@ -307,7 +317,9 @@ FillStatus FIG2_4::fill(uint8_t *buf, size_t max_size)
const bool is_programme = (*service)->getType(ensemble) == subchannel_type_t::Audio;
- const size_t id_length = is_programme ? 2 : 4;
+ const size_t id_length = is_programme ?
+ sizeof(FIGtype2_4_Programme_Identifier) :
+ sizeof(FIGtype2_4_Data_Identifier);
const ssize_t required_bytes = sizeof(FIGtype2) + id_length + segments.current_segment_length() +
((segments.current_segment_index() == 0) ? sizeof(FIG2_Extended_Label) : 0);
@@ -388,30 +400,5 @@ FillStatus FIG2_4::fill(uint8_t *buf, size_t max_size)
return fs;
}
-// Data service label
-FillStatus FIG2_5::fill(uint8_t *buf, size_t max_size)
-{
- FillStatus fs;
-
- ssize_t remaining = max_size;
-
- if (not m_initialised) {
- service = m_rti->ensemble->services.end();
- m_initialised = true;
- }
-
- auto ensemble = m_rti->ensemble;
-
- service = ensemble->services.end(); // TODO
-
- if (service == ensemble->services.end()) {
- service = ensemble->services.begin();
- fs.complete_fig_transmitted = true;
- }
-
- fs.num_bytes_written = max_size - remaining;
- return fs;
-}
-
} // namespace FIC
diff --git a/src/fig/FIG2.h b/src/fig/FIG2.h
index b742c89..6fad658 100644
--- a/src/fig/FIG2.h
+++ b/src/fig/FIG2.h
@@ -74,21 +74,26 @@ class FIG2_0 : public IFIG
FIG2_Segments m_segments;
};
-// FIG type 2/1, programme service label
-class FIG2_1 : public IFIG
+// FIG type 2/1, programme service label and FIG type 2/5, data service label
+// share this code.
+class FIG2_1_and_5 : public IFIG
{
public:
- FIG2_1(FIGRuntimeInformation* rti) :
- m_rti(rti), m_initialised(false) {}
+ FIG2_1_and_5(FIGRuntimeInformation* rti, bool programme) :
+ m_rti(rti),
+ m_initialised(false),
+ m_programme(programme) {}
+
virtual FillStatus fill(uint8_t *buf, size_t max_size);
virtual FIG_rate repetition_rate() const { return FIG_rate::B; }
- virtual int figtype() const { return 2; }
- virtual int figextension() const { return 1; }
+ virtual int figtype() const { return 2;}
+ virtual int figextension() const { return m_programme ? 1 : 5; }
private:
FIGRuntimeInformation *m_rti;
bool m_initialised;
+ bool m_programme;
vec_sp_service::iterator service;
std::map<uint32_t, FIG2_Segments> segment_per_service;
};
@@ -112,24 +117,6 @@ class FIG2_4 : public IFIG
std::map<std::pair<uint32_t, uint8_t>, FIG2_Segments> segment_per_component;
};
-// FIG type 2/5, data service label
-class FIG2_5 : public IFIG
-{
- public:
- FIG2_5(FIGRuntimeInformation* rti) :
- m_rti(rti), m_initialised(false) {}
- virtual FillStatus fill(uint8_t *buf, size_t max_size);
- virtual FIG_rate repetition_rate() const { return FIG_rate::B; }
-
- virtual int figtype() const { return 2; }
- virtual int figextension() const { return 5; }
-
- private:
- FIGRuntimeInformation *m_rti;
- bool m_initialised;
- vec_sp_service::iterator service;
-};
-
#ifdef _WIN32
# pragma pack(push)
#endif
diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp
index c0cebf7..8ea183c 100644
--- a/src/fig/FIGCarousel.cpp
+++ b/src/fig/FIGCarousel.cpp
@@ -96,7 +96,8 @@ FIGCarousel::FIGCarousel(std::shared_ptr<dabEnsemble> ensemble) :
m_fig0_21(&m_rti),
m_fig0_24(&m_rti),
m_fig2_0(&m_rti),
- m_fig2_1(&m_rti),
+ m_fig2_1(&m_rti, true),
+ m_fig2_5(&m_rti, false),
m_fig2_4(&m_rti)
{
/* Complete MCI except FIG0/8 should be in FIB0.
@@ -136,6 +137,7 @@ FIGCarousel::FIGCarousel(std::shared_ptr<dabEnsemble> ensemble) :
load_and_allocate(m_fig2_0, FIBAllocation::FIB_ANY);
load_and_allocate(m_fig2_1, FIBAllocation::FIB_ANY);
+ load_and_allocate(m_fig2_5, FIBAllocation::FIB_ANY);
load_and_allocate(m_fig2_4, FIBAllocation::FIB_ANY);
}
diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h
index 9797554..a07a855 100644
--- a/src/fig/FIGCarousel.h
+++ b/src/fig/FIGCarousel.h
@@ -112,7 +112,8 @@ class FIGCarousel {
FIG0_21 m_fig0_21;
FIG0_24 m_fig0_24;
FIG2_0 m_fig2_0;
- FIG2_1 m_fig2_1;
+ FIG2_1_and_5 m_fig2_1;
+ FIG2_1_and_5 m_fig2_5;
FIG2_4 m_fig2_4;
};