aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Khassraf <roman@khassraf.at>2015-08-11 11:52:15 +0200
committerRoman Khassraf <roman@khassraf.at>2015-08-11 11:52:15 +0200
commit23c8d8a92f1c1a19f5c1ce29df91c27f53e51359 (patch)
tree3daed088ebe364473c9e859dcc038e461adbd51f
parentb78bd07fd665cb1a97d15d1fdc71f31fdf7d8b36 (diff)
Implemented boundary check for voice decoding. Issue 107
-rw-r--r--grc/decoding/gsm_tch_f_decoder.xml26
-rw-r--r--include/grgsm/decoding/tch_f_decoder.h2
-rw-r--r--lib/decoding/tch_f_decoder_impl.cc40
-rw-r--r--lib/decoding/tch_f_decoder_impl.h4
4 files changed, 65 insertions, 7 deletions
diff --git a/grc/decoding/gsm_tch_f_decoder.xml b/grc/decoding/gsm_tch_f_decoder.xml
index 59ac97d..632162f 100644
--- a/grc/decoding/gsm_tch_f_decoder.xml
+++ b/grc/decoding/gsm_tch_f_decoder.xml
@@ -3,7 +3,7 @@
<name>TCH/F decoder</name>
<key>gsm_tch_f_decoder</key>
<import>import grgsm</import>
- <make>grgsm.tch_f_decoder($mode, $file)</make>
+ <make>grgsm.tch_f_decoder($mode, $file, $boundary_check)</make>
<param>
<name>TCH coding mode</name>
@@ -56,7 +56,21 @@
<value>/tmp/speech.gsm</value>
<type>file_open</type>
</param>
-
+ <param>
+ <name>Voice boundary detection</name>
+ <key>boundary_check</key>
+ <value>True</value>
+ <type>bool</type>
+ <option>
+ <name>False</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>True</name>
+ <key>True</key>
+ </option>
+ </param>
+
<sink>
<name>bursts</name>
<type>message</type>
@@ -66,4 +80,12 @@
<type>message</type>
<optional>1</optional>
</source>
+
+ <doc>
+If "Voice boundary detection" is enabled, then only bursts are decoded as voice where
+
+- the framenumber is greater then the framenumber of a received "Connect" or "Connect Acknowlegde" message, and
+- the framenumber is less then the framenumber of a "Release" message
+ </doc>
+
</block>
diff --git a/include/grgsm/decoding/tch_f_decoder.h b/include/grgsm/decoding/tch_f_decoder.h
index efe082c..8dbf68b 100644
--- a/include/grgsm/decoding/tch_f_decoder.h
+++ b/include/grgsm/decoding/tch_f_decoder.h
@@ -62,7 +62,7 @@ namespace gr {
* class. gsm::tch_f_decoder::make is the public interface for
* creating new instances.
*/
- static sptr make(tch_mode mode, const std::string &file);
+ static sptr make(tch_mode mode, const std::string &file, bool boundary_check=true);
};
diff --git a/lib/decoding/tch_f_decoder_impl.cc b/lib/decoding/tch_f_decoder_impl.cc
index a3b09fb..f3099fd 100644
--- a/lib/decoding/tch_f_decoder_impl.cc
+++ b/lib/decoding/tch_f_decoder_impl.cc
@@ -35,21 +35,23 @@ namespace gr {
namespace gsm {
tch_f_decoder::sptr
- tch_f_decoder::make(tch_mode mode, const std::string &file)
+ tch_f_decoder::make(tch_mode mode, const std::string &file, bool boundary_check)
{
return gnuradio::get_initial_sptr
- (new tch_f_decoder_impl(mode, file));
+ (new tch_f_decoder_impl(mode, file, boundary_check));
}
/*
* Constructor
*/
- tch_f_decoder_impl::tch_f_decoder_impl(tch_mode mode, const std::string &file)
+ tch_f_decoder_impl::tch_f_decoder_impl(tch_mode mode, const std::string &file, bool boundary_check)
: gr::block("tch_f_decoder",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0)),
d_tch_mode(mode),
d_collected_bursts_num(0),
+ d_boundary_check(boundary_check),
+ d_boundary_decode(!boundary_check),
mBlockCoder(0x10004820009ULL, 40, 224),
mU(228),
mP(mU.segment(184,40)),
@@ -163,6 +165,32 @@ namespace gr {
pmt::pmt_t msg_out = pmt::cons(pmt::PMT_NIL, msg_binary_blob);
message_port_pub(pmt::mp("msgs"), msg_out);
+
+ // if d_boundary_check is enabled, we set d_boundary_decode to true, when a
+ // "Connect" or "Connect Acknowledge" message is received, and
+ // we set d_boundary_decode back to false, when "Release" message is received
+ if (d_boundary_check)
+ {
+ // check if this is a call control message
+ if ((outmsg[3] & 0x0f) == 0x03)
+ {
+ // Connect specified in GSM 04.08, 9.3.5
+ if ((outmsg[4] & 0x3f) == 0x07)
+ {
+ d_boundary_decode = true;
+ }
+ // Connect Acknowledge specified in GSM 04.08, 9.3.6
+ else if ((outmsg[4] & 0x3f) == 0x0f)
+ {
+ d_boundary_decode = true;
+ }
+ // Release specified in GSM 04.08, 9.3.18
+ else if ((outmsg[4] & 0x3f) == 0x2d)
+ {
+ d_boundary_decode = false;
+ }
+ }
+ }
// if we are in an AMR-mode and we receive a channel mode modify message,
// we set the mode according to the multirate configuration from the message
@@ -215,6 +243,12 @@ namespace gr {
}
}
}
+
+ // if boundary_check is enabled and d_boundary_decode is false, we are done
+ if (d_boundary_check && !d_boundary_decode)
+ {
+ return;
+ }
// Decode voice frames and write to file
if (d_tch_mode == TCH_FS || d_tch_mode == TCH_EFR)
diff --git a/lib/decoding/tch_f_decoder_impl.h b/lib/decoding/tch_f_decoder_impl.h
index f6d054b..3e8c79a 100644
--- a/lib/decoding/tch_f_decoder_impl.h
+++ b/lib/decoding/tch_f_decoder_impl.h
@@ -54,6 +54,8 @@ namespace gr {
pmt::pmt_t d_bursts[8];
FILE * d_speech_file;
enum tch_mode d_tch_mode;
+ bool d_boundary_check;
+ bool d_boundary_decode;
BitVector mU;
BitVector mP;
@@ -87,7 +89,7 @@ namespace gr {
void decode(pmt::pmt_t msg);
void setCodingMode(tch_mode mode);
public:
- tch_f_decoder_impl(tch_mode mode, const std::string &file);
+ tch_f_decoder_impl(tch_mode mode, const std::string &file, bool boundary_check=true);
~tch_f_decoder_impl();
};