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
fd8b78aa
Commit
fd8b78aa
authored
May 06, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testhls: add simple segment watermarking by zero padding / tmpfile
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
1a49f92f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
Makefile.am
src/Makefile.am
+1
-1
testhls.cc
src/testhls.cc
+47
-0
No files found.
src/Makefile.am
View file @
fd8b78aa
...
...
@@ -34,5 +34,5 @@ testshortcode_LDFLAGS = $(COMMON_LIBS)
testmpegts_SOURCES
=
testmpegts.cc
$(COMMON_SRC)
testmpegts_LDFLAGS
=
$(COMMON_LIBS)
testhls_SOURCES
=
testhls.cc
$(COMMON_SRC)
testhls_SOURCES
=
testhls.cc
wmadd.cc
$(COMMON_SRC)
testhls_LDFLAGS
=
$(COMMON_LIBS)
src/testhls.cc
View file @
fd8b78aa
...
...
@@ -23,6 +23,7 @@
#include "utils.hh"
#include "mpegts.hh"
#include "wavdata.hh"
#include "wmcommon.hh"
using
std
::
string
;
using
std
::
regex
;
...
...
@@ -238,6 +239,48 @@ hls_embed_context (const string& in_dir, const string& out_dir, const string& fi
return
0
;
}
int
mark_zexpand
(
WavData
&
wav_data
,
size_t
zero_frames
,
const
string
&
bits
)
{
vector
<
float
>
samples
;
samples
=
wav_data
.
samples
();
samples
.
insert
(
samples
.
begin
(),
zero_frames
*
wav_data
.
n_channels
(),
/* value */
0
);
wav_data
.
set_samples
(
samples
);
FILE
*
tmp_in
=
tmpfile
();
ScopedFile
tmp_in_s
(
tmp_in
);
string
tmp_in_name
=
string_printf
(
"/dev/fd/%d"
,
fileno
(
tmp_in
));
FILE
*
tmp_out
=
tmpfile
();
ScopedFile
tmp_out_s
(
tmp_out
);
string
tmp_out_name
=
string_printf
(
"/dev/fd/%d"
,
fileno
(
tmp_out
));
Error
err
=
wav_data
.
save
(
tmp_in_name
);
if
(
err
)
{
error
(
"mark zexpand save: %s"
,
err
.
message
());
return
1
;
}
int
rc
=
add_watermark
(
tmp_in_name
,
tmp_out_name
,
bits
);
if
(
rc
!=
0
)
return
rc
;
err
=
wav_data
.
load
(
tmp_out_name
);
if
(
err
)
{
error
(
"mark zexpand load: %s"
,
err
.
message
());
return
1
;
}
samples
=
wav_data
.
samples
();
samples
.
erase
(
samples
.
begin
(),
samples
.
begin
()
+
zero_frames
*
wav_data
.
n_channels
());
wav_data
.
set_samples
(
samples
);
return
0
;
}
int
hls_mark
(
const
string
&
infile
,
const
string
&
outfile
,
const
string
&
bits
)
{
...
...
@@ -272,6 +315,10 @@ hls_mark (const string& infile, const string& outfile, const string& bits)
size_t
next_ctx
=
min
<
size_t
>
(
1024
*
3
,
next_size
);
size_t
prev_ctx
=
min
<
size_t
>
(
1024
*
3
,
prev_size
);
int
zrc
=
mark_zexpand
(
wav_data
,
start_pos
-
prev_size
,
bits
);
if
(
zrc
!=
0
)
return
zrc
;
/* erase extra samples caused by concatting with prev.ts */
auto
samples
=
wav_data
.
samples
();
samples
.
erase
(
samples
.
begin
(),
samples
.
begin
()
+
(
prev_size
-
prev_ctx
)
*
wav_data
.
n_channels
());
...
...
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