Skip to content

Commit 7e59060

Browse files
authored
Merge pull request #1907 from CastagnaIT/segmented_subs_fix
[SubtitleSampleReader] Fix packet pts
2 parents 502e364 + 8c614fc commit 7e59060

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

src/Session.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ bool SESSION::CSession::SeekTime(double seekTime, unsigned int streamId, bool pr
966966

967967
streamReader->SetPTSDiff(ptsDiff);
968968

969-
double seekSecs{static_cast<double>(seekTimeCorrected - streamReader->GetPTSDiff()) /
969+
double seekSecs{static_cast<double>(seekTimeCorrected - ptsDiff) /
970970
STREAM_TIME_BASE};
971971
if (stream->m_adStream.seek_time(seekSecs, preceeding, reset))
972972
{

src/samplereader/SubtitleSampleReader.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ AP4_Result CSubtitleSampleReader::ReadSample()
187187
// Wait for manifest live update to get next segment
188188
return AP4_SUCCESS;
189189
}
190-
else
191-
{
192-
LOG::LogF(LOGERROR, "Failed to get segment data from subtitle stream");
193-
}
194190
}
195191

196192
m_eos = true;
@@ -204,6 +200,7 @@ void CSubtitleSampleReader::Reset(bool bEOS)
204200
m_sampleData.SetDataSize(0);
205201
m_eos = bEOS;
206202
m_codecHandler->Reset();
203+
m_pts = 0;
207204
}
208205
}
209206

@@ -223,7 +220,6 @@ bool CSubtitleSampleReader::TimeSeek(uint64_t pts, bool preceeding)
223220
{
224221
if (dynamic_cast<WebVTTCodecHandler*>(m_codecHandler.get()))
225222
{
226-
m_pts = pts;
227223
return true;
228224
}
229225
else
@@ -233,11 +229,3 @@ bool CSubtitleSampleReader::TimeSeek(uint64_t pts, bool preceeding)
233229
return false;
234230
}
235231
}
236-
237-
void CSubtitleSampleReader::SetPTSDiff(uint64_t pts)
238-
{
239-
// Its needed set the PTS diff from the timing stream
240-
// to allow sync segmented subtitles for cases like
241-
// HLS with multiple periods
242-
m_ptsDiff = pts;
243-
}

src/samplereader/SubtitleSampleReader.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class ATTR_DLL_LOCAL CSubtitleSampleReader : public ISampleReader
4141
bool GetInformation(kodi::addon::InputstreamInfo& info) override;
4242
bool TimeSeek(uint64_t pts, bool preceeding) override;
4343
void SetPTSOffset(uint64_t offset) override { }
44-
int64_t GetPTSDiff() const override { return m_ptsDiff; }
45-
void SetPTSDiff(uint64_t pts) override;
44+
int64_t GetPTSDiff() const override { return 0; }
4645
uint32_t GetTimeScale() const override { return 1000; }
4746
AP4_Size GetSampleDataSize() const override { return m_sampleData.GetDataSize(); }
4847
const AP4_Byte* GetSampleData() const override { return m_sampleData.GetData(); }
@@ -53,7 +52,6 @@ class ATTR_DLL_LOCAL CSubtitleSampleReader : public ISampleReader
5352
bool InitializeFile(std::string url);
5453

5554
uint64_t m_pts{0};
56-
int64_t m_ptsDiff{0};
5755
bool m_eos{false};
5856
bool m_started{false};
5957
std::unique_ptr<CodecHandler> m_codecHandler;

0 commit comments

Comments
 (0)