Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
3e3afa03
Commit
3e3afa03
authored
16 years ago
by
tho
Browse files
Options
Downloads
Patches
Plain Diff
DVBSocketController: some code convention clean ups
parent
0cd2cabe
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Socket/Protocols/DVB/DVBSocketController.cc
+113
-94
113 additions, 94 deletions
Socket/Protocols/DVB/DVBSocketController.cc
Socket/Protocols/DVB/DVBSocketController.hh
+157
-122
157 additions, 122 deletions
Socket/Protocols/DVB/DVBSocketController.hh
with
270 additions
and
216 deletions
Socket/Protocols/DVB/DVBSocketController.cc
+
113
−
94
View file @
3e3afa03
...
...
@@ -20,26 +20,30 @@
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
\brief DVBSocketController non-inline non-template implementation */
#include
"DVBSocketController.hh"
// Custom includes
#include
<sstream>
#include
"senf/Utils/Exception.hh"
#include
"senf/Utils/Logger/Logger.hh"
#include
"senf/Utils/membind.hh"
#include
"DVBSocketController.hh"
#include
<sstream>
using
namespace
std
;
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
using
namespace
std
;
senf
::
DVBSocketController
::
DVBSocketController
(
DVBFrontendHandle
frontendHandle_
,
DVBDemuxSectionHandle
sectionHandle_
,
const
Callback
&
cb_
)
:
dir
(
this
),
frontendHandle
(
frontendHandle_
),
sectionHandle
(
sectionHandle_
),
type
(
frontendHandle
.
protocol
().
getInfo
().
type
),
parser
(
type
),
cb
(
cb_
),
event
(
"senf::DVBSocketController::readEvent"
,
senf
::
membind
(
&
DVBSocketController
::
readEvent
,
this
),
frontendHandle
,
senf
::
scheduler
::
FdEvent
::
EV_PRIO
,
false
)
senf
::
DVBSocketController
::
DVBSocketController
(
DVBFrontendHandle
frontendHandle_
,
DVBDemuxSectionHandle
sectionHandle_
,
const
Callback
&
cb_
)
:
dir
(
this
),
frontendHandle
(
frontendHandle_
),
sectionHandle
(
sectionHandle_
),
type
(
frontendHandle
.
protocol
().
getInfo
().
type
),
parser
(
type
),
cb
(
cb_
),
event
(
"senf::DVBSocketController::readEvent"
,
senf
::
membind
(
&
DVBSocketController
::
readEvent
,
this
),
frontendHandle
,
senf
::
scheduler
::
FdEvent
::
EV_PRIO
,
false
)
{
initConsole
();
}
...
...
@@ -47,10 +51,11 @@ senf::DVBSocketController::DVBSocketController(DVBFrontendHandle frontendHandle_
prefix_
senf
::
DVBSocketController
::~
DVBSocketController
()
{
}
prefix_
void
senf
::
DVBSocketController
::
tuneToCMD
(
const
string
&
input
,
const
string
&
mode
){
prefix_
void
senf
::
DVBSocketController
::
tuneToCMD
(
const
string
&
input
,
const
string
&
mode
)
{
struct
dvb_frontend_parameters
frontend
;
// no valid configline, so it will be treaten like a channel name
if
(
input
.
find
(
":"
)
==
string
::
npos
){
if
(
mode
.
c_str
()[
0
]
==
'a'
)
...
...
@@ -61,7 +66,7 @@ prefix_ void senf::DVBSocketController::tuneToCMD(const string & input, const st
}
// add psydo name "foo" to complete configline syntax
frontend
=
parser
.
getFrontendParam
(
"foo:"
+
input
);
if
(
mode
.
c_str
()[
0
]
==
'a'
){
switch
(
type
)
{
case
FE_QPSK
:
...
...
@@ -97,9 +102,9 @@ prefix_ void senf::DVBSocketController::tuneToCMD(const string & input, const st
prefix_
void
senf
::
DVBSocketController
::
tuneTo
(
const
string
&
channel
)
{
struct
dvb_frontend_parameters
frontend
;
string
configLine
=
parser
.
getConfigLine
(
channel
);
frontend
=
parser
.
getFrontendParam
(
configLine
);
switch
(
type
)
{
case
FE_QPSK
:
...
...
@@ -113,61 +118,62 @@ prefix_ void senf::DVBSocketController::tuneTo(const string & channel)
break
;
default:
SENF_THROW_SYSTEM_EXCEPTION
(
"Could not determine type of card."
);
}
}
}
prefix_
void
senf
::
DVBSocketController
::
tuneDVB_T
(
unsigned
int
frequency
,
prefix_
void
senf
::
DVBSocketController
::
tuneDVB_T
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
fe_bandwidth_t
bandwidth
,
fe_bandwidth_t
bandwidth
,
fe_code_rate_t
code_rate_HP
,
/* high priority stream code rate */
fe_code_rate_t
code_rate_LP
,
/* low priority stream code rate */
fe_modulation_t
constellation
,
/* modulation type (see above) */
fe_transmit_mode_t
transmission_mode
,
fe_transmit_mode_t
transmission_mode
,
fe_guard_interval_t
guard_interval
,
fe_hierarchy_t
hierarchy_information
)
{
if
(
type
!=
FE_OFDM
)
SENF_THROW_SYSTEM_EXCEPTION
(
"Type of card is: "
)
<<
getTypeString
()
<<
" for this operation you need a DVB-T Card!"
;
event
.
enable
();
frontendHandle
.
protocol
().
setNonBlock
();
frontendHandle
.
protocol
().
tuneDVB_T
(
frequency
,
inversion
,
bandwidth
,
code_rate_HP
,
code_rate_LP
,
constellation
,
transmission_mode
,
guard_interval
,
frontendHandle
.
protocol
().
tuneDVB_T
(
frequency
,
inversion
,
bandwidth
,
code_rate_HP
,
code_rate_LP
,
constellation
,
transmission_mode
,
guard_interval
,
hierarchy_information
);
}
prefix_
void
senf
::
DVBSocketController
::
tuneDVB_S
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
unsigned
int
symbole_rate
,
fe_code_rate_t
code_rate
){
prefix_
void
senf
::
DVBSocketController
::
tuneDVB_S
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
unsigned
int
symbole_rate
,
fe_code_rate_t
code_rate
)
{
if
(
type
!=
FE_QPSK
)
SENF_THROW_SYSTEM_EXCEPTION
(
"Type of card is: "
)
<<
getTypeString
()
<<
" for this operation you need a DVB-S Card!"
;
event
.
enable
();
frontendHandle
.
protocol
().
setNonBlock
();
frontendHandle
.
protocol
().
tuneDVB_S
(
frequency
,
inversion
,
symbole_rate
,
code_rate
);
}
prefix_
void
senf
::
DVBSocketController
::
tuneDVB_C
(
unsigned
int
frequency
,
prefix_
void
senf
::
DVBSocketController
::
tuneDVB_C
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
unsigned
int
symbol_rate
,
fe_code_rate_t
fec_inner
,
fe_modulation_t
modulation
)
{
{
if
(
type
!=
FE_QAM
)
SENF_THROW_SYSTEM_EXCEPTION
(
"Type of card is: "
)
<<
getTypeString
()
<<
" for this operation you need a DVB-C Card!"
;
event
.
enable
();
frontendHandle
.
protocol
().
setNonBlock
();
frontendHandle
.
protocol
().
tuneDVB_C
(
frequency
,
inversion
,
symbol_rate
,
fec_inner
,
modulation
);
}
...
...
@@ -176,7 +182,7 @@ prefix_ dvb_frontend_event senf::DVBSocketController::tuneTo_sync(const string &
struct
dvb_frontend_parameters
frontend
;
dvb_frontend_event
ev
;
string
configLine
=
parser
.
getConfigLine
(
channel
);
frontend
=
parser
.
getFrontendParam
(
configLine
);
switch
(
type
)
{
case
FE_QPSK
:
...
...
@@ -194,69 +200,69 @@ prefix_ dvb_frontend_event senf::DVBSocketController::tuneTo_sync(const string &
return
ev
;
}
prefix_
dvb_frontend_event
senf
::
DVBSocketController
::
tuneDVB_T_sync
(
unsigned
int
frequency
,
prefix_
dvb_frontend_event
senf
::
DVBSocketController
::
tuneDVB_T_sync
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
fe_bandwidth_t
bandwidth
,
fe_bandwidth_t
bandwidth
,
fe_code_rate_t
code_rate_HP
,
/* high priority stream code rate */
fe_code_rate_t
code_rate_LP
,
/* low priority stream code rate */
fe_modulation_t
constellation
,
/* modulation type (see above) */
fe_transmit_mode_t
transmission_mode
,
fe_transmit_mode_t
transmission_mode
,
fe_guard_interval_t
guard_interval
,
fe_hierarchy_t
hierarchy_information
)
{
if
(
type
!=
FE_OFDM
)
SENF_THROW_SYSTEM_EXCEPTION
(
"Type of card is: "
)
<<
getTypeString
()
<<
" for this operation you need a DVB-T Card!"
;
event
.
disable
();
frontendHandle
.
protocol
().
setNonBlock
(
false
);
frontendHandle
.
protocol
().
tuneDVB_T
(
frequency
,
inversion
,
bandwidth
,
code_rate_HP
,
code_rate_LP
,
constellation
,
transmission_mode
,
guard_interval
,
frontendHandle
.
protocol
().
tuneDVB_T
(
frequency
,
inversion
,
bandwidth
,
code_rate_HP
,
code_rate_LP
,
constellation
,
transmission_mode
,
guard_interval
,
hierarchy_information
);
if
(
!
frontendHandle
.
waitOOBReadable
(
senf
::
ClockService
::
seconds
(
2
)))
SENF_THROW_SYSTEM_EXCEPTION
(
"Could not tune to channel!"
);
return
frontendHandle
.
protocol
().
getEvent
();
}
prefix_
dvb_frontend_event
senf
::
DVBSocketController
::
tuneDVB_S_sync
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
unsigned
int
symbole_rate
,
fe_code_rate_t
code_rate
){
if
(
type
!=
FE_QPSK
)
SENF_THROW_SYSTEM_EXCEPTION
(
"Type of card is: "
)
<<
getTypeString
()
<<
" for this operation you need a DVB-S Card!"
;
event
.
disable
();
frontendHandle
.
protocol
().
setNonBlock
(
false
);
frontendHandle
.
protocol
().
tuneDVB_S
(
frequency
,
inversion
,
symbole_rate
,
code_rate
);
if
(
!
frontendHandle
.
waitOOBReadable
(
senf
::
ClockService
::
seconds
(
2
)))
SENF_THROW_SYSTEM_EXCEPTION
(
"Could not tune to channel!"
);
return
frontendHandle
.
protocol
().
getEvent
();
}
prefix_
dvb_frontend_event
senf
::
DVBSocketController
::
tuneDVB_C_sync
(
unsigned
int
frequency
,
prefix_
dvb_frontend_event
senf
::
DVBSocketController
::
tuneDVB_C_sync
(
unsigned
int
frequency
,
fe_spectral_inversion_t
inversion
,
unsigned
int
symbol_rate
,
fe_code_rate_t
fec_inner
,
fe_modulation_t
modulation
)
{
{
if
(
type
!=
FE_QAM
)
SENF_THROW_SYSTEM_EXCEPTION
(
"Type of card is: "
)
<<
getTypeString
()
<<
" for this operation you need a DVB-C Card!"
;
event
.
disable
();
frontendHandle
.
protocol
().
setNonBlock
(
false
);
frontendHandle
.
protocol
().
tuneDVB_C
(
frequency
,
inversion
,
symbol_rate
,
fec_inner
,
modulation
);
if
(
!
frontendHandle
.
waitOOBReadable
(
senf
::
ClockService
::
seconds
(
2
)))
SENF_THROW_SYSTEM_EXCEPTION
(
"Could not tune to channel!"
);
...
...
@@ -265,7 +271,8 @@ prefix_ dvb_frontend_event senf::DVBSocketController::tuneDVB_C_sync(unsigned in
}
prefix_
string
senf
::
DVBSocketController
::
getTypeString
(){
prefix_
string
senf
::
DVBSocketController
::
getTypeString
()
{
switch
(
type
)
{
case
FE_QPSK
:
return
"DVB-S"
;
...
...
@@ -276,24 +283,28 @@ prefix_ string senf::DVBSocketController::getTypeString(){
default:
SENF_THROW_SYSTEM_EXCEPTION
(
"Could not determine type of card."
);
}
}
prefix_
unsigned
int
senf
::
DVBSocketController
::
bitErrorRate
(){
prefix_
unsigned
int
senf
::
DVBSocketController
::
bitErrorRate
()
{
return
frontendHandle
.
protocol
().
bitErrorRate
();
}
prefix_
unsigned
int
senf
::
DVBSocketController
::
signalToNoiseRatio
(){
prefix_
unsigned
int
senf
::
DVBSocketController
::
signalToNoiseRatio
()
{
return
frontendHandle
.
protocol
().
signalNoiseRatio
();
}
prefix_
unsigned
int
senf
::
DVBSocketController
::
signalStrength
(){
prefix_
unsigned
int
senf
::
DVBSocketController
::
signalStrength
()
{
return
frontendHandle
.
protocol
().
signalStrength
();
}
prefix_
string
senf
::
DVBSocketController
::
getTuneInfo
(
const
string
&
conf
){
prefix_
string
senf
::
DVBSocketController
::
getTuneInfo
(
const
string
&
conf
)
{
const
char
*
cConf
=
conf
.
c_str
();
stringstream
info
;
fe_status_t
status
;
frontendHandle
.
protocol
().
setNonBlock
(
false
);
uint16_t
snr
,
signal
;
...
...
@@ -303,9 +314,9 @@ prefix_ string senf::DVBSocketController::getTuneInfo(const string & conf){
signal
=
frontendHandle
.
protocol
().
signalStrength
();
ber
=
frontendHandle
.
protocol
().
bitErrorRate
();
uncorrected_blocks
=
frontendHandle
.
protocol
().
uncorrectedBlocks
();
info
<<
hex
;
for
(
unsigned
int
i
=
0
;
i
<
conf
.
size
();
++
i
){
if
(
i
>
0
)
info
<<
" | "
;
...
...
@@ -313,7 +324,7 @@ prefix_ string senf::DVBSocketController::getTuneInfo(const string & conf){
case
'S'
:
info
<<
"signal "
<<
signal
;
break
;
case
's'
:
case
's'
:
info
<<
"snr "
<<
snr
;
break
;
case
'b'
:
...
...
@@ -331,10 +342,12 @@ prefix_ string senf::DVBSocketController::getTuneInfo(const string & conf){
}
return
info
.
str
();
}
prefix_
string
senf
::
DVBSocketController
::
status2String
(
fe_status_t
status
){
string
s
(
""
);
prefix_
string
senf
::
DVBSocketController
::
status2String
(
fe_status_t
status
)
{
string
s
(
""
);
if
(
status
&
FE_HAS_LOCK
)
return
s
+=
"HAS LOCK"
;
return
s
+=
"HAS LOCK"
;
if
(
status
&
FE_HAS_CARRIER
)
s
+=
"HAS CARRIER "
;
if
(
status
&
FE_HAS_VITERBI
)
...
...
@@ -351,15 +364,15 @@ prefix_ string senf::DVBSocketController::status2String(fe_status_t status){
return
s
;
}
prefix_
void
senf
::
DVBSocketController
::
setSectionFilter
(
unsigned
short
int
pid
,
prefix_
void
senf
::
DVBSocketController
::
setSectionFilter
(
unsigned
short
int
pid
,
u_int8_t
filter
,
unsigned
int
flags
,
u_int8_t
mask
,
unsigned
int
flags
,
u_int8_t
mask
,
u_int8_t
mode
,
unsigned
int
timeout
)
{
sectionHandle
.
protocol
().
setSectionFilter
(
pid
,
timeout
,
flags
,
filter
,
mask
,
mode
);
}
prefix_
void
senf
::
DVBSocketController
::
setBufferSize
(
unsigned
long
size
)
...
...
@@ -377,23 +390,26 @@ prefix_ void senf::DVBSocketController::stopFiltering()
sectionHandle
.
protocol
().
stopFiltering
();
}
prefix_
fe_type_t
senf
::
DVBSocketController
::
getType
(){
prefix_
fe_type_t
senf
::
DVBSocketController
::
getType
()
{
return
type
;
}
prefix_
void
senf
::
DVBSocketController
::
readEvent
(
int
event
){
prefix_
void
senf
::
DVBSocketController
::
readEvent
(
int
event
)
{
if
(
cb
)
cb
(
frontendHandle
.
protocol
().
getEvent
());
}
prefix_
void
senf
::
DVBSocketController
::
initConsole
(){
prefix_
void
senf
::
DVBSocketController
::
initConsole
()
{
// binding functions to console
namespace
kw
=
senf
::
console
::
kw
;
dir
.
doc
(
"DVB Controller"
);
dir
.
add
(
"type"
,
&
DVBSocketController
::
getTypeString
)
.
doc
(
"Shows actual type of card DVB-{T, S, C}"
);
dir
.
add
(
"info"
,
&
DVBSocketController
::
getTuneInfo
)
.
doc
(
"Returns a string which shows actual tuning status.
\n
\
\"
S
\"
prints signal strength (in hex)
\n
\
...
...
@@ -405,22 +421,22 @@ prefix_ void senf::DVBSocketController::initConsole(){
features may not be supported be your current driver implementation
\n
\
and could end in throwing an exception!"
)
.
arg
(
"conf"
,
"Ssbuf"
,
kw
::
default_value
=
"Ssbuf"
);
dir
.
add
(
"tune"
,
&
DVBSocketController
::
tuneToCMD
)
.
doc
(
"tunes to channel listet in the configfile."
)
.
arg
(
"channel"
,
"channel to tune"
)
.
arg
(
"mode"
,
"mode
\"
sync
\"
or
\"
async
\"
"
,
kw
::
default_value
=
"async"
);
dir
.
add
(
"buffersize"
,
&
DVBSocketController
::
setBufferSize
)
.
doc
(
"Set the size of the circular buffer used for filtered data."
)
.
arg
(
"size"
,
"in byte"
);
dir
.
add
(
"start"
,
&
DVBSocketController
::
startFiltering
)
.
doc
(
"Starts filtering"
);
dir
.
add
(
"stop"
,
&
DVBSocketController
::
setBufferSize
)
.
doc
(
"Stops filtering"
);
dir
.
add
(
"filter"
,
&
DVBSocketController
::
setSectionFilter
)
.
arg
(
"pid"
,
"pid to filter"
)
.
arg
(
"filter"
,
"filter"
,
kw
::
default_value
=
62
,
kw
::
default_doc
=
"0x3e"
)
...
...
@@ -429,7 +445,10 @@ prefix_ void senf::DVBSocketController::initConsole(){
.
arg
(
"mode"
,
"mode"
,
kw
::
default_value
=
0
,
kw
::
default_doc
=
"0x00"
)
.
arg
(
"timeout"
,
"timeout"
,
kw
::
default_value
=
0
,
kw
::
default_doc
=
"0x00"
)
.
doc
(
"Sets parameters for section filter."
);
dir
.
add
(
"stop"
,
&
DVBSocketController
::
setBufferSize
)
.
doc
(
"Stops filtering"
);
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
This diff is collapsed.
Click to expand it.
Socket/Protocols/DVB/DVBSocketController.hh
+
157
−
122
View file @
3e3afa03
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment