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
c28a5019
Commit
c28a5019
authored
Apr 27, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started to implement hls reader.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
eff7ff6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
1 deletion
+115
-1
Makefile.am
src/Makefile.am
+4
-1
testhls.cc
src/testhls.cc
+111
-0
No files found.
src/Makefile.am
View file @
c28a5019
...
...
@@ -11,7 +11,7 @@ COMMON_LIBS = $(SNDFILE_LIBS) $(FFTW_LIBS) $(LIBGCRYPT_LIBS) $(LIBMPG123_LIBS)
audiowmark_SOURCES
=
audiowmark.cc wmget.cc wmadd.cc
$(COMMON_SRC)
audiowmark_LDFLAGS
=
$(COMMON_LIBS)
noinst_PROGRAMS
=
testconvcode testrandom testmp3 teststream testlimiter testmpegts
noinst_PROGRAMS
=
testconvcode testrandom testmp3 teststream testlimiter testmpegts
testhls
testconvcode_SOURCES
=
testconvcode.cc
$(COMMON_SRC)
testconvcode_LDFLAGS
=
$(COMMON_LIBS)
...
...
@@ -30,3 +30,6 @@ testlimiter_LDFLAGS = $(COMMON_LIBS)
testmpegts_SOURCES
=
testmpegts.cc
$(COMMON_SRC)
testmpegts_LDFLAGS
=
$(COMMON_LIBS)
testhls_SOURCES
=
testhls.cc
$(COMMON_SRC)
testhls_LDFLAGS
=
$(COMMON_LIBS)
src/testhls.cc
0 → 100644
View file @
c28a5019
/*
* Copyright (C) 2018-2020 Stefan Westerfeld
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdio.h>
#include <regex>
#include "utils.hh"
using
std
::
string
;
using
std
::
regex
;
using
std
::
vector
;
class
TSWriter
{
public
:
void
append_file
(
const
string
&
name
,
const
string
&
filename
)
{}
void
process
(
const
string
&
in_name
,
const
string
&
out_name
)
{}
};
int
hls_embed_context
(
const
string
&
in_dir
,
const
string
&
out_dir
,
const
string
&
filename
)
{
string
in_name
=
in_dir
+
"/"
+
filename
;
FILE
*
in_file
=
fopen
(
in_name
.
c_str
(),
"r"
);
ScopedFile
in_file_s
(
in_file
);
if
(
!
in_file
)
{
error
(
"audiowmark: error opening input playlist %s
\n
"
,
in_name
.
c_str
());
return
1
;
}
string
out_name
=
out_dir
+
"/"
+
filename
;
FILE
*
out_file
=
fopen
(
out_name
.
c_str
(),
"w"
);
ScopedFile
out_file_s
(
out_file
);
if
(
!
out_file
)
{
error
(
"audiowmark: error opening output playlist %s
\n
"
,
out_name
.
c_str
());
return
1
;
}
vector
<
string
>
segments
;
char
buffer
[
1024
];
int
line
=
1
;
const
regex
blank_re
(
R"(\s*(#.*)?)"
);
while
(
fgets
(
buffer
,
1024
,
in_file
))
{
/* kill newline chars at end */
int
last
=
strlen
(
buffer
)
-
1
;
while
(
last
>
0
&&
(
buffer
[
last
]
==
'\n'
||
buffer
[
last
]
==
'\r'
))
buffer
[
last
--
]
=
0
;
string
s
=
buffer
;
std
::
smatch
match
;
if
(
regex_match
(
s
,
blank_re
))
{
/* blank line or comment */
fprintf
(
out_file
,
"%s
\n
"
,
s
.
c_str
());
}
else
{
fprintf
(
out_file
,
"%s
\n
"
,
s
.
c_str
());
segments
.
push_back
(
s
);
}
line
++
;
}
for
(
size_t
i
=
0
;
i
<
segments
.
size
();
i
++
)
{
TSWriter
writer
;
if
(
i
>
0
)
writer
.
append_file
(
"prev.ts"
,
out_dir
+
"/"
+
segments
[
i
-
1
]);
if
(
i
+
1
<
segments
.
size
())
writer
.
append_file
(
"next.ts"
,
out_dir
+
"/"
+
segments
[
i
+
1
]);
writer
.
process
(
in_dir
+
"/"
+
segments
[
i
],
out_dir
+
"/"
+
segments
[
i
]);
}
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
5
&&
strcmp
(
argv
[
1
],
"hls-embed-context"
)
==
0
)
{
printf
(
"hls-embed-context: in_dir=%s out_dir=%s m3u8=%s
\n
"
,
argv
[
2
],
argv
[
3
],
argv
[
4
]);
return
hls_embed_context
(
argv
[
2
],
argv
[
3
],
argv
[
4
]);
}
else
{
error
(
"testhls: error parsing command line arguments
\n
"
);
}
}
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