Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
4k
Issue boards
Milestones
Code
Merge requests
450
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC
Commits
57ce124f
Commit
57ce124f
authored
3 years ago
by
Alaric Senat
Committed by
Jean-Baptiste Kempf
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
transcode: implement SetPCR
Refs #27050
parent
12917f6b
No related branches found
Branches containing commit
No related tags found
1 merge request
!2052
transcode: implement SetPCR
Pipeline
#241434
passed with stage
in 17 minutes and 11 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/stream_out/transcode/transcode.c
+71
-4
71 additions, 4 deletions
modules/stream_out/transcode/transcode.c
modules/stream_out/transcode/transcode.h
+4
-0
4 additions, 0 deletions
modules/stream_out/transcode/transcode.h
with
75 additions
and
4 deletions
modules/stream_out/transcode/transcode.c
+
71
−
4
View file @
57ce124f
...
...
@@ -230,6 +230,7 @@ static const char *const ppsz_sout_options[] = {
static
void
*
Add
(
sout_stream_t
*
,
const
es_format_t
*
);
static
void
Del
(
sout_stream_t
*
,
void
*
);
static
int
Send
(
sout_stream_t
*
,
void
*
,
block_t
*
);
static
void
SetPCR
(
sout_stream_t
*
,
vlc_tick_t
);
static
void
SetAudioEncoderConfig
(
sout_stream_t
*
p_stream
,
transcode_encoder_config_t
*
p_cfg
)
{
...
...
@@ -368,7 +369,7 @@ static int Control( sout_stream_t *p_stream, int i_query, va_list args )
}
static
const
struct
sout_stream_operations
ops
=
{
Add
,
Del
,
Send
,
Control
,
NULL
,
NULL
,
Add
,
Del
,
Send
,
Control
,
NULL
,
SetPCR
,
};
/*****************************************************************************
...
...
@@ -385,6 +386,13 @@ static int Open( vlc_object_t *p_this )
config_ChainParse
(
p_stream
,
SOUT_CFG_PREFIX
,
ppsz_sout_options
,
p_stream
->
p_cfg
);
p_sys
->
pcr_sync
=
vlc_pcr_sync_New
();
if
(
unlikely
(
p_sys
->
pcr_sync
==
NULL
)
)
{
free
(
p_sys
);
return
VLC_ENOMEM
;
}
/* Audio transcoding parameters */
transcode_encoder_config_init
(
&
p_sys
->
aenc_cfg
);
SetAudioEncoderConfig
(
p_stream
,
&
p_sys
->
aenc_cfg
);
...
...
@@ -477,6 +485,8 @@ static void Close( vlc_object_t * p_this )
transcode_encoder_config_clean
(
&
p_sys
->
senc_cfg
);
vlc_pcr_sync_Delete
(
p_sys
->
pcr_sync
);
free
(
p_sys
);
}
...
...
@@ -648,6 +658,18 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
if
(
!
success
)
goto
error
;
if
(
id
->
b_transcode
)
{
// TODO properly estimate the delay
id
->
pcr_helper
=
transcode_track_pcr_helper_New
(
p_sys
->
pcr_sync
,
VLC_TICK_FROM_SEC
(
2
)
);
if
(
unlikely
(
id
->
pcr_helper
==
NULL
)
)
goto
error
;
}
else
{
id
->
pcr_helper
=
NULL
;
}
return
id
;
error:
...
...
@@ -694,6 +716,7 @@ static void Del( sout_stream_t *p_stream, void *_id )
default:
break
;
}
transcode_track_pcr_helper_Delete
(
id
->
pcr_helper
);
}
else
decoder_Destroy
(
id
->
p_decoder
);
...
...
@@ -718,6 +741,19 @@ static int Send( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
goto
error
;
}
sout_stream_sys_t
*
sys
=
p_stream
->
p_sys
;
if
(
p_buffer
!=
NULL
)
{
assert
(
p_buffer
->
p_next
==
NULL
);
vlc_tick_t
dropped_frame_ts
;
transcode_track_pcr_helper_SignalEnteringFrame
(
id
->
pcr_helper
,
p_buffer
,
&
dropped_frame_ts
);
if
(
dropped_frame_ts
!=
VLC_TICK_INVALID
)
{
sout_StreamSetPCR
(
p_stream
->
p_next
,
dropped_frame_ts
);
}
}
int
i_ret
;
switch
(
id
->
p_decoder
->
fmt_in
.
i_cat
)
{
...
...
@@ -737,9 +773,30 @@ static int Send( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
goto
error
;
}
if
(
p_out
&&
sout_StreamIdSend
(
p_stream
->
p_next
,
id
->
downstream_id
,
p_out
)
)
i_ret
=
VLC_EGENERIC
;
if
(
p_out
)
{
for
(
block_t
*
it
=
p_out
;
it
!=
NULL
;
)
{
block_t
*
next
=
it
->
p_next
;
it
->
p_next
=
NULL
;
const
vlc_tick_t
pcr
=
transcode_track_pcr_helper_SignalLeavingFrame
(
id
->
pcr_helper
,
it
);
if
(
sout_StreamIdSend
(
p_stream
->
p_next
,
id
->
downstream_id
,
it
)
!=
VLC_SUCCESS
)
{
p_buffer
=
next
;
goto
error
;
}
if
(
pcr
!=
VLC_TICK_INVALID
)
{
sout_StreamSetPCR
(
p_stream
->
p_next
,
pcr
);
}
it
=
next
;
}
}
if
(
i_ret
!=
VLC_SUCCESS
)
id
->
b_error
=
true
;
...
...
@@ -750,3 +807,13 @@ error:
block_Release
(
p_buffer
);
return
VLC_EGENERIC
;
}
static
void
SetPCR
(
sout_stream_t
*
stream
,
vlc_tick_t
pcr
)
{
sout_stream_sys_t
*
sys
=
stream
->
p_sys
;
const
int
status
=
vlc_pcr_sync_SignalPCR
(
sys
->
pcr_sync
,
pcr
);
if
(
status
==
VLC_PCR_SYNC_FORWARD_PCR
)
{
sout_StreamSetPCR
(
stream
->
p_next
,
pcr
);
}
}
This diff is collapsed.
Click to expand it.
modules/stream_out/transcode/transcode.h
+
4
−
0
View file @
57ce124f
...
...
@@ -2,6 +2,7 @@
#include
<vlc_filter.h>
#include
<vlc_codec.h>
#include
"encoder/encoder.h"
#include
"pcr_helper.h"
/*100ms is around the limit where people are noticing lipsync issues*/
#define MASTER_SYNC_MAX_DRIFT VLC_TICK_FROM_MS(100)
...
...
@@ -64,6 +65,7 @@ typedef struct
/* Spu's video */
sout_stream_id_sys_t
*
id_video
;
vlc_pcr_sync_t
*
pcr_sync
;
}
sout_stream_sys_t
;
struct
aout_filters
;
...
...
@@ -147,6 +149,8 @@ struct sout_stream_id_sys_t
/* Sync */
date_t
next_input_pts
;
/**< Incoming calculated PTS */
vlc_tick_t
i_drift
;
/** how much buffer is ahead of calculated PTS */
transcode_track_pcr_helper_t
*
pcr_helper
;
};
struct
decoder_owner
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment