Skip to content

Commit

Permalink
FIB_source: add individual labels for each service
Browse files Browse the repository at this point in the history
  • Loading branch information
MLsmd committed Aug 17, 2017
1 parent 5ae9b92 commit 87641b0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 72 deletions.
4 changes: 2 additions & 2 deletions grc/dab_fib_source_b.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<key>dab_fib_source_b</key>
<category>DAB</category>
<import>import dab</import>
<make>dab.fib_source_b($dab_mode, $num_subch, $ensemble_label, $programme_service_label, $service_comp_label, $service_comp_lang, $protection_mode, $data_rate_n)</make>
<make>dab.fib_source_b($dab_mode, $num_subch, $ensemble_label, $programme_service_labels, $service_comp_label, $service_comp_lang, $protection_mode, $data_rate_n)</make>
<param>
<name>DAB Mode</name>
<key>dab_mode</key>
Expand Down Expand Up @@ -38,7 +38,7 @@
</param>
<param>
<name>Service label</name>
<key>programme_service_label</key>
<key>programme_service_labels</key>
<type>string</type>
</param>
<param>
Expand Down
2 changes: 1 addition & 1 deletion include/dab/fib_source_b.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace gr {
* class. dab::fib_source_b::make is the public interface for
* creating new instances.
*/
static sptr make(int transmission_mode, int num_subch, std::string ensemble_label, std::string programme_service_label, std::string service_comp_label, uint8_t service_comp_lang, const std::vector<uint8_t> &protection_mode, const std::vector<uint8_t> &data_rate_n);
static sptr make(int transmission_mode, int num_subch, std::string ensemble_label, std::string programme_service_labels, std::string service_comp_label, uint8_t service_comp_lang, const std::vector<uint8_t> &protection_mode, const std::vector<uint8_t> &data_rate_n);
};

} // namespace dab
Expand Down
88 changes: 31 additions & 57 deletions lib/fib_source_b_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,70 +98,47 @@ namespace gr {
1, 0, 0};
//001 10101 0000 0 001 0100000000000000 01011111 01000111 01100001 01101100 01100001 01111000 01111001 01011111 01010010 01100001 01100100 01101001 01101111 00110001 01011111 01011111 0111000111100100

//Programme Service Component label
char fib_source_b_impl::d_service_comp_label[184] = {0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0,
1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0,
1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0,
1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1,
1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1,
1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
//001 10110 0000 0 100 0 000 0000 0100000000000000 01000001 01110111 01100101 01110011 01101111 01101101 01100101 01011111 01001101 01101001 01111000 01011111 01010110 01101111 01101100 00110001 0000000011111111

//service component language
char fib_source_b_impl::d_service_comp_language[32] = {0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0};
//"000 00011 000 00101 0 0 000000 00001000";

/// d_SI_pointer array contains all SI for transmission.
const char *fib_source_b_impl::d_SI_pointer[
d_num_SI_basic + d_num_SI_subch] = {d_ensemble_label, d_programme_service_label, d_service_comp_language,
d_service_comp_label};
/// contains the lengths of the SI FIGs for transmission
const int fib_source_b_impl::d_SI_size[d_num_SI_basic + d_num_SI_subch] = {176, 176, 32, 184};

fib_source_b::sptr
fib_source_b::make(int transmission_mode, int num_subch, std::string ensemble_label,
std::string programme_service_label, std::string service_comp_label, uint8_t service_comp_lang,
std::string programme_service_labels, std::string service_comp_label, uint8_t service_comp_lang,
const std::vector <uint8_t> &protection_mode, const std::vector <uint8_t> &data_rate_n)
{
return gnuradio::get_initial_sptr
(new fib_source_b_impl(transmission_mode, num_subch, ensemble_label,
programme_service_label, service_comp_label, service_comp_lang, protection_mode,
programme_service_labels, service_comp_label, service_comp_lang, protection_mode,
data_rate_n));
}

/*
* The private constructor
*/
fib_source_b_impl::fib_source_b_impl(int transmission_mode, int num_subch, std::string ensemble_label,
std::string programme_service_label, std::string service_comp_label,
std::string programme_service_labels, std::string service_comp_label,
uint8_t service_comp_lang, const std::vector <uint8_t> &protection_mode,
const std::vector <uint8_t> &data_rate_n)
: gr::sync_block("fib_source_b",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, sizeof(char))),
d_transmission_mode(transmission_mode), d_num_subch(num_subch), d_nFIBs_written(0), d_nSI_written(0),
d_subch_iterate(0), d_protection_mode(protection_mode), d_data_rate_n(data_rate_n)
d_transmission_mode(transmission_mode), d_num_subch(num_subch), d_nFIBs_written(0),
d_protection_mode(protection_mode), d_data_rate_n(data_rate_n)
{
if (d_transmission_mode != 3) set_output_multiple((8 * FIB_LENGTH) * 3);
else set_output_multiple((8 * FIB_LENGTH) * 4);
//write the labels with input strings once at beginning
//write the ensemble label with input string once at beginning
write_label(d_ensemble_label + 32, ensemble_label);
write_label(d_programme_service_label + 32, programme_service_label);
write_label(d_service_comp_label + 40, service_comp_label);
//change service comp language
bit_adaption(d_service_comp_language + d_size_service_comp_language, service_comp_lang, 8);
if (protection_mode.size() != num_subch) {
throw std::invalid_argument((boost::format("size of vector protection_mode (%d) does not fit with number of subchannels (%d)") % protection_mode.size() % num_subch).str());
}
if (data_rate_n.size() != num_subch) {
throw std::invalid_argument((boost::format("size of vector data_rate_n (%d) does not fit with number of subchannels (%d)") % data_rate_n.size() % num_subch).str());
}
// init counter for iterating over the services
d_label_counter = 0;
d_service_labels = programme_service_labels;
// the string programme_service_labels containts num_subch * 16 chars, appended. Note that every subchannel is strutured in a different service in this implementation.
if (programme_service_labels.size() != 16*num_subch){
throw std::invalid_argument((boost::format("size of service label strings is (%d) but should be %d * 16 = %d") % programme_service_labels.size() % num_subch % (16*num_subch)).str());
}
}

