Index: media/gpu/video_encode_accelerator_unittest.cc |
diff --git a/media/gpu/video_encode_accelerator_unittest.cc b/media/gpu/video_encode_accelerator_unittest.cc |
index 0cfbfaaee3f657974a7ecbb8ea9dbcd367ee821b..b75bdca8c8c6a03398381946021ea817895c57c2 100644 |
--- a/media/gpu/video_encode_accelerator_unittest.cc |
+++ b/media/gpu/video_encode_accelerator_unittest.cc |
@@ -11,6 +11,7 @@ |
#include <queue> |
#include <string> |
#include <utility> |
+#include <vector> |
#include "base/at_exit.h" |
#include "base/bind.h" |
@@ -808,7 +809,8 @@ class VEAClient : public VideoEncodeAccelerator::Client { |
size_t output_buffer_size) override; |
void BitstreamBufferReady(int32_t bitstream_buffer_id, |
size_t payload_size, |
- bool key_frame) override; |
+ bool key_frame, |
+ base::TimeDelta timestamp) override; |
void NotifyError(VideoEncodeAccelerator::Error error) override; |
private: |
@@ -989,6 +991,13 @@ class VEAClient : public VideoEncodeAccelerator::Client { |
// The timer used to feed the encoder with the input frames. |
std::unique_ptr<base::RepeatingTimer> input_timer_; |
+ |
+ // The timestamps for each frame in the order of CreateFrame() invocation. |
+ std::vector<base::TimeDelta> frame_timestamps_; |
+ |
+ // The counter to keep track of which timestamp in |frame_timestamps| we are |
+ // checking now. |
+ unsigned int output_frame_count_; |
Pawel Osciak
2016/05/26 07:39:23
Perhaps we could use a queue for frame_timestamps_
shenghao
2016/05/26 10:38:20
Done.
|
}; |
VEAClient::VEAClient(TestStream* test_stream, |
@@ -1025,7 +1034,8 @@ VEAClient::VEAClient(TestStream* test_stream, |
requested_bitrate_(0), |
requested_framerate_(0), |
requested_subsequent_bitrate_(0), |
- requested_subsequent_framerate_(0) { |
+ requested_subsequent_framerate_(0), |
+ output_frame_count_(0) { |
if (keyframe_period_) |
LOG_ASSERT(kMaxKeyframeDelay < keyframe_period_); |
@@ -1250,7 +1260,8 @@ void VEAClient::RequireBitstreamBuffers(unsigned int input_count, |
void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id, |
size_t payload_size, |
- bool key_frame) { |
+ bool key_frame, |
+ base::TimeDelta timestamp) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
ASSERT_LE(payload_size, output_buffer_size_); |
@@ -1262,6 +1273,10 @@ void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id, |
if (state_ == CS_FINISHED || state_ == CS_VALIDATED) |
return; |
+ ASSERT_GT(frame_timestamps_.size(), output_frame_count_); |
+ ASSERT_EQ(timestamp, frame_timestamps_[output_frame_count_]); |
+ ++output_frame_count_; |
+ |
encoded_stream_size_since_last_check_ += payload_size; |
const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory()); |
@@ -1400,6 +1415,7 @@ void VEAClient::FeedEncoderWithOneInput() { |
int32_t input_id; |
scoped_refptr<media::VideoFrame> video_frame = |
PrepareInputFrame(pos_in_input_stream_, &input_id); |
+ frame_timestamps_.push_back(video_frame->timestamp()); |
pos_in_input_stream_ += test_stream_->aligned_buffer_size; |
bool force_keyframe = false; |