mirror of
https://github.com/JvanKatwijk/dab-cmdline
synced 2025-10-05 23:52:50 +02:00
added dab-scanner
This commit is contained in:
339
LICENSE
Normal file
339
LICENSE
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
315
dab-scanner/CMakeLists.txt
Normal file
315
dab-scanner/CMakeLists.txt
Normal file
@@ -0,0 +1,315 @@
|
||||
cmake_minimum_required( VERSION 2.8.11 )
|
||||
set (objectName dab_scanner)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -flto")
|
||||
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -g")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
|
||||
#set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g")
|
||||
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set (CMAKE_INSTALL_PREFIX "/usr/local/bin" CACHE PATH "default install path" FORCE )
|
||||
endif()
|
||||
#set (CMAKE_INSTALL_PREFIX /usr/local/bin)
|
||||
|
||||
if(MINGW)
|
||||
add_definitions ( -municode)
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# select the release build type by default to get optimization flags
|
||||
########################################################################
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
message(STATUS "Build type not specified: defaulting to release.")
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
||||
|
||||
### make sure our local CMake Modules path comes first
|
||||
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
|
||||
######################################################################
|
||||
#
|
||||
########################################################################
|
||||
if(DEFINED AIRSPY)
|
||||
set(AIRSPY true)
|
||||
set(objectName dab-scanner-airspy)
|
||||
endif ()
|
||||
|
||||
if(DEFINED SDRPLAY)
|
||||
set(SDRPLAY true)
|
||||
set(objectName dab-scanner-sdrplay)
|
||||
endif ()
|
||||
|
||||
if(DEFINED RTLSDR)
|
||||
set(RTLSDR true)
|
||||
set(objectName dab-scanner-rtlsdr)
|
||||
endif ()
|
||||
|
||||
#if(DEFINED HACKRF)
|
||||
# set(HACKRF true)
|
||||
# set(objectName dab-scanner-hackrf)
|
||||
#endif ()
|
||||
|
||||
#########################################################################
|
||||
find_package (PkgConfig)
|
||||
|
||||
find_package(FFTW3f)
|
||||
if (NOT FFTW3F_FOUND)
|
||||
message(FATAL_ERROR "please install FFTW3")
|
||||
endif ()
|
||||
|
||||
find_package(Faad)
|
||||
if (NOT FAAD_FOUND )
|
||||
message(FATAL_ERROR "please install libfaad")
|
||||
endif ()
|
||||
|
||||
find_package(zlib)
|
||||
if (NOT ZLIB_FOUND)
|
||||
message(FATAL_ERROR "please install libz")
|
||||
endif ()
|
||||
list(APPEND extraLibs ${ZLIB_LIBRARY})
|
||||
|
||||
|
||||
find_library (PTHREADS pthread)
|
||||
if (NOT(PTHREADS))
|
||||
message (FATAL_ERROR "please install libpthread")
|
||||
else (NOT(PTHREADS))
|
||||
set (extraLibs ${extraLibs} ${PTHREADS})
|
||||
endif (NOT(PTHREADS))
|
||||
|
||||
|
||||
#########################################################################
|
||||
find_package (PkgConfig)
|
||||
|
||||
##########################################################################
|
||||
# The devices
|
||||
#
|
||||
|
||||
if (SDRPLAY)
|
||||
find_path (SDRPLAYLIB_INCLUDE_DIR
|
||||
NAMES mirsdrapi-rsp.h
|
||||
PATHS
|
||||
/usr/local/include/
|
||||
)
|
||||
include_directories (${SDRPLAYLIB_INCLUDE_DIR})
|
||||
|
||||
find_library (SDRPLAYLIB mirsdrapi-rsp)
|
||||
if(NOT(SDRPLAYLIB))
|
||||
message(FATAL_ERROR "please install -lmirsdrapi-rsp")
|
||||
else(NOT(SDRPLAYLIB))
|
||||
list (APPEND extraLibs ${SDRPLAYLIB})
|
||||
endif(NOT(SDRPLAYLIB))
|
||||
|
||||
include_directories (
|
||||
../devices/sdrplay-handler
|
||||
)
|
||||
|
||||
set ($(objectName)_HDRS
|
||||
${${objectName}_HDRS}
|
||||
../devices/sdrplay-handler/sdrplay-handler.h
|
||||
)
|
||||
|
||||
set (${objectName}_SRCS
|
||||
${${objectName}_SRCS}
|
||||
../devices/sdrplay-handler/sdrplay-handler.cpp
|
||||
)
|
||||
|
||||
add_definitions (-DHAVE_SDRPLAY)
|
||||
endif (SDRPLAY)
|
||||
|
||||
if (AIRSPY)
|
||||
find_package(LibAIRSPY)
|
||||
if (NOT LIBAIRSPY_FOUND)
|
||||
message(FATAL_ERROR "please install airspy library")
|
||||
endif ()
|
||||
### include_directories (${AIRSPYLIB_INCLUDE_DIR})
|
||||
|
||||
include_directories (
|
||||
../devices/airspy-handler
|
||||
)
|
||||
|
||||
set ($(objectName)_HDRS
|
||||
${${objectName}_HDRS}
|
||||
../devices/airspy-handler/airspy-handler.h
|
||||
)
|
||||
|
||||
set (${objectName}_SRCS
|
||||
${${objectName}_SRCS}
|
||||
../devices/airspy-handler/airspy-handler.cpp
|
||||
)
|
||||
|
||||
add_definitions (-DHAVE_AIRSPY)
|
||||
endif (AIRSPY)
|
||||
|
||||
|
||||
if (RTLSDR)
|
||||
find_package(LibRTLSDR)
|
||||
if (NOT LIBRTLSDR_FOUND)
|
||||
message(FATAL_ERROR "please install librtlsdr")
|
||||
endif ()
|
||||
###include_directories (${RTLSDR_INCLUDE_DIR})
|
||||
|
||||
include_directories (
|
||||
../devices/rtlsdr-handler/
|
||||
)
|
||||
|
||||
set (${objectName}_HDRS
|
||||
${${objectName}_HDRS}
|
||||
../devices/rtlsdr-handler/rtlsdr-handler.h
|
||||
)
|
||||
|
||||
set (${objectName}_SRCS
|
||||
${${objectName}_SRCS}
|
||||
../devices/rtlsdr-handler/rtlsdr-handler.cpp
|
||||
)
|
||||
|
||||
add_definitions (-DHAVE_RTLSDR)
|
||||
endif()
|
||||
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# Here we really start
|
||||
|
||||
include_directories (
|
||||
${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
.
|
||||
./
|
||||
../
|
||||
../library
|
||||
../library/includes
|
||||
../library/includes/ofdm
|
||||
../library/includes/backend
|
||||
../library/includes/backend/audio
|
||||
../library/includes/backend/data
|
||||
../library/includes/backend/data/mot
|
||||
../library/includes/backend/data/journaline
|
||||
../library/includes/support
|
||||
../library/includes/support/viterbi_768
|
||||
/usr/include/
|
||||
)
|
||||
|
||||
set (${objectName}_HDRS
|
||||
${${objectName}_HDRS}
|
||||
./ringbuffer.h
|
||||
./band-handler.h
|
||||
./dab_tables.h
|
||||
./service-printer.h
|
||||
../dab-api.h
|
||||
../devices/device-handler.h
|
||||
../library/includes/dab-constants.h
|
||||
../library/includes/dab-processor.h
|
||||
../library/includes/ofdm/phasereference.h
|
||||
../library/includes/ofdm/phasetable.h
|
||||
../library/includes/ofdm/freq-interleaver.h
|
||||
../library/includes/ofdm/timesyncer.h
|
||||
../library/includes/ofdm/fic-handler.h
|
||||
../library/includes/ofdm/fib-processor.cpp
|
||||
../library/includes/ofdm/sample-reader.h
|
||||
../library/includes/backend/firecode-checker.h
|
||||
../library/includes/backend/backend-base.h
|
||||
../library/includes/backend/charsets.h
|
||||
../library/includes/backend/galois.h
|
||||
../library/includes/backend/reed-solomon.h
|
||||
../library/includes/backend/msc-handler.h
|
||||
../library/includes/backend/virtual-backend.h
|
||||
../library/includes/backend/audio-backend.h
|
||||
../library/includes/backend/data-backend.h
|
||||
../library/includes/backend/audio/faad-decoder.h
|
||||
../library/includes/backend/audio/mp4processor.h
|
||||
../library/includes/backend/audio/mp2processor.h
|
||||
../library/includes/backend/data/virtual-datahandler.h
|
||||
../library/includes/backend/data/tdc-datahandler.h
|
||||
../library/includes/backend/data/pad-handler.h
|
||||
../library/includes/backend/data/data-processor.h
|
||||
../library/includes/backend/data/mot/mot-handler.h
|
||||
../library/includes/backend/data/mot/mot-dir.h
|
||||
../library/includes/backend/data/mot/mot-object.h
|
||||
../library/includes/support/viterbi_768/viterbi-768.h
|
||||
../library/includes/support/protTables.h
|
||||
../library/includes/support/protection.h
|
||||
../library/includes/support/uep-protection.h
|
||||
../library/includes/support/eep-protection.h
|
||||
../library/includes/support/fft_handler.h
|
||||
../library/includes/support/dab-params.h
|
||||
../library/includes/support/tii_table.h
|
||||
)
|
||||
|
||||
set (${objectName}_SRCS
|
||||
${${objectName}_SRCS}
|
||||
./main.cpp
|
||||
./band-handler.cpp
|
||||
./dab_tables.cpp
|
||||
./service-printer.cpp
|
||||
../devices/device-handler.cpp
|
||||
../library/dab-api.cpp
|
||||
../library/src/dab-processor.cpp
|
||||
../library/src/ofdm/ofdm-decoder.cpp
|
||||
../library/src/ofdm/phasereference.cpp
|
||||
../library/src/ofdm/phasetable.cpp
|
||||
../library/src/ofdm/freq-interleaver.cpp
|
||||
../library/src/ofdm/timesyncer.cpp
|
||||
../library/src/ofdm/sample-reader.cpp
|
||||
../library/src/ofdm/fib-processor.cpp
|
||||
../library/src/ofdm/fic-handler.cpp
|
||||
../library/src/backend/firecode-checker.cpp
|
||||
../library/src/backend/backend-base.cpp
|
||||
../library/src/backend/charsets.cpp
|
||||
../library/src/backend/galois.cpp
|
||||
../library/src/backend/reed-solomon.cpp
|
||||
../library/src/backend/msc-handler.cpp
|
||||
../library/src/backend/virtual-backend.cpp
|
||||
../library/src/backend/audio-backend.cpp
|
||||
../library/src/backend/data-backend.cpp
|
||||
../library/src/backend/audio/mp4processor.cpp
|
||||
../library/src/backend/audio/mp2processor.cpp
|
||||
../library/src/backend/data/virtual-datahandler.cpp
|
||||
../library/src/backend/data/tdc-datahandler.cpp
|
||||
../library/src/backend/data/pad-handler.cpp
|
||||
../library/src/backend/data/data-processor.cpp
|
||||
../library/src/backend/data/mot/mot-handler.cpp
|
||||
../library/src/backend/data/mot/mot-dir.cpp
|
||||
../library/src/backend/data/mot/mot-object.cpp
|
||||
../library/src/support/viterbi_768/viterbi-768.cpp
|
||||
../library/src/support/viterbi_768/spiral-no-sse.c
|
||||
../library/src/support/protTables.cpp
|
||||
../library/src/support/protection.cpp
|
||||
../library/src/support/eep-protection.cpp
|
||||
../library/src/support/uep-protection.cpp
|
||||
../library/src/support/fft_handler.cpp
|
||||
../library/src/support/dab-params.cpp
|
||||
../library/src/support/tii_table.cpp
|
||||
)
|
||||
#
|
||||
include_directories (
|
||||
${FFTW_INCLUDE_DIRS}
|
||||
${PORTAUDIO_INCLUDE_DIRS}
|
||||
${FAAD_INCLUDE_DIRS}
|
||||
${SNDFILES_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#####################################################################
|
||||
|
||||
add_executable (${objectName}
|
||||
${${objectName}_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries (${objectName}
|
||||
${FFTW3F_LIBRARIES}
|
||||
${extraLibs}
|
||||
${FAAD_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
|
||||
INSTALL (TARGETS ${objectName} DESTINATION .)
|
||||
|
||||
########################################################################
|
||||
# Create uninstall target
|
||||
########################################################################
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
25
dab-scanner/README
Normal file
25
dab-scanner/README
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
dab-scanner-xxx
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||

|
||||
|
||||
dab-scanner-xxx is a simple command line program, based on the DAB library.
|
||||
It will perform a scan over all channels in the selected band and
|
||||
- for those channels where DAB signals are identifier - list the
|
||||
contents in a format compatible with input for excel.
|
||||
|
||||
The input device is fixed, depends on the setting in the CMakeLists.txt
|
||||
file. The output is either to the terminal or written onto a file.
|
||||
(-F option).
|
||||
|
||||
All callbacks are defined, most of them with an empty body.
|
||||
|
||||
See the file main.cpp for the command line options
|
||||
|
||||
FEEL FREE TO IMPROVE THE PROGRAM
|
||||
|
141
dab-scanner/band-handler.cpp
Normal file
141
dab-scanner/band-handler.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
#
|
||||
/*
|
||||
* Copyright (C) 2013, 2014, 2015, 2016, 2017
|
||||
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
||||
* Lazy Chair Computing
|
||||
*
|
||||
* This file is part of the DAB library
|
||||
*
|
||||
* DAB library 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DAB library 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 DAB library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "band-handler.h"
|
||||
|
||||
struct dabFrequencies {
|
||||
const char *key;
|
||||
int fKHz;
|
||||
};
|
||||
|
||||
static
|
||||
struct dabFrequencies bandIII_frequencies [] = {
|
||||
{"5A", 174928},
|
||||
{"5B", 176640},
|
||||
{"5C", 178352},
|
||||
{"5D", 180064},
|
||||
{"6A", 181936},
|
||||
{"6B", 183648},
|
||||
{"6C", 185360},
|
||||
{"6D", 187072},
|
||||
{"7A", 188928},
|
||||
{"7B", 190640},
|
||||
{"7C", 192352},
|
||||
{"7D", 194064},
|
||||
{"8A", 195936},
|
||||
{"8B", 197648},
|
||||
{"8C", 199360},
|
||||
{"8D", 201072},
|
||||
{"9A", 202928},
|
||||
{"9B", 204640},
|
||||
{"9C", 206352},
|
||||
{"9D", 208064},
|
||||
{"10A", 209936},
|
||||
{"10B", 211648},
|
||||
{"10C", 213360},
|
||||
{"10D", 215072},
|
||||
{"11A", 216928},
|
||||
{"11B", 218640},
|
||||
{"11C", 220352},
|
||||
{"11D", 222064},
|
||||
{"12A", 223936},
|
||||
{"12B", 225648},
|
||||
{"12C", 227360},
|
||||
{"12D", 229072},
|
||||
{"13A", 230748},
|
||||
{"13B", 232496},
|
||||
{"13C", 234208},
|
||||
{"13D", 235776},
|
||||
{"13E", 237488},
|
||||
{"13F", 239200},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static
|
||||
struct dabFrequencies Lband_frequencies [] = {
|
||||
{"LA", 1452960},
|
||||
{"LB", 1454672},
|
||||
{"LC", 1456384},
|
||||
{"LD", 1458096},
|
||||
{"LE", 1459808},
|
||||
{"LF", 1461520},
|
||||
{"LG", 1463232},
|
||||
{"LH", 1464944},
|
||||
{"LI", 1466656},
|
||||
{"LJ", 1468368},
|
||||
{"LK", 1470080},
|
||||
{"LL", 1471792},
|
||||
{"LM", 1473504},
|
||||
{"LN", 1475216},
|
||||
{"LO", 1476928},
|
||||
{"LP", 1478640},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
bandHandler::bandHandler (void) {}
|
||||
bandHandler::~bandHandler (void) {}
|
||||
|
||||
// find the frequency for a given channel in a given band
|
||||
int32_t bandHandler::Frequency (uint8_t dabBand, std::string Channel) {
|
||||
int32_t tunedFrequency = 0;
|
||||
struct dabFrequencies *finger;
|
||||
int i;
|
||||
|
||||
if (dabBand == BAND_III)
|
||||
finger = bandIII_frequencies;
|
||||
else
|
||||
finger = Lband_frequencies;
|
||||
|
||||
for (i = 0; finger [i]. key != NULL; i ++) {
|
||||
if (finger [i]. key == Channel) {
|
||||
tunedFrequency = finger [i]. fKHz * 1000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tunedFrequency == 0)
|
||||
tunedFrequency = finger [0]. fKHz * 1000;
|
||||
|
||||
return tunedFrequency;
|
||||
}
|
||||
|
||||
std::string bandHandler::nextChannel (uint8_t dabBand, std::string Channel) {
|
||||
struct dabFrequencies *finger;
|
||||
int i;
|
||||
|
||||
if (dabBand == BAND_III)
|
||||
finger = bandIII_frequencies;
|
||||
else
|
||||
finger = Lband_frequencies;
|
||||
|
||||
for (i = 0; finger [i]. key != NULL; i ++) {
|
||||
if (finger [i]. key == Channel) {
|
||||
if (finger [i + 1]. key == NULL)
|
||||
return finger [0]. key;
|
||||
else
|
||||
return finger [i + 1]. key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
dab-scanner/band-handler.h
Normal file
43
dab-scanner/band-handler.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
/*
|
||||
* Copyright (C) 2013, 2014, 2015, 2016, 2017
|
||||
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
||||
* Lazy Chair Computing
|
||||
*
|
||||
* This file is part of the Qt-DAB program
|
||||
* Qt-DAB 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Qt-DAB 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 Qt-DAB; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __BANDHANDLER__
|
||||
#define __BANDHANDLER__
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
//
|
||||
// a simple convenience class
|
||||
//
|
||||
|
||||
#define BAND_III 0100
|
||||
#define L_BAND 0101
|
||||
|
||||
class bandHandler {
|
||||
public:
|
||||
bandHandler (void);
|
||||
~bandHandler (void);
|
||||
int32_t Frequency (uint8_t band, std::string Channel);
|
||||
std::string nextChannel (uint8_t dabBand, std::string Channel);
|
||||
|
||||
};
|
||||
#endif
|
||||
|
41
dab-scanner/cmake/Modules/FindFFTW3f.cmake
Normal file
41
dab-scanner/cmake/Modules/FindFFTW3f.cmake
Normal file
@@ -0,0 +1,41 @@
|
||||
# http://tim.klingt.org/code/projects/supernova/repository/revisions/d336dd6f400e381bcfd720e96139656de0c53b6a/entry/cmake_modules/FindFFTW3f.cmake
|
||||
# Modified to use pkg config and use standard var names
|
||||
|
||||
# Find single-precision (float) version of FFTW3
|
||||
|
||||
INCLUDE(FindPkgConfig)
|
||||
PKG_CHECK_MODULES(PC_FFTW3F "fftw3f >= 3.0")
|
||||
|
||||
FIND_PATH(
|
||||
FFTW3F_INCLUDE_DIRS
|
||||
NAMES fftw3.h
|
||||
HINTS $ENV{FFTW3_DIR}/include
|
||||
${PC_FFTW3F_INCLUDE_DIR}
|
||||
PATHS /usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(
|
||||
FFTW3F_LIBRARIES
|
||||
NAMES fftw3f libfftw3f
|
||||
HINTS $ENV{FFTW3_DIR}/lib
|
||||
${PC_FFTW3F_LIBDIR}
|
||||
PATHS /usr/local/lib
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
)
|
||||
|
||||
FIND_LIBRARY(
|
||||
FFTW3F_THREADS_LIBRARIES
|
||||
NAMES fftw3f_threads libfftw3f_threads
|
||||
HINTS $ENV{FFTW3_DIR}/lib
|
||||
${PC_FFTW3F_LIBDIR}
|
||||
PATHS /usr/local/lib
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
)
|
||||
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFTW3F DEFAULT_MSG FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIRS)
|
||||
MARK_AS_ADVANCED(FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIRS FFTW3F_THREADS_LIBRARIES)
|
34
dab-scanner/cmake/Modules/FindFaad.cmake
Normal file
34
dab-scanner/cmake/Modules/FindFaad.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
# Try to find FAAD library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# FAAD_INCLUDE_DIRS - where to find faad.h, etc.
|
||||
# FAAD_LIBRARIES - List of libraries when using libfaad.
|
||||
# FAAD_FOUND - True if libfaad found.
|
||||
|
||||
find_path(FAAD_INCLUDE_DIR faad.h DOC "The directory where faad.h resides")
|
||||
find_library(FAAD_LIBRARY NAMES faad DOC "The libfaad library")
|
||||
|
||||
if(FAAD_INCLUDE_DIR AND FAAD_LIBRARY)
|
||||
set(FAAD_FOUND 1)
|
||||
set(FAAD_LIBRARIES ${FAAD_LIBRARY})
|
||||
set(FAAD_INCLUDE_DIRS ${FAAD_INCLUDE_DIR})
|
||||
else(FAAD_INCLUDE_DIR AND FAAD_LIBRARY)
|
||||
set(FAAD_FOUND 0)
|
||||
set(FAAD_LIBRARIES)
|
||||
set(FAAD_INCLUDE_DIRS)
|
||||
endif(FAAD_INCLUDE_DIR AND FAAD_LIBRARY)
|
||||
|
||||
mark_as_advanced(FAAD_INCLUDE_DIR)
|
||||
mark_as_advanced(FAAD_LIBRARY)
|
||||
mark_as_advanced(FAAD_FOUND)
|
||||
|
||||
if(NOT FAAD_FOUND)
|
||||
set(FAAD_DIR_MESSAGE "libfaad was not found. Make sure FAAD_LIBRARY and FAAD_INCLUDE_DIR are set.")
|
||||
if(NOT FAAD_FIND_QUIETLY)
|
||||
message(STATUS "${FAAD_DIR_MESSAGE}")
|
||||
else(NOT FAAD_FIND_QUIETLY)
|
||||
if(FAAD_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "${FAAD_DIR_MESSAGE}")
|
||||
endif(FAAD_FIND_REQUIRED)
|
||||
endif(NOT FAAD_FIND_QUIETLY)
|
||||
endif(NOT FAAD_FOUND)
|
28
dab-scanner/cmake/Modules/FindLibAIRSPY.cmake
Normal file
28
dab-scanner/cmake/Modules/FindLibAIRSPY.cmake
Normal file
@@ -0,0 +1,28 @@
|
||||
if(NOT LIBAIRSPY_FOUND)
|
||||
|
||||
pkg_check_modules (LIBAIRSPY_PKG libairspy)
|
||||
find_path(LIBAIRSPY_INCLUDE_DIR NAMES libairspy/airspy.h
|
||||
PATHS
|
||||
${LIBAIRSPY_PKG_INCLUDE_DIRS}
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
)
|
||||
|
||||
find_library(LIBAIRSPY_LIBRARIES NAMES airspy
|
||||
PATHS
|
||||
${LIBAIRSPY_PKG_LIBRARY_DIRS}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
)
|
||||
|
||||
if(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
|
||||
set(LIBAIRSPY_FOUND TRUE CACHE INTERNAL "libairspy found")
|
||||
message(STATUS "Found libairspy: ${LIBAIRSPY_INCLUDE_DIR}, ${LIBAIRSPY_LIBRARIES}")
|
||||
else(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
|
||||
set(LIBAIRSPY_FOUND FALSE CACHE INTERNAL "libairspy found")
|
||||
message(STATUS "libairspy not found.")
|
||||
endif(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
|
||||
|
||||
mark_as_advanced(LIBAIRSPY_INCLUDE_DIR LIBAIRSPY_LIBRARIES)
|
||||
|
||||
endif(NOT LIBAIRSPY_FOUND)
|
28
dab-scanner/cmake/Modules/FindLibRTLSDR.cmake
Normal file
28
dab-scanner/cmake/Modules/FindLibRTLSDR.cmake
Normal file
@@ -0,0 +1,28 @@
|
||||
if(NOT LIBRTLSDR_FOUND)
|
||||
|
||||
pkg_check_modules (LIBRTLSDR_PKG librtlsdr)
|
||||
find_path(LIBRTLSDR_INCLUDE_DIR NAMES rtl-sdr.h
|
||||
PATHS
|
||||
${LIBRTLSDR_PKG_INCLUDE_DIRS}
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
)
|
||||
|
||||
find_library(LIBRTLSDR_LIBRARIES NAMES rtlsdr
|
||||
PATHS
|
||||
${LIBRTLSDR_PKG_LIBRARY_DIRS}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
)
|
||||
|
||||
if(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
|
||||
set(LIBRTLSDR_FOUND TRUE CACHE INTERNAL "librtlsdr found")
|
||||
message(STATUS "Found librtlsdr: ${LIBRTLSDR_INCLUDE_DIR}, ${LIBRTLSDR_LIBRARIES}")
|
||||
else(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
|
||||
set(LIBRTLSDR_FOUND FALSE CACHE INTERNAL "librtlsdr found")
|
||||
message(STATUS "librtlsdr not found.")
|
||||
endif(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
|
||||
|
||||
mark_as_advanced(LIBRTLSDR_INCLUDE_DIR LIBRTLSDR_LIBRARIES)
|
||||
|
||||
endif(NOT LIBRTLSDR_FOUND)
|
20
dab-scanner/cmake/Modules/FindLibSampleRate.cmake
Normal file
20
dab-scanner/cmake/Modules/FindLibSampleRate.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Find libsamplerate
|
||||
|
||||
FIND_PATH(LIBSAMPLERATE_INCLUDE_DIR samplerate.h)
|
||||
|
||||
SET(LIBSAMPLERATE_NAMES ${LIBSAMPLERATE_NAMES} samplerate libsamplerate)
|
||||
FIND_LIBRARY(LIBSAMPLERATE_LIBRARY NAMES ${LIBSAMPLERATE_NAMES} PATH)
|
||||
|
||||
IF (LIBSAMPLERATE_INCLUDE_DIR AND LIBSAMPLERATE_LIBRARY)
|
||||
SET(LIBSAMPLERATE_FOUND TRUE)
|
||||
ENDIF (LIBSAMPLERATE_INCLUDE_DIR AND LIBSAMPLERATE_LIBRARY)
|
||||
|
||||
IF (LIBSAMPLERATE_FOUND)
|
||||
IF (NOT LibSampleRate_FIND_QUIETLY)
|
||||
MESSAGE (STATUS "Found LibSampleRate: ${LIBSNDFILE_LIBRARY}")
|
||||
ENDIF (NOT LibSampleRate_FIND_QUIETLY)
|
||||
ELSE (LIBSAMPLERATE_FOUND)
|
||||
IF (LibSampleRate_FIND_REQUIRED)
|
||||
MESSAGE (FATAL_ERROR "Could not find samplerate")
|
||||
ENDIF (LibSampleRate_FIND_REQUIRED)
|
||||
ENDIF (LIBSAMPLERATE_FOUND)
|
20
dab-scanner/cmake/Modules/FindLibSndFile.cmake
Normal file
20
dab-scanner/cmake/Modules/FindLibSndFile.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Find libsndfile
|
||||
|
||||
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)
|
||||
|
||||
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile)
|
||||
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)
|
||||
|
||||
IF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
|
||||
SET(LIBSNDFILE_FOUND TRUE)
|
||||
ENDIF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
|
||||
|
||||
IF (LIBSNDFILE_FOUND)
|
||||
IF (NOT LibSndFile_FIND_QUIETLY)
|
||||
MESSAGE (STATUS "Found LibSndFile: ${LIBSNDFILE_LIBRARY}")
|
||||
ENDIF (NOT LibSndFile_FIND_QUIETLY)
|
||||
ELSE (LIBSNDFILE_FOUND)
|
||||
IF (LibSndFile_FIND_REQUIRED)
|
||||
MESSAGE (FATAL_ERROR "Could not find sndfile")
|
||||
ENDIF (LibSndFile_FIND_REQUIRED)
|
||||
ENDIF (LIBSNDFILE_FOUND)
|
52
dab-scanner/cmake/Modules/FindPortaudio.cmake
Normal file
52
dab-scanner/cmake/Modules/FindPortaudio.cmake
Normal file
@@ -0,0 +1,52 @@
|
||||
# - Try to find Portaudio
|
||||
# Once done this will define
|
||||
#
|
||||
# PORTAUDIO_FOUND - system has Portaudio
|
||||
# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory
|
||||
# PORTAUDIO_LIBRARIES - Link these to use Portaudio
|
||||
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(PC_PORTAUDIO portaudio-2.0)
|
||||
|
||||
find_path(PORTAUDIO_INCLUDE_DIRS
|
||||
NAMES
|
||||
portaudio.h
|
||||
PATHS
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
HINTS
|
||||
${PC_PORTAUDIO_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(PORTAUDIO_LIBRARIES
|
||||
NAMES
|
||||
portaudio
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
HINTS
|
||||
${PC_PORTAUDIO_LIBDIR}
|
||||
)
|
||||
|
||||
mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
|
||||
|
||||
# Found PORTAUDIO, but it may be version 18 which is not acceptable.
|
||||
if(EXISTS ${PORTAUDIO_INCLUDE_DIRS}/portaudio.h)
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_INCLUDES_SAVED ${CMAKE_REQUIRED_INCLUDES})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${PORTAUDIO_INCLUDE_DIRS})
|
||||
CHECK_CXX_SOURCE_COMPILES(
|
||||
"#include <portaudio.h>\nPaDeviceIndex pa_find_device_by_name(const char *name); int main () {return 0;}"
|
||||
PORTAUDIO2_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVED})
|
||||
unset(CMAKE_REQUIRED_INCLUDES_SAVED)
|
||||
if(PORTAUDIO2_FOUND)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PORTAUDIO DEFAULT_MSG PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
|
||||
else(PORTAUDIO2_FOUND)
|
||||
message(STATUS
|
||||
" portaudio.h not compatible (requires API 2.0)")
|
||||
set(PORTAUDIO_FOUND FALSE)
|
||||
endif(PORTAUDIO2_FOUND)
|
||||
endif()
|
64
dab-scanner/cmake/Modules/FindQwt.cmake
Normal file
64
dab-scanner/cmake/Modules/FindQwt.cmake
Normal file
@@ -0,0 +1,64 @@
|
||||
# - try to find Qwt libraries and include files
|
||||
# QWT_INCLUDE_DIR where to find qwt_global.h, etc.
|
||||
# QWT_LIBRARIES libraries to link against
|
||||
# QWT_FOUND If false, do not try to use Qwt
|
||||
# qwt_global.h holds a string with the QWT version;
|
||||
# test to make sure it's at least 5.2
|
||||
|
||||
find_path(QWT_INCLUDE_DIRS
|
||||
NAMES qwt_global.h
|
||||
HINTS
|
||||
${CMAKE_INSTALL_PREFIX}/include/qwt
|
||||
PATHS
|
||||
/usr/local/include/qwt-qt4
|
||||
/usr/local/include/qwt
|
||||
/usr/include/qwt6
|
||||
/usr/include/qwt-qt4
|
||||
/usr/include/qwt-qt4
|
||||
/usr/include/qwt
|
||||
/usr/include/qwt5
|
||||
/usr/include/qwt6-qt5
|
||||
/opt/local/include/qwt
|
||||
/sw/include/qwt
|
||||
/usr/local/lib/qwt.framework/Headers
|
||||
)
|
||||
|
||||
find_library (QWT_LIBRARIES
|
||||
NAMES qwt6 qwt6-qt5 qwt-qt5 qwt6-qt4 qwt qwt-qt4
|
||||
HINTS
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
${CMAKE_INSTALL_PREFIX}/lib64
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
/usr/local/lib/qwt.framework
|
||||
)
|
||||
|
||||
set(QWT_FOUND FALSE)
|
||||
if(QWT_INCLUDE_DIRS)
|
||||
file(STRINGS "${QWT_INCLUDE_DIRS}/qwt_global.h"
|
||||
QWT_STRING_VERSION REGEX "QWT_VERSION_STR")
|
||||
set(QWT_WRONG_VERSION True)
|
||||
set(QWT_VERSION "No Version")
|
||||
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" QWT_VERSION ${QWT_STRING_VERSION})
|
||||
string(COMPARE LESS ${QWT_VERSION} "5.2.0" QWT_WRONG_VERSION)
|
||||
string(COMPARE GREATER ${QWT_VERSION} "6.2.0" QWT_WRONG_VERSION)
|
||||
|
||||
message(STATUS "QWT Version: ${QWT_VERSION}")
|
||||
if(NOT QWT_WRONG_VERSION)
|
||||
set(QWT_FOUND TRUE)
|
||||
else(NOT QWT_WRONG_VERSION)
|
||||
message(STATUS "QWT Version must be >= 5.2 and <= 6.2.0, Found ${QWT_VERSION}")
|
||||
endif(NOT QWT_WRONG_VERSION)
|
||||
|
||||
endif(QWT_INCLUDE_DIRS)
|
||||
|
||||
if(QWT_FOUND)
|
||||
# handle the QUIETLY and REQUIRED arguments and set QWT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include ( FindPackageHandleStandardArgs )
|
||||
find_package_handle_standard_args( Qwt DEFAULT_MSG QWT_LIBRARIES QWT_INCLUDE_DIRS )
|
||||
MARK_AS_ADVANCED(QWT_LIBRARIES QWT_INCLUDE_DIRS)
|
||||
endif(QWT_FOUND)
|
20
dab-scanner/cmake/Modules/Findzlib.cmake
Normal file
20
dab-scanner/cmake/Modules/Findzlib.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Find zlib
|
||||
|
||||
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
|
||||
|
||||
SET(ZLIB_NAMES ${ZLIB_NAMES} libz z)
|
||||
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} PATH)
|
||||
|
||||
IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
|
||||
SET(ZLIB_FOUND TRUE)
|
||||
ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
|
||||
|
||||
IF (ZLIB_FOUND)
|
||||
IF (NOT zlib_FIND_QUIETLY)
|
||||
MESSAGE (STATUS "Found zlib: ${ZLIBFILE_LIBRARY}")
|
||||
ENDIF (NOT zlib_FIND_QUIETLY)
|
||||
ELSE (ZLIB_FOUND)
|
||||
IF (zlib_FIND_REQUIRED)
|
||||
MESSAGE (FATAL_ERROR "Could not find zlib")
|
||||
ENDIF (zlib_FIND_REQUIRED)
|
||||
ENDIF (ZLIB_FOUND)
|
21
dab-scanner/cmake/cmake_uninstall.cmake.in
Normal file
21
dab-scanner/cmake/cmake_uninstall.cmake.in
Normal file
@@ -0,0 +1,21 @@
|
||||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
673
dab-scanner/dab_tables.cpp
Normal file
673
dab-scanner/dab_tables.cpp
Normal file
@@ -0,0 +1,673 @@
|
||||
#
|
||||
/*
|
||||
* Copyright (C) 2018
|
||||
* Hayati Ayguen (h_ayguen@web.de)
|
||||
*
|
||||
* DAB-library 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DAB-library 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 DAB-library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "dab_tables.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
// ETSI TS 101 756 V2.2.1: Registered Tables
|
||||
// for Extended Country Code, Country Id, Language Code,
|
||||
// Program Type, User Application Type, Content Type
|
||||
// https://www.etsi.org/deliver/etsi_ts/101700_101799/101756/02.02.01_60/ts_101756v020201p.pdf
|
||||
|
||||
// ETSI TR 101 496-3 V1.1.2
|
||||
// protection level/classes, ..
|
||||
// https://www.etsi.org/deliver/etsi_tr/101400_101499/10149603/01.01.02_60/tr_10149603v010102p.pdf
|
||||
|
||||
static const char *uep_rates [] = {"7/20", "2/5", "1/2", "3/5"};
|
||||
static const char *eep_Arates[] = {"1/4", "3/8", "1/2", "3/4"}; // see ETSI EN 300 401 V1.3.2 (2000-09), Table 8, page 46
|
||||
static const char *eep_Brates[] = {"4/9", "4/7", "4/6", "4/5"}; // see ETSI EN 300 401 V1.3.2 (2000-09), Table 9, page 46
|
||||
|
||||
|
||||
struct country_codes {
|
||||
uint8_t ecc;
|
||||
uint8_t countryId;
|
||||
const char *countryName;
|
||||
};
|
||||
|
||||
// following countryTable[] is sorted over all regions to make
|
||||
// it easier to find "missing" / "old" but still unused entries.
|
||||
// achieved by searching old standard tables document for each ECC code.
|
||||
// Table 3: ITU Region 1 - European broadcasting area
|
||||
// Table 4: ITU Region 1 - African broadcasting area
|
||||
// Table 6: ITU Region 2 - North and South Americas
|
||||
// Table 7: ITU Region 3 - Asia and Pacific
|
||||
|
||||
static country_codes countryTable[] = {
|
||||
{0xA0, 0x1, "United States of America"},
|
||||
{0xA0, 0x2, "United States of America"},
|
||||
{0xA0, 0x3, "United States of America"},
|
||||
{0xA0, 0x4, "United States of America"},
|
||||
{0xA0, 0x5, "United States of America"},
|
||||
{0xA0, 0x6, "United States of America"},
|
||||
{0xA0, 0x7, "United States of America"},
|
||||
{0xA0, 0x8, "United States of America"},
|
||||
{0xA0, 0x9, "United States of America"},
|
||||
{0xA0, 0xA, "United States of America"},
|
||||
{0xA0, 0xB, "United States of America"},
|
||||
{0xA0, 0xC, "United States of America"},
|
||||
{0xA0, 0xD, "United States of America"},
|
||||
{0xA0, 0xE, "United States of America"},
|
||||
|
||||
{0xA1, 0xC, "Canada"},
|
||||
{0xA1, 0xF, "Greenland"},
|
||||
|
||||
{0xA2, 0x1, "Anguilla"},
|
||||
{0xA2, 0x2, "Antigua and Barbuda"},
|
||||
{0xA2, 0x3, "Equador"},
|
||||
{0xA2, 0x4, "Falkland Islands"},
|
||||
{0xA2, 0x5, "Barbados"},
|
||||
{0xA2, 0x6, "Belize"},
|
||||
{0xA2, 0x7, "Cayman Islands"},
|
||||
{0xA2, 0x8, "Costa Rica"},
|
||||
{0xA2, 0x9, "Cuba"},
|
||||
{0xA2, 0xA, "Argentina"},
|
||||
{0xA2, 0xB, "Brazil"},
|
||||
{0xA2, 0xC, "Bermuda"},
|
||||
{0xA2, 0xD, "Netherlands Antilles"},
|
||||
{0xA2, 0xE, "Guadeloupe"},
|
||||
{0xA2, 0xF, "Bahamas"},
|
||||
|
||||
{0xA3, 0x1, "Bolivia"},
|
||||
{0xA3, 0x2, "Colombia"},
|
||||
{0xA3, 0x3, "Jamaica"},
|
||||
{0xA3, 0x4, "Martinique"},
|
||||
{0xA3, 0x6, "Paraguay"},
|
||||
{0xA3, 0x7, "Nicaragua"},
|
||||
{0xA3, 0x8, "Puerto Rico"},
|
||||
{0xA3, 0x9, "Panama"},
|
||||
{0xA3, 0xA, "Dominica"},
|
||||
{0xA3, 0xB, "Dominican Republic"},
|
||||
{0xA3, 0xC, "Chile"},
|
||||
{0xA3, 0xD, "Grenada"},
|
||||
{0xA3, 0xE, "Turks and Caicos islands"},
|
||||
{0xA3, 0xF, "Guyana"},
|
||||
|
||||
{0xA4, 0x1, "Guatemala"},
|
||||
{0xA4, 0x2, "Honduras"},
|
||||
{0xA4, 0x3, "Aruba"},
|
||||
{0xA4, 0x5, "Montserrat"},
|
||||
{0xA4, 0x6, "Trinidad and Tobago"},
|
||||
{0xA4, 0x7, "Peru"},
|
||||
{0xA4, 0x8, "Surinam"},
|
||||
{0xA4, 0x9, "Uruguay"},
|
||||
{0xA4, 0xA, "St. Kitts"},
|
||||
{0xA4, 0xB, "St. Lucia"},
|
||||
{0xA4, 0xC, "El Salvador"},
|
||||
{0xA4, 0xD, "Haiti"},
|
||||
{0xA4, 0xE, "Venezuela"},
|
||||
{0xA4, 0xF, "Mexico"},
|
||||
|
||||
{0xA5, 0xC, "St. Vincent"},
|
||||
{0xA5, 0xF, "Virgin islands (British or USA)"}, // British and USA have same IDs! amended "or USA"
|
||||
{0xA5, 0xF, "Virgin islands (USA)"}, // keep this entry .. doesn't hurt
|
||||
|
||||
{0xA6, 0xF, "St. Pierre and Miquelon"},
|
||||
|
||||
{0xD0, 0x1, "Cameroon"},
|
||||
{0xD0, 0x2, "Central African Republic"},
|
||||
{0xD0, 0x3, "Djibouti"},
|
||||
{0xD0, 0x4, "Madagascar"},
|
||||
{0xD0, 0x5, "Mali"},
|
||||
{0xD0, 0x6, "Angola"},
|
||||
{0xD0, 0x7, "Equatorial Guinea"},
|
||||
{0xD0, 0x8, "Gabon"},
|
||||
{0xD0, 0x9, "Republic of Guinea"},
|
||||
{0xD0, 0xA, "South Africa"},
|
||||
{0xD0, 0xB, "Burkina Faso"},
|
||||
{0xD0, 0xC, "Congo"},
|
||||
{0xD0, 0xD, "Togo"},
|
||||
{0xD0, 0xE, "Benin"},
|
||||
{0xD0, 0xF, "Malawi"},
|
||||
|
||||
{0xD1, 0x1, "Namibia"},
|
||||
{0xD1, 0x2, "Liberia"},
|
||||
{0xD1, 0x3, "Ghana"},
|
||||
{0xD1, 0x4, "Mauritania"},
|
||||
{0xD1, 0x5, "Sao Tome & Principe"},
|
||||
{0xD1, 0x6, "Cape Verde"},
|
||||
{0xD1, 0x7, "Senegal"},
|
||||
{0xD1, 0x8, "Gambia"},
|
||||
{0xD1, 0x9, "Burundi"},
|
||||
{0xD1, 0xA, "Ascension island"},
|
||||
{0xD1, 0xB, "Botswana"},
|
||||
{0xD1, 0xC, "Comoros"},
|
||||
{0xD1, 0xD, "Tanzania"},
|
||||
{0xD1, 0xE, "Ethiopia"},
|
||||
{0xD1, 0xF, "Nigeria"},
|
||||
|
||||
{0xD2, 0x1, "Sierra Leone"},
|
||||
{0xD2, 0x2, "Zimbabwe"},
|
||||
{0xD2, 0x3, "Mozambique"},
|
||||
{0xD2, 0x4, "Uganda"},
|
||||
{0xD2, 0x5, "Swaziland"},
|
||||
{0xD2, 0x6, "Kenya"},
|
||||
{0xD2, 0x7, "Somalia"},
|
||||
{0xD2, 0x8, "Niger"},
|
||||
{0xD2, 0x9, "Chad"},
|
||||
{0xD2, 0xA, "Guinea-Bissau"},
|
||||
{0xD2, 0xB, "Zaire"},
|
||||
{0xD2, 0xC, "Cote d'Ivoire"},
|
||||
{0xD2, 0xD, "Zanzibar"},
|
||||
{0xD2, 0xE, "Zambia"},
|
||||
|
||||
{0xD3, 0x3, "Western Sahara"},
|
||||
{0xD3, 0x4, "Cabinda"}, // was in V1.4.1. was removed later. but IDs are unused .. so keep it here
|
||||
{0xD3, 0x5, "Rwanda"},
|
||||
{0xD3, 0x6, "Lesotho"},
|
||||
{0xD3, 0x8, "Seychelles"},
|
||||
{0xD3, 0xA, "Mauritius"},
|
||||
{0xD3, 0xC, "Sudan"},
|
||||
|
||||
{0xE0, 0x1, "Germany"},
|
||||
{0xE0, 0x2, "Algeria"},
|
||||
{0xE0, 0x3, "Andorra"},
|
||||
{0xE0, 0x4, "Israel"},
|
||||
{0xE0, 0x5, "Italy"},
|
||||
{0xE0, 0x6, "Belgium"},
|
||||
{0xE0, 0x7, "Russian Federation"},
|
||||
{0xE0, 0x8, "Azores (Portugal)"}, // was in V1.4.1. was removed later. but IDs are unused .. so keep it here
|
||||
{0xE0, 0x9, "Albania"},
|
||||
{0xE0, 0xA, "Austria"},
|
||||
{0xE0, 0xB, "Hungary"},
|
||||
{0xE0, 0xC, "Malta"},
|
||||
{0xE0, 0xD, "Germany"},
|
||||
{0xE0, 0xE, "Canary Islands (Spain)"}, // amended "(Spain)"
|
||||
{0xE0, 0xF, "Egypt"},
|
||||
|
||||
{0xE1, 0x1, "Greece"},
|
||||
{0xE1, 0x2, "Cyprus"},
|
||||
{0xE1, 0x3, "San Marino"},
|
||||
{0xE1, 0x4, "Switzerland"},
|
||||
{0xE1, 0x5, "Jordan"},
|
||||
{0xE1, 0x6, "Finland"},
|
||||
{0xE1, 0x7, "Luxembourg"},
|
||||
{0xE1, 0x8, "Bulgaria"},
|
||||
{0xE1, 0x9, "Faroe (Denmark)"},
|
||||
{0xE1, 0xA, "Gibraltar (UK)"}, // amended "(UK)"
|
||||
{0xE1, 0xB, "Iraq"},
|
||||
{0xE1, 0xC, "United Kingdom"},
|
||||
{0xE1, 0xD, "Libya"},
|
||||
{0xE1, 0xE, "Romania"},
|
||||
{0xE1, 0xF, "France"},
|
||||
|
||||
{0xE2, 0x1, "Marocco"},
|
||||
{0xE2, 0x2, "Czech Republic"},
|
||||
{0xE2, 0x3, "Poland"},
|
||||
{0xE2, 0x4, "Vatican"},
|
||||
{0xE2, 0x5, "Slovak Republic"},
|
||||
{0xE2, 0x6, "Syria"},
|
||||
{0xE2, 0x7, "Tunisia"},
|
||||
{0xE2, 0x8, "Madeira"}, // was in V1.4.1. was removed later. but IDs are unused .. so keep it here
|
||||
{0xE2, 0x9, "Liechtenstein"},
|
||||
{0xE2, 0xA, "Iceland"},
|
||||
{0xE2, 0xB, "Monaco"},
|
||||
{0xE2, 0xC, "Lithuania"},
|
||||
{0xE2, 0xD, "Serbia"},
|
||||
{0xE2, 0xE, "Spain"},
|
||||
{0xE2, 0xF, "Norway"},
|
||||
|
||||
{0xE3, 0x1, "Montenegro"},
|
||||
{0xE3, 0x2, "Ireland"},
|
||||
{0xE3, 0x3, "Turkey"},
|
||||
{0xE3, 0x4, "Macedonia"},
|
||||
{0xE3, 0x5, "Tajikistan"}, // was in V1.4.1. was removed later. but IDs are unused .. so keep it here
|
||||
{0xE3, 0x8, "Netherlands"},
|
||||
{0xE3, 0x9, "Latvia"},
|
||||
{0xE3, 0xA, "Lebanon"},
|
||||
{0xE3, 0xB, "Azerbaijan"}, // was in V1.4.1. was removed later. but IDs are unused .. so keep it here
|
||||
{0xE3, 0xC, "Croatia"},
|
||||
{0xE3, 0xD, "Kazakhstan"}, // was in V1.4.1. was removed later. but IDs are unused .. so keep it here
|
||||
{0xE3, 0xE, "Sweden"},
|
||||
{0xE3, 0xF, "Belarus"},
|
||||
|
||||
{0xE4, 0x1, "Moldova"},
|
||||
{0xE4, 0x2, "Estonia"},
|
||||
{0xE4, 0x3, "Macedonia / Kyrghyzstan"}, // amended "/ Kyrghyzstan" double used Id
|
||||
{0xE4, 0x3, "Kyrghyzstan"}, // keep this entry .. doesn't hurt
|
||||
{0xE4, 0x6, "Ukraine"},
|
||||
{0xE4, 0x7, "Kosovo"},
|
||||
{0xE4, 0x8, "Portugal"},
|
||||
{0xE4, 0x9, "Slovenia"},
|
||||
{0xE4, 0xA, "Armenia"},
|
||||
{0xE4, 0xB, "Uzbekistan"},
|
||||
{0xE4, 0xC, "Georgia"},
|
||||
{0xE4, 0xE, "Turkmenistan"},
|
||||
{0xE4, 0xF, "Bosnia Herzegovina"},
|
||||
|
||||
{0xF0, 0x1, "Australia: Capital Cities (commercial and community)"},
|
||||
{0xF0, 0x2, "Australia: New South Wales and ACT"},
|
||||
{0xF0, 0x3, "Australia: Capital Cities (national broadcasters, was Victoria)"},
|
||||
{0xF0, 0x4, "Australia: Queensland"},
|
||||
{0xF0, 0x5, "Australia: South and Northern Territory"},
|
||||
{0xF0, 0x6, "Australia: Western"},
|
||||
{0xF0, 0x7, "Australia: Victoria and Tasmania"},
|
||||
{0xF0, 0x8, "Australia: (future, was Northern Territory)"},
|
||||
{0xF0, 0x9, "Saudi Arabia"},
|
||||
{0xF0, 0xA, "Afghanistan"},
|
||||
{0xF0, 0xB, "Myanmar (Burma)"},
|
||||
{0xF0, 0xC, "China"},
|
||||
{0xF0, 0xD, "Korea (North)"},
|
||||
{0xF0, 0xE, "Bahrain"},
|
||||
{0xF0, 0xF, "Malaysia"},
|
||||
|
||||
{0xF1, 0x1, "Kiribati"},
|
||||
{0xF1, 0x2, "Bhutan"},
|
||||
{0xF1, 0x3, "Bangladesh"},
|
||||
{0xF1, 0x4, "Pakistan"},
|
||||
{0xF1, 0x5, "Fiji"},
|
||||
{0xF1, 0x6, "Oman"},
|
||||
{0xF1, 0x7, "Nauru"},
|
||||
{0xF1, 0x8, "Iran"},
|
||||
{0xF1, 0x9, "New Zealand"},
|
||||
{0xF1, 0xA, "Solomon Islands"},
|
||||
{0xF1, 0xB, "Brunei Darussalam"},
|
||||
{0xF1, 0xC, "Sri Lanka"},
|
||||
{0xF1, 0xD, "Taiwan"},
|
||||
{0xF1, 0xE, "Korea (South)"},
|
||||
{0xF1, 0xF, "Hong Kong"},
|
||||
|
||||
{0xF2, 0x1, "Kuwait"},
|
||||
{0xF2, 0x2, "Qatar"},
|
||||
{0xF2, 0x3, "Cambodia"},
|
||||
{0xF2, 0x4, "Western Samoa"},
|
||||
{0xF2, 0x5, "India"},
|
||||
{0xF2, 0x6, "Macau"},
|
||||
{0xF2, 0x7, "Vietnam"},
|
||||
{0xF2, 0x8, "Philippines"},
|
||||
{0xF2, 0x9, "Japan"},
|
||||
{0xF2, 0xA, "Singapore"},
|
||||
{0xF2, 0xB, "Maldives"},
|
||||
{0xF2, 0xC, "Indonesia"},
|
||||
{0xF2, 0xD, "United Arab Emirates"},
|
||||
{0xF2, 0xE, "Nepal"},
|
||||
{0xF2, 0xF, "Vanuatu"},
|
||||
|
||||
{0xF3, 0x1, "Laos"},
|
||||
{0xF3, 0x2, "Thailand"},
|
||||
{0xF3, 0x3, "Tonga"},
|
||||
{0xF3, 0x9, "Papua New Guinea"},
|
||||
{0xF3, 0xB, "Yemen"},
|
||||
{0xF3, 0xE, "Micronesia"},
|
||||
{0xF3, 0xF, "Mongolia"},
|
||||
|
||||
{0x00, 0x0, nullptr }
|
||||
};
|
||||
|
||||
// from Table 2a
|
||||
const char * getASCTy (int16_t ASCTy) {
|
||||
switch (ASCTy) {
|
||||
case 0: return "DAB";
|
||||
case 63: return "DAB+";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
// from Table 2b
|
||||
const char * getDSCTy (int16_t DSCTy) {
|
||||
switch (DSCTy) {
|
||||
case 1: return "Traffic Message CHannel (TMC)";
|
||||
case 2: return "Emergency Warning System (EWS)";
|
||||
case 3: return "Interactive Text Transmission System (ITTS)";
|
||||
case 4: return "Paging";
|
||||
case 5: return "Transparent Data Channel (TDC)";
|
||||
case 24: return "MPEG-2 Transport Stream";
|
||||
case 59: return "Embedded IP packets";
|
||||
case 60: return "Multimedia Object Transfer (MOT)";
|
||||
case 61: return "Proprietary service";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
// from Table 9 and 10
|
||||
const char * getLanguage (int16_t language) {
|
||||
switch (language) {
|
||||
case 0x00: return "Unknown/not applicable";
|
||||
case 0x01: return "Albanian";
|
||||
case 0x02: return "Breton";
|
||||
case 0x03: return "Catalan";
|
||||
case 0x04: return "Croatian";
|
||||
case 0x05: return "Welsh";
|
||||
case 0x06: return "Czech";
|
||||
case 0x07: return "Danish";
|
||||
case 0x08: return "German";
|
||||
case 0x09: return "English";
|
||||
case 0x0A: return "Spanish";
|
||||
case 0x0B: return "Esperanto";
|
||||
case 0x0C: return "Estonian";
|
||||
case 0x0D: return "Basque";
|
||||
case 0x0E: return "Faroese";
|
||||
case 0x0F: return "French";
|
||||
case 0x10: return "Frisian";
|
||||
case 0x11: return "Irish";
|
||||
case 0x12: return "Gaelic";
|
||||
case 0x13: return "Galician";
|
||||
case 0x14: return "Icelandic";
|
||||
case 0x15: return "Italian";
|
||||
case 0x16: return "Sami";
|
||||
case 0x17: return "Latin";
|
||||
case 0x18: return "Latvian";
|
||||
case 0x19: return "Luxembourgian";
|
||||
case 0x1A: return "Lithuanian";
|
||||
case 0x1B: return "Hungarian";
|
||||
case 0x1C: return "Maltese";
|
||||
case 0x1D: return "Dutch";
|
||||
case 0x1E: return "Norwegian";
|
||||
case 0x1F: return "Occitan";
|
||||
case 0x20: return "Polish";
|
||||
case 0x21: return "Portuguese";
|
||||
case 0x22: return "Romanian";
|
||||
case 0x23: return "Romansh";
|
||||
case 0x24: return "Serbian";
|
||||
case 0x25: return "Slovak";
|
||||
case 0x26: return "Slovene";
|
||||
case 0x27: return "Finnish";
|
||||
case 0x28: return "Swedish";
|
||||
case 0x29: return "Turkish";
|
||||
case 0x2A: return "Flemish";
|
||||
case 0x2B: return "Walloon";
|
||||
case 0x30: // no break
|
||||
case 0x31: // no break
|
||||
case 0x32: // no break
|
||||
case 0x33: // no break
|
||||
case 0x34: // no break
|
||||
case 0x35: // no break
|
||||
case 0x36: // no break
|
||||
case 0x37: // no break
|
||||
case 0x38: // no break
|
||||
case 0x39: // no break
|
||||
case 0x3A: // no break
|
||||
case 0x3B: // no break
|
||||
case 0x3C: // no break
|
||||
case 0x3D: // no break
|
||||
case 0x3E: // no break
|
||||
case 0x3F: return "Reserved for national assignment";
|
||||
case 0x7F: return "Amharic";
|
||||
case 0x7E: return "Arabic";
|
||||
case 0x7D: return "Armenian";
|
||||
case 0x7C: return "Assamese";
|
||||
case 0x7B: return "Azerbaijani";
|
||||
case 0x7A: return "Bambora";
|
||||
case 0x79: return "Belorussian";
|
||||
case 0x78: return "Bengali";
|
||||
case 0x77: return "Bulgarian";
|
||||
case 0x76: return "Burmese";
|
||||
case 0x75: return "Chinese";
|
||||
case 0x74: return "Chuvash";
|
||||
case 0x73: return "Dari";
|
||||
case 0x72: return "Fulani";
|
||||
case 0x71: return "Georgian";
|
||||
case 0x70: return "Greek";
|
||||
case 0x6F: return "Gujurati";
|
||||
case 0x6E: return "Gurani";
|
||||
case 0x6D: return "Hausa";
|
||||
case 0x6C: return "Hebrew";
|
||||
case 0x6B: return "Hindi";
|
||||
case 0x6A: return "Indonesian";
|
||||
case 0x69: return "Japanese";
|
||||
case 0x68: return "Kannada";
|
||||
case 0x67: return "Kazakh";
|
||||
case 0x66: return "Khmer";
|
||||
case 0x65: return "Korean";
|
||||
case 0x64: return "Laotian";
|
||||
case 0x63: return "Macedonian";
|
||||
case 0x62: return "Malagasay";
|
||||
case 0x61: return "Malaysian";
|
||||
case 0x60: return "Moldavian";
|
||||
case 0x5F: return "Marathi";
|
||||
case 0x5E: return "Ndebele";
|
||||
case 0x5D: return "Nepali";
|
||||
case 0x5C: return "Oriya";
|
||||
case 0x5B: return "Papiamento";
|
||||
case 0x5A: return "Persian";
|
||||
case 0x59: return "Punjabi";
|
||||
case 0x58: return "Pushtu";
|
||||
case 0x57: return "Quechua";
|
||||
case 0x56: return "Russian";
|
||||
case 0x55: return "Rusyn";
|
||||
case 0x54: return "Serbo-Croat";
|
||||
case 0x53: return "Shona";
|
||||
case 0x52: return "Sinhalese";
|
||||
case 0x51: return "Somali";
|
||||
case 0x50: return "Sranan Tongo";
|
||||
case 0x4F: return "Swahili";
|
||||
case 0x4E: return "Tadzhik";
|
||||
case 0x4D: return "Tamil";
|
||||
case 0x4C: return "Tatar";
|
||||
case 0x4B: return "Telugu";
|
||||
case 0x4A: return "Thai";
|
||||
case 0x49: return "Ukranian";
|
||||
case 0x48: return "Urdu";
|
||||
case 0x47: return "Uzbek";
|
||||
case 0x46: return "Vietnamese";
|
||||
case 0x45: return "Zulu";
|
||||
case 0x40: return "Background sound/clean feed";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char *getCountry (uint8_t ecc, uint8_t countryId) {
|
||||
int16_t i = 0;
|
||||
|
||||
while (countryTable [i].ecc != 0) {
|
||||
if ((countryTable[i].ecc == ecc) &&
|
||||
(countryTable[i].countryId == countryId) )
|
||||
return countryTable[i].countryName;
|
||||
++i;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// from Table 12
|
||||
const char *getProgramType_Not_NorthAmerica (int16_t programType) {
|
||||
|
||||
switch (programType) {
|
||||
case 0: return "No programme type";
|
||||
case 1: return "News";
|
||||
case 2: return "Current Affairs";
|
||||
case 3: return "Information";
|
||||
case 4: return "Sport";
|
||||
case 5: return "Education";
|
||||
case 6: return "Drama";
|
||||
case 7: return "Culture";
|
||||
case 8: return "Science";
|
||||
case 9: return "Varied"; //Talk
|
||||
case 10: return "Pop Music";
|
||||
case 11: return "Rock Music";
|
||||
case 12: return "Easy Listening Music";
|
||||
case 13: return "Light Classical";
|
||||
case 14: return "Serious Classical";
|
||||
case 15: return "Other Music";
|
||||
case 16: return "Weather/meteorology";
|
||||
case 17: return "Finance/Business";
|
||||
case 18: return "Children's programmes";
|
||||
case 19: return "Social Affairs"; //Factual
|
||||
case 20: return "Religion";
|
||||
case 21: return "Phone In";
|
||||
case 22: return "Travel";
|
||||
case 23: return "Leisure";
|
||||
case 24: return "Jazz Music";
|
||||
case 25: return "Country Music";
|
||||
case 26: return "National Music";
|
||||
case 27: return "Oldies Music";
|
||||
case 28: return "Folk Music";
|
||||
case 29: return "Documentary";
|
||||
case 30: return "unknown programme type 30";
|
||||
case 31: return "unknown programme type 31";
|
||||
default: return "unknown programme type";
|
||||
}
|
||||
}
|
||||
|
||||
// from Table 13
|
||||
const char *getProgramType_For_NorthAmerica (int16_t programType) {
|
||||
switch (programType) {
|
||||
case 0: return "No programme type";
|
||||
case 1: return "News";
|
||||
case 2: return "Information";
|
||||
case 3: return "Sports";
|
||||
case 4: return "Talk";
|
||||
case 5: return "Rock";
|
||||
case 6: return "Classic Rock";
|
||||
case 7: return "Adult Hits";
|
||||
case 8: return "Soft Rock";
|
||||
case 9: return "Top 40";
|
||||
case 10: return "Country";
|
||||
case 11: return "Oldies";
|
||||
case 12: return "Soft";
|
||||
case 13: return "Nostalgia";
|
||||
case 14: return "Jazz";
|
||||
case 15: return "Classical";
|
||||
case 16: return "Rhythm and Blues";
|
||||
case 17: return "Soft Rhythm and Blues";
|
||||
case 18: return "Foreign Language";
|
||||
case 19: return "Religious Music";
|
||||
case 20: return "Religious Talk";
|
||||
case 21: return "Personality";
|
||||
case 22: return "Public";
|
||||
case 23: return "College";
|
||||
case 24: return "unknown programme type 24";
|
||||
case 25: return "unknown programme type 25";
|
||||
case 26: return "unknown programme type 26";
|
||||
case 27: return "unknown programme type 27";
|
||||
case 28: return "unknown programme type 28";
|
||||
case 29: return "Weather";
|
||||
case 30: return "unknown programme type 30";
|
||||
case 31: return "unknown programme type 31";
|
||||
default: return "unknown programme type";
|
||||
}
|
||||
}
|
||||
|
||||
const char *getProgramType (bool gotInterTabId,
|
||||
uint8_t interTabId, int16_t programType) {
|
||||
if (gotInterTabId && (interTabId == 1))
|
||||
return getProgramType_Not_NorthAmerica (programType);
|
||||
else
|
||||
if (gotInterTabId && (interTabId == 2))
|
||||
return getProgramType_For_NorthAmerica (programType);
|
||||
else {
|
||||
switch (programType) {
|
||||
case 0: return "unknown programme type 0";
|
||||
case 1: return "unknown programme type 1";
|
||||
case 2: return "unknown programme type 2";
|
||||
case 3: return "unknown programme type 3";
|
||||
case 4: return "unknown programme type 4";
|
||||
case 5: return "unknown programme type 5";
|
||||
case 6: return "unknown programme type 6";
|
||||
case 7: return "unknown programme type 7";
|
||||
case 8: return "unknown programme type 8";
|
||||
case 9: return "unknown programme type 9";
|
||||
case 10: return "unknown programme type 10";
|
||||
case 11: return "unknown programme type 11";
|
||||
case 12: return "unknown programme type 12";
|
||||
case 13: return "unknown programme type 13";
|
||||
case 14: return "unknown programme type 14";
|
||||
case 15: return "unknown programme type 15";
|
||||
case 16: return "unknown programme type 16";
|
||||
case 17: return "unknown programme type 17";
|
||||
case 18: return "unknown programme type 18";
|
||||
case 19: return "unknown programme type 19";
|
||||
case 20: return "unknown programme type 20";
|
||||
case 21: return "unknown programme type 21";
|
||||
case 22: return "unknown programme type 22";
|
||||
case 23: return "unknown programme type 23";
|
||||
case 24: return "unknown programme type 24";
|
||||
case 25: return "unknown programme type 25";
|
||||
case 26: return "unknown programme type 26";
|
||||
case 27: return "unknown programme type 27";
|
||||
case 28: return "unknown programme type 28";
|
||||
case 29: return "unknown programme type 29";
|
||||
case 30: return "unknown programme type 30";
|
||||
case 31: return "unknown programme type 31";
|
||||
default: return "unknown programme type";
|
||||
}
|
||||
}
|
||||
return "unknown programme type";
|
||||
}
|
||||
|
||||
// 11-bit from HandleFIG0Extension13, see ETSI TS 101 756 table 16
|
||||
const char *getUserApplicationType (int16_t appType) {
|
||||
switch (appType) {
|
||||
case 1: return "Dynamic labels (X-PAD only)";
|
||||
case 2: return "MOT Slide Show";
|
||||
case 3: return "MOT Broadcast Web Site";
|
||||
case 4: return "TPEG";
|
||||
case 5: return "DGPS";
|
||||
case 6: return "TMC";
|
||||
case 7: return "SPI, was EPG";
|
||||
case 8: return "DAB Java";
|
||||
case 9: return "DMB";
|
||||
case 0x00a: return "IPDC services";
|
||||
case 0x00b: return "Voice applications";
|
||||
case 0x00c: return "Middleware";
|
||||
case 0x00d: return "Filecasting";
|
||||
case 0x44a: return "Journaline";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char * getFECscheme (int16_t FEC_scheme) {
|
||||
switch (FEC_scheme) {
|
||||
case 0: return "no FEC";
|
||||
case 1: return "FEC";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char * getProtectionLevel (bool shortForm, int16_t protLevel) {
|
||||
if (!shortForm) {
|
||||
switch (protLevel) {
|
||||
case 0: return "EEP 1-A";
|
||||
case 1: return "EEP 2-A";
|
||||
case 2: return "EEP 3-A";
|
||||
case 3: return "EEP 4-A";
|
||||
case 4: return "EEP 1-B";
|
||||
case 5: return "EEP 2-B";
|
||||
case 6: return "EEP 3-B";
|
||||
case 7: return "EEP 4-B";
|
||||
default: return "EEP unknown";
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (protLevel) {
|
||||
case 1: return "UEP 1";
|
||||
case 2: return "UEP 2";
|
||||
case 3: return "UEP 3";
|
||||
case 4: return "UEP 4";
|
||||
case 5: return "UEP 5";
|
||||
default: return "UEP unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *getCodeRate (bool shortForm, int16_t protLevel) {
|
||||
int h = protLevel;
|
||||
|
||||
if (!shortForm)
|
||||
return ((h & (1 << 2)) == 0) ?
|
||||
eep_Arates [h & 03] :
|
||||
eep_Brates [h & 03]; // EEP -A/-B
|
||||
else
|
||||
return uep_rates [h & 03]; // UEP
|
||||
}
|
||||
|
16
dab-scanner/dab_tables.h
Normal file
16
dab-scanner/dab_tables.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
const char * getASCTy (int16_t ASCTy);
|
||||
const char * getDSCTy (int16_t DSCTy);
|
||||
const char * getLanguage (int16_t language);
|
||||
const char * getCountry (uint8_t ecc, uint8_t countryId);
|
||||
const char * getProgramType_Not_NorthAmerica(int16_t programType);
|
||||
const char * getProgramType_For_NorthAmerica(int16_t programType);
|
||||
const char * getProgramType(bool, uint8_t interTabId, int16_t programType);
|
||||
const char * getUserApplicationType(int16_t appType);
|
||||
const char * getFECscheme(int16_t FEC_scheme);
|
||||
const char * getProtectionLevel (bool shortForm, int16_t protLevel);
|
||||
const char * getCodeRate (bool shortForm, int16_t protLevel);
|
||||
|
462
dab-scanner/main.cpp
Normal file
462
dab-scanner/main.cpp
Normal file
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
* Copyright (C) 2015, 2016, 2017
|
||||
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
||||
* Lazy Chair Computing
|
||||
*
|
||||
* This file is part of the DAB-library
|
||||
*
|
||||
* DAB-library 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* DAB-library 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 DAB-library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* E X A M P L E P R O G R A M
|
||||
* for the DAB-library
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
#include "dab-api.h"
|
||||
#include "band-handler.h"
|
||||
#include "service-printer.h"
|
||||
#ifdef HAVE_SDRPLAY
|
||||
#include "sdrplay-handler.h"
|
||||
#elif HAVE_AIRSPY
|
||||
#include "airspy-handler.h"
|
||||
#elif HAVE_RTLSDR
|
||||
#include "rtlsdr-handler.h"
|
||||
#endif
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
void printOptions (void); // forward declaration
|
||||
// we deal with some callbacks, so we have some data that needs
|
||||
// to be accessed from global contexts
|
||||
static
|
||||
std::atomic<bool> run;
|
||||
|
||||
static
|
||||
void *theRadio = NULL;
|
||||
|
||||
static
|
||||
std::atomic<bool>timeSynced;
|
||||
|
||||
static
|
||||
std::atomic<bool>timesyncSet;
|
||||
|
||||
static
|
||||
std::atomic<bool>ensembleRecognized;
|
||||
|
||||
static
|
||||
FILE *outFile = stderr;
|
||||
|
||||
static void sighandler (int signum) {
|
||||
fprintf (stderr, "Signal caught, terminating!\n");
|
||||
run. store (false);
|
||||
}
|
||||
|
||||
static
|
||||
void syncsignalHandler (bool b, void *userData) {
|
||||
timeSynced. store (b);
|
||||
timesyncSet. store (true);
|
||||
(void)userData;
|
||||
}
|
||||
//
|
||||
// This function is called whenever the dab engine has taken
|
||||
// some time to gather information from the FIC bloks
|
||||
// the Boolean b tells whether or not an ensemble has been
|
||||
// recognized, the names of the programs are in the
|
||||
// ensemble
|
||||
std::string ensembleName;
|
||||
uint32_t ensembleId;
|
||||
static
|
||||
void ensemblenameHandler (std::string name, int Id, void *userData) {
|
||||
fprintf (stderr, "ensemble %s is (%X) recognized\n",
|
||||
name. c_str (), (uint32_t)Id);
|
||||
ensembleRecognized. store (true);
|
||||
ensembleName = name;
|
||||
ensembleId = Id;
|
||||
}
|
||||
|
||||
std::vector<std::string> programNames;
|
||||
std::vector<int> programSIds;
|
||||
|
||||
static
|
||||
void programnameHandler (std::string s, int SId, void *userdata) {
|
||||
for (std::vector<std::string>::iterator it = programNames.begin();
|
||||
it != programNames. end(); ++it)
|
||||
if (*it == s)
|
||||
return;
|
||||
programNames. push_back (s);
|
||||
programSIds . push_back (SId);
|
||||
// fprintf (stderr, "program %s is part of the ensemble\n", s. c_str ());
|
||||
}
|
||||
|
||||
static
|
||||
void programdataHandler (audiodata *d, void *ctx) {
|
||||
(void) *d;
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
//
|
||||
// The function is called from within the library with
|
||||
// a string, the so-called dynamic label
|
||||
static
|
||||
void dataOut_Handler (std::string dynamicLabel, void *ctx) {
|
||||
(void)ctx;
|
||||
// fprintf (stderr, "%s\n", dynamicLabel. c_str ());
|
||||
}
|
||||
//
|
||||
// Note: the function is called from the tdcHandler with a
|
||||
// frame, either frame 0 or frame 1.
|
||||
// The frames are packed bytes, here an additional header
|
||||
// is added, a header of 8 bytes:
|
||||
// the first 4 bytes for a pattern 0xFF 0x00 0xFF 0x00 0xFF
|
||||
// the length of the contents, i.e. framelength without header
|
||||
// is stored in bytes 5 (high byte) and byte 6.
|
||||
// byte 7 contains 0x00, byte 8 contains 0x00 for frametype 0
|
||||
// and 0xFF for frametype 1
|
||||
// Note that the callback function is executed in the thread
|
||||
// that executes the tdcHandler code.
|
||||
static
|
||||
void bytesOut_Handler (uint8_t *data, int16_t amount,
|
||||
uint8_t type, void *ctx) {
|
||||
#ifdef DATA_STREAMER
|
||||
uint8_t localBuf [amount + 8];
|
||||
int16_t i;
|
||||
localBuf [0] = 0xFF;
|
||||
localBuf [1] = 0x00;
|
||||
localBuf [2] = 0xFF;
|
||||
localBuf [3] = 0x00;
|
||||
localBuf [4] = (amount >> 8) & 0xFF;
|
||||
localBuf [5] = amount & 0xFF;
|
||||
localBuf [6] = 0x00;
|
||||
localBuf [7] = type == 0 ? 0 : 0xFF;
|
||||
for (i = 0; i < amount; i ++)
|
||||
localBuf [8 + i] = data;
|
||||
tdcServer. sendData (localBuf, amount + 8);
|
||||
#else
|
||||
(void)data;
|
||||
(void)amount;
|
||||
#endif
|
||||
(void)ctx;
|
||||
}
|
||||
//
|
||||
static
|
||||
void pcmHandler (int16_t *buffer, int size, int rate,
|
||||
bool isStereo, void *ctx) {
|
||||
(void)buffer;
|
||||
(void)size;
|
||||
(void)rate;
|
||||
(void)ctx;
|
||||
}
|
||||
|
||||
static
|
||||
void systemData (bool flag, int16_t snr, int32_t freqOff, void *ctx) {
|
||||
// fprintf (stderr, "synced = %s, snr = %d, offset = %d\n",
|
||||
// flag? "on":"off", snr, freqOff);
|
||||
}
|
||||
|
||||
static
|
||||
void fibQuality (int16_t q, void *ctx) {
|
||||
// fprintf (stderr, "fic quality = %d\n", q);
|
||||
}
|
||||
|
||||
static
|
||||
void mscQuality (int16_t fe, int16_t rsE, int16_t aacE, void *ctx) {
|
||||
// fprintf (stderr, "msc quality = %d %d %d\n", fe, rsE, aacE);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
// Default values
|
||||
uint8_t theMode = 1;
|
||||
std::string theChannel = "5A";
|
||||
std::string startChannel = "5A";
|
||||
uint8_t theBand = BAND_III;
|
||||
int16_t ppmCorrection = 0;
|
||||
int theGain = 35; // scale = 0 .. 100
|
||||
int16_t latency = 10;
|
||||
int16_t timeSyncTime = 5;
|
||||
int16_t freqSyncTime = 10;
|
||||
bool autogain = false;
|
||||
int opt;
|
||||
struct sigaction sigact;
|
||||
bandHandler dabBand;
|
||||
deviceHandler *theDevice;
|
||||
bool err;
|
||||
|
||||
fprintf (stderr, "dab_scanner V 1.0alfa,\n\
|
||||
Copyright 2018 J van Katwijk, Lazy Chair Computing\n\ 2018 Hayati Ayguen");
|
||||
timeSynced. store (false);
|
||||
timesyncSet. store (false);
|
||||
run. store (false);
|
||||
|
||||
if (argc == 1) {
|
||||
printOptions ();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
while ((opt = getopt (argc, argv, "F:D:d:M:B:p:G:QC:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'F':
|
||||
outFile = fopen (optarg, "w");
|
||||
if (outFile == NULL)
|
||||
outFile = stderr;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
freqSyncTime = atoi (optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
timeSyncTime = atoi (optarg);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
theMode = atoi (optarg);
|
||||
if (!((theMode == 1) || (theMode == 2) || (theMode == 4)))
|
||||
theMode = 1;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
theBand = std::string (optarg) == std::string ("L_BAND") ?
|
||||
L_BAND : BAND_III;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
ppmCorrection = atoi (optarg);
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
theGain = atoi (optarg);
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
autogain = true;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
theChannel = std::string (optarg);
|
||||
startChannel = theChannel;
|
||||
break;
|
||||
|
||||
default:
|
||||
printOptions ();
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
//
|
||||
sigact.sa_handler = sighandler;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigact.sa_flags = 0;
|
||||
|
||||
int32_t frequency = dabBand. Frequency (theBand, theChannel);
|
||||
try {
|
||||
#ifdef HAVE_SDRPLAY
|
||||
theDevice = new sdrplayHandler (frequency,
|
||||
ppmCorrection,
|
||||
theGain,
|
||||
autogain,
|
||||
0,
|
||||
0);
|
||||
#elif HAVE_AIRSPY
|
||||
theDevice = new airspyHandler (frequency,
|
||||
ppmCorrection,
|
||||
theGain);
|
||||
#elif HAVE_RTLSDR
|
||||
theDevice = new rtlsdrHandler (frequency,
|
||||
ppmCorrection,
|
||||
theGain,
|
||||
autogain);
|
||||
#endif
|
||||
|
||||
}
|
||||
catch (int e) {
|
||||
fprintf (stderr, "allocating device failed (%d), fatal\n", e);
|
||||
exit (32);
|
||||
}
|
||||
//
|
||||
// and with a sound device we can create a "backend"
|
||||
theRadio = dabInit (theDevice,
|
||||
theMode,
|
||||
syncsignalHandler,
|
||||
systemData,
|
||||
ensemblenameHandler,
|
||||
programnameHandler,
|
||||
fibQuality,
|
||||
pcmHandler,
|
||||
dataOut_Handler,
|
||||
bytesOut_Handler,
|
||||
programdataHandler,
|
||||
mscQuality,
|
||||
NULL, // no mot slides
|
||||
NULL, // no spectrum shown
|
||||
NULL, // no constellations
|
||||
NULL
|
||||
);
|
||||
if (theRadio == NULL) {
|
||||
fprintf (stderr, "sorry, no radio available, fatal\n");
|
||||
exit (4);
|
||||
}
|
||||
|
||||
theDevice -> setGain (theGain);
|
||||
if (autogain)
|
||||
theDevice -> set_autogain (autogain);
|
||||
|
||||
while (true) {
|
||||
bool firstTime = true;
|
||||
theDevice -> stopReader ();
|
||||
int32_t frequency =
|
||||
dabBand. Frequency (theBand, theChannel);
|
||||
theDevice -> setVFOFrequency (frequency);
|
||||
theDevice -> restartReader ();
|
||||
|
||||
ensembleRecognized. store (false);
|
||||
dabReset (theRadio);
|
||||
// The device should be working right now
|
||||
|
||||
fprintf (stderr, "checking data in channel %s\n",
|
||||
theChannel. c_str ());
|
||||
timesyncSet. store (false);
|
||||
timeSynced. store (false);
|
||||
timeSyncTime = 5;
|
||||
freqSyncTime = 10;
|
||||
|
||||
while (!timesyncSet. load () && (--timeSyncTime >= 0))
|
||||
sleep (1);
|
||||
|
||||
if (!timeSynced. load ()) {
|
||||
theChannel = dabBand. nextChannel (theBand, theChannel);
|
||||
if (theChannel == startChannel)
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!ensembleRecognized. load () &&
|
||||
(--freqSyncTime >= 0)) {
|
||||
fprintf (stderr, "%d\r", freqSyncTime);
|
||||
sleep (1);
|
||||
}
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
if (!ensembleRecognized. load ()) {
|
||||
theChannel = dabBand. nextChannel (theBand, theChannel);
|
||||
if (theChannel == startChannel)
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
sleep (5);
|
||||
//
|
||||
// print ensemble data here
|
||||
print_ensembleData (outFile,
|
||||
theRadio,
|
||||
theChannel,
|
||||
ensembleName,
|
||||
ensembleId);
|
||||
|
||||
print_audioheader (outFile);
|
||||
for (int i = 0; i < programNames. size (); i ++) {
|
||||
if (is_audioService (theRadio, programNames [i]. c_str ())) {
|
||||
audiodata ad;
|
||||
dataforAudioService (theRadio,
|
||||
programNames [i]. c_str (),
|
||||
&ad, 0);
|
||||
print_audioService (outFile,
|
||||
theRadio,
|
||||
programNames [i]. c_str (),
|
||||
&ad);
|
||||
for (int j = 1; j < 5; j ++) {
|
||||
packetdata pd;
|
||||
dataforDataService (theRadio,
|
||||
programNames [i]. c_str (),
|
||||
&pd, j);
|
||||
if (pd. defined)
|
||||
print_dataService (outFile,
|
||||
theRadio,
|
||||
programNames [i]. c_str (),
|
||||
j,
|
||||
&pd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < programNames. size (); i ++) {
|
||||
if (is_dataService (theRadio, programNames [i]. c_str ())) {
|
||||
if (firstTime)
|
||||
print_dataHeader (outFile);
|
||||
firstTime = false;
|
||||
for (int j = 0; j < 5; j ++) {
|
||||
packetdata pd;
|
||||
dataforDataService (theRadio,
|
||||
programNames [i]. c_str (),
|
||||
&pd, j);
|
||||
if (pd. defined)
|
||||
print_dataService (outFile,
|
||||
theRadio,
|
||||
programNames [i]. c_str (),
|
||||
j,
|
||||
&pd);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (is_audioService (theRadio, programNames [i]. c_str ())) {
|
||||
for (int j = 1; j < 5; j ++) {
|
||||
packetdata pd;
|
||||
dataforDataService (theRadio,
|
||||
programNames [i]. c_str (),
|
||||
&pd, j);
|
||||
if (pd. defined)
|
||||
print_dataService (outFile,
|
||||
theRadio,
|
||||
programNames [i]. c_str (),
|
||||
j,
|
||||
&pd);
|
||||
}
|
||||
}
|
||||
}
|
||||
theDevice -> stopReader ();
|
||||
dabStop (theRadio);
|
||||
programNames. resize (0);
|
||||
programSIds. resize (0);
|
||||
theChannel = dabBand. nextChannel (theBand, theChannel);
|
||||
}
|
||||
|
||||
fclose (outFile);
|
||||
theDevice -> stopReader ();
|
||||
dabStop (theRadio);
|
||||
dabExit (theRadio);
|
||||
delete theDevice;
|
||||
}
|
||||
|
||||
void printOptions (void) {
|
||||
fprintf (stderr,
|
||||
" dab-scanner options are\n\
|
||||
-d number amount of time to look for time synchr\n\
|
||||
-D number amount of time to look for full sync\n\
|
||||
-M Mode Mode is 1, 2 or 4. Default is Mode 1\n\
|
||||
-B Band Band is either L_BAND or BAND_III (default)\n\
|
||||
-G number gain for device (range 1 .. 100)\n\
|
||||
-Q if set, set autogain for device true\n\
|
||||
-p number ppm correction for the attached device\n\
|
||||
-F filename in case the output is to a file\n");
|
||||
}
|
||||
|
321
dab-scanner/ringbuffer.h
Normal file
321
dab-scanner/ringbuffer.h
Normal file
@@ -0,0 +1,321 @@
|
||||
#
|
||||
/*
|
||||
* $Id: pa_ringbuffer.c 1738 2011-08-18 11:47:28Z rossb $
|
||||
* Portable Audio I/O Library
|
||||
* Ring Buffer utility.
|
||||
*
|
||||
* Author: Phil Burk, http://www.softsynth.com
|
||||
* modified for SMP safety on Mac OS X by Bjorn Roche
|
||||
* modified for SMP safety on Linux by Leland Lucius
|
||||
* also, allowed for const where possible
|
||||
* modified for multiple-byte-sized data elements by Sven Fischer
|
||||
*
|
||||
* Note that this is safe only for a single-thread reader and a
|
||||
* single-thread writer.
|
||||
*
|
||||
* This program uses the PortAudio Portable Audio Library.
|
||||
* For more information see: http://www.portaudio.com
|
||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2008, 2009, 2010
|
||||
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
||||
* Lazy Chair Computing
|
||||
*
|
||||
* The ringbuffer here is a rewrite of the ringbuffer used in the PA code
|
||||
* All rights remain with their owners
|
||||
* This file is part of the SDR-J.
|
||||
* Many of the ideas as implemented in SDR-J are derived from
|
||||
* other work, made available through the GNU general Public License.
|
||||
* All copyrights of the original authors are recognized.
|
||||
*
|
||||
* SDR-J 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SDR-J 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 ESDR; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __RINGBUFFER
|
||||
#define __RINGBUFFER
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
/*
|
||||
* a simple ringbuffer, lockfree, however only for a
|
||||
* single reader and a single writer.
|
||||
* Mostly used for getting samples from or to the soundcard
|
||||
*/
|
||||
#if defined(__APPLE__)
|
||||
# include <libkern/OSAtomic.h>
|
||||
/* Here are the memory barrier functions. Mac OS X only provides
|
||||
full memory barriers, so the three types of barriers are the same,
|
||||
however, these barriers are superior to compiler-based ones. */
|
||||
# define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
|
||||
# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
|
||||
# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
|
||||
#elif defined(__GNUC__)
|
||||
/* GCC >= 4.1 has built-in intrinsics. We'll use those */
|
||||
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
|
||||
# define PaUtil_FullMemoryBarrier() __sync_synchronize()
|
||||
# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
|
||||
# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
|
||||
/* as a fallback, GCC understands volatile asm and "memory" to mean it
|
||||
* should not reorder memory read/writes */
|
||||
# elif defined( __PPC__ )
|
||||
# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
|
||||
# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
|
||||
# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
|
||||
# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || defined( __i686__ ) || defined( __x86_64__ )
|
||||
# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
|
||||
# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
|
||||
# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
|
||||
# else
|
||||
# ifdef ALLOW_SMP_DANGERS
|
||||
# warning Memory barriers not defined on this system or system unknown
|
||||
# warning For SMP safety, you should fix this.
|
||||
# define PaUtil_FullMemoryBarrier()
|
||||
# define PaUtil_ReadMemoryBarrier()
|
||||
# define PaUtil_WriteMemoryBarrier()
|
||||
# else
|
||||
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# ifdef ALLOW_SMP_DANGERS
|
||||
# warning Memory barriers not defined on this system or system unknown
|
||||
# warning For SMP safety, you should fix this.
|
||||
# define PaUtil_FullMemoryBarrier()
|
||||
# define PaUtil_ReadMemoryBarrier()
|
||||
# define PaUtil_WriteMemoryBarrier()
|
||||
# else
|
||||
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <class elementtype>
|
||||
class RingBuffer {
|
||||
private:
|
||||
uint32_t bufferSize;
|
||||
volatile uint32_t writeIndex;
|
||||
volatile uint32_t readIndex;
|
||||
uint32_t bigMask;
|
||||
uint32_t smallMask;
|
||||
char *buffer;
|
||||
public:
|
||||
RingBuffer (uint32_t elementCount) {
|
||||
if (((elementCount - 1) & elementCount) != 0)
|
||||
elementCount = 2 * 16384; /* default */
|
||||
|
||||
bufferSize = elementCount;
|
||||
buffer = new char [2 * bufferSize * sizeof (elementtype)];
|
||||
writeIndex = 0;
|
||||
readIndex = 0;
|
||||
smallMask = (elementCount)- 1;
|
||||
bigMask = (elementCount * 2) - 1;
|
||||
}
|
||||
|
||||
~RingBuffer () {
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* functions for checking available data for reading and space
|
||||
* for writing
|
||||
*/
|
||||
int32_t GetRingBufferReadAvailable (void) {
|
||||
return (writeIndex - readIndex) & bigMask;
|
||||
}
|
||||
|
||||
int32_t ReadSpace (void){
|
||||
return GetRingBufferReadAvailable ();
|
||||
}
|
||||
|
||||
int32_t GetRingBufferWriteAvailable (void) {
|
||||
return bufferSize - GetRingBufferReadAvailable ();
|
||||
}
|
||||
|
||||
int32_t WriteSpace (void) {
|
||||
return GetRingBufferWriteAvailable ();
|
||||
}
|
||||
|
||||
void FlushRingBuffer () {
|
||||
writeIndex = 0;
|
||||
readIndex = 0;
|
||||
}
|
||||
/* ensure that previous writes are seen before we update the write index
|
||||
(write after write)
|
||||
*/
|
||||
int32_t AdvanceRingBufferWriteIndex (int32_t elementCount) {
|
||||
PaUtil_WriteMemoryBarrier();
|
||||
return writeIndex = (writeIndex + elementCount) & bigMask;
|
||||
}
|
||||
|
||||
/* ensure that previous reads (copies out of the ring buffer) are
|
||||
* always completed before updating (writing) the read index.
|
||||
* (write-after-read) => full barrier
|
||||
*/
|
||||
int32_t AdvanceRingBufferReadIndex (int32_t elementCount) {
|
||||
PaUtil_FullMemoryBarrier();
|
||||
return readIndex = (readIndex + elementCount) & bigMask;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Get address of region(s) to which we can write data.
|
||||
** If the region is contiguous, size2 will be zero.
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be written or elementCount, whichever is smaller.
|
||||
*/
|
||||
int32_t GetRingBufferWriteRegions (uint32_t elementCount,
|
||||
void **dataPtr1, int32_t *sizePtr1,
|
||||
void **dataPtr2, int32_t *sizePtr2 ) {
|
||||
uint32_t index;
|
||||
uint32_t available = GetRingBufferWriteAvailable ();
|
||||
|
||||
if (elementCount > available)
|
||||
elementCount = available;
|
||||
|
||||
/* Check to see if write is not contiguous. */
|
||||
index = writeIndex & smallMask;
|
||||
if ((index + elementCount) > bufferSize ) {
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
int32_t firstHalf = bufferSize - index;
|
||||
*dataPtr1 = &buffer[index * sizeof(elementtype)];
|
||||
*sizePtr1 = firstHalf;
|
||||
*dataPtr2 = &buffer [0];
|
||||
*sizePtr2 = elementCount - firstHalf;
|
||||
}
|
||||
else { // fits
|
||||
*dataPtr1 = &buffer [index * sizeof(elementtype)];
|
||||
*sizePtr1 = elementCount;
|
||||
*dataPtr2 = NULL;
|
||||
*sizePtr2 = 0;
|
||||
}
|
||||
|
||||
if (available > 0)
|
||||
PaUtil_FullMemoryBarrier(); /* (write-after-read) => full barrier */
|
||||
|
||||
return elementCount;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
** Get address of region(s) from which we can read data.
|
||||
** If the region is contiguous, size2 will be zero.
|
||||
** If non-contiguous, size2 will be the size of second region.
|
||||
** Returns room available to be read or elementCount, whichever is smaller.
|
||||
*/
|
||||
int32_t GetRingBufferReadRegions (uint32_t elementCount,
|
||||
void **dataPtr1, int32_t *sizePtr1,
|
||||
void **dataPtr2, int32_t *sizePtr2) {
|
||||
uint32_t index;
|
||||
uint32_t available = GetRingBufferReadAvailable (); /* doesn't use memory barrier */
|
||||
|
||||
if (elementCount > available)
|
||||
elementCount = available;
|
||||
|
||||
/* Check to see if read is not contiguous. */
|
||||
index = readIndex & smallMask;
|
||||
if ((index + elementCount) > bufferSize) {
|
||||
/* Write data in two blocks that wrap the buffer. */
|
||||
int32_t firstHalf = bufferSize - index;
|
||||
*dataPtr1 = &buffer [index * sizeof(elementtype)];
|
||||
*sizePtr1 = firstHalf;
|
||||
*dataPtr2 = &buffer [0];
|
||||
*sizePtr2 = elementCount - firstHalf;
|
||||
}
|
||||
else {
|
||||
*dataPtr1 = &buffer [index * sizeof(elementtype)];
|
||||
*sizePtr1 = elementCount;
|
||||
*dataPtr2 = NULL;
|
||||
*sizePtr2 = 0;
|
||||
}
|
||||
|
||||
if (available)
|
||||
PaUtil_ReadMemoryBarrier(); /* (read-after-read) => read barrier */
|
||||
|
||||
return elementCount;
|
||||
}
|
||||
|
||||
int32_t putDataIntoBuffer (const void *data, int32_t elementCount) {
|
||||
int32_t size1, size2, numWritten;
|
||||
void *data1;
|
||||
void *data2;
|
||||
|
||||
numWritten = GetRingBufferWriteRegions (elementCount,
|
||||
&data1, &size1,
|
||||
&data2, &size2 );
|
||||
if (size2 > 0) {
|
||||
memcpy (data1, data, size1 * sizeof(elementtype));
|
||||
data = ((char *)data) + size1 * sizeof(elementtype);
|
||||
memcpy (data2, data, size2 * sizeof(elementtype));
|
||||
}
|
||||
else
|
||||
memcpy (data1, data, size1 * sizeof(elementtype));
|
||||
|
||||
AdvanceRingBufferWriteIndex (numWritten );
|
||||
return numWritten;
|
||||
}
|
||||
|
||||
int32_t getDataFromBuffer (void *data, int32_t elementCount ) {
|
||||
int32_t size1, size2, numRead;
|
||||
void *data1;
|
||||
void *data2;
|
||||
|
||||
numRead = GetRingBufferReadRegions (elementCount,
|
||||
&data1, &size1,
|
||||
&data2, &size2 );
|
||||
if (size2 > 0) {
|
||||
memcpy (data, data1, size1 * sizeof(elementtype));
|
||||
data = ((char *)data) + size1 * sizeof(elementtype);
|
||||
memcpy (data, data2, size2 * sizeof(elementtype));
|
||||
}
|
||||
else
|
||||
memcpy (data, data1, size1 * sizeof(elementtype));
|
||||
|
||||
AdvanceRingBufferReadIndex (numRead );
|
||||
return numRead;
|
||||
}
|
||||
|
||||
int32_t skipDataInBuffer (uint32_t n_values) {
|
||||
// ensure that we have the correct read and write indices
|
||||
PaUtil_FullMemoryBarrier ();
|
||||
if (n_values > GetRingBufferReadAvailable ())
|
||||
n_values = GetRingBufferReadAvailable ();
|
||||
AdvanceRingBufferReadIndex (n_values);
|
||||
return n_values;
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
121
dab-scanner/service-printer.cpp
Normal file
121
dab-scanner/service-printer.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
#
|
||||
/*
|
||||
* Copyright (C) 2013, 2014, 2015, 2016, 2017
|
||||
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
||||
* Lazy Chair Computing
|
||||
*
|
||||
* This file is part of the Qt-DAB (formerly SDR-J, JSDR).
|
||||
* Qt-DAB 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Qt-DAB 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 Qt-DAB; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "service-printer.h"
|
||||
#include "dab_tables.h"
|
||||
#include "dab-api.h"
|
||||
|
||||
|
||||
void print_ensembleData (FILE *f,
|
||||
void *theRadio,
|
||||
std::string currentChannel,
|
||||
std::string ensembleLabel,
|
||||
uint32_t ensembleId) {
|
||||
|
||||
if (ensembleLabel == std::string (""))
|
||||
return;
|
||||
|
||||
fprintf (f, "\n\nEnsemble %s; ensembleId %X; channel %s; \n\n",
|
||||
ensembleLabel. c_str (),
|
||||
ensembleId,
|
||||
currentChannel. c_str ());
|
||||
}
|
||||
|
||||
void print_audioheader (FILE *f) {
|
||||
fprintf (f, "\nAudio services\nprogram name;country;serviceId;subchannelId;start address;length (CU); bit rate;DAB/DAB+; prot level; code rate; language; program type\n\n");
|
||||
}
|
||||
|
||||
void print_audioService (FILE *f,
|
||||
void *theRadio,
|
||||
std::string serviceName,
|
||||
audiodata *d) {
|
||||
bool success;
|
||||
|
||||
if (!d -> defined)
|
||||
return;
|
||||
|
||||
std::string protL = getProtectionLevel (d -> shortForm,
|
||||
d -> protLevel);
|
||||
std::string codeRate = getCodeRate (d -> shortForm, d -> protLevel);
|
||||
uint8_t ecc_byte = dab_getExtendedCountryCode (theRadio, &success);
|
||||
uint32_t serviceId = dab_getSId (theRadio, serviceName. c_str ());
|
||||
uint8_t countryId = (serviceId >> 12) & 0xF;
|
||||
const char *country = getCountry (ecc_byte, countryId);
|
||||
if (country == nullptr)
|
||||
country = " ";
|
||||
uint8_t ITabId = dab_getInternationalTabId (theRadio, &success);
|
||||
std::string programType = getProgramType (success,
|
||||
ITabId, d -> programType);
|
||||
|
||||
fprintf (f, "%s;%s;%X;%d;%d;%d;%d;%s;%s;%s;%s;%s;\n",
|
||||
serviceName. c_str (),
|
||||
country,
|
||||
serviceId,
|
||||
d -> subchId,
|
||||
d -> startAddr,
|
||||
d -> length,
|
||||
d -> bitRate,
|
||||
getASCTy (d -> ASCTy),
|
||||
protL. c_str (),
|
||||
codeRate. c_str (),
|
||||
getLanguage (d -> language),
|
||||
programType. c_str () );
|
||||
}
|
||||
|
||||
void print_dataHeader (FILE *f) {
|
||||
fprintf (f, "\n\n\nData Services\nprogram name;;serviceId;subchannelId;start address;length (CU); bit rate; FEC; prot level; appType ; subService ; \n\n");
|
||||
}
|
||||
|
||||
void print_dataService (FILE *f,
|
||||
void *theRadio,
|
||||
std::string serviceName,
|
||||
uint8_t compnr,
|
||||
packetdata *d) {
|
||||
bool success;
|
||||
|
||||
if (!d -> defined)
|
||||
return;
|
||||
|
||||
std::string protL = getProtectionLevel (d -> shortForm,
|
||||
d -> protLevel);
|
||||
std::string codeRate = getCodeRate (d -> shortForm,
|
||||
d -> protLevel);
|
||||
uint8_t ecc_byte = dab_getExtendedCountryCode (theRadio, &success);
|
||||
uint32_t serviceId = dab_getSId (theRadio, serviceName. c_str ());
|
||||
uint8_t countryId = (serviceId >> 12) & 0xF;
|
||||
const char *country = getCountry (ecc_byte, countryId);
|
||||
if (country == nullptr)
|
||||
country = " ";
|
||||
fprintf (f, "%s;%s;%X;%d;%d;%d;%d;%s;%s;%s;%s;;\n",
|
||||
serviceName. c_str (),
|
||||
country,
|
||||
serviceId,
|
||||
d -> subchId,
|
||||
d -> startAddr,
|
||||
d -> length,
|
||||
d -> bitRate,
|
||||
getFECscheme (d -> FEC_scheme),
|
||||
protL. c_str (),
|
||||
getUserApplicationType (d -> appType),
|
||||
compnr == 0 ? "no": "yes");
|
||||
}
|
||||
|
41
dab-scanner/service-printer.h
Normal file
41
dab-scanner/service-printer.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#
|
||||
/*
|
||||
* Copyright (C) 2013, 2014, 2015, 2016, 2017
|
||||
* Jan van Katwijk (J.vanKatwijk@gmail.com)
|
||||
* Lazy Chair Computing
|
||||
*
|
||||
* This file is part of the Qt-DAB (formerly SDR-J, JSDR).
|
||||
* Qt-DAB 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Qt-DAB 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 Qt-DAB; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "dab_tables.h"
|
||||
#include "dab-api.h"
|
||||
|
||||
void print_ensembleData (FILE *f,
|
||||
void *theRadio,
|
||||
std::string channel,
|
||||
std::string ensembleLabel,
|
||||
uint32_t ensembleId);
|
||||
void print_audioheader (FILE *f);
|
||||
void print_audioService (FILE *f,
|
||||
void *theRadio,
|
||||
std::string serviceName,
|
||||
audiodata *d);
|
||||
void print_dataHeader (FILE *f);
|
||||
void print_dataService (FILE *f,
|
||||
void *theRadio,
|
||||
std::string serviceName,
|
||||
uint8_t compnr,
|
||||
packetdata *d);
|
@@ -221,7 +221,6 @@ int localGRed = 102 - theGain;
|
||||
if (running. load ())
|
||||
return true;
|
||||
|
||||
fprintf (stderr, "frequency = %d localGred = %d\n", frequency, localGRed);
|
||||
err = mir_sdr_StreamInit (&localGRed,
|
||||
double (inputRate) / 1000000.0,
|
||||
double (frequency) / 1000000.0,
|
||||
|
@@ -108,7 +108,8 @@ public:
|
||||
void dataforDataService (std::string &, packetdata *, int16_t);
|
||||
std::complex<float>
|
||||
get_coordinates (int16_t, int16_t, bool *);
|
||||
//
|
||||
|
||||
void reset (void);
|
||||
// Extended functions, contributed by Hayati Ayguen
|
||||
std::complex<float>
|
||||
get_coordinates (int16_t, int16_t, bool *,
|
||||
|
@@ -59,6 +59,7 @@ public:
|
||||
get_coordinates (int16_t, int16_t, bool *,
|
||||
int16_t *pMainId, int16_t *,
|
||||
int16_t *pTD);
|
||||
void reset (void);
|
||||
uint8_t getECC (bool *);
|
||||
uint8_t getInterTabId (bool *);
|
||||
private:
|
||||
|
@@ -102,8 +102,8 @@ void mscHandler::start (void) {
|
||||
fprintf (stderr, "cannot restart mscHandler, still active\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
fprintf (stderr, "starting mscHandler\n");
|
||||
// else
|
||||
// fprintf (stderr, "starting mscHandler\n");
|
||||
threadHandle = std::thread (&mscHandler::run, this);
|
||||
}
|
||||
|
||||
|
@@ -114,7 +114,7 @@ int index_attempts = 0;
|
||||
|
||||
isSynced = false;
|
||||
running. store (true);
|
||||
my_ficHandler. clearEnsemble ();
|
||||
my_ficHandler. reset ();
|
||||
myReader. setRunning (true);
|
||||
my_mscHandler. start ();
|
||||
try {
|
||||
@@ -340,7 +340,7 @@ void dabProcessor::set_dataChannel (packetdata *d) {
|
||||
}
|
||||
|
||||
void dabProcessor::clearEnsemble (void) {
|
||||
my_ficHandler. clearEnsemble ();
|
||||
my_ficHandler. reset ();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -104,11 +104,8 @@
|
||||
this -> programnameHandler = programnameHandler;
|
||||
this -> userData = userData;
|
||||
memset (dateTime, 0, 8 * sizeof (uint8_t));
|
||||
dateFlag = false;
|
||||
ecc_Present = false;
|
||||
interTab_Present = false;
|
||||
clearEnsemble ();
|
||||
coordinates. cleanUp ();
|
||||
|
||||
reset ();
|
||||
}
|
||||
|
||||
fib_processor::~fib_processor (void) {
|
||||
@@ -139,7 +136,7 @@ uint8_t *d = p;
|
||||
break;
|
||||
|
||||
default:
|
||||
// fprintf (stderr, "FIG%d aanwezig\n", FIGtype);
|
||||
fprintf (stderr, "FIG%d aanwezig\n", FIGtype);
|
||||
break;
|
||||
}
|
||||
//
|
||||
@@ -1272,7 +1269,6 @@ int16_t i;
|
||||
isSynced = false;
|
||||
for (i = 0; i < 64; i ++)
|
||||
ServiceComps [i]. inUse = false;
|
||||
|
||||
}
|
||||
|
||||
void fib_processor::clearEnsemble (void) {
|
||||
@@ -1290,6 +1286,7 @@ int16_t i;
|
||||
subChannels [i]. inUse = false;
|
||||
}
|
||||
firstTime = true;
|
||||
fprintf (stderr, "clearEnsemble done\n");
|
||||
}
|
||||
|
||||
std::string fib_processor::nameFor (int32_t serviceId) {
|
||||
@@ -1541,3 +1538,10 @@ uint8_t fib_processor::getInterTabId (bool *success) {
|
||||
return interTabId;
|
||||
}
|
||||
|
||||
void fib_processor::reset (void) {
|
||||
dateFlag = false;
|
||||
ecc_Present = false;
|
||||
interTab_Present = false;
|
||||
clearEnsemble ();
|
||||
}
|
||||
|
||||
|
@@ -304,3 +304,7 @@ void ficHandler::show_ficCRC (bool b) {
|
||||
}
|
||||
}
|
||||
|
||||
void ficHandler::reset (void) {
|
||||
fibProcessor. reset ();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user