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
ecaeec1e
Commit
ecaeec1e
authored
17 years ago
by
tho
Browse files
Options
Downloads
Patches
Plain Diff
psi2ts: payload pointer handling still missing :(
parent
f3bfad44
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Examples/psi2tsModule/psi2ts.cc
+8
-2
8 additions, 2 deletions
Examples/psi2tsModule/psi2ts.cc
Examples/psi2tsModule/psi2ts.hh
+2
-1
2 additions, 1 deletion
Examples/psi2tsModule/psi2ts.hh
Examples/psi2tsModule/psi2ts.test.cc
+91
-18
91 additions, 18 deletions
Examples/psi2tsModule/psi2ts.test.cc
with
101 additions
and
21 deletions
Examples/psi2tsModule/psi2ts.cc
+
8
−
2
View file @
ecaeec1e
...
...
@@ -43,8 +43,9 @@ namespace {
}
prefix_
Psi2TsModule
::
Psi2TsModule
()
prefix_
Psi2TsModule
::
Psi2TsModule
(
unsigned
pid
)
{
pid_
=
pid
;
continuity_counter_
=
0
;
state_
=
IDLE
;
route
(
input
,
output
);
...
...
@@ -62,12 +63,17 @@ prefix_ void Psi2TsModule::onRequest()
do
{
senf
::
TransportPacket
tsPacket
(
senf
::
TransportPacket
::
create
(
188
));
tsPacket
->
continuity_counter
()
=
next_continuity_counter
();
tsPacket
->
pid
()
=
pid_
;
if
(
state_
==
IDLE
)
{
state_
=
PROC
;
tsPacket
->
pusi
()
=
true
;
}
senf
::
PacketData
&
payloadData
(
tsPacket
.
next
().
data
());
std
::
copy
(
begin
,
end
,
payloadData
.
begin
()
);
std
::
fill
(
std
::
copy
(
begin
,
end
,
payloadData
.
begin
()
),
payloadData
.
end
(),
0xff
);
tsPacket
.
finalize
();
output
.
write
(
tsPacket
);
...
...
This diff is collapsed.
Click to expand it.
Examples/psi2tsModule/psi2ts.hh
+
2
−
1
View file @
ecaeec1e
...
...
@@ -44,7 +44,7 @@ class Psi2TsModule
public:
senf
::
ppi
::
connector
::
PassiveInput
<>
input
;
senf
::
ppi
::
connector
::
ActiveOutput
<
senf
::
TransportPacket
>
output
;
Psi2TsModule
();
Psi2TsModule
(
unsigned
pid
);
void
onRequest
();
private:
...
...
@@ -53,6 +53,7 @@ private:
unsigned
continuity_counter_
;
unsigned
next_continuity_counter
();
state
state_
;
unsigned
pid_
;
};
...
...
This diff is collapsed.
Click to expand it.
Examples/psi2tsModule/psi2ts.test.cc
+
91
−
18
View file @
ecaeec1e
...
...
@@ -49,36 +49,109 @@ void check_transportpacket_header(senf::TransportPacket tsPacket, bool pusi, uns
}
template
<
class
InputIterator
,
class
T
>
bool
equal_elements
(
InputIterator
first
,
InputIterator
last
,
const
T
&
value
)
{
return
std
::
find_if
(
first
,
last
,
boost
::
lambda
::
_1
!=
value
)
==
last
;
}
BOOST_AUTO_UNIT_TEST
(
one_section_to_one_transportpacket
)
{
senf
::
ppi
::
module
::
debug
::
ActiveSource
source
;
senf
::
ppi
::
module
::
debug
::
PassiveSink
sink
;
Psi2TsModule
psi2ts
;
unsigned
PID
=
42
;
Psi2TsModule
psi2ts
(
PID
);
senf
::
ppi
::
connect
(
source
,
psi2ts
);
senf
::
ppi
::
connect
(
psi2ts
,
sink
);
senf
::
ppi
::
connect
(
source
,
psi2ts
);
senf
::
ppi
::
connect
(
psi2ts
,
sink
);
senf
::
ppi
::
init
();
std
::
string
payload
_data
(
"psi2ts_test: one_section_to_one_transportpacket"
);
senf
::
Packet
payload
(
senf
::
DataPacket
::
create
(
payload
_data
));
payload
.
finalize
();
std
::
string
sec
_data
(
"psi2ts_test: one_section_to_one_transportpacket"
);
senf
::
Packet
sec_packet
(
senf
::
DataPacket
::
create
(
sec
_data
));
sec_packet
.
finalize
();
source
.
submit
(
payload
);
source
.
submit
(
sec_packet
);
BOOST_CHECK_EQUAL
(
sink
.
size
(),
1u
);
senf
::
TransportPacket
ts
P
acket
=
sink
.
pop_front
().
as
<
senf
::
TransportPacket
>
();
check_transportpacket_header
(
ts
P
acket
,
true
,
0
,
1
);
senf
::
PacketData
&
ts_data
=
ts
P
acket
.
next
().
data
();
senf
::
TransportPacket
ts
_p
acket
=
sink
.
pop_front
().
as
<
senf
::
TransportPacket
>
();
check_transportpacket_header
(
ts
_p
acket
,
true
,
PID
,
1
);
senf
::
PacketData
&
ts_
payload_
data
=
ts
_p
acket
.
next
().
data
();
BOOST_CHECK_EQUAL_COLLECTIONS
(
ts_data
.
begin
(),
boost
::
next
(
ts_data
.
begin
(),
payload_data
.
size
()),
payload_data
.
begin
(),
payload_data
.
end
());
// BOOST_CHECK( std::find_if(
// boost::next( ts_data.begin(), payload_data.size()),
// ts_data.end(),
// boost::lambda::_1 != 0xffu) == ts_data.end() );
ts_payload_data
.
begin
(),
boost
::
next
(
ts_payload_data
.
begin
(),
sec_data
.
size
()),
sec_data
.
begin
(),
sec_data
.
end
());
BOOST_CHECK
(
equal_elements
(
boost
::
next
(
ts_payload_data
.
begin
(),
ts_payload_data
.
size
()),
ts_payload_data
.
end
(),
0xffu
));
}
BOOST_AUTO_UNIT_TEST
(
one_section_to_two_transportpackets
)
{
senf
::
ppi
::
module
::
debug
::
ActiveSource
source
;
senf
::
ppi
::
module
::
debug
::
PassiveSink
sink
;
unsigned
PID
=
42
;
Psi2TsModule
psi2ts
(
PID
);
senf
::
ppi
::
connect
(
source
,
psi2ts
);
senf
::
ppi
::
connect
(
psi2ts
,
sink
);
senf
::
ppi
::
init
();
std
::
string
sec_data
(
184
,
0x42
);
std
::
string
sec_data2
(
"psi2ts_test: one_section_to_two_transportpackets"
);
sec_data
.
append
(
sec_data2
);
senf
::
Packet
sec_packet
(
senf
::
DataPacket
::
create
(
sec_data
));
sec_packet
.
finalize
();
source
.
submit
(
sec_packet
);
BOOST_CHECK_EQUAL
(
sink
.
size
(),
2u
);
senf
::
TransportPacket
ts_packet
=
sink
.
pop_front
().
as
<
senf
::
TransportPacket
>
();
check_transportpacket_header
(
ts_packet
,
true
,
PID
,
1
);
senf
::
PacketData
&
ts_payload_data1
=
ts_packet
.
next
().
data
();
BOOST_CHECK
(
equal_elements
(
ts_payload_data1
.
begin
(),
ts_payload_data1
.
end
(),
0x42
));
ts_packet
=
sink
.
pop_front
().
as
<
senf
::
TransportPacket
>
();
check_transportpacket_header
(
ts_packet
,
false
,
PID
,
2
);
senf
::
PacketData
&
ts_payload_data2
=
ts_packet
.
next
().
data
();
BOOST_CHECK_EQUAL_COLLECTIONS
(
ts_payload_data2
.
begin
(),
boost
::
next
(
ts_payload_data2
.
begin
(),
sec_data2
.
size
()),
sec_data2
.
begin
(),
sec_data2
.
end
());
BOOST_CHECK
(
equal_elements
(
boost
::
next
(
ts_payload_data2
.
begin
(),
sec_data2
.
size
()),
ts_payload_data2
.
end
(),
0xffu
));
}
BOOST_AUTO_UNIT_TEST
(
many_sections_to_many_transportpackets
)
{
senf
::
ppi
::
module
::
debug
::
ActiveSource
source
;
senf
::
ppi
::
module
::
debug
::
PassiveSink
sink
;
unsigned
PID
=
42
;
Psi2TsModule
psi2ts
(
PID
);
senf
::
ppi
::
connect
(
source
,
psi2ts
);
senf
::
ppi
::
connect
(
psi2ts
,
sink
);
senf
::
ppi
::
init
();
std
::
string
sec_data
(
"many_sections_to_many_transportpackets"
);
senf
::
Packet
sec_packet
(
senf
::
DataPacket
::
create
(
sec_data
));
sec_packet
.
finalize
();
unsigned
NUMBER_OF_SECTIONS
=
42u
;
for
(
unsigned
i
=
1
;
i
<=
NUMBER_OF_SECTIONS
;
i
++
)
{
source
.
submit
(
sec_packet
);
}
BOOST_CHECK_EQUAL
(
sink
.
size
(),
NUMBER_OF_SECTIONS
);
for
(
unsigned
i
=
1
;
i
<=
NUMBER_OF_SECTIONS
;
i
++
)
{
senf
::
TransportPacket
ts_packet
=
sink
.
pop_front
().
as
<
senf
::
TransportPacket
>
();
check_transportpacket_header
(
ts_packet
,
true
,
PID
,
i
%
16
);
}
}
///////////////////////////////cc.e////////////////////////////////////////
...
...
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