summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Pöschel <github@basicmaster.de>2015-07-21 18:02:20 +0200
committerStefan Pöschel <github@basicmaster.de>2015-07-21 18:02:20 +0200
commitf31d0a1819e9212d5daf47833f5599221f25c014 (patch)
treedb4cb1af644bd5b7877d796af8b11673a33dc8fc /src
parentcef3e6facc28bd08c170d26240295abbc3658170 (diff)
downloadfdk-aac-dabplus-f31d0a1819e9212d5daf47833f5599221f25c014.tar.gz
fdk-aac-dabplus-f31d0a1819e9212d5daf47833f5599221f25c014.tar.bz2
fdk-aac-dabplus-f31d0a1819e9212d5daf47833f5599221f25c014.zip
DLS: added cmdline option to insert Remove Label cmd when replacing a text
Diffstat (limited to 'src')
-rw-r--r--src/mot-encoder.cpp47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/mot-encoder.cpp b/src/mot-encoder.cpp
index c3c82b5..5bb285a 100644
--- a/src/mot-encoder.cpp
+++ b/src/mot-encoder.cpp
@@ -233,7 +233,7 @@ struct DATA_GROUP;
DATA_GROUP* packMscDG(MSCDG* msc);
void prepend_dls_dgs(const std::string& text, uint8_t charset);
-void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool raw_dls);
+void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool raw_dls, bool remove_dls);
// PAD related
#define CRC_LEN 2
@@ -305,6 +305,7 @@ static int cindex_body = 0;
#define FPAD_LEN 2
#define DLS_SEG_LEN_PREFIX 2
#define DLS_SEG_LEN_CHAR_MAX 16
+#define DLS_CMD_REMOVE_LABEL 0x01
CharsetConverter charset_converter;
@@ -610,6 +611,7 @@ void usage(char* name)
" ID = 6: ISO/IEC 10646 using UCS-2 BE\n"
" ID = 15: ISO/IEC 10646 using UTF-8\n"
" Default: 15\n"
+ " -r, --remove-dls Always insert a DLS Remove Label command when replacing a DLS text.\n"
" -C, --raw-dls Do not convert DLS texts to Complete EBU Latin based repertoire\n"
" character set encoding.\n"
" -R, --raw-slides Do not process slides. Integrity checks and resizing\n"
@@ -633,6 +635,7 @@ int main(int argc, char *argv[])
bool raw_slides = false;
int charset = CHARSET_UTF8;
bool raw_dls = false;
+ bool remove_dls = false;
const char* dir = NULL;
const char* output = "/tmp/pad.fifo";
@@ -641,6 +644,7 @@ int main(int argc, char *argv[])
const struct option longopts[] = {
{"charset", required_argument, 0, 'c'},
{"raw-dls", no_argument, 0, 'C'},
+ {"remove-dls", no_argument, 0, 'r'},
{"dir", required_argument, 0, 'd'},
{"erase", no_argument, 0, 'e'},
{"output", required_argument, 0, 'o'},
@@ -656,7 +660,7 @@ int main(int argc, char *argv[])
int ch=0;
int index;
while(ch != -1) {
- ch = getopt_long(argc, argv, "eChRc:d:o:p:s:t:v", longopts, &index);
+ ch = getopt_long(argc, argv, "eChRrc:d:o:p:s:t:v", longopts, &index);
switch (ch) {
case 'c':
charset = atoi(optarg);
@@ -664,6 +668,9 @@ int main(int argc, char *argv[])
case 'C':
raw_dls = true;
break;
+ case 'r':
+ remove_dls = true;
+ break;
case 'd':
dir = optarg;
break;
@@ -819,7 +826,7 @@ int main(int argc, char *argv[])
if (not dls_file.empty()) {
// Maybe we have no slides, always update DLS
- writeDLS(output_fd, dls_file, charset, raw_dls);
+ writeDLS(output_fd, dls_file, charset, raw_dls, remove_dls);
sleep(sleepdelay);
}
@@ -843,7 +850,7 @@ int main(int argc, char *argv[])
// Always retransmit DLS after each slide, we want it to be updated frequently
if (not dls_file.empty()) {
- writeDLS(output_fd, dls_file, charset, raw_dls);
+ writeDLS(output_fd, dls_file, charset, raw_dls, remove_dls);
}
sleep(sleepdelay);
@@ -857,7 +864,7 @@ int main(int argc, char *argv[])
}
else if (not dls_file.empty()) { // only DLS
// Always retransmit DLS, we want it to be updated frequently
- writeDLS(output_fd, dls_file, charset, raw_dls);
+ writeDLS(output_fd, dls_file, charset, raw_dls, remove_dls);
sleep(sleepdelay);
}
@@ -1272,7 +1279,28 @@ DATA_GROUP* packMscDG(MSCDG* msc)
}
-void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool raw_dls)
+DATA_GROUP* createDynamicLabelCommand(uint8_t command) {
+ DATA_GROUP* dg = new DATA_GROUP(2, 2, 3);
+ uint8_vector_t &seg_data = dg->data;
+
+ // prefix: toggle? + first seg + last seg + command flag + command
+ seg_data[0] =
+ (dls_toggle ? (1 << 7) : 0) +
+ (1 << 6) +
+ (1 << 5) +
+ (1 << 4) +
+ command;
+
+ // prefix: charset (though irrelevant here)
+ seg_data[1] = CHARSET_COMPLETE_EBU_LATIN;
+
+ // CRC
+ dg->AppendCRC();
+
+ return dg;
+}
+
+void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool raw_dls, bool remove_dls)
{
std::ifstream dls_fstream(dls_file.c_str());
if (!dls_fstream.is_open()) {
@@ -1326,7 +1354,12 @@ void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool
if (verbose) {
fprintf(stderr, "mot-encoder writing %s DLS text \"%s\"\n", dlstext_is_new ? "new" : "old", dlstext.c_str());
}
+
+ DATA_GROUP *remove_label_dg = NULL;
if (dlstext_is_new) {
+ if (remove_dls)
+ remove_label_dg = createDynamicLabelCommand(DLS_CMD_REMOVE_LABEL);
+
dls_toggle = !dls_toggle; // indicate changed text
dlstext_prev = dlstext;
@@ -1334,6 +1367,8 @@ void writeDLS(int output_fd, const std::string& dls_file, uint8_t charset, bool
}
prepend_dls_dgs(dlstext, charset);
+ if (remove_label_dg)
+ pad_packetizer->queue.push_front(remove_label_dg);
pad_packetizer->WriteAllPADs(output_fd);
}