Port Android relocation packer to chromium build
[chromium-blink-merge.git] / ppapi / proxy / video_encoder_resource_unittest.cc
blob0adc1eabe5dcc55c8c1209a4ce476baf282f1f71
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/memory/shared_memory.h"
6 #include "base/process/process.h"
7 #include "base/synchronization/waitable_event.h"
8 #include "ppapi/c/pp_codecs.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_video_encoder.h"
11 #include "ppapi/c/ppb_video_frame.h"
12 #include "ppapi/proxy/locking_resource_releaser.h"
13 #include "ppapi/proxy/plugin_message_filter.h"
14 #include "ppapi/proxy/ppapi_message_utils.h"
15 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ppapi/proxy/ppapi_proxy_test.h"
17 #include "ppapi/proxy/video_encoder_resource.h"
18 #include "ppapi/shared_impl/media_stream_buffer.h"
19 #include "ppapi/shared_impl/proxy_lock.h"
20 #include "ppapi/thunk/thunk.h"
22 using ppapi::proxy::ResourceMessageTestSink;
24 namespace ppapi {
25 namespace proxy {
27 namespace {
29 class MockCompletionCallback {
30 public:
31 MockCompletionCallback() : called_(false), call_event_(false, false) {}
33 bool called() { return called_; }
34 int32_t result() { return result_; }
36 void WaitUntilCalled() { call_event_.Wait(); }
38 void Reset() {
39 called_ = false;
40 call_event_.Reset();
43 static void Callback(void* user_data, int32_t result) {
44 MockCompletionCallback* that =
45 reinterpret_cast<MockCompletionCallback*>(user_data);
46 that->call_event_.Signal();
47 that->called_ = true;
48 that->result_ = result;
51 private:
52 bool called_;
53 int32_t result_;
54 base::WaitableEvent call_event_;
57 class VideoEncoderResourceTest : public PluginProxyTest,
58 public MediaStreamBufferManager::Delegate {
59 public:
60 VideoEncoderResourceTest()
61 : encoder_iface_(thunk::GetPPB_VideoEncoder_0_1_Thunk()),
62 video_frames_manager_(this) {}
63 ~VideoEncoderResourceTest() override {}
65 const PPB_VideoEncoder_0_1* encoder_iface() const { return encoder_iface_; }
67 const uint32_t kBitstreamBufferSize = 4000;
68 const uint32_t kBitstreamBufferCount = 5;
69 const uint32_t kVideoFrameCount = 3;
70 const uint32_t kBitrate = 200000;
72 const PP_Size kFrameSize = PP_MakeSize(640, 480);
74 void SendReply(const ResourceMessageCallParams& params,
75 int32_t result,
76 const IPC::Message& nested_message) {
77 ResourceMessageReplyParams reply_params(params.pp_resource(),
78 params.sequence());
79 reply_params.set_result(result);
80 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
81 nested_message);
84 void SendReplyWithHandle(const ResourceMessageCallParams& params,
85 int32_t result,
86 const IPC::Message& nested_message,
87 const SerializedHandle& handle) {
88 ResourceMessageReplyParams reply_params(params.pp_resource(),
89 params.sequence());
90 reply_params.set_result(result);
91 reply_params.AppendHandle(handle);
92 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
93 nested_message);
96 void SendReplyWithHandles(const ResourceMessageCallParams& params,
97 int32_t result,
98 const IPC::Message& nested_message,
99 const std::vector<SerializedHandle>& handles) {
100 ResourceMessageReplyParams reply_params(params.pp_resource(),
101 params.sequence());
102 reply_params.set_result(result);
103 for (SerializedHandle handle : handles)
104 reply_params.AppendHandle(handle);
105 PluginMessageFilter::DispatchResourceReplyForTest(reply_params,
106 nested_message);
109 PP_Resource CreateEncoder() {
110 PP_Resource result = encoder_iface()->Create(pp_instance());
111 return result;
114 void CreateBitstreamSharedMemory(uint32_t buffer_size, uint32_t nb_buffers) {
115 shared_memory_bitstreams_.clear();
116 for (uint32_t i = 0; i < nb_buffers; ++i) {
117 scoped_ptr<base::SharedMemory> mem(new base::SharedMemory());
118 ASSERT_TRUE(mem->CreateAnonymous(buffer_size));
119 shared_memory_bitstreams_.push_back(mem.Pass());
123 void CreateVideoFramesSharedMemory(uint32_t frame_length,
124 uint32_t frame_count) {
125 scoped_ptr<base::SharedMemory> shared_memory_frames(
126 new base::SharedMemory());
127 uint32_t buffer_length =
128 frame_length + sizeof(ppapi::MediaStreamBuffer::Video);
129 ASSERT_TRUE(shared_memory_frames->CreateAnonymous(buffer_length *
130 frame_count));
131 ASSERT_TRUE(video_frames_manager_.SetBuffers(frame_count,
132 buffer_length,
133 shared_memory_frames.Pass(),
134 true));
135 for (int32_t i = 0; i < video_frames_manager_.number_of_buffers(); ++i) {
136 ppapi::MediaStreamBuffer::Video* buffer =
137 &(video_frames_manager_.GetBufferPointer(i)->video);
138 buffer->header.size = buffer_length;
139 buffer->header.type = ppapi::MediaStreamBuffer::TYPE_VIDEO;
140 buffer->format = PP_VIDEOFRAME_FORMAT_I420;
141 buffer->size = kFrameSize;
142 buffer->data_size = frame_length;
146 PP_Resource CreateAndInitializeEncoder() {
147 PP_Resource encoder = CreateEncoder();
148 PP_Size size = kFrameSize;
149 MockCompletionCallback cb;
150 int32_t result = encoder_iface()->Initialize(
151 encoder, PP_VIDEOFRAME_FORMAT_I420, &size, PP_VIDEOPROFILE_H264MAIN,
152 kBitrate, PP_HARDWAREACCELERATION_WITHFALLBACK,
153 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
154 &cb));
155 if (result != PP_OK_COMPLETIONPENDING)
156 return 0;
157 ResourceMessageCallParams params;
158 IPC::Message msg;
159 if (!sink().GetFirstResourceCallMatching(
160 PpapiHostMsg_VideoEncoder_Initialize::ID, &params, &msg))
161 return 0;
162 sink().ClearMessages();
164 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
165 CreateBitstreamSharedMemory(kBitstreamBufferSize, kBitstreamBufferCount);
166 SendBitstreamBuffers(params, kBitstreamBufferSize);
168 if (!cb.called() || cb.result() != PP_OK)
169 return 0;
171 return encoder;
174 int32_t CallGetFramesRequired(PP_Resource pp_encoder) {
175 return encoder_iface()->GetFramesRequired(pp_encoder);
178 int32_t CallGetFrameCodedSize(PP_Resource pp_encoder, PP_Size* coded_size) {
179 return encoder_iface()->GetFrameCodedSize(pp_encoder, coded_size);
182 int32_t CallGetVideoFrame(PP_Resource pp_encoder,
183 PP_Resource* video_frame,
184 MockCompletionCallback* cb) {
185 return encoder_iface()->GetVideoFrame(
186 pp_encoder, video_frame, PP_MakeOptionalCompletionCallback(
187 &MockCompletionCallback::Callback, cb));
190 int32_t CallFirstGetVideoFrame(PP_Resource pp_encoder,
191 PP_Resource* video_frame,
192 MockCompletionCallback* cb) {
193 int32_t result = encoder_iface()->GetVideoFrame(
194 pp_encoder, video_frame, PP_MakeOptionalCompletionCallback(
195 &MockCompletionCallback::Callback, cb));
196 if (result != PP_OK_COMPLETIONPENDING)
197 return result;
199 ResourceMessageCallParams params;
200 CheckGetVideoFramesMsg(&params);
202 uint32_t frame_length = kFrameSize.width * kFrameSize.height * 2;
203 CreateVideoFramesSharedMemory(frame_length, kVideoFrameCount);
204 SendGetVideoFramesReply(params, kVideoFrameCount, frame_length, kFrameSize);
206 return result;
209 int32_t CallEncode(PP_Resource pp_encoder,
210 PP_Resource video_frame,
211 PP_Bool force_keyframe,
212 MockCompletionCallback* cb) {
213 return encoder_iface()->Encode(pp_encoder, video_frame, force_keyframe,
214 PP_MakeOptionalCompletionCallback(
215 &MockCompletionCallback::Callback, cb));
218 int32_t CallCompleteEncode(PP_Resource pp_encoder,
219 PP_Resource video_frame,
220 PP_Bool force_keyframe,
221 MockCompletionCallback* cb) {
222 int32_t result =
223 encoder_iface()->Encode(pp_encoder, video_frame, force_keyframe,
224 PP_MakeOptionalCompletionCallback(
225 &MockCompletionCallback::Callback, cb));
226 if (result != PP_OK_COMPLETIONPENDING)
227 return result;
229 ResourceMessageCallParams params;
230 uint32_t frame_id;
231 bool forced_keyframe;
232 if (!CheckEncodeMsg(&params, &frame_id, &forced_keyframe))
233 return PP_ERROR_FAILED;
235 SendEncodeReply(params, frame_id);
237 return result;
240 int32_t CallGetBitstreamBuffer(PP_Resource pp_encoder,
241 PP_BitstreamBuffer* bitstream_buffer,
242 MockCompletionCallback* cb) {
243 return encoder_iface()->GetBitstreamBuffer(
244 pp_encoder, bitstream_buffer,
245 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
246 cb));
249 void CallRecycleBitstreamBuffer(PP_Resource pp_encoder,
250 const PP_BitstreamBuffer& buffer) {
251 encoder_iface()->RecycleBitstreamBuffer(pp_encoder, &buffer);
254 void CallRequestEncodingParametersChange(PP_Resource pp_encoder,
255 uint32_t bitrate,
256 uint32_t framerate) {
257 encoder_iface()->RequestEncodingParametersChange(pp_encoder, bitrate,
258 framerate);
261 void CallClose(PP_Resource pp_encoder) {
262 encoder_iface()->Close(pp_encoder);
265 void SendGetSupportedProfilesReply(
266 const ResourceMessageCallParams& params,
267 const std::vector<PP_VideoProfileDescription>& profiles) {
268 SendReply(params, PP_OK,
269 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(profiles));
272 void SendInitializeReply(const ResourceMessageCallParams& params,
273 int32_t success,
274 uint32_t input_frame_count,
275 const PP_Size& input_coded_size) {
276 SendReply(params, success, PpapiPluginMsg_VideoEncoder_InitializeReply(
277 input_frame_count, input_coded_size));
280 void SendBitstreamBuffers(const ResourceMessageCallParams& params,
281 uint32_t buffer_length) {
282 std::vector<SerializedHandle> handles;
283 for (base::SharedMemory* mem : shared_memory_bitstreams_) {
284 ASSERT_EQ(mem->requested_size(), buffer_length);
285 base::SharedMemoryHandle handle;
287 ASSERT_TRUE(
288 mem->ShareToProcess(base::Process::Current().Handle(), &handle));
289 handles.push_back(SerializedHandle(handle, buffer_length));
291 SendReplyWithHandles(
292 params, PP_OK,
293 PpapiPluginMsg_VideoEncoder_BitstreamBuffers(buffer_length), handles);
296 void SendGetVideoFramesReply(const ResourceMessageCallParams& params,
297 uint32_t frame_count,
298 uint32_t frame_length,
299 const PP_Size& size) {
300 base::SharedMemoryHandle handle;
301 ASSERT_TRUE(video_frames_manager_.shm()->ShareToProcess(
302 base::Process::Current().Handle(), &handle));
303 SendReplyWithHandle(
304 params, PP_OK, PpapiPluginMsg_VideoEncoder_GetVideoFramesReply(
305 frame_count,
306 frame_length + sizeof(MediaStreamBuffer::Video),
307 size),
308 SerializedHandle(
309 handle,
310 static_cast<uint32_t>(
311 video_frames_manager_.shm()->requested_size())));
314 void SendEncodeReply(const ResourceMessageCallParams& params,
315 uint32_t frame_id) {
316 SendReply(params, PP_OK, PpapiPluginMsg_VideoEncoder_EncodeReply(frame_id));
319 void SendBitstreamBufferReady(const ResourceMessageCallParams& params,
320 uint32_t buffer_id,
321 uint32_t buffer_size,
322 bool keyframe) {
323 SendReply(params, PP_OK,
324 PpapiPluginMsg_VideoEncoder_BitstreamBufferReady(
325 buffer_id, buffer_size, PP_FromBool(keyframe)));
328 void SendNotifyError(const ResourceMessageCallParams& params, int32_t error) {
329 SendReply(params, PP_OK, PpapiPluginMsg_VideoEncoder_NotifyError(error));
332 bool CheckGetSupportedProfilesMsg(ResourceMessageCallParams* params) {
333 IPC::Message msg;
334 return sink().GetFirstResourceCallMatching(
335 PpapiHostMsg_VideoEncoder_GetSupportedProfiles::ID, params, &msg);
338 bool CheckInitializeMsg(ResourceMessageCallParams* params,
339 PP_VideoFrame_Format* input_format,
340 struct PP_Size* input_visible_size,
341 PP_VideoProfile* output_profile,
342 uint32_t* bitrate,
343 PP_HardwareAcceleration* acceleration) {
344 IPC::Message msg;
345 if (!sink().GetFirstResourceCallMatching(
346 PpapiHostMsg_VideoEncoder_Initialize::ID, params, &msg))
347 return false;
348 sink().ClearMessages();
349 return UnpackMessage<PpapiHostMsg_VideoEncoder_Initialize>(
350 msg, input_format, input_visible_size, output_profile, bitrate,
351 acceleration);
354 bool CheckGetVideoFramesMsg(ResourceMessageCallParams* params) {
355 IPC::Message msg;
356 if (!sink().GetFirstResourceCallMatching(
357 PpapiHostMsg_VideoEncoder_GetVideoFrames::ID, params, &msg))
358 return false;
359 sink().ClearMessages();
360 return true;
363 bool CheckEncodeMsg(ResourceMessageCallParams* params,
364 uint32_t* frame_id,
365 bool* keyframe) {
366 IPC::Message msg;
367 if (!sink().GetFirstResourceCallMatching(
368 PpapiHostMsg_VideoEncoder_Encode::ID, params, &msg))
369 return false;
370 sink().ClearMessages();
371 return UnpackMessage<PpapiHostMsg_VideoEncoder_Encode>(msg, frame_id,
372 keyframe);
375 bool CheckRecycleBitstreamBufferMsg(ResourceMessageCallParams* params,
376 uint32_t* buffer_id) {
377 IPC::Message msg;
378 if (!sink().GetFirstResourceCallMatching(
379 PpapiHostMsg_VideoEncoder_RecycleBitstreamBuffer::ID, params, &msg))
380 return false;
381 sink().ClearMessages();
382 return UnpackMessage<PpapiHostMsg_VideoEncoder_RecycleBitstreamBuffer>(
383 msg, buffer_id);
386 bool CheckRequestEncodingParametersChangeMsg(
387 ResourceMessageCallParams* params,
388 uint32_t* bitrate,
389 uint32_t* framerate) {
390 IPC::Message msg;
391 if (!sink().GetFirstResourceCallMatching(
392 PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange::ID,
393 params, &msg))
394 return false;
395 sink().ClearMessages();
396 return UnpackMessage<
397 PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange>(msg, bitrate,
398 framerate);
401 bool CheckIsVideoFrame(PP_Resource video_frame) {
402 return thunk::GetPPB_VideoFrame_0_1_Thunk()->IsVideoFrame(video_frame);
405 bool CheckIsVideoFrameValid(PP_Resource video_frame) {
406 PP_Size frame_size;
407 return thunk::GetPPB_VideoFrame_0_1_Thunk()->GetSize(
408 video_frame, &frame_size) == PP_TRUE;
411 private:
412 // MediaStreamBufferManager::Delegate:
413 void OnNewBufferEnqueued() override {}
415 const PPB_VideoEncoder_0_1* encoder_iface_;
417 ScopedVector<base::SharedMemory> shared_memory_bitstreams_;
419 MediaStreamBufferManager video_frames_manager_;
422 void* ForwardUserData(void* user_data,
423 uint32_t element_count,
424 uint32_t element_size) {
425 return user_data;
428 } // namespace
430 TEST_F(VideoEncoderResourceTest, GetSupportedProfiles) {
431 // Verifies that GetSupportedProfiles calls into the renderer and
432 // the we get the right results back.
434 LockingResourceReleaser encoder(CreateEncoder());
435 PP_VideoProfileDescription profiles[2];
436 PP_ArrayOutput output;
437 output.user_data = &profiles[0];
438 output.GetDataBuffer = ForwardUserData;
439 ResourceMessageCallParams params;
440 MockCompletionCallback cb;
441 int32_t result = encoder_iface()->GetSupportedProfiles(
442 encoder.get(), output, PP_MakeOptionalCompletionCallback(
443 &MockCompletionCallback::Callback, &cb));
444 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
445 ASSERT_TRUE(CheckGetSupportedProfilesMsg(&params));
447 std::vector<PP_VideoProfileDescription> profiles_response;
448 PP_VideoProfileDescription profile;
449 profile.profile = PP_VIDEOPROFILE_H264MAIN;
450 profile.max_resolution.width = 1920;
451 profile.max_resolution.height = 1080;
452 profile.max_framerate_numerator = 30;
453 profile.max_framerate_denominator = 1;
454 profile.acceleration = PP_HARDWAREACCELERATION_ONLY;
455 profiles_response.push_back(profile);
456 profile.profile = PP_VIDEOPROFILE_VP8_ANY;
457 profile.max_resolution.width = 1920;
458 profile.max_resolution.height = 1080;
459 profile.max_framerate_numerator = 30;
460 profile.max_framerate_denominator = 1;
461 profile.acceleration = PP_HARDWAREACCELERATION_NONE;
462 profiles_response.push_back(profile);
464 SendGetSupportedProfilesReply(params, profiles_response);
465 ASSERT_EQ(PP_OK, cb.result());
467 ASSERT_EQ(2U, profiles_response.size());
468 ASSERT_EQ(0, memcmp(&profiles[0], &profiles_response[0],
469 sizeof(PP_VideoProfileDescription) * 2));
473 TEST_F(VideoEncoderResourceTest, InitializeFailure) {
475 // Verify the initialize callback is called in case of failure.
476 LockingResourceReleaser encoder(CreateEncoder());
477 ResourceMessageCallParams params;
478 PP_Size size = kFrameSize;
479 MockCompletionCallback cb;
480 int32_t result = encoder_iface()->Initialize(
481 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
482 PP_VIDEOPROFILE_H264MAIN, kBitrate,
483 PP_HARDWAREACCELERATION_WITHFALLBACK,
484 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
485 &cb));
486 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
488 PP_VideoFrame_Format input_format;
489 PP_Size input_visible_size;
490 PP_VideoProfile output_profile;
491 uint32_t bitrate;
492 PP_HardwareAcceleration acceleration;
493 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
494 &output_profile, &bitrate, &acceleration));
495 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format);
496 ASSERT_EQ(size.width, input_visible_size.width);
497 ASSERT_EQ(size.height, input_visible_size.height);
498 ASSERT_EQ(kBitrate, bitrate);
499 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
500 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
502 SendInitializeReply(params, PP_ERROR_NOTSUPPORTED, kVideoFrameCount,
503 kFrameSize);
504 ASSERT_TRUE(cb.called());
505 ASSERT_EQ(PP_ERROR_NOTSUPPORTED, cb.result());
508 // Verify the initialize callback is called in case of error
509 // notification.
510 LockingResourceReleaser encoder(CreateEncoder());
511 ResourceMessageCallParams params;
512 PP_Size size = kFrameSize;
513 MockCompletionCallback cb;
514 int32_t result = encoder_iface()->Initialize(
515 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
516 PP_VIDEOPROFILE_H264MAIN, kBitrate,
517 PP_HARDWAREACCELERATION_WITHFALLBACK,
518 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
519 &cb));
520 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
522 PP_VideoFrame_Format input_format;
523 PP_Size input_visible_size;
524 PP_VideoProfile output_profile;
525 uint32_t bitrate;
526 PP_HardwareAcceleration acceleration;
527 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
528 &output_profile, &bitrate, &acceleration));
529 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format);
530 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
531 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
532 ASSERT_EQ(kBitrate, bitrate);
533 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
534 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
536 ResourceMessageCallParams error_params(encoder.get(), 0);
537 SendNotifyError(error_params, PP_ERROR_FAILED);
538 ASSERT_TRUE(cb.called());
539 ASSERT_EQ(PP_ERROR_FAILED, cb.result());
542 // Verify that calling initialize twice fails the second time if
543 // we haven't received a response yet.
544 LockingResourceReleaser encoder(CreateEncoder());
545 ResourceMessageCallParams params;
546 PP_Size size = kFrameSize;
547 MockCompletionCallback cb;
548 int32_t result = encoder_iface()->Initialize(
549 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
550 PP_VIDEOPROFILE_H264MAIN, kBitrate,
551 PP_HARDWAREACCELERATION_WITHFALLBACK,
552 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
553 &cb));
554 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
556 PP_VideoFrame_Format input_format;
557 PP_Size input_visible_size;
558 PP_VideoProfile output_profile;
559 uint32_t bitrate;
560 PP_HardwareAcceleration acceleration;
561 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
562 &output_profile, &bitrate, &acceleration));
563 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format);
564 ASSERT_EQ(size.width, input_visible_size.width);
565 ASSERT_EQ(size.height, input_visible_size.height);
566 ASSERT_EQ(kBitrate, bitrate);
567 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
568 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
570 result = encoder_iface()->Initialize(
571 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
572 PP_VIDEOPROFILE_H264MAIN, kBitrate,
573 PP_HARDWAREACCELERATION_WITHFALLBACK,
574 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
575 &cb));
576 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
578 ResourceMessageCallParams error_params(encoder.get(), 0);
579 SendNotifyError(error_params, PP_ERROR_FAILED);
580 ASSERT_TRUE(cb.called());
581 ASSERT_EQ(PP_ERROR_FAILED, cb.result());
585 TEST_F(VideoEncoderResourceTest, InitializeSuccess) {
587 // Verify the initialize callback is called when initialization is
588 // successfull.
589 LockingResourceReleaser encoder(CreateEncoder());
590 ResourceMessageCallParams params;
591 PP_Size size = kFrameSize;
592 const uint32_t kBitrate = 420000;
593 MockCompletionCallback cb;
594 int32_t result = encoder_iface()->Initialize(
595 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
596 PP_VIDEOPROFILE_H264MAIN, kBitrate,
597 PP_HARDWAREACCELERATION_WITHFALLBACK,
598 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
599 &cb));
600 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
602 PP_VideoFrame_Format input_format;
603 PP_Size input_visible_size;
604 PP_VideoProfile output_profile;
605 uint32_t bitrate;
606 PP_HardwareAcceleration acceleration;
607 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
608 &output_profile, &bitrate, &acceleration));
609 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format);
610 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
611 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
612 ASSERT_EQ(kBitrate, bitrate);
613 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
614 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
616 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
618 ASSERT_TRUE(cb.called());
619 ASSERT_EQ(PP_OK, cb.result());
622 // Verify that calling initialize a second time, after it already
623 // succeeded, fails.
624 LockingResourceReleaser encoder(CreateEncoder());
625 ResourceMessageCallParams params;
626 PP_Size size = kFrameSize;
627 const uint32_t kBitrate = 420000;
628 MockCompletionCallback cb;
629 int32_t result = encoder_iface()->Initialize(
630 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
631 PP_VIDEOPROFILE_H264MAIN, kBitrate,
632 PP_HARDWAREACCELERATION_WITHFALLBACK,
633 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
634 &cb));
635 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
637 PP_VideoFrame_Format input_format;
638 PP_Size input_visible_size;
639 PP_VideoProfile output_profile;
640 uint32_t bitrate;
641 PP_HardwareAcceleration acceleration;
642 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
643 &output_profile, &bitrate, &acceleration));
644 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format);
645 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
646 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
647 ASSERT_EQ(kBitrate, bitrate);
648 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
649 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
651 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
653 ASSERT_TRUE(cb.called());
654 ASSERT_EQ(PP_OK, cb.result());
656 result = encoder_iface()->Initialize(
657 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
658 PP_VIDEOPROFILE_H264MAIN, kBitrate,
659 PP_HARDWAREACCELERATION_WITHFALLBACK,
660 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
661 &cb));
662 ASSERT_EQ(PP_ERROR_FAILED, result);
665 // Verify the sending the bitstream buffers details makes them
666 // available through the API. the right values.
667 LockingResourceReleaser encoder(CreateEncoder());
668 ResourceMessageCallParams params;
669 PP_Size size = kFrameSize;
670 const uint32_t kBitrate = 420000;
671 MockCompletionCallback cb;
672 int32_t result = encoder_iface()->Initialize(
673 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
674 PP_VIDEOPROFILE_H264MAIN, kBitrate,
675 PP_HARDWAREACCELERATION_WITHFALLBACK,
676 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
677 &cb));
678 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
680 PP_VideoFrame_Format input_format;
681 PP_Size input_visible_size;
682 PP_VideoProfile output_profile;
683 uint32_t bitrate;
684 PP_HardwareAcceleration acceleration;
685 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
686 &output_profile, &bitrate, &acceleration));
687 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format);
688 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
689 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
690 ASSERT_EQ(kBitrate, bitrate);
691 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
692 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
694 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
696 ASSERT_TRUE(cb.called());
697 ASSERT_EQ(PP_OK, cb.result());
699 PP_Size coded_size;
700 ASSERT_EQ(PP_OK, CallGetFrameCodedSize(encoder.get(), &coded_size));
701 ASSERT_EQ(kFrameSize.width, coded_size.width);
702 ASSERT_EQ(kFrameSize.height, coded_size.height);
703 ASSERT_EQ(static_cast<int32_t>(kVideoFrameCount),
704 CallGetFramesRequired(encoder.get()));
708 TEST_F(VideoEncoderResourceTest, Uninitialized) {
709 // Operations on uninitialized encoders should fail.
710 LockingResourceReleaser encoder(CreateEncoder());
712 ASSERT_EQ(PP_ERROR_FAILED, CallGetFramesRequired(encoder.get()));
714 PP_Size size;
715 ASSERT_EQ(PP_ERROR_FAILED, CallGetFrameCodedSize(encoder.get(), &size));
717 MockCompletionCallback uncalled_cb;
718 PP_Resource video_frame = 0;
719 ASSERT_EQ(PP_ERROR_FAILED,
720 CallGetVideoFrame(encoder.get(), &video_frame, &uncalled_cb));
721 ASSERT_FALSE(uncalled_cb.called());
722 ASSERT_EQ(0, video_frame);
724 ASSERT_EQ(PP_ERROR_FAILED,
725 CallEncode(encoder.get(), video_frame, PP_FALSE, &uncalled_cb));
726 ASSERT_FALSE(uncalled_cb.called());
728 PP_BitstreamBuffer bitstream_buffer;
729 ASSERT_EQ(
730 PP_ERROR_FAILED,
731 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, &uncalled_cb));
732 ASSERT_FALSE(uncalled_cb.called());
734 ResourceMessageCallParams params;
735 uint32_t buffer_id;
736 CallRecycleBitstreamBuffer(encoder.get(), bitstream_buffer);
737 ASSERT_FALSE(CheckRecycleBitstreamBufferMsg(&params, &buffer_id));
739 uint32_t bitrate, framerate;
740 CallRequestEncodingParametersChange(encoder.get(), 0, 0);
741 ASSERT_FALSE(
742 CheckRequestEncodingParametersChangeMsg(&params, &bitrate, &framerate));
745 TEST_F(VideoEncoderResourceTest, InitializeAndGetVideoFrame) {
746 // Verify that we can pull the right number of video frames before
747 // the proxy makes us wait.
748 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
749 ResourceMessageCallParams params;
750 std::vector<PP_Resource> video_frames;
751 MockCompletionCallback get_frame_cb;
753 video_frames.resize(kVideoFrameCount + 1);
755 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
756 CallGetVideoFrame(encoder.get(), &video_frames[0], &get_frame_cb));
757 ASSERT_FALSE(get_frame_cb.called());
758 ASSERT_TRUE(CheckGetVideoFramesMsg(&params));
760 uint32_t frame_length = kFrameSize.width * kFrameSize.height * 2;
761 CreateVideoFramesSharedMemory(frame_length, kVideoFrameCount);
762 SendGetVideoFramesReply(params, kVideoFrameCount, frame_length, kFrameSize);
764 for (uint32_t i = 1; i < kVideoFrameCount; ++i) {
765 get_frame_cb.Reset();
766 ASSERT_EQ(
767 PP_OK_COMPLETIONPENDING,
768 CallGetVideoFrame(encoder.get(), &video_frames[i], &get_frame_cb));
769 ASSERT_TRUE(get_frame_cb.called());
770 ASSERT_EQ(PP_OK, get_frame_cb.result());
771 ASSERT_TRUE(CheckIsVideoFrame(video_frames[i]));
774 get_frame_cb.Reset();
775 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
776 CallGetVideoFrame(encoder.get(), &video_frames[kVideoFrameCount],
777 &get_frame_cb));
778 ASSERT_FALSE(get_frame_cb.called());
780 MockCompletionCallback get_frame_fail_cb;
781 ASSERT_EQ(PP_ERROR_INPROGRESS,
782 CallGetVideoFrame(encoder.get(), &video_frames[kVideoFrameCount],
783 &get_frame_fail_cb));
784 ASSERT_FALSE(get_frame_fail_cb.called());
786 // Unblock the GetVideoFrame callback by freeing up a frame.
787 MockCompletionCallback encode_cb;
788 ASSERT_EQ(
789 PP_OK_COMPLETIONPENDING,
790 CallCompleteEncode(encoder.get(), video_frames[0], PP_FALSE, &encode_cb));
791 ASSERT_TRUE(encode_cb.called());
792 ASSERT_EQ(PP_OK, encode_cb.result());
793 ASSERT_TRUE(get_frame_cb.called());
795 CallClose(encoder.get());
798 TEST_F(VideoEncoderResourceTest, Encode) {
799 // Check Encode() calls into the renderer.
800 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
801 PP_Resource video_frame;
802 MockCompletionCallback get_frame_cb;
804 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
805 CallFirstGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
806 ASSERT_TRUE(get_frame_cb.called());
807 ASSERT_EQ(PP_OK, get_frame_cb.result());
809 MockCompletionCallback encode_cb;
810 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
811 CallEncode(encoder.get(), video_frame, PP_TRUE, &encode_cb));
812 ASSERT_FALSE(encode_cb.called());
813 ASSERT_FALSE(CheckIsVideoFrameValid(video_frame));
815 ResourceMessageCallParams params;
816 uint32_t frame_id;
817 bool force_frame;
818 ASSERT_TRUE(CheckEncodeMsg(&params, &frame_id, &force_frame));
820 SendEncodeReply(params, frame_id);
822 ASSERT_TRUE(encode_cb.called());
823 ASSERT_EQ(PP_OK, encode_cb.result());
826 TEST_F(VideoEncoderResourceTest, EncodeAndGetVideoFrame) {
827 // Check the encoding loop works well.
828 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
829 ResourceMessageCallParams params;
830 PP_Resource video_frame;
831 MockCompletionCallback get_frame_cb, encode_cb;
833 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
834 CallFirstGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
835 ASSERT_TRUE(get_frame_cb.called());
836 ASSERT_EQ(PP_OK, get_frame_cb.result());
838 for (uint32_t i = 1; i < 20 * kVideoFrameCount; ++i) {
839 encode_cb.Reset();
840 ASSERT_EQ(
841 PP_OK_COMPLETIONPENDING,
842 CallCompleteEncode(encoder.get(), video_frame, PP_FALSE, &encode_cb));
843 ASSERT_TRUE(encode_cb.called());
844 ASSERT_EQ(PP_OK, encode_cb.result());
846 get_frame_cb.Reset();
847 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
848 CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
849 ASSERT_TRUE(get_frame_cb.called());
850 ASSERT_EQ(PP_OK, get_frame_cb.result());
851 ASSERT_TRUE(CheckIsVideoFrame(video_frame));
854 ASSERT_EQ(
855 PP_OK_COMPLETIONPENDING,
856 CallCompleteEncode(encoder.get(), video_frame, PP_FALSE, &encode_cb));
857 ASSERT_TRUE(encode_cb.called());
858 ASSERT_EQ(PP_OK, encode_cb.result());
861 TEST_F(VideoEncoderResourceTest, GetBitstreamBuffer) {
863 // Verify that the GetBitstreamBuffer callback is fired whenever the
864 // renderer signals a buffer is available.
865 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
867 MockCompletionCallback get_bitstream_buffer_cb;
868 PP_BitstreamBuffer bitstream_buffer;
869 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
870 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
871 &get_bitstream_buffer_cb));
872 ASSERT_FALSE(get_bitstream_buffer_cb.called());
874 ResourceMessageCallParams buffer_params(encoder.get(), 0);
875 SendBitstreamBufferReady(buffer_params, 0, 10, true);
877 ASSERT_TRUE(get_bitstream_buffer_cb.called());
878 ASSERT_EQ(PP_OK, get_bitstream_buffer_cb.result());
879 ASSERT_EQ(10U, bitstream_buffer.size);
880 ASSERT_EQ(PP_TRUE, bitstream_buffer.key_frame);
883 // Verify that calling GetBitstreamBuffer a second time, while the
884 // first callback hasn't been fired fails.
885 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
887 MockCompletionCallback get_bitstream_buffer_cb;
888 PP_BitstreamBuffer bitstream_buffer;
889 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
890 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
891 &get_bitstream_buffer_cb));
892 ASSERT_FALSE(get_bitstream_buffer_cb.called());
894 ASSERT_EQ(PP_ERROR_INPROGRESS,
895 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
896 &get_bitstream_buffer_cb));
897 ASSERT_FALSE(get_bitstream_buffer_cb.called());
899 ResourceMessageCallParams buffer_params(encoder.get(), 0);
900 SendBitstreamBufferReady(buffer_params, 0, 10, true);
904 TEST_F(VideoEncoderResourceTest, RecycleBitstreamBuffer) {
905 // Verify that we signal the renderer that a bitstream buffer has been
906 // recycled.
907 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
909 MockCompletionCallback get_bitstream_buffer_cb;
910 PP_BitstreamBuffer bitstream_buffer;
911 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
912 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
913 &get_bitstream_buffer_cb));
914 ASSERT_FALSE(get_bitstream_buffer_cb.called());
916 ResourceMessageCallParams buffer_params(encoder.get(), 0);
917 SendBitstreamBufferReady(buffer_params, kBitstreamBufferCount - 1, 10, true);
919 ASSERT_TRUE(get_bitstream_buffer_cb.called());
920 ASSERT_EQ(PP_OK, get_bitstream_buffer_cb.result());
922 CallRecycleBitstreamBuffer(encoder.get(), bitstream_buffer);
924 ResourceMessageCallParams recycle_params;
925 uint32_t buffer_id;
926 ASSERT_TRUE(CheckRecycleBitstreamBufferMsg(&recycle_params, &buffer_id));
927 ASSERT_EQ(kBitstreamBufferCount - 1, buffer_id);
930 TEST_F(VideoEncoderResourceTest, RequestEncodingParametersChange) {
931 // Check encoding parameter changes are correctly sent to the
932 // renderer.
933 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
935 CallRequestEncodingParametersChange(encoder.get(), 1, 2);
936 ResourceMessageCallParams params;
937 uint32_t bitrate, framerate;
938 ASSERT_TRUE(
939 CheckRequestEncodingParametersChangeMsg(&params, &bitrate, &framerate));
940 ASSERT_EQ(1U, bitrate);
941 ASSERT_EQ(2U, framerate);
944 TEST_F(VideoEncoderResourceTest, NotifyError) {
946 // Check an error from the encoder aborts GetVideoFrame and
947 // GetBitstreamBuffer callbacks.
948 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
950 MockCompletionCallback get_frame_cb;
951 PP_Resource video_frame;
952 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
953 CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
954 ASSERT_FALSE(get_frame_cb.called());
956 MockCompletionCallback get_bitstream_buffer_cb;
957 PP_BitstreamBuffer bitstream_buffer;
958 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
959 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
960 &get_bitstream_buffer_cb));
962 ResourceMessageCallParams error_params(encoder.get(), 0);
963 SendNotifyError(error_params, PP_ERROR_FAILED);
965 ASSERT_TRUE(get_frame_cb.called());
966 ASSERT_EQ(PP_ERROR_FAILED, get_frame_cb.result());
967 ASSERT_TRUE(get_bitstream_buffer_cb.called());
968 ASSERT_EQ(PP_ERROR_FAILED, get_bitstream_buffer_cb.result());
971 // Check an error from the encoder aborts Encode and GetBitstreamBuffer
972 // callbacks.
973 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
975 MockCompletionCallback get_frame_cb, encode_cb1, encode_cb2;
976 PP_Resource video_frame1, video_frame2;
977 ASSERT_EQ(
978 PP_OK_COMPLETIONPENDING,
979 CallFirstGetVideoFrame(encoder.get(), &video_frame1, &get_frame_cb));
980 ASSERT_TRUE(get_frame_cb.called());
981 ASSERT_EQ(PP_OK, get_frame_cb.result());
983 get_frame_cb.Reset();
984 ASSERT_EQ(
985 PP_OK_COMPLETIONPENDING,
986 CallFirstGetVideoFrame(encoder.get(), &video_frame2, &get_frame_cb));
987 ASSERT_TRUE(get_frame_cb.called());
988 ASSERT_EQ(PP_OK, get_frame_cb.result());
990 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
991 CallEncode(encoder.get(), video_frame1, PP_FALSE, &encode_cb1));
992 ASSERT_FALSE(encode_cb1.called());
993 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
994 CallEncode(encoder.get(), video_frame2, PP_FALSE, &encode_cb2));
995 ASSERT_FALSE(encode_cb2.called());
997 MockCompletionCallback get_bitstream_buffer_cb;
998 PP_BitstreamBuffer bitstream_buffer;
999 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1000 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
1001 &get_bitstream_buffer_cb));
1003 ResourceMessageCallParams error_params(encoder.get(), 0);
1004 SendNotifyError(error_params, PP_ERROR_FAILED);
1006 ASSERT_TRUE(encode_cb1.called());
1007 ASSERT_EQ(PP_ERROR_FAILED, encode_cb1.result());
1008 ASSERT_TRUE(encode_cb2.called());
1009 ASSERT_EQ(PP_ERROR_FAILED, encode_cb2.result());
1010 ASSERT_TRUE(get_bitstream_buffer_cb.called());
1011 ASSERT_EQ(PP_ERROR_FAILED, get_bitstream_buffer_cb.result());
1015 TEST_F(VideoEncoderResourceTest, Close) {
1017 // Check closing the encoder aborts GetVideoFrame and
1018 // GetBitstreamBuffer callbacks.
1019 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
1021 MockCompletionCallback get_frame_cb;
1022 PP_Resource video_frame;
1023 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1024 CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
1025 ASSERT_FALSE(get_frame_cb.called());
1027 MockCompletionCallback get_bitstream_buffer_cb;
1028 PP_BitstreamBuffer bitstream_buffer;
1029 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1030 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
1031 &get_bitstream_buffer_cb));
1033 CallClose(encoder.get());
1035 ASSERT_TRUE(get_frame_cb.called());
1036 ASSERT_EQ(PP_ERROR_ABORTED, get_frame_cb.result());
1037 ASSERT_TRUE(get_bitstream_buffer_cb.called());
1038 ASSERT_EQ(PP_ERROR_ABORTED, get_bitstream_buffer_cb.result());
1041 // Check closing the encoder aborts Encode and GetBitstreamBuffer
1042 // callbacks.
1043 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
1045 MockCompletionCallback get_frame_cb, encode_cb1, encode_cb2;
1046 PP_Resource video_frame1, video_frame2;
1047 ASSERT_EQ(
1048 PP_OK_COMPLETIONPENDING,
1049 CallFirstGetVideoFrame(encoder.get(), &video_frame1, &get_frame_cb));
1050 ASSERT_TRUE(get_frame_cb.called());
1051 ASSERT_EQ(PP_OK, get_frame_cb.result());
1053 get_frame_cb.Reset();
1054 ASSERT_EQ(
1055 PP_OK_COMPLETIONPENDING,
1056 CallFirstGetVideoFrame(encoder.get(), &video_frame2, &get_frame_cb));
1057 ASSERT_TRUE(get_frame_cb.called());
1058 ASSERT_EQ(PP_OK, get_frame_cb.result());
1060 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1061 CallEncode(encoder.get(), video_frame1, PP_FALSE, &encode_cb1));
1062 ASSERT_FALSE(encode_cb1.called());
1063 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1064 CallEncode(encoder.get(), video_frame2, PP_FALSE, &encode_cb2));
1065 ASSERT_FALSE(encode_cb2.called());
1067 MockCompletionCallback get_bitstream_buffer_cb;
1068 PP_BitstreamBuffer bitstream_buffer;
1069 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1070 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
1071 &get_bitstream_buffer_cb));
1073 CallClose(encoder.get());
1075 ASSERT_TRUE(encode_cb1.called());
1076 ASSERT_EQ(PP_ERROR_ABORTED, encode_cb1.result());
1077 ASSERT_TRUE(encode_cb2.called());
1078 ASSERT_EQ(PP_ERROR_ABORTED, encode_cb2.result());
1079 ASSERT_TRUE(get_bitstream_buffer_cb.called());
1080 ASSERT_EQ(PP_ERROR_ABORTED, get_bitstream_buffer_cb.result());
1084 } // namespace proxy
1085 } // namespace ppapi