Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
706fcffc
Commit
706fcffc
authored
Jul 18, 2014
by
Nicolas Martyanoff
Committed by
Michael Niedermayer
Jul 30, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/hlsenc: rename some identifers to make the code easier to read
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
53f10e03
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
+27
-27
hlsenc.c
libavformat/hlsenc.c
+27
-27
No files found.
libavformat/hlsenc.c
View file @
706fcffc
...
...
@@ -31,11 +31,11 @@
#include "avformat.h"
#include "internal.h"
typedef
struct
ListEntry
{
char
name
[
1024
];
typedef
struct
HLSSegment
{
char
file
name
[
1024
];
double
duration
;
/* in seconds */
struct
ListEntry
*
next
;
}
ListEntry
;
struct
HLSSegment
*
next
;
}
HLSSegment
;
typedef
struct
HLSContext
{
const
AVClass
*
class
;
// Class for private options.
...
...
@@ -45,7 +45,7 @@ typedef struct HLSContext {
AVOutputFormat
*
oformat
;
AVFormatContext
*
avf
;
float
time
;
// Set by a private option.
int
size
;
// Set by a private option.
int
max_nb_segments
;
// Set by a private option.
int
wrap
;
// Set by a private option.
int64_t
recording_time
;
int
has_video
;
...
...
@@ -53,8 +53,8 @@ typedef struct HLSContext {
int64_t
end_pts
;
double
duration
;
// last segment duration computed so far, in seconds
int
nb_entries
;
ListEntry
*
list
;
ListEntry
*
end_lis
t
;
HLSSegment
*
segments
;
HLSSegment
*
last_segmen
t
;
char
*
basename
;
char
*
baseurl
;
AVIOContext
*
pb
;
...
...
@@ -86,28 +86,28 @@ static int hls_mux_init(AVFormatContext *s)
}
/* Create a new segment and append it to the segment list */
static
int
append_entry
(
HLSContext
*
hls
,
double
duration
)
static
int
hls_append_segment
(
HLSContext
*
hls
,
double
duration
)
{
ListEntry
*
en
=
av_malloc
(
sizeof
(
*
en
));
HLSSegment
*
en
=
av_malloc
(
sizeof
(
*
en
));
if
(
!
en
)
return
AVERROR
(
ENOMEM
);
av_strlcpy
(
en
->
name
,
av_basename
(
hls
->
avf
->
filename
),
sizeof
(
en
->
name
));
av_strlcpy
(
en
->
filename
,
av_basename
(
hls
->
avf
->
filename
),
sizeof
(
en
->
file
name
));
en
->
duration
=
duration
;
en
->
next
=
NULL
;
if
(
!
hls
->
list
)
hls
->
list
=
en
;
if
(
!
hls
->
segments
)
hls
->
segments
=
en
;
else
hls
->
end_lis
t
->
next
=
en
;
hls
->
last_segmen
t
->
next
=
en
;
hls
->
end_lis
t
=
en
;
hls
->
last_segmen
t
=
en
;
if
(
hls
->
size
&&
hls
->
nb_entries
>=
hls
->
size
)
{
en
=
hls
->
list
;
hls
->
list
=
en
->
next
;
if
(
hls
->
max_nb_segments
&&
hls
->
nb_entries
>=
hls
->
max_nb_segments
)
{
en
=
hls
->
segments
;
hls
->
segments
=
en
->
next
;
av_free
(
en
);
}
else
hls
->
nb_entries
++
;
...
...
@@ -117,9 +117,9 @@ static int append_entry(HLSContext *hls, double duration)
return
0
;
}
static
void
free_entrie
s
(
HLSContext
*
hls
)
static
void
hls_free_segment
s
(
HLSContext
*
hls
)
{
ListEntry
*
p
=
hls
->
list
,
*
en
;
HLSSegment
*
p
=
hls
->
segments
,
*
en
;
while
(
p
)
{
en
=
p
;
...
...
@@ -131,7 +131,7 @@ static void free_entries(HLSContext *hls)
static
int
hls_window
(
AVFormatContext
*
s
,
int
last
)
{
HLSContext
*
hls
=
s
->
priv_data
;
ListEntry
*
en
;
HLSSegment
*
en
;
int
target_duration
=
0
;
int
ret
=
0
;
int64_t
sequence
=
FFMAX
(
hls
->
start_sequence
,
hls
->
sequence
-
hls
->
nb_entries
);
...
...
@@ -140,7 +140,7 @@ static int hls_window(AVFormatContext *s, int last)
&
s
->
interrupt_callback
,
NULL
))
<
0
)
goto
fail
;
for
(
en
=
hls
->
list
;
en
;
en
=
en
->
next
)
{
for
(
en
=
hls
->
segments
;
en
;
en
=
en
->
next
)
{
if
(
target_duration
<
en
->
duration
)
target_duration
=
ceil
(
en
->
duration
);
}
...
...
@@ -153,11 +153,11 @@ static int hls_window(AVFormatContext *s, int last)
av_log
(
s
,
AV_LOG_VERBOSE
,
"EXT-X-MEDIA-SEQUENCE:%"
PRId64
"
\n
"
,
sequence
);
for
(
en
=
hls
->
list
;
en
;
en
=
en
->
next
)
{
for
(
en
=
hls
->
segments
;
en
;
en
=
en
->
next
)
{
avio_printf
(
hls
->
pb
,
"#EXTINF:%f,
\n
"
,
en
->
duration
);
if
(
hls
->
baseurl
)
avio_printf
(
hls
->
pb
,
"%s"
,
hls
->
baseurl
);
avio_printf
(
hls
->
pb
,
"%s
\n
"
,
en
->
name
);
avio_printf
(
hls
->
pb
,
"%s
\n
"
,
en
->
file
name
);
}
if
(
last
)
...
...
@@ -282,7 +282,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
if
(
can_split
&&
av_compare_ts
(
pkt
->
pts
-
hls
->
start_pts
,
st
->
time_base
,
end_pts
,
AV_TIME_BASE_Q
)
>=
0
)
{
ret
=
append_entry
(
hls
,
hls
->
duration
);
ret
=
hls_append_segment
(
hls
,
hls
->
duration
);
if
(
ret
)
return
ret
;
...
...
@@ -317,10 +317,10 @@ static int hls_write_trailer(struct AVFormatContext *s)
avio_closep
(
&
oc
->
pb
);
avformat_free_context
(
oc
);
av_free
(
hls
->
basename
);
append_entry
(
hls
,
hls
->
duration
);
hls_append_segment
(
hls
,
hls
->
duration
);
hls_window
(
s
,
1
);
free_entrie
s
(
hls
);
hls_free_segment
s
(
hls
);
avio_close
(
hls
->
pb
);
return
0
;
}
...
...
@@ -330,7 +330,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
static
const
AVOption
options
[]
=
{
{
"start_number"
,
"set first number in the sequence"
,
OFFSET
(
start_sequence
),
AV_OPT_TYPE_INT64
,
{.
i64
=
0
},
0
,
INT64_MAX
,
E
},
{
"hls_time"
,
"set segment length in seconds"
,
OFFSET
(
time
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
2
},
0
,
FLT_MAX
,
E
},
{
"hls_list_size"
,
"set maximum number of playlist entries"
,
OFFSET
(
size
),
AV_OPT_TYPE_INT
,
{.
i64
=
5
},
0
,
INT_MAX
,
E
},
{
"hls_list_size"
,
"set maximum number of playlist entries"
,
OFFSET
(
max_nb_segments
),
AV_OPT_TYPE_INT
,
{.
i64
=
5
},
0
,
INT_MAX
,
E
},
{
"hls_wrap"
,
"set number after which the index wraps"
,
OFFSET
(
wrap
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
INT_MAX
,
E
},
{
"hls_base_url"
,
"url to prepend to each playlist entry"
,
OFFSET
(
baseurl
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
,
E
},
{
NULL
},
...
...
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