| Index: ppapi/examples/video_encode/video_encode.cc
|
| diff --git a/ppapi/examples/video_encode/video_encode.cc b/ppapi/examples/video_encode/video_encode.cc
|
| index c6a09211a8c50fc0fb3811ab35a778cc9dd7cb77..7a55df294cfa2e89ce2ea21f64d974761d554871 100644
|
| --- a/ppapi/examples/video_encode/video_encode.cc
|
| +++ b/ppapi/examples/video_encode/video_encode.cc
|
| @@ -6,6 +6,7 @@
|
| #include <stdio.h>
|
| #include <string.h>
|
|
|
| +#include <algorithm>
|
| #include <iostream>
|
| #include <map>
|
| #include <sstream>
|
| @@ -176,6 +177,8 @@ class VideoEncoderInstance : public pp::Instance {
|
| pp::VideoFrame current_track_frame_;
|
|
|
| IVFWriter ivf_writer_;
|
| +
|
| + PP_Time last_encode_tick_;
|
| };
|
|
|
| VideoEncoderInstance::VideoEncoderInstance(PP_Instance instance,
|
| @@ -189,7 +192,8 @@ VideoEncoderInstance::VideoEncoderInstance(PP_Instance instance,
|
| video_profile_(PP_VIDEOPROFILE_H264MAIN),
|
| #endif
|
| frame_format_(PP_VIDEOFRAME_FORMAT_I420),
|
| - encoded_frames_(0) {
|
| + encoded_frames_(0),
|
| + last_encode_tick_(0) {
|
| InitializeVideoProfiles();
|
| ProbeEncoder();
|
| }
|
| @@ -339,10 +343,12 @@ void VideoEncoderInstance::OnInitializedEncoder(int32_t result) {
|
| }
|
|
|
| void VideoEncoderInstance::ScheduleNextEncode() {
|
| + PP_Time now = pp::Module::Get()->core()->GetTime();
|
| pp::Module::Get()->core()->CallOnMainThread(
|
| - 1000 / 30,
|
| + std::min(std::max(now - last_encode_tick_, 0.0), 1000.0 / 30),
|
| callback_factory_.NewCallback(&VideoEncoderInstance::GetEncoderFrameTick),
|
| 0);
|
| + last_encode_tick_ = now;
|
| }
|
|
|
| void VideoEncoderInstance::GetEncoderFrameTick(int32_t result) {
|
|
|