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
Hide 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 @@
...
@@ -31,11 +31,11 @@
#include "avformat.h"
#include "avformat.h"
#include "internal.h"
#include "internal.h"
typedef
struct
ListEntry
{
typedef
struct
HLSSegment
{
char
name
[
1024
];
char
file
name
[
1024
];
double
duration
;
/* in seconds */
double
duration
;
/* in seconds */
struct
ListEntry
*
next
;
struct
HLSSegment
*
next
;
}
ListEntry
;
}
HLSSegment
;
typedef
struct
HLSContext
{
typedef
struct
HLSContext
{
const
AVClass
*
class
;
// Class for private options.
const
AVClass
*
class
;
// Class for private options.
...
@@ -45,7 +45,7 @@ typedef struct HLSContext {
...
@@ -45,7 +45,7 @@ typedef struct HLSContext {
AVOutputFormat
*
oformat
;
AVOutputFormat
*
oformat
;
AVFormatContext
*
avf
;
AVFormatContext
*
avf
;
float
time
;
// Set by a private option.
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.
int
wrap
;
// Set by a private option.
int64_t
recording_time
;
int64_t
recording_time
;
int
has_video
;
int
has_video
;
...
@@ -53,8 +53,8 @@ typedef struct HLSContext {
...
@@ -53,8 +53,8 @@ typedef struct HLSContext {
int64_t
end_pts
;
int64_t
end_pts
;
double
duration
;
// last segment duration computed so far, in seconds
double
duration
;
// last segment duration computed so far, in seconds
int
nb_entries
;
int
nb_entries
;
ListEntry
*
list
;
HLSSegment
*
segments
;
ListEntry
*
end_lis
t
;
HLSSegment
*
last_segmen
t
;
char
*
basename
;
char
*
basename
;
char
*
baseurl
;
char
*
baseurl
;
AVIOContext
*
pb
;
AVIOContext
*
pb
;
...
@@ -86,28 +86,28 @@ static int hls_mux_init(AVFormatContext *s)
...
@@ -86,28 +86,28 @@ static int hls_mux_init(AVFormatContext *s)
}
}
/* Create a new segment and append it to the segment list */
/* 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
)
if
(
!
en
)
return
AVERROR
(
ENOMEM
);
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
->
duration
=
duration
;
en
->
next
=
NULL
;
en
->
next
=
NULL
;
if
(
!
hls
->
list
)
if
(
!
hls
->
segments
)
hls
->
list
=
en
;
hls
->
segments
=
en
;
else
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
)
{
if
(
hls
->
max_nb_segments
&&
hls
->
nb_entries
>=
hls
->
max_nb_segments
)
{
en
=
hls
->
list
;
en
=
hls
->
segments
;
hls
->
list
=
en
->
next
;
hls
->
segments
=
en
->
next
;
av_free
(
en
);
av_free
(
en
);
}
else
}
else
hls
->
nb_entries
++
;
hls
->
nb_entries
++
;
...
@@ -117,9 +117,9 @@ static int append_entry(HLSContext *hls, double duration)
...
@@ -117,9 +117,9 @@ static int append_entry(HLSContext *hls, double duration)
return
0
;
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
)
{
while
(
p
)
{
en
=
p
;
en
=
p
;
...
@@ -131,7 +131,7 @@ static void free_entries(HLSContext *hls)
...
@@ -131,7 +131,7 @@ static void free_entries(HLSContext *hls)
static
int
hls_window
(
AVFormatContext
*
s
,
int
last
)
static
int
hls_window
(
AVFormatContext
*
s
,
int
last
)
{
{
HLSContext
*
hls
=
s
->
priv_data
;
HLSContext
*
hls
=
s
->
priv_data
;
ListEntry
*
en
;
HLSSegment
*
en
;
int
target_duration
=
0
;
int
target_duration
=
0
;
int
ret
=
0
;
int
ret
=
0
;
int64_t
sequence
=
FFMAX
(
hls
->
start_sequence
,
hls
->
sequence
-
hls
->
nb_entries
);
int64_t
sequence
=
FFMAX
(
hls
->
start_sequence
,
hls
->
sequence
-
hls
->
nb_entries
);
...
@@ -140,7 +140,7 @@ static int hls_window(AVFormatContext *s, int last)
...
@@ -140,7 +140,7 @@ static int hls_window(AVFormatContext *s, int last)
&
s
->
interrupt_callback
,
NULL
))
<
0
)
&
s
->
interrupt_callback
,
NULL
))
<
0
)
goto
fail
;
goto
fail
;
for
(
en
=
hls
->
list
;
en
;
en
=
en
->
next
)
{
for
(
en
=
hls
->
segments
;
en
;
en
=
en
->
next
)
{
if
(
target_duration
<
en
->
duration
)
if
(
target_duration
<
en
->
duration
)
target_duration
=
ceil
(
en
->
duration
);
target_duration
=
ceil
(
en
->
duration
);
}
}
...
@@ -153,11 +153,11 @@ static int hls_window(AVFormatContext *s, int last)
...
@@ -153,11 +153,11 @@ static int hls_window(AVFormatContext *s, int last)
av_log
(
s
,
AV_LOG_VERBOSE
,
"EXT-X-MEDIA-SEQUENCE:%"
PRId64
"
\n
"
,
av_log
(
s
,
AV_LOG_VERBOSE
,
"EXT-X-MEDIA-SEQUENCE:%"
PRId64
"
\n
"
,
sequence
);
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
);
avio_printf
(
hls
->
pb
,
"#EXTINF:%f,
\n
"
,
en
->
duration
);
if
(
hls
->
baseurl
)
if
(
hls
->
baseurl
)
avio_printf
(
hls
->
pb
,
"%s"
,
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
)
if
(
last
)
...
@@ -282,7 +282,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
...
@@ -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
,
if
(
can_split
&&
av_compare_ts
(
pkt
->
pts
-
hls
->
start_pts
,
st
->
time_base
,
end_pts
,
AV_TIME_BASE_Q
)
>=
0
)
{
end_pts
,
AV_TIME_BASE_Q
)
>=
0
)
{
ret
=
append_entry
(
hls
,
hls
->
duration
);
ret
=
hls_append_segment
(
hls
,
hls
->
duration
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
...
@@ -317,10 +317,10 @@ static int hls_write_trailer(struct AVFormatContext *s)
...
@@ -317,10 +317,10 @@ static int hls_write_trailer(struct AVFormatContext *s)
avio_closep
(
&
oc
->
pb
);
avio_closep
(
&
oc
->
pb
);
avformat_free_context
(
oc
);
avformat_free_context
(
oc
);
av_free
(
hls
->
basename
);
av_free
(
hls
->
basename
);
append_entry
(
hls
,
hls
->
duration
);
hls_append_segment
(
hls
,
hls
->
duration
);
hls_window
(
s
,
1
);
hls_window
(
s
,
1
);
free_entrie
s
(
hls
);
hls_free_segment
s
(
hls
);
avio_close
(
hls
->
pb
);
avio_close
(
hls
->
pb
);
return
0
;
return
0
;
}
}
...
@@ -330,7 +330,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
...
@@ -330,7 +330,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
static
const
AVOption
options
[]
=
{
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
},
{
"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_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_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
},
{
"hls_base_url"
,
"url to prepend to each playlist entry"
,
OFFSET
(
baseurl
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
0
,
0
,
E
},
{
NULL
},
{
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