/*
Expand Down Expand Up @@ -338,29 +315,26 @@ namespace gr {
/// write a not primary FIB with SI
/////////////////////////////////////////////////
do { //fill FIB with FIGs
//write one SI-FIG in FIB
std::memcpy(out + d_offset, d_SI_pointer[d_nSI_written], d_SI_size[d_nSI_written]);
//change content if subchannel specific SI
d_offset += d_SI_size[d_nSI_written];

//SI for each subchannel?
if (d_nSI_written + 1 >= d_num_SI_basic) //a subchannel specific FIG has to be written d_num_subch times
{
if (++d_subch_iterate >= d_num_subch) //all subchannels were written; go on with next SI
{
d_nSI_written++;
d_subch_iterate = 0;
}
} else //basic SI -> just write once
{
d_nSI_written++;
if(d_label_counter == 0){
// write ensemble label
std::memcpy(out + d_offset, d_ensemble_label, d_size_label);
d_offset += d_size_label;
++d_label_counter;
}
//start from first FIG when all FIGs are written
if (d_nSI_written >= d_num_SI_basic + d_num_SI_subch) {
d_nSI_written = 0;
else{
// write service label
std::memcpy(out + d_offset, d_programme_service_label, d_size_label);
// change label
std::string label = d_service_labels.substr((d_label_counter-1)*16, 16);
write_label(out + d_offset + 32, label);
d_offset += d_size_label;
bit_adaption(out + d_offset - 144, d_label_counter-1, 8);
if(++d_label_counter > d_num_subch){
d_label_counter = 0;
}

}
} while ((8 * FIB_DATA_FIELD_LENGTH) - (d_offset % (8 * FIB_LENGTH)) >=
d_SI_size[d_nSI_written]); //check if there is enough space for next FIG
} while ((8 * FIB_DATA_FIELD_LENGTH) - (d_offset % (8 * FIB_LENGTH)) >= 176); //check if there is enough space for next FIG
//FIB is filled, set endmarker and padding
if ((8 * FIB_DATA_FIELD_LENGTH) - (d_offset % (8 * FIB_LENGTH)) >=
8) {//add EndMarker (111 11111) if there is minimum one byte left in FIG
Expand Down
16 changes: 4 additions & 12 deletions lib/fib_source_b_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,19 @@ namespace gr {
std::vector <uint8_t> d_protection_mode, d_data_rate_n;

//Service Information
int d_label_counter;
const static int d_size_label = 176;
static char d_ensemble_label[176]; //21*8+8, ensemble label (FIG 1/0)
const static int d_size_ensemble_label = 176;
static char d_programme_service_label[176]; //21*8+8, service label (FIG 1/0)
const static int d_size_service_label = 176;
static char d_service_comp_label[184]; //21*8+8, service component label (FIG 1/0)
const static int d_size_service_comp_label = 184;
static char d_service_comp_language[32]; //3*8+8, service component language; short form (FIG 0/5)
const static int d_size_service_comp_language = 32;

const static int d_num_SI_basic = 4; //no subchannel specific SI
const static int d_num_SI_subch = 0; //SI for a specific subchannel
const static char *d_SI_pointer[d_num_SI_basic +
d_num_SI_subch]; //pointer to iterate the SI data in non-primary FIBs, saves the start adress from each SI_Array
const static int d_SI_size[d_num_SI_basic + d_num_SI_subch]; //Saves the lengths of the SI_Arrays
int d_nSI_written, d_subch_iterate;
std::string d_service_labels;

int write_label(char *out_ptr, std::string label, int num_chars = 16);//default for 16 characters (16 byte)

public:
fib_source_b_impl(int transmission_mode, int num_subch, std::string ensemble_label,
std::string programme_service_label, std::string service_comp_label, uint8_t service_comp_lang,
std::string programme_service_labels, std::string service_comp_label, uint8_t service_comp_lang,
const std::vector <uint8_t> &protection_mode, const std::vector <uint8_t> &data_rate_n);

~fib_source_b_impl();
Expand Down

0 comments on commit 87641b0

Please sign in to comment.