Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixed] [eServiceMP3] DVB subtitles sync in case of HLS stream #1088

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions lib/service/servicemp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ RESULT eServiceMP3::getPlayPosition(pts_t &pts)
if (!m_gst_playbin || m_state != stRunning)
return -1;

if ((audioSink || videoSink) && !m_paused && !m_sourceinfo.is_hls)
if ((audioSink || videoSink) && !m_paused)
{
g_signal_emit_by_name(videoSink ? videoSink : audioSink, "get-decoder-time", &pos);
if (!GST_CLOCK_TIME_IS_VALID(pos)) return -1;
Expand Down Expand Up @@ -2737,7 +2737,6 @@ void eServiceMP3::subtitle_reset()

void eServiceMP3::subtitle_redraw(int page_id)
{
eDebug("REDRAWINGGGGGGGGGGG!!!!! %d", page_id);
subtitle_page *page = m_pages;

while (page)
Expand All @@ -2747,33 +2746,30 @@ void eServiceMP3::subtitle_redraw(int page_id)
page = page->next;
}
if (!page){
eDebug("NOT PAGE!!!!!");
return;
}

/* iterate all regions in this pcs */
subtitle_page_region *region = page->page_regions;

eDVBSubtitlePage Page;
Page.m_show_time = m_show_time;
Page.m_show_time = m_show_time / 1000000ULL;
for (; region; region=region->next)
{
/* find corresponding region */
subtitle_region *reg = page->regions;
while (reg)
{
eDebug("LOOP REGIONS!!!!!");
eDebug("REGION reg->region_id/region->region_id = %d/%d", reg->region_id, region->region_id);
eTrace("[eServiceMP3] DVB subtitles reg->region_id/region->region_id = %d/%d", reg->region_id, region->region_id);
if (reg->region_id == region->region_id){
eDebug("REGION FFFFFFOUND reg->region_id == region->region_id");
eTrace("[eServiceMP3] DVB subtitles found correct region");
break;
}

reg = reg->next;
}
if (reg)
{
eDebug("FOUND REGION!!!!!");
int x0 = region->region_horizontal_address;
int y0 = region->region_vertical_address;

Expand Down Expand Up @@ -3745,8 +3741,7 @@ void eServiceMP3::pullSubtitle(GstBuffer *buffer)

void eServiceMP3::pushDVBSubtitles()
{
pts_t running_pts = 0;
int32_t next_timer = 0, decoder_ms;
pts_t running_pts = 0, decoder_ms;

if (getPlayPosition(running_pts) < 0)
eTrace("[eServiceMP3] Cant get current decoder time.");
Expand All @@ -3758,20 +3753,20 @@ void eServiceMP3::pushDVBSubtitles()
if (!m_dvb_subtitle_pages.empty())
{
dvb_page = m_dvb_subtitle_pages.front();
show_time = dvb_page.m_show_time / 1000000ULL;
show_time = dvb_page.m_show_time;
}
else
return;

decoder_ms = running_pts / 90LL;
decoder_ms = running_pts / 90;

// If subtitle is overdue or within 20ms the video timing then display it.
// If cant get decoder PTS then display the subtitles.
// If not, pause subtitle processing until the subtitle should be shown
pts_t diff = show_time - decoder_ms;
if (diff < 20 || decoder_ms == 0LL)
if (diff < 20 || decoder_ms == 0)
{
eTrace("[eServiceMP3] Showing subtitles at %u . Current decoder time: %lld", show_time, decoder_ms);
eTrace("[eServiceMP3] Showing subtitles at %lld. Current decoder time: %lld. Difference: %lld", show_time, decoder_ms, diff);
m_subtitle_widget->setPage(dvb_page);
m_dvb_subtitle_pages.pop_front();
}
Expand Down