Index: content/common/gpu/media/video_decode_accelerator_unittest.cc |
diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc |
index 071dced9f09f49c11f3a2362e5d1037b5c9cc51c..65cc9397a6e9090cd28b92eedf978f7f3d27d2bb 100644 |
--- a/content/common/gpu/media/video_decode_accelerator_unittest.cc |
+++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc |
@@ -193,9 +193,10 @@ enum ClientState { |
// the TESTs below. |
class GLRenderingVDAClient |
: public VideoDecodeAccelerator::Client, |
- public RenderingHelper::Client, |
public base::SupportsWeakPtr<GLRenderingVDAClient> { |
public: |
+ // |window_id| the window_id of the client, which is used to identify the |
+ // rendering area in the |rendering_helper|. |
// Doesn't take ownership of |rendering_helper| or |note|, which must outlive |
// |*this|. |
// |num_play_throughs| indicates how many times to play through the video. |
@@ -212,7 +213,8 @@ class GLRenderingVDAClient |
// will start delaying the call to ReusePictureBuffer() for kReuseDelay. |
// |decode_calls_per_second| is the number of VDA::Decode calls per second. |
// If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. |
- GLRenderingVDAClient(RenderingHelper* rendering_helper, |
+ GLRenderingVDAClient(size_t window_id, |
+ RenderingHelper* rendering_helper, |
ClientStateNotification<ClientState>* note, |
const std::string& encoded_data, |
int num_in_flight_decodes, |
@@ -242,14 +244,8 @@ class GLRenderingVDAClient |
virtual void NotifyResetDone() OVERRIDE; |
virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE; |
- // RenderingHelper::Client implementation. |
- virtual void RenderContent(RenderingHelper*) OVERRIDE; |
- virtual const gfx::Size& GetWindowSize() OVERRIDE; |
- |
void OutputFrameDeliveryTimes(base::File* output); |
- void NotifyFrameDropped(int32 picture_buffer_id); |
- |
// Simple getters for inspecting the state of the Client. |
int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } |
int num_skipped_fragments() { return num_skipped_fragments_; } |
@@ -285,6 +281,7 @@ class GLRenderingVDAClient |
// Request decode of the next fragment in the encoded data. |
void DecodeNextFragment(); |
+ size_t window_id_; |
RenderingHelper* rendering_helper_; |
gfx::Size frame_size_; |
std::string encoded_data_; |
@@ -319,13 +316,12 @@ class GLRenderingVDAClient |
// The number of VDA::Decode calls per second. This is to simulate webrtc. |
int decode_calls_per_second_; |
bool render_as_thumbnails_; |
- bool pending_picture_updated_; |
- std::deque<int32> pending_picture_buffer_ids_; |
DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); |
}; |
GLRenderingVDAClient::GLRenderingVDAClient( |
+ size_t window_id, |
RenderingHelper* rendering_helper, |
ClientStateNotification<ClientState>* note, |
const std::string& encoded_data, |
@@ -340,7 +336,8 @@ GLRenderingVDAClient::GLRenderingVDAClient( |
int delay_reuse_after_frame_num, |
int decode_calls_per_second, |
bool render_as_thumbnails) |
- : rendering_helper_(rendering_helper), |
+ : window_id_(window_id), |
+ rendering_helper_(rendering_helper), |
frame_size_(frame_width, frame_height), |
encoded_data_(encoded_data), |
num_in_flight_decodes_(num_in_flight_decodes), |
@@ -360,8 +357,7 @@ GLRenderingVDAClient::GLRenderingVDAClient( |
suppress_rendering_(suppress_rendering), |
delay_reuse_after_frame_num_(delay_reuse_after_frame_num), |
decode_calls_per_second_(decode_calls_per_second), |
- render_as_thumbnails_(render_as_thumbnails), |
- pending_picture_updated_(true) { |
+ render_as_thumbnails_(render_as_thumbnails) { |
CHECK_GT(num_in_flight_decodes, 0); |
CHECK_GT(num_play_throughs, 0); |
// |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. |
@@ -459,42 +455,6 @@ void GLRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) { |
picture_buffers_by_id_.erase(it); |
} |
-void GLRenderingVDAClient::RenderContent(RenderingHelper*) { |
- CHECK(!render_as_thumbnails_); |
- |
- // No decoded texture for rendering yet, just skip. |
- if (pending_picture_buffer_ids_.size() == 0) |
- return; |
- |
- int32 buffer_id = pending_picture_buffer_ids_.front(); |
- media::PictureBuffer* picture_buffer = picture_buffers_by_id_[buffer_id]; |
- |
- CHECK(picture_buffer); |
- if (!pending_picture_updated_) { |
- // Frame dropped, just redraw the last texture. |
- rendering_helper_->RenderTexture(texture_target_, |
- picture_buffer->texture_id()); |
- return; |
- } |
- |
- base::TimeTicks now = base::TimeTicks::Now(); |
- frame_delivery_times_.push_back(now); |
- |
- rendering_helper_->RenderTexture(texture_target_, |
- picture_buffer->texture_id()); |
- |
- if (pending_picture_buffer_ids_.size() == 1) { |
- pending_picture_updated_ = false; |
- } else { |
- pending_picture_buffer_ids_.pop_front(); |
- ReturnPicture(buffer_id); |
- } |
-} |
- |
-const gfx::Size& GLRenderingVDAClient::GetWindowSize() { |
- return render_as_thumbnails_ ? kThumbnailsPageSize : frame_size_; |
-} |
- |
void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
// We shouldn't be getting pictures delivered after Reset has completed. |
CHECK_LT(state_, CS_RESET); |
@@ -503,6 +463,9 @@ void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
return; |
base::TimeTicks now = base::TimeTicks::Now(); |
+ |
+ frame_delivery_times_.push_back(now); |
+ |
// Save the decode time of this picture. |
std::map<int, base::TimeTicks>::iterator it = |
decode_start_time_.find(picture.bitstream_buffer_id()); |
@@ -524,25 +487,22 @@ void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { |
encoded_data_next_pos_to_decode_ = 0; |
} |
+ media::PictureBuffer* picture_buffer = |
+ picture_buffers_by_id_[picture.picture_buffer_id()]; |
+ CHECK(picture_buffer); |
+ |
+ scoped_refptr<VideoFrameTexture> video_frame = |
+ new VideoFrameTexture(texture_target_, |
+ picture_buffer->texture_id(), |
+ base::Bind(&GLRenderingVDAClient::ReturnPicture, |
+ AsWeakPtr(), |
+ picture.picture_buffer_id())); |
+ |
if (render_as_thumbnails_) { |
- frame_delivery_times_.push_back(now); |
- media::PictureBuffer* picture_buffer = |
- picture_buffers_by_id_[picture.picture_buffer_id()]; |
- CHECK(picture_buffer); |
- rendering_helper_->RenderThumbnail(texture_target_, |
- picture_buffer->texture_id()); |
- ReturnPicture(picture.picture_buffer_id()); |
+ rendering_helper_->RenderThumbnail(video_frame->texture_target(), |
+ video_frame->texture_id()); |
} else if (!suppress_rendering_) { |
- // Keep the picture for rendering. |
- pending_picture_buffer_ids_.push_back(picture.picture_buffer_id()); |
- if (pending_picture_buffer_ids_.size() > 1 && !pending_picture_updated_) { |
- ReturnPicture(pending_picture_buffer_ids_.front()); |
- pending_picture_buffer_ids_.pop_front(); |
- pending_picture_updated_ = true; |
- } |
- } else { |
- frame_delivery_times_.push_back(now); |
- ReturnPicture(picture.picture_buffer_id()); |
+ rendering_helper_->QueueVideoFrame(window_id_, video_frame); |
} |
} |
@@ -590,12 +550,7 @@ void GLRenderingVDAClient::NotifyResetDone() { |
if (decoder_deleted()) |
return; |
- // Clear pending_pictures and reuse them. |
- while (!pending_picture_buffer_ids_.empty()) { |
- decoder_->ReusePictureBuffer(pending_picture_buffer_ids_.front()); |
- pending_picture_buffer_ids_.pop_front(); |
- } |
- pending_picture_updated_ = true; |
+ rendering_helper_->DropPendingFrames(window_id_); |
if (reset_after_frame_num_ == MID_STREAM_RESET) { |
reset_after_frame_num_ = END_OF_STREAM_RESET; |
@@ -637,10 +592,6 @@ void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { |
} |
} |
-void GLRenderingVDAClient::NotifyFrameDropped(int32 picture_buffer_id) { |
- decoder_->ReusePictureBuffer(picture_buffer_id); |
-} |
- |
static bool LookingAtNAL(const std::string& encoded, size_t pos) { |
return encoded[pos] == 0 && encoded[pos + 1] == 0 && |
encoded[pos + 2] == 0 && encoded[pos + 3] == 1; |
@@ -1127,7 +1078,8 @@ TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
} |
GLRenderingVDAClient* client = |
- new GLRenderingVDAClient(&rendering_helper_, |
+ new GLRenderingVDAClient(index, |
+ &rendering_helper_, |
note, |
video_file->data_str, |
num_in_flight_decodes, |
@@ -1143,7 +1095,10 @@ TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
render_as_thumbnails); |
clients[index] = client; |
- helper_params.clients.push_back(client->AsWeakPtr()); |
+ helper_params.window_sizes.push_back( |
+ render_as_thumbnails |
+ ? kThumbnailsPageSize |
+ : gfx::Size(video_file->width, video_file->height)); |
} |
InitializeRenderingHelper(helper_params); |
@@ -1376,7 +1331,8 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
ClientStateNotification<ClientState>* note = |
new ClientStateNotification<ClientState>(); |
GLRenderingVDAClient* client = |
- new GLRenderingVDAClient(&rendering_helper_, |
+ new GLRenderingVDAClient(0, |
+ &rendering_helper_, |
note, |
test_video_files_[0]->data_str, |
1, |
@@ -1390,7 +1346,8 @@ TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
std::numeric_limits<int>::max(), |
kWebRtcDecodeCallsPerSecond, |
false /* render_as_thumbnail */); |
- helper_params.clients.push_back(client->AsWeakPtr()); |
+ helper_params.window_sizes.push_back( |
+ gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); |
InitializeRenderingHelper(helper_params); |
CreateAndStartDecoder(client, note); |
WaitUntilDecodeFinish(note); |