Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
33973159
Commit
33973159
authored
Apr 29, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TSReader/TSWriter: implement generic key/value store.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
e7cc04f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
mpegts.cc
src/mpegts.cc
+53
-0
mpegts.hh
src/mpegts.hh
+2
-0
No files found.
src/mpegts.cc
View file @
33973159
...
...
@@ -24,6 +24,7 @@
using
std
::
string
;
using
std
::
vector
;
using
std
::
map
;
using
std
::
regex
;
class
TSPacket
...
...
@@ -167,6 +168,23 @@ TSWriter::append_file (const string& name, const string& filename)
return
Error
::
Code
::
NONE
;
}
void
TSWriter
::
append_vars
(
const
string
&
name
,
const
map
<
string
,
string
>&
vars
)
{
vector
<
unsigned
char
>
data
;
for
(
auto
kv
:
vars
)
{
for
(
auto
k
:
kv
.
first
)
data
.
push_back
(
k
);
data
.
push_back
(
'='
);
for
(
auto
v
:
kv
.
second
)
data
.
push_back
(
v
);
data
.
push_back
(
0
);
}
entries
.
push_back
({
name
,
data
});
}
Error
TSWriter
::
process
(
const
string
&
inname
,
const
string
&
outname
)
{
...
...
@@ -312,6 +330,41 @@ TSReader::entries()
return
m_entries
;
}
map
<
string
,
string
>
TSReader
::
parse_vars
(
const
string
&
name
)
{
map
<
string
,
string
>
vars
;
for
(
auto
entry
:
m_entries
)
{
if
(
entry
.
filename
==
name
)
{
enum
{
KEY
,
VALUE
}
mode
=
KEY
;
string
s
;
string
key
;
for
(
auto
c
:
entry
.
data
)
{
if
(
c
==
'='
&&
mode
==
KEY
)
{
key
=
s
;
s
.
clear
();
mode
=
VALUE
;
}
else
if
(
c
==
'\0'
&&
mode
==
VALUE
)
{
vars
[
key
]
=
s
;
s
.
clear
();
mode
=
KEY
;
}
else
{
s
+=
c
;
}
}
}
}
return
vars
;
}
int
pcr
(
const
string
&
filename
,
const
string
&
outname
,
double
d
)
...
...
src/mpegts.hh
View file @
33973159
...
...
@@ -37,6 +37,7 @@ private:
public
:
Error
load
(
const
std
::
string
&
inname
);
const
std
::
vector
<
Entry
>&
entries
();
std
::
map
<
std
::
string
,
std
::
string
>
parse_vars
(
const
std
::
string
&
name
);
};
class
TSWriter
...
...
@@ -49,6 +50,7 @@ class TSWriter
std
::
vector
<
Entry
>
entries
;
public
:
Error
append_file
(
const
std
::
string
&
name
,
const
std
::
string
&
filename
);
void
append_vars
(
const
std
::
string
&
name
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
vars
);
Error
process
(
const
std
::
string
&
in_name
,
const
std
::
string
&
out_name
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment