Skip to content

Commit

Permalink
seek has problems;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Aug 24, 2023
1 parent d900aca commit 55c8dfd
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 17 deletions.
8 changes: 5 additions & 3 deletions ffmpeg/audiodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ AudioDecoder::AudioDecoder(QObject *parent)

AudioDecoder::~AudioDecoder() = default;

void AudioDecoder::seek(qint64 seekTime)
bool AudioDecoder::seek(qint64 seekTime)
{
Decoder<PacketPtr>::seek(seekTime);
d_ptr->decoderAudioFrame->seek(seekTime);
if (!Decoder<PacketPtr>::seek(seekTime)) {
return false;
}
return d_ptr->decoderAudioFrame->seek(seekTime);
}

void AudioDecoder::pause(bool state)
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/audiodecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AudioDecoder : public Decoder<PacketPtr>
explicit AudioDecoder(QObject *parent = nullptr);
~AudioDecoder() override;

void seek(qint64 seekTime) override;
bool seek(qint64 seekTime) override;

void pause(bool state) override;

Expand Down
5 changes: 3 additions & 2 deletions ffmpeg/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ class Decoder : public QThread

virtual void pause(bool state) = 0;

virtual void seek(qint64 seekTime) // microsecond
virtual bool seek(qint64 seekTime) // microsecond
{
clear();
m_seekTime = seekTime;
assertVaild();
if (!m_contextInfo->isIndexVaild()) {
return;
return false;
}
pause(false);
return true;
}

protected:
Expand Down
7 changes: 5 additions & 2 deletions ffmpeg/decoderaudioframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ void DecoderAudioFrame::stopDecoder()
Decoder<FramePtr>::stopDecoder();
}

void DecoderAudioFrame::seek(qint64 seekTime)
bool DecoderAudioFrame::seek(qint64 seekTime)
{
Decoder<FramePtr>::seek(seekTime);
if (!Decoder<FramePtr>::seek(seekTime)) {
return false;
}
setMediaClock(m_seekTime);
d_ptr->firstSeekFrame = true;
d_ptr->pauseTime = 0;
return true;
}

void DecoderAudioFrame::pause(bool state)
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/decoderaudioframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DecoderAudioFrame : public Decoder<FramePtr>

void stopDecoder() override;

void seek(qint64 seekTime) override;
bool seek(qint64 seekTime) override;

void pause(bool state) override;
auto isPause() -> bool;
Expand Down
8 changes: 5 additions & 3 deletions ffmpeg/subtitledecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ SubtitleDecoder::SubtitleDecoder(QObject *parent)

SubtitleDecoder::~SubtitleDecoder() = default;

void SubtitleDecoder::seek(qint64 seekTime)
bool SubtitleDecoder::seek(qint64 seekTime)
{
Decoder<PacketPtr>::seek(seekTime);
d_ptr->decoderSubtitleFrame->seek(seekTime);
if (!Decoder<PacketPtr>::seek(seekTime)) {
return false;
}
return d_ptr->decoderSubtitleFrame->seek(seekTime);
}

void SubtitleDecoder::pause(bool state)
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/subtitledecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SubtitleDecoder : public Decoder<PacketPtr>
explicit SubtitleDecoder(QObject *parent = nullptr);
~SubtitleDecoder();

void seek(qint64 seekTime) override;
bool seek(qint64 seekTime) override;

void pause(bool state) override;

Expand Down
8 changes: 5 additions & 3 deletions ffmpeg/videodecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ VideoDecoder::VideoDecoder(QObject *parent)

VideoDecoder::~VideoDecoder() = default;

void VideoDecoder::seek(qint64 seekTime)
bool VideoDecoder::seek(qint64 seekTime)
{
Decoder<PacketPtr>::seek(seekTime);
d_ptr->decoderVideoFrame->seek(seekTime);
if (!Decoder<PacketPtr>::seek(seekTime)) {
return false;
}
return d_ptr->decoderVideoFrame->seek(seekTime);
}

void VideoDecoder::pause(bool state)
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/videodecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VideoDecoder : public Decoder<PacketPtr>
explicit VideoDecoder(QObject *parent = nullptr);
~VideoDecoder();

void seek(qint64 seekTime) override;
bool seek(qint64 seekTime) override;

void pause(bool state) override;

Expand Down

0 comments on commit 55c8dfd

Please sign in to comment.