Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
3958244c
Commit
3958244c
authored
Dec 10, 2019
by
Marton Balint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/mpegtsenc: factorize determining stream_type
Signed-off-by:
Marton Balint
<
cus@passwd.hu
>
parent
bcc19933
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
68 deletions
+79
-68
mpegtsenc.c
libavformat/mpegtsenc.c
+79
-68
No files found.
libavformat/mpegtsenc.c
View file @
3958244c
...
...
@@ -282,6 +282,83 @@ static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag)
*
q_ptr
=
q
;
}
static
int
get_dvb_stream_type
(
AVFormatContext
*
s
,
AVStream
*
st
)
{
MpegTSWrite
*
ts
=
s
->
priv_data
;
int
stream_type
;
switch
(
st
->
codecpar
->
codec_id
)
{
case
AV_CODEC_ID_MPEG1VIDEO
:
case
AV_CODEC_ID_MPEG2VIDEO
:
stream_type
=
STREAM_TYPE_VIDEO_MPEG2
;
break
;
case
AV_CODEC_ID_MPEG4
:
stream_type
=
STREAM_TYPE_VIDEO_MPEG4
;
break
;
case
AV_CODEC_ID_H264
:
stream_type
=
STREAM_TYPE_VIDEO_H264
;
break
;
case
AV_CODEC_ID_HEVC
:
stream_type
=
STREAM_TYPE_VIDEO_HEVC
;
break
;
case
AV_CODEC_ID_CAVS
:
stream_type
=
STREAM_TYPE_VIDEO_CAVS
;
break
;
case
AV_CODEC_ID_DIRAC
:
stream_type
=
STREAM_TYPE_VIDEO_DIRAC
;
break
;
case
AV_CODEC_ID_VC1
:
stream_type
=
STREAM_TYPE_VIDEO_VC1
;
break
;
case
AV_CODEC_ID_MP2
:
case
AV_CODEC_ID_MP3
:
if
(
st
->
codecpar
->
sample_rate
>
0
&&
st
->
codecpar
->
sample_rate
<
32000
)
{
stream_type
=
STREAM_TYPE_AUDIO_MPEG2
;
}
else
{
stream_type
=
STREAM_TYPE_AUDIO_MPEG1
;
}
break
;
case
AV_CODEC_ID_AAC
:
stream_type
=
(
ts
->
flags
&
MPEGTS_FLAG_AAC_LATM
)
?
STREAM_TYPE_AUDIO_AAC_LATM
:
STREAM_TYPE_AUDIO_AAC
;
break
;
case
AV_CODEC_ID_AAC_LATM
:
stream_type
=
STREAM_TYPE_AUDIO_AAC_LATM
;
break
;
case
AV_CODEC_ID_AC3
:
stream_type
=
(
ts
->
flags
&
MPEGTS_FLAG_SYSTEM_B
)
?
STREAM_TYPE_PRIVATE_DATA
:
STREAM_TYPE_AUDIO_AC3
;
break
;
case
AV_CODEC_ID_EAC3
:
stream_type
=
(
ts
->
flags
&
MPEGTS_FLAG_SYSTEM_B
)
?
STREAM_TYPE_PRIVATE_DATA
:
STREAM_TYPE_AUDIO_EAC3
;
break
;
case
AV_CODEC_ID_DTS
:
stream_type
=
STREAM_TYPE_AUDIO_DTS
;
break
;
case
AV_CODEC_ID_TRUEHD
:
stream_type
=
STREAM_TYPE_AUDIO_TRUEHD
;
break
;
case
AV_CODEC_ID_OPUS
:
stream_type
=
STREAM_TYPE_PRIVATE_DATA
;
break
;
case
AV_CODEC_ID_TIMED_ID3
:
stream_type
=
STREAM_TYPE_METADATA
;
break
;
default:
av_log
(
s
,
AV_LOG_WARNING
,
"Stream %d, codec %s, is muxed as a private data stream "
"and may not be recognized upon reading.
\n
"
,
st
->
index
,
avcodec_get_name
(
st
->
codecpar
->
codec_id
));
stream_type
=
STREAM_TYPE_PRIVATE_DATA
;
break
;
}
return
stream_type
;
}
static
int
mpegts_write_pmt
(
AVFormatContext
*
s
,
MpegTSService
*
service
)
{
MpegTSWrite
*
ts
=
s
->
priv_data
;
...
...
@@ -323,74 +400,8 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
err
=
1
;
break
;
}
switch
(
st
->
codecpar
->
codec_id
)
{
case
AV_CODEC_ID_MPEG1VIDEO
:
case
AV_CODEC_ID_MPEG2VIDEO
:
stream_type
=
STREAM_TYPE_VIDEO_MPEG2
;
break
;
case
AV_CODEC_ID_MPEG4
:
stream_type
=
STREAM_TYPE_VIDEO_MPEG4
;
break
;
case
AV_CODEC_ID_H264
:
stream_type
=
STREAM_TYPE_VIDEO_H264
;
break
;
case
AV_CODEC_ID_HEVC
:
stream_type
=
STREAM_TYPE_VIDEO_HEVC
;
break
;
case
AV_CODEC_ID_CAVS
:
stream_type
=
STREAM_TYPE_VIDEO_CAVS
;
break
;
case
AV_CODEC_ID_DIRAC
:
stream_type
=
STREAM_TYPE_VIDEO_DIRAC
;
break
;
case
AV_CODEC_ID_VC1
:
stream_type
=
STREAM_TYPE_VIDEO_VC1
;
break
;
case
AV_CODEC_ID_MP2
:
case
AV_CODEC_ID_MP3
:
if
(
st
->
codecpar
->
sample_rate
>
0
&&
st
->
codecpar
->
sample_rate
<
32000
)
{
stream_type
=
STREAM_TYPE_AUDIO_MPEG2
;
}
else
{
stream_type
=
STREAM_TYPE_AUDIO_MPEG1
;
}
break
;
case
AV_CODEC_ID_AAC
:
stream_type
=
(
ts
->
flags
&
MPEGTS_FLAG_AAC_LATM
)
?
STREAM_TYPE_AUDIO_AAC_LATM
:
STREAM_TYPE_AUDIO_AAC
;
break
;
case
AV_CODEC_ID_AAC_LATM
:
stream_type
=
STREAM_TYPE_AUDIO_AAC_LATM
;
break
;
case
AV_CODEC_ID_AC3
:
stream_type
=
(
ts
->
flags
&
MPEGTS_FLAG_SYSTEM_B
)
?
STREAM_TYPE_PRIVATE_DATA
:
STREAM_TYPE_AUDIO_AC3
;
break
;
case
AV_CODEC_ID_EAC3
:
stream_type
=
(
ts
->
flags
&
MPEGTS_FLAG_SYSTEM_B
)
?
STREAM_TYPE_PRIVATE_DATA
:
STREAM_TYPE_AUDIO_EAC3
;
break
;
case
AV_CODEC_ID_DTS
:
stream_type
=
STREAM_TYPE_AUDIO_DTS
;
break
;
case
AV_CODEC_ID_TRUEHD
:
stream_type
=
STREAM_TYPE_AUDIO_TRUEHD
;
break
;
case
AV_CODEC_ID_OPUS
:
stream_type
=
STREAM_TYPE_PRIVATE_DATA
;
break
;
case
AV_CODEC_ID_TIMED_ID3
:
stream_type
=
STREAM_TYPE_METADATA
;
break
;
default:
av_log
(
s
,
AV_LOG_WARNING
,
"Stream %d, codec %s, is muxed as a private data stream "
"and may not be recognized upon reading.
\n
"
,
i
,
avcodec_get_name
(
st
->
codecpar
->
codec_id
));
stream_type
=
STREAM_TYPE_PRIVATE_DATA
;
break
;
}
stream_type
=
get_dvb_stream_type
(
s
,
st
);
*
q
++
=
stream_type
;
put16
(
&
q
,
0xe000
|
ts_st
->
pid
);
...
...
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