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
5100e1af
Commit
5100e1af
authored
Jun 25, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSOutputStream: more error handling
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
a1a6f71b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
hlsoutputstream.cc
src/hlsoutputstream.cc
+18
-9
hlsoutputstream.hh
src/hlsoutputstream.hh
+2
-2
No files found.
src/hlsoutputstream.cc
View file @
5100e1af
...
...
@@ -115,14 +115,14 @@ HLSOutputStream::add_stream (AVCodec **codec, enum AVCodecID codec_id)
AVFrame
*
HLSOutputStream
::
alloc_audio_frame
(
AVSampleFormat
sample_fmt
,
uint64_t
channel_layout
,
int
sample_rate
,
int
nb_samples
)
HLSOutputStream
::
alloc_audio_frame
(
AVSampleFormat
sample_fmt
,
uint64_t
channel_layout
,
int
sample_rate
,
int
nb_samples
,
Error
&
err
)
{
AVFrame
*
frame
=
av_frame_alloc
();
if
(
!
frame
)
{
fprintf
(
stderr
,
"Error allocating an audio frame
\n
"
);
exit
(
1
)
;
err
=
Error
(
"error allocating an audio frame
"
);
return
nullptr
;
}
frame
->
format
=
sample_fmt
;
...
...
@@ -135,8 +135,8 @@ HLSOutputStream::alloc_audio_frame (AVSampleFormat sample_fmt, uint64_t channel_
int
ret
=
av_frame_get_buffer
(
frame
,
0
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error allocating an audio buffer
\n
"
);
exit
(
1
)
;
err
=
Error
(
"Error allocating an audio buffer
"
);
return
nullptr
;
}
}
...
...
@@ -144,7 +144,7 @@ HLSOutputStream::alloc_audio_frame (AVSampleFormat sample_fmt, uint64_t channel_
}
void
Error
HLSOutputStream
::
open_audio
(
AVCodec
*
codec
,
AVDictionary
*
opt_arg
)
{
int
nb_samples
;
...
...
@@ -166,8 +166,14 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
else
nb_samples
=
m_enc
->
frame_size
;
m_frame
=
alloc_audio_frame
(
m_enc
->
sample_fmt
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
);
m_tmp_frame
=
alloc_audio_frame
(
AV_SAMPLE_FMT_FLT
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
);
Error
err
;
m_frame
=
alloc_audio_frame
(
m_enc
->
sample_fmt
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
,
err
);
if
(
err
)
return
err
;
m_tmp_frame
=
alloc_audio_frame
(
AV_SAMPLE_FMT_FLT
,
m_enc
->
channel_layout
,
m_enc
->
sample_rate
,
nb_samples
,
err
);
if
(
err
)
return
err
;
/* copy the stream parameters to the muxer */
ret
=
avcodec_parameters_from_context
(
m_st
->
codecpar
,
m_enc
);
...
...
@@ -199,6 +205,7 @@ HLSOutputStream::open_audio (AVCodec *codec, AVDictionary *opt_arg)
fprintf
(
stderr
,
"Failed to initialize the resampling context
\n
"
);
exit
(
1
);
}
return
Error
::
Code
::
NONE
;
}
/* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
...
...
@@ -340,7 +347,9 @@ HLSOutputStream::open (const string& out_filename, size_t cut_aac_frames, size_t
if
(
err
)
return
err
;
open_audio
(
audio_codec
,
opt
);
err
=
open_audio
(
audio_codec
,
opt
);
if
(
err
)
return
err
;
/* Write the stream header, if any. */
ret
=
avformat_write_header
(
m_fmt_ctx
,
&
opt
);
...
...
src/hlsoutputstream.hh
View file @
5100e1af
...
...
@@ -90,11 +90,11 @@ class HLSOutputStream : public AudioOutputStream {
size_t
m_delete_input_start
=
0
;
Error
add_stream
(
AVCodec
**
codec
,
enum
AVCodecID
codec_id
);
void
open_audio
(
AVCodec
*
codec
,
AVDictionary
*
opt_arg
);
Error
open_audio
(
AVCodec
*
codec
,
AVDictionary
*
opt_arg
);
AVFrame
*
get_audio_frame
();
int
write_audio_frame
();
void
close_stream
();
AVFrame
*
alloc_audio_frame
(
enum
AVSampleFormat
sample_fmt
,
uint64_t
channel_layout
,
int
sample_rate
,
int
nb_samples
);
AVFrame
*
alloc_audio_frame
(
AVSampleFormat
sample_fmt
,
uint64_t
channel_layout
,
int
sample_rate
,
int
nb_samples
,
Error
&
err
);
int
write_frame
(
const
AVRational
*
time_base
,
AVStream
*
st
,
AVPacket
*
pkt
);
public
:
HLSOutputStream
(
int
n_channels
,
int
sample_rate
,
int
bit_depth
);
...
...
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