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
f3139e6f
Commit
f3139e6f
authored
Jun 25, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HLSOutputStream: coding style fixes
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
1f083c5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
49 deletions
+50
-49
hlsoutputstream.cc
src/hlsoutputstream.cc
+50
-49
No files found.
src/hlsoutputstream.cc
View file @
f3139e6f
...
...
@@ -57,63 +57,64 @@ HLSOutputStream::HLSOutputStream (int n_channels, int sample_rate, int bit_depth
void
HLSOutputStream
::
add_stream
(
AVCodec
**
codec
,
enum
AVCodecID
codec_id
)
{
AVCodecContext
*
c
;
int
i
;
/* find the encoder */
*
codec
=
avcodec_find_encoder
(
codec_id
);
if
(
!
(
*
codec
))
{
fprintf
(
stderr
,
"Could not find encoder for '%s'
\n
"
,
avcodec_get_name
(
codec_id
));
exit
(
1
);
}
/* find the encoder */
*
codec
=
avcodec_find_encoder
(
codec_id
);
if
(
!
(
*
codec
))
{
fprintf
(
stderr
,
"Could not find encoder for '%s'
\n
"
,
avcodec_get_name
(
codec_id
));
exit
(
1
);
m_st
=
avformat_new_stream
(
m_fmt_ctx
,
NULL
);
if
(
!
m_st
)
{
fprintf
(
stderr
,
"Could not allocate stream
\n
"
);
exit
(
1
);
}
m_st
->
id
=
m_fmt_ctx
->
nb_streams
-
1
;
m_st
=
avformat_new_stream
(
m_fmt_ctx
,
NULL
);
if
(
!
m_st
)
{
fprintf
(
stderr
,
"Could not allocate stream
\n
"
);
exit
(
1
);
m_enc
=
avcodec_alloc_context3
(
*
codec
);
if
(
!
m_enc
)
{
fprintf
(
stderr
,
"Could not alloc an encoding context
\n
"
);
exit
(
1
);
}
m_st
->
id
=
m_fmt_ctx
->
nb_streams
-
1
;
c
=
avcodec_alloc_context3
(
*
codec
);
if
(
!
c
)
{
fprintf
(
stderr
,
"Could not alloc an encoding context
\n
"
);
exit
(
1
);
if
((
*
codec
)
->
type
!=
AVMEDIA_TYPE_AUDIO
)
{
error
(
"HLSOutputStream: codec type must be audio
"
);
exit
(
1
);
}
m_enc
=
c
;
switch
((
*
codec
)
->
type
)
{
case
AVMEDIA_TYPE_AUDIO
:
c
->
sample_fmt
=
(
*
codec
)
->
sample_fmts
?
(
*
codec
)
->
sample_fmts
[
0
]
:
AV_SAMPLE_FMT_FLTP
;
c
->
bit_rate
=
128000
;
c
->
sample_rate
=
44100
;
if
((
*
codec
)
->
supported_samplerates
)
{
c
->
sample_rate
=
(
*
codec
)
->
supported_samplerates
[
0
];
for
(
i
=
0
;
(
*
codec
)
->
supported_samplerates
[
i
];
i
++
)
{
if
((
*
codec
)
->
supported_samplerates
[
i
]
==
44100
)
c
->
sample_rate
=
44100
;
}
}
c
->
channels
=
av_get_channel_layout_nb_channels
(
c
->
channel_layout
);
c
->
channel_layout
=
AV_CH_LAYOUT_STEREO
;
if
((
*
codec
)
->
channel_layouts
)
{
c
->
channel_layout
=
(
*
codec
)
->
channel_layouts
[
0
];
for
(
i
=
0
;
(
*
codec
)
->
channel_layouts
[
i
];
i
++
)
{
if
((
*
codec
)
->
channel_layouts
[
i
]
==
AV_CH_LAYOUT_STEREO
)
c
->
channel_layout
=
AV_CH_LAYOUT_STEREO
;
}
}
c
->
channels
=
av_get_channel_layout_nb_channels
(
c
->
channel_layout
);
m_st
->
time_base
=
(
AVRational
){
1
,
c
->
sample_rate
};
break
;
default
:
break
;
m_enc
->
sample_fmt
=
(
*
codec
)
->
sample_fmts
?
(
*
codec
)
->
sample_fmts
[
0
]
:
AV_SAMPLE_FMT_FLTP
;
m_enc
->
bit_rate
=
128000
;
m_enc
->
sample_rate
=
44100
;
if
((
*
codec
)
->
supported_samplerates
)
{
m_enc
->
sample_rate
=
(
*
codec
)
->
supported_samplerates
[
0
];
for
(
int
i
=
0
;
(
*
codec
)
->
supported_samplerates
[
i
];
i
++
)
{
if
((
*
codec
)
->
supported_samplerates
[
i
]
==
44100
)
m_enc
->
sample_rate
=
44100
;
}
}
m_enc
->
channels
=
av_get_channel_layout_nb_channels
(
m_enc
->
channel_layout
);
m_enc
->
channel_layout
=
AV_CH_LAYOUT_STEREO
;
if
((
*
codec
)
->
channel_layouts
)
{
m_enc
->
channel_layout
=
(
*
codec
)
->
channel_layouts
[
0
];
for
(
int
i
=
0
;
(
*
codec
)
->
channel_layouts
[
i
];
i
++
)
{
if
((
*
codec
)
->
channel_layouts
[
i
]
==
AV_CH_LAYOUT_STEREO
)
m_enc
->
channel_layout
=
AV_CH_LAYOUT_STEREO
;
}
}
m_enc
->
channels
=
av_get_channel_layout_nb_channels
(
m_enc
->
channel_layout
);
m_st
->
time_base
=
(
AVRational
){
1
,
m_enc
->
sample_rate
};
/* Some formats want stream headers to be separate. */
if
(
m_fmt_ctx
->
oformat
->
flags
&
AVFMT_GLOBALHEADER
)
c
->
flags
|=
AV_CODEC_FLAG_GLOBAL_HEADER
;
/* Some formats want stream headers to be separate. */
if
(
m_fmt_ctx
->
oformat
->
flags
&
AVFMT_GLOBALHEADER
)
m_en
c
->
flags
|=
AV_CODEC_FLAG_GLOBAL_HEADER
;
}
...
...
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