diff --git a/interfaces/inner_api/native/decoder_surface_filter.h b/interfaces/inner_api/native/decoder_surface_filter.h
index 6b4c9c49029b66fda7f4d677aad137bdd203c97c..5cac71ea2f47726cb17ce3fc008fa37604dc6154 100644
--- a/interfaces/inner_api/native/decoder_surface_filter.h
+++ b/interfaces/inner_api/native/decoder_surface_filter.h
@@ -116,6 +116,7 @@ public:
Status SetPostProcessorOn(bool isSuperResolutionOn);
Status SetVideoWindowSize(int32_t width, int32_t height);
void NotifyAudioComplete();
+ Status SetSpeed(float speed);
protected:
Status OnLinked(StreamType inType, const std::shared_ptr &meta,
diff --git a/services/media_engine/filters/decoder_surface_filter.cpp b/services/media_engine/filters/decoder_surface_filter.cpp
index e13d25a0171254be416bf441d3496cf1f9fa0a7c..667347fe1977fa2dee01927f9529e5d009730eba 100644
--- a/services/media_engine/filters/decoder_surface_filter.cpp
+++ b/services/media_engine/filters/decoder_surface_filter.cpp
@@ -48,6 +48,7 @@ static const uint32_t TASK_DELAY_TOLERANCE = 5 * 1000 * 1000; // task delay tole
static const int64_t MAX_DEBUG_LOG = 10;
static const int32_t MAX_ADVANCE_US = 80000; // max advance us at render time
static const int64_t OVERTIME_WARNING_MS = 50;
+static const double DEFAULT_FRAME_RATE = 30.0; // 30.0 is the hisi default frame rate.
static AutoRegisterFilter g_registerDecoderSurfaceFilter("builtin.player.videodecoder",
FilterType::FILTERTYPE_VDEC, [](const std::string& name, const FilterType type) {
@@ -629,7 +630,7 @@ void DecoderSurfaceFilter::SetParameter(const std::shared_ptr ¶meter)
}
}
if (rate <= 0) {
- rate = 30.0; // 30.0 is the hisi default frame rate.
+ rate = DEFAULT_FRAME_RATE;
}
format.PutDoubleValue(Tag::VIDEO_FRAME_RATE, rate);
}
@@ -1361,6 +1362,25 @@ Status DecoderSurfaceFilter::SetVideoWindowSize(int32_t width, int32_t height)
return postProcessor_->SetVideoWindowSize(width, height);
}
+
+Status DecoderSurfaceFilter::SetSpeed(float speed)
+{
+ FALSE_RETURN_V(videoDecoder_ != nullptr, Status::ERROR_INVALID_OPERATION);
+ MEDIA_LOG_D("SetSpeed in");
+ double frameRate = 0.0;
+ configFormat_.GetDoubleValue(Tag::VIDEO_FRAME_RATE, frameRate);
+ if (frameRate <= 0) {
+ frameRate = DEFAULT_FRAME_RATE;
+ }
+ double frameRateWithSpeed = speed >= 1.0 ? frameRate * speed : frameRate;
+ MEDIA_LOG_I("frameRate: %{public}f, speed: %{public}f, frameRateWithSpeed: %{public}f",
+ frameRate, speed, frameRateWithSpeed);
+
+ Format format;
+ format.PutDoubleValue(Tag::VIDEO_FRAME_RATE, frameRateWithSpeed);
+ videoDecoder_->SetParameter(format);
+ return Status::OK;
+}
} // namespace Pipeline
} // namespace MEDIA
} // namespace OHOS