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
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
Show 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,47 +282,11 @@ static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag)
...
@@ -282,47 +282,11 @@ static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag)
*
q_ptr
=
q
;
*
q_ptr
=
q
;
}
}
static
int
mpegts_write_pmt
(
AVFormatContext
*
s
,
MpegTSService
*
service
)
static
int
get_dvb_stream_type
(
AVFormatContext
*
s
,
AVStream
*
st
)
{
{
MpegTSWrite
*
ts
=
s
->
priv_data
;
MpegTSWrite
*
ts
=
s
->
priv_data
;
uint8_t
data
[
SECTION_LENGTH
],
*
q
,
*
desc_length_ptr
,
*
program_info_length_ptr
;
int
stream_type
;
int
val
,
stream_type
,
i
,
err
=
0
;
q
=
data
;
put16
(
&
q
,
0xe000
|
service
->
pcr_pid
);
program_info_length_ptr
=
q
;
q
+=
2
;
/* patched after */
/* put program info here */
val
=
0xf000
|
(
q
-
program_info_length_ptr
-
2
);
program_info_length_ptr
[
0
]
=
val
>>
8
;
program_info_length_ptr
[
1
]
=
val
;
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
AVStream
*
st
=
s
->
streams
[
i
];
MpegTSWriteStream
*
ts_st
=
st
->
priv_data
;
AVDictionaryEntry
*
lang
=
av_dict_get
(
st
->
metadata
,
"language"
,
NULL
,
0
);
if
(
s
->
nb_programs
)
{
int
k
,
found
=
0
;
AVProgram
*
program
=
service
->
program
;
for
(
k
=
0
;
k
<
program
->
nb_stream_indexes
;
k
++
)
if
(
program
->
stream_index
[
k
]
==
i
)
{
found
=
1
;
break
;
}
if
(
!
found
)
continue
;
}
if
(
q
-
data
>
SECTION_LENGTH
-
32
)
{
err
=
1
;
break
;
}
switch
(
st
->
codecpar
->
codec_id
)
{
switch
(
st
->
codecpar
->
codec_id
)
{
case
AV_CODEC_ID_MPEG1VIDEO
:
case
AV_CODEC_ID_MPEG1VIDEO
:
case
AV_CODEC_ID_MPEG2VIDEO
:
case
AV_CODEC_ID_MPEG2VIDEO
:
...
@@ -387,11 +351,58 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
...
@@ -387,11 +351,58 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
break
;
break
;
default:
default:
av_log
(
s
,
AV_LOG_WARNING
,
"Stream %d, codec %s, is muxed as a private data stream "
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
));
"and may not be recognized upon reading.
\n
"
,
st
->
index
,
avcodec_get_name
(
st
->
codecpar
->
codec_id
));
stream_type
=
STREAM_TYPE_PRIVATE_DATA
;
stream_type
=
STREAM_TYPE_PRIVATE_DATA
;
break
;
break
;
}
}
return
stream_type
;
}
static
int
mpegts_write_pmt
(
AVFormatContext
*
s
,
MpegTSService
*
service
)
{
MpegTSWrite
*
ts
=
s
->
priv_data
;
uint8_t
data
[
SECTION_LENGTH
],
*
q
,
*
desc_length_ptr
,
*
program_info_length_ptr
;
int
val
,
stream_type
,
i
,
err
=
0
;
q
=
data
;
put16
(
&
q
,
0xe000
|
service
->
pcr_pid
);
program_info_length_ptr
=
q
;
q
+=
2
;
/* patched after */
/* put program info here */
val
=
0xf000
|
(
q
-
program_info_length_ptr
-
2
);
program_info_length_ptr
[
0
]
=
val
>>
8
;
program_info_length_ptr
[
1
]
=
val
;
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
AVStream
*
st
=
s
->
streams
[
i
];
MpegTSWriteStream
*
ts_st
=
st
->
priv_data
;
AVDictionaryEntry
*
lang
=
av_dict_get
(
st
->
metadata
,
"language"
,
NULL
,
0
);
if
(
s
->
nb_programs
)
{
int
k
,
found
=
0
;
AVProgram
*
program
=
service
->
program
;
for
(
k
=
0
;
k
<
program
->
nb_stream_indexes
;
k
++
)
if
(
program
->
stream_index
[
k
]
==
i
)
{
found
=
1
;
break
;
}
if
(
!
found
)
continue
;
}
if
(
q
-
data
>
SECTION_LENGTH
-
32
)
{
err
=
1
;
break
;
}
stream_type
=
get_dvb_stream_type
(
s
,
st
);
*
q
++
=
stream_type
;
*
q
++
=
stream_type
;
put16
(
&
q
,
0xe000
|
ts_st
->
pid
);
put16
(
&
q
,
0xe000
|
ts_st
->
pid
);
desc_length_ptr
=
q
;
desc_length_ptr
=
q
;
...
...
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