First steps on integration tasks.
git-svn-id: http://op25.osmocom.org/svn/trunk@146 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
a3e1715e6f
commit
828bda192d
|
@ -1,7 +1,6 @@
|
|||
#include <dummy_imbe_decoder.h>
|
||||
#include <imbe_decoder.h>
|
||||
// #include <dummy_imbe_decoder.h>
|
||||
#include <offline_imbe_decoder.h>
|
||||
// #include <offline_imbe_decoder.h>
|
||||
// #include <vc55_imbe_decoder.h>
|
||||
|
||||
imbe_decoder_sptr
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2008 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <stdint.h>
|
||||
#include <swab.h>
|
||||
#include <offline_imbe_decoder.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
offline_imbe_decoder::offline_imbe_decoder()
|
||||
{
|
||||
const char *dev = getenv("IMBE_FILE");
|
||||
if(!dev) {
|
||||
const char *default_filename = "imbe.dat";
|
||||
dev = default_filename;
|
||||
}
|
||||
d_fp = fopen(dev, "w");
|
||||
if(NULL == d_fp) {
|
||||
perror("fopen(dev, \"w\");"); // a warning, not an error
|
||||
}
|
||||
}
|
||||
|
||||
offline_imbe_decoder::~offline_imbe_decoder()
|
||||
{
|
||||
if(d_fp) {
|
||||
fclose(d_fp);
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
offline_imbe_decoder::decode(voice_codeword& in_out, audio_output& out)
|
||||
{
|
||||
if(d_fp) {
|
||||
uint8_t codewords[18];
|
||||
extract(in_out, 0, 144, codewords);
|
||||
if(0 == fwrite(codewords, sizeof(codewords), 1, d_fp)) {
|
||||
perror("fwrite(d_fp, 1, codewords, sizeof(codewords))");
|
||||
fclose(d_fp);
|
||||
d_fp = NULL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2008 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_OFFLINE_IMBE_DECODER_H
|
||||
#define INCLUDED_OFFLINE_IMBE_DECODER_H
|
||||
|
||||
#include <imbe_decoder.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
/**
|
||||
* offline_imbe_decoder dumps voice codewords to file for offline decoding.
|
||||
*
|
||||
*/
|
||||
class offline_imbe_decoder : public imbe_decoder {
|
||||
public:
|
||||
|
||||
/**
|
||||
* offline_imbe_decoder default constructor.
|
||||
*/
|
||||
offline_imbe_decoder();
|
||||
|
||||
/**
|
||||
* offline_imbe_decoder (virtual) destructor.
|
||||
*/
|
||||
virtual ~offline_imbe_decoder();
|
||||
|
||||
/**
|
||||
* Dump voice_codeword in_out to file.
|
||||
*
|
||||
* \param in_out IMBE codewords and parity.
|
||||
* \param in Queue of audio samples to which output is written.
|
||||
* \return The number of samples written to out.
|
||||
*/
|
||||
virtual size_t decode(voice_codeword& in_out, audio_output& out);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The output file.
|
||||
*/
|
||||
FILE *d_fp;
|
||||
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_OFFLINE_IMBE_DECODER_H */
|
|
@ -0,0 +1,115 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2008 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <value_string.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct value_string {
|
||||
uint16_t value;
|
||||
const char *label;
|
||||
};
|
||||
|
||||
string
|
||||
lookup(uint16_t value, const value_string mappings[], size_t mappings_sz)
|
||||
{
|
||||
for(size_t i = 0; i < mappings_sz; ++i) {
|
||||
if(mappings[i].value == value) {
|
||||
return mappings[i].label;
|
||||
}
|
||||
}
|
||||
ostringstream os;
|
||||
os << "Unknown (" << hex << value << ")";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
const value_string ALGIDS[] = {
|
||||
/* Type I */
|
||||
{ 0x00, "ACCORDION 1.3" },
|
||||
{ 0x01, "BATON (Auto Even)" },
|
||||
{ 0x02, "FIREFLY Type 1" },
|
||||
{ 0x03, "MAYFLY Type 1" },
|
||||
{ 0x04, "SAVILLE" },
|
||||
{ 0x41, "BATON (Auto Odd)" },
|
||||
/* Type III */
|
||||
{ 0x80, "Unencrypted message" },
|
||||
{ 0x81, "DES-OFB" },
|
||||
{ 0x82, "2 key Triple DES" },
|
||||
{ 0x83, "3 key Triple DES" },
|
||||
{ 0x84, "AES-256" },
|
||||
/* Motorola proprietary */
|
||||
{ 0x9F, "DES-XL" },
|
||||
{ 0xA0, "DVI-XL" },
|
||||
{ 0xA1, "DVP-XL" },
|
||||
};
|
||||
const size_t ALGIDS_SZ = sizeof(ALGIDS) / sizeof(ALGIDS[0]);
|
||||
|
||||
|
||||
const value_string MFIDS[] = {
|
||||
{ 0x00, "Standard MFID (pre-2001)" },
|
||||
{ 0x01, "Standard MFID (post-2001)" },
|
||||
{ 0x09, "Aselsan Inc." },
|
||||
{ 0x10, "Relm / BK Radio" },
|
||||
{ 0x18, "EADS Public Safety Inc." },
|
||||
{ 0x20, "Cycomm" },
|
||||
{ 0x28, "Efratom Time and Frequency Products, Inc" },
|
||||
{ 0x30, "Com-Net Ericsson" },
|
||||
{ 0x34, "Etherstack" },
|
||||
{ 0x38, "Datron" },
|
||||
{ 0x40, "Icom" },
|
||||
{ 0x48, "Garmin" },
|
||||
{ 0x50, "GTE" },
|
||||
{ 0x55, "IFR Systems" },
|
||||
{ 0x5A, "INIT Innovations in Transportation, Inc" },
|
||||
{ 0x60, "GEC-Marconi" },
|
||||
{ 0x64, "Harris Corp." },
|
||||
{ 0x68, "Kenwood Communications" },
|
||||
{ 0x70, "Glenayre Electronics" },
|
||||
{ 0x74, "Japan Radio Co." },
|
||||
{ 0x78, "Kokusai" },
|
||||
{ 0x7C, "Maxon" },
|
||||
{ 0x80, "Midland" },
|
||||
{ 0x86, "Daniels Electronics Ltd." },
|
||||
{ 0x90, "Motorola" },
|
||||
{ 0xA0, "Thales" },
|
||||
{ 0xA4, "M/A-COM" },
|
||||
{ 0xB0, "Raytheon" },
|
||||
{ 0xC0, "SEA" },
|
||||
{ 0xC8, "Securicor" },
|
||||
{ 0xD0, "ADI" },
|
||||
{ 0xD8, "Tait Electronics" },
|
||||
{ 0xE0, "Teletec" },
|
||||
{ 0xF0, "Transcrypt International" },
|
||||
{ 0xF8, "Vertex Standard" },
|
||||
{ 0xFC, "Zetron, Inc" },
|
||||
};
|
||||
const size_t MFIDS_SZ = sizeof(MFIDS) / sizeof(MFIDS[0]);
|
||||
|
||||
const value_string NACS[] = {
|
||||
{ 0x293, "Default NAC" },
|
||||
{ 0xF7E, "Receiver to open on any NAC" },
|
||||
{ 0xF7F, "Repeater to receive and retransmit any NAC" },
|
||||
};
|
||||
const size_t NACS_SZ = sizeof(NACS) / sizeof(NACS[0]);
|
|
@ -0,0 +1,48 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2008 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_VALUE_STRING
|
||||
#define INCLUDED_VALUE_STRING
|
||||
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Look up a value in a value_string array.
|
||||
*
|
||||
*/
|
||||
extern std::string lookup(uint16_t value, const class value_string mappings[], size_t mappings_sz);
|
||||
|
||||
/*
|
||||
* Look up tables.
|
||||
*/
|
||||
|
||||
extern const value_string ALGIDS[];
|
||||
extern const size_t ALGIDS_SZ;
|
||||
|
||||
extern const value_string MFIDS[];
|
||||
extern const size_t MFIDS_SZ;
|
||||
|
||||
extern const value_string NACS[];
|
||||
extern const size_t NACS_SZ;
|
||||
|
||||
#endif // INCLUDED_VALUE_STRING
|
Reference in New Issue