decoder: signal indexing progress
Better UI interactions, actually shows the progress of the index function in the task manager now.
This commit is contained in:
@@ -180,3 +180,10 @@ void Decoder::Conform(const AudioRenderingParams ¶ms, const QAtomicInt* canc
|
||||
void Decoder::Index(const QAtomicInt *cancelled)
|
||||
{
|
||||
}
|
||||
|
||||
void Decoder::SignalIndexProgress(const int64_t &ts)
|
||||
{
|
||||
if (stream()->duration() != AV_NOPTS_VALUE && stream()->duration() != 0) {
|
||||
emit IndexProgress(qRound(100.0 * static_cast<double>(ts) / static_cast<double>(stream()->duration())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,15 @@ public:
|
||||
*/
|
||||
virtual void Index(const QAtomicInt* cancelled);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief While indexing, this signal will provide progress as a percentage (0-100 inclusive) if available
|
||||
*/
|
||||
void IndexProgress(int);
|
||||
|
||||
protected:
|
||||
void SignalIndexProgress(const int64_t& ts);
|
||||
|
||||
bool open_;
|
||||
|
||||
private:
|
||||
|
||||
@@ -868,6 +868,8 @@ void FFmpegDecoder::UnconditionalAudioIndex(AVPacket *pkt, AVFrame *frame, const
|
||||
if (data_frame != frame) {
|
||||
av_frame_free(&data_frame);
|
||||
}
|
||||
|
||||
SignalIndexProgress(frame->pts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -917,6 +919,8 @@ void FFmpegDecoder::UnconditionalVideoIndex(AVPacket* pkt, AVFrame* frame, const
|
||||
//CacheFrameToDisk(frame);
|
||||
|
||||
video_stream->append_frame_index(frame->pts);
|
||||
|
||||
SignalIndexProgress(frame->pts);
|
||||
} else {
|
||||
// Assume we've reached the end of the file
|
||||
break;
|
||||
|
||||
@@ -17,6 +17,8 @@ void IndexTask::Action()
|
||||
|
||||
decoder->set_stream(stream_);
|
||||
|
||||
connect(decoder.get(), &Decoder::IndexProgress, this, &IndexTask::ProgressChanged);
|
||||
|
||||
decoder->Open();
|
||||
decoder->Index(&IsCancelled());
|
||||
decoder->Close();
|
||||
|
||||
Reference in New Issue
Block a user