Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ppapi / proxy / video_encoder_resource_unittest.cc
blobcc7ecc88af797dbc0f44684262109d1e7bbe375c
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(profiles_response.size(), static_cast<uint32_t>(cb.result()));
466 ASSERT_EQ(0, memcmp(&profiles[0], &profiles_response[0], sizeof(profiles)));
470 TEST_F(VideoEncoderResourceTest, InitializeFailure) {
472 // Verify the initialize callback is called in case of failure.
473 LockingResourceReleaser encoder(CreateEncoder());
474 ResourceMessageCallParams params;
475 PP_Size size = kFrameSize;
476 MockCompletionCallback cb;
477 int32_t result = encoder_iface()->Initialize(
478 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
479 PP_VIDEOPROFILE_H264MAIN, kBitrate,
480 PP_HARDWAREACCELERATION_WITHFALLBACK,
481 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
482 &cb));
483 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
485 PP_VideoFrame_Format input_format;
486 PP_Size input_visible_size;
487 PP_VideoProfile output_profile;
488 uint32_t bitrate;
489 PP_HardwareAcceleration acceleration;
490 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
491 &output_profile, &bitrate, &acceleration));
492 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format);
493 ASSERT_EQ(size.width, input_visible_size.width);
494 ASSERT_EQ(size.height, input_visible_size.height);
495 ASSERT_EQ(kBitrate, bitrate);
496 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
497 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
499 SendInitializeReply(params, PP_ERROR_NOTSUPPORTED, kVideoFrameCount,
500 kFrameSize);
501 ASSERT_TRUE(cb.called());
502 ASSERT_EQ(PP_ERROR_NOTSUPPORTED, cb.result());
505 // Verify the initialize callback is called in case of error
506 // notification.
507 LockingResourceReleaser encoder(CreateEncoder());
508 ResourceMessageCallParams params;
509 PP_Size size = kFrameSize;
510 MockCompletionCallback cb;
511 int32_t result = encoder_iface()->Initialize(
512 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
513 PP_VIDEOPROFILE_H264MAIN, kBitrate,
514 PP_HARDWAREACCELERATION_WITHFALLBACK,
515 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
516 &cb));
517 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
519 PP_VideoFrame_Format input_format;
520 PP_Size input_visible_size;
521 PP_VideoProfile output_profile;
522 uint32_t bitrate;
523 PP_HardwareAcceleration acceleration;
524 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
525 &output_profile, &bitrate, &acceleration));
526 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format);
527 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
528 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
529 ASSERT_EQ(kBitrate, bitrate);
530 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
531 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
533 ResourceMessageCallParams error_params(encoder.get(), 0);
534 SendNotifyError(error_params, PP_ERROR_FAILED);
535 ASSERT_TRUE(cb.called());
536 ASSERT_EQ(PP_ERROR_FAILED, cb.result());
539 // Verify that calling initialize twice fails the second time if
540 // we haven't received a response yet.
541 LockingResourceReleaser encoder(CreateEncoder());
542 ResourceMessageCallParams params;
543 PP_Size size = kFrameSize;
544 MockCompletionCallback cb;
545 int32_t result = encoder_iface()->Initialize(
546 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
547 PP_VIDEOPROFILE_H264MAIN, kBitrate,
548 PP_HARDWAREACCELERATION_WITHFALLBACK,
549 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
550 &cb));
551 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
553 PP_VideoFrame_Format input_format;
554 PP_Size input_visible_size;
555 PP_VideoProfile output_profile;
556 uint32_t bitrate;
557 PP_HardwareAcceleration acceleration;
558 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
559 &output_profile, &bitrate, &acceleration));
560 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_BGRA, input_format);
561 ASSERT_EQ(size.width, input_visible_size.width);
562 ASSERT_EQ(size.height, input_visible_size.height);
563 ASSERT_EQ(kBitrate, bitrate);
564 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
565 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
567 result = encoder_iface()->Initialize(
568 encoder.get(), PP_VIDEOFRAME_FORMAT_BGRA, &size,
569 PP_VIDEOPROFILE_H264MAIN, kBitrate,
570 PP_HARDWAREACCELERATION_WITHFALLBACK,
571 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
572 &cb));
573 ASSERT_EQ(PP_ERROR_INPROGRESS, result);
575 ResourceMessageCallParams error_params(encoder.get(), 0);
576 SendNotifyError(error_params, PP_ERROR_FAILED);
577 ASSERT_TRUE(cb.called());
578 ASSERT_EQ(PP_ERROR_FAILED, cb.result());
582 TEST_F(VideoEncoderResourceTest, InitializeSuccess) {
584 // Verify the initialize callback is called when initialization is
585 // successfull.
586 LockingResourceReleaser encoder(CreateEncoder());
587 ResourceMessageCallParams params;
588 PP_Size size = kFrameSize;
589 const uint32_t kBitrate = 420000;
590 MockCompletionCallback cb;
591 int32_t result = encoder_iface()->Initialize(
592 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
593 PP_VIDEOPROFILE_H264MAIN, kBitrate,
594 PP_HARDWAREACCELERATION_WITHFALLBACK,
595 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
596 &cb));
597 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
599 PP_VideoFrame_Format input_format;
600 PP_Size input_visible_size;
601 PP_VideoProfile output_profile;
602 uint32_t bitrate;
603 PP_HardwareAcceleration acceleration;
604 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
605 &output_profile, &bitrate, &acceleration));
606 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format);
607 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
608 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
609 ASSERT_EQ(kBitrate, bitrate);
610 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
611 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
613 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
615 ASSERT_TRUE(cb.called());
616 ASSERT_EQ(PP_OK, cb.result());
619 // Verify that calling initialize a second time, after it already
620 // succeeded, fails.
621 LockingResourceReleaser encoder(CreateEncoder());
622 ResourceMessageCallParams params;
623 PP_Size size = kFrameSize;
624 const uint32_t kBitrate = 420000;
625 MockCompletionCallback cb;
626 int32_t result = encoder_iface()->Initialize(
627 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
628 PP_VIDEOPROFILE_H264MAIN, kBitrate,
629 PP_HARDWAREACCELERATION_WITHFALLBACK,
630 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
631 &cb));
632 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
634 PP_VideoFrame_Format input_format;
635 PP_Size input_visible_size;
636 PP_VideoProfile output_profile;
637 uint32_t bitrate;
638 PP_HardwareAcceleration acceleration;
639 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
640 &output_profile, &bitrate, &acceleration));
641 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format);
642 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
643 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
644 ASSERT_EQ(kBitrate, bitrate);
645 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
646 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
648 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
650 ASSERT_TRUE(cb.called());
651 ASSERT_EQ(PP_OK, cb.result());
653 result = encoder_iface()->Initialize(
654 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
655 PP_VIDEOPROFILE_H264MAIN, kBitrate,
656 PP_HARDWAREACCELERATION_WITHFALLBACK,
657 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
658 &cb));
659 ASSERT_EQ(PP_ERROR_FAILED, result);
662 // Verify the sending the bitstream buffers details makes them
663 // available through the API. the right values.
664 LockingResourceReleaser encoder(CreateEncoder());
665 ResourceMessageCallParams params;
666 PP_Size size = kFrameSize;
667 const uint32_t kBitrate = 420000;
668 MockCompletionCallback cb;
669 int32_t result = encoder_iface()->Initialize(
670 encoder.get(), PP_VIDEOFRAME_FORMAT_I420, &size,
671 PP_VIDEOPROFILE_H264MAIN, kBitrate,
672 PP_HARDWAREACCELERATION_WITHFALLBACK,
673 PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
674 &cb));
675 ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
677 PP_VideoFrame_Format input_format;
678 PP_Size input_visible_size;
679 PP_VideoProfile output_profile;
680 uint32_t bitrate;
681 PP_HardwareAcceleration acceleration;
682 ASSERT_TRUE(CheckInitializeMsg(&params, &input_format, &input_visible_size,
683 &output_profile, &bitrate, &acceleration));
684 ASSERT_EQ(PP_VIDEOFRAME_FORMAT_I420, input_format);
685 ASSERT_EQ(kFrameSize.width, input_visible_size.width);
686 ASSERT_EQ(kFrameSize.height, input_visible_size.height);
687 ASSERT_EQ(kBitrate, bitrate);
688 ASSERT_EQ(PP_VIDEOPROFILE_H264MAIN, output_profile);
689 ASSERT_EQ(PP_HARDWAREACCELERATION_WITHFALLBACK, acceleration);
691 SendInitializeReply(params, PP_OK, kVideoFrameCount, kFrameSize);
693 ASSERT_TRUE(cb.called());
694 ASSERT_EQ(PP_OK, cb.result());
696 PP_Size coded_size;
697 ASSERT_EQ(PP_OK, CallGetFrameCodedSize(encoder.get(), &coded_size));
698 ASSERT_EQ(kFrameSize.width, coded_size.width);
699 ASSERT_EQ(kFrameSize.height, coded_size.height);
700 ASSERT_EQ(static_cast<int32_t>(kVideoFrameCount),
701 CallGetFramesRequired(encoder.get()));
705 TEST_F(VideoEncoderResourceTest, Uninitialized) {
706 // Operations on uninitialized encoders should fail.
707 LockingResourceReleaser encoder(CreateEncoder());
709 ASSERT_EQ(PP_ERROR_FAILED, CallGetFramesRequired(encoder.get()));
711 PP_Size size;
712 ASSERT_EQ(PP_ERROR_FAILED, CallGetFrameCodedSize(encoder.get(), &size));
714 MockCompletionCallback uncalled_cb;
715 PP_Resource video_frame = 0;
716 ASSERT_EQ(PP_ERROR_FAILED,
717 CallGetVideoFrame(encoder.get(), &video_frame, &uncalled_cb));
718 ASSERT_FALSE(uncalled_cb.called());
719 ASSERT_EQ(0, video_frame);
721 ASSERT_EQ(PP_ERROR_FAILED,
722 CallEncode(encoder.get(), video_frame, PP_FALSE, &uncalled_cb));
723 ASSERT_FALSE(uncalled_cb.called());
725 PP_BitstreamBuffer bitstream_buffer;
726 ASSERT_EQ(
727 PP_ERROR_FAILED,
728 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer, &uncalled_cb));
729 ASSERT_FALSE(uncalled_cb.called());
731 ResourceMessageCallParams params;
732 uint32_t buffer_id;
733 CallRecycleBitstreamBuffer(encoder.get(), bitstream_buffer);
734 ASSERT_FALSE(CheckRecycleBitstreamBufferMsg(&params, &buffer_id));
736 uint32_t bitrate, framerate;
737 CallRequestEncodingParametersChange(encoder.get(), 0, 0);
738 ASSERT_FALSE(
739 CheckRequestEncodingParametersChangeMsg(&params, &bitrate, &framerate));
742 TEST_F(VideoEncoderResourceTest, InitializeAndGetVideoFrame) {
743 // Verify that we can pull the right number of video frames before
744 // the proxy makes us wait.
745 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
746 ResourceMessageCallParams params;
747 std::vector<PP_Resource> video_frames;
748 MockCompletionCallback get_frame_cb;
750 video_frames.resize(kVideoFrameCount + 1);
752 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
753 CallGetVideoFrame(encoder.get(), &video_frames[0], &get_frame_cb));
754 ASSERT_FALSE(get_frame_cb.called());
755 ASSERT_TRUE(CheckGetVideoFramesMsg(&params));
757 uint32_t frame_length = kFrameSize.width * kFrameSize.height * 2;
758 CreateVideoFramesSharedMemory(frame_length, kVideoFrameCount);
759 SendGetVideoFramesReply(params, kVideoFrameCount, frame_length, kFrameSize);
761 for (uint32_t i = 1; i < kVideoFrameCount; ++i) {
762 get_frame_cb.Reset();
763 ASSERT_EQ(
764 PP_OK_COMPLETIONPENDING,
765 CallGetVideoFrame(encoder.get(), &video_frames[i], &get_frame_cb));
766 ASSERT_TRUE(get_frame_cb.called());
767 ASSERT_EQ(PP_OK, get_frame_cb.result());
768 ASSERT_TRUE(CheckIsVideoFrame(video_frames[i]));
771 get_frame_cb.Reset();
772 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
773 CallGetVideoFrame(encoder.get(), &video_frames[kVideoFrameCount],
774 &get_frame_cb));
775 ASSERT_FALSE(get_frame_cb.called());
777 MockCompletionCallback get_frame_fail_cb;
778 ASSERT_EQ(PP_ERROR_INPROGRESS,
779 CallGetVideoFrame(encoder.get(), &video_frames[kVideoFrameCount],
780 &get_frame_fail_cb));
781 ASSERT_FALSE(get_frame_fail_cb.called());
783 // Unblock the GetVideoFrame callback by freeing up a frame.
784 MockCompletionCallback encode_cb;
785 ASSERT_EQ(
786 PP_OK_COMPLETIONPENDING,
787 CallCompleteEncode(encoder.get(), video_frames[0], PP_FALSE, &encode_cb));
788 ASSERT_TRUE(encode_cb.called());
789 ASSERT_EQ(PP_OK, encode_cb.result());
790 ASSERT_TRUE(get_frame_cb.called());
792 CallClose(encoder.get());
795 TEST_F(VideoEncoderResourceTest, Encode) {
796 // Check Encode() calls into the renderer.
797 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
798 PP_Resource video_frame;
799 MockCompletionCallback get_frame_cb;
801 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
802 CallFirstGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
803 ASSERT_TRUE(get_frame_cb.called());
804 ASSERT_EQ(PP_OK, get_frame_cb.result());
806 MockCompletionCallback encode_cb;
807 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
808 CallEncode(encoder.get(), video_frame, PP_TRUE, &encode_cb));
809 ASSERT_FALSE(encode_cb.called());
810 ASSERT_FALSE(CheckIsVideoFrameValid(video_frame));
812 ResourceMessageCallParams params;
813 uint32_t frame_id;
814 bool force_frame;
815 ASSERT_TRUE(CheckEncodeMsg(&params, &frame_id, &force_frame));
817 SendEncodeReply(params, frame_id);
819 ASSERT_TRUE(encode_cb.called());
820 ASSERT_EQ(PP_OK, encode_cb.result());
823 TEST_F(VideoEncoderResourceTest, EncodeAndGetVideoFrame) {
824 // Check the encoding loop works well.
825 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
826 ResourceMessageCallParams params;
827 PP_Resource video_frame;
828 MockCompletionCallback get_frame_cb, encode_cb;
830 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
831 CallFirstGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
832 ASSERT_TRUE(get_frame_cb.called());
833 ASSERT_EQ(PP_OK, get_frame_cb.result());
835 for (uint32_t i = 1; i < 20 * kVideoFrameCount; ++i) {
836 encode_cb.Reset();
837 ASSERT_EQ(
838 PP_OK_COMPLETIONPENDING,
839 CallCompleteEncode(encoder.get(), video_frame, PP_FALSE, &encode_cb));
840 ASSERT_TRUE(encode_cb.called());
841 ASSERT_EQ(PP_OK, encode_cb.result());
843 get_frame_cb.Reset();
844 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
845 CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
846 ASSERT_TRUE(get_frame_cb.called());
847 ASSERT_EQ(PP_OK, get_frame_cb.result());
848 ASSERT_TRUE(CheckIsVideoFrame(video_frame));
851 ASSERT_EQ(
852 PP_OK_COMPLETIONPENDING,
853 CallCompleteEncode(encoder.get(), video_frame, PP_FALSE, &encode_cb));
854 ASSERT_TRUE(encode_cb.called());
855 ASSERT_EQ(PP_OK, encode_cb.result());
858 TEST_F(VideoEncoderResourceTest, GetBitstreamBuffer) {
860 // Verify that the GetBitstreamBuffer callback is fired whenever the
861 // renderer signals a buffer is available.
862 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
864 MockCompletionCallback get_bitstream_buffer_cb;
865 PP_BitstreamBuffer bitstream_buffer;
866 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
867 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
868 &get_bitstream_buffer_cb));
869 ASSERT_FALSE(get_bitstream_buffer_cb.called());
871 ResourceMessageCallParams buffer_params(encoder.get(), 0);
872 SendBitstreamBufferReady(buffer_params, 0, 10, true);
874 ASSERT_TRUE(get_bitstream_buffer_cb.called());
875 ASSERT_EQ(PP_OK, get_bitstream_buffer_cb.result());
876 ASSERT_EQ(10U, bitstream_buffer.size);
877 ASSERT_EQ(PP_TRUE, bitstream_buffer.key_frame);
880 // Verify that calling GetBitstreamBuffer a second time, while the
881 // first callback hasn't been fired fails.
882 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
884 MockCompletionCallback get_bitstream_buffer_cb;
885 PP_BitstreamBuffer bitstream_buffer;
886 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
887 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
888 &get_bitstream_buffer_cb));
889 ASSERT_FALSE(get_bitstream_buffer_cb.called());
891 ASSERT_EQ(PP_ERROR_INPROGRESS,
892 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
893 &get_bitstream_buffer_cb));
894 ASSERT_FALSE(get_bitstream_buffer_cb.called());
896 ResourceMessageCallParams buffer_params(encoder.get(), 0);
897 SendBitstreamBufferReady(buffer_params, 0, 10, true);
901 TEST_F(VideoEncoderResourceTest, RecycleBitstreamBuffer) {
902 // Verify that we signal the renderer that a bitstream buffer has been
903 // recycled.
904 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
906 MockCompletionCallback get_bitstream_buffer_cb;
907 PP_BitstreamBuffer bitstream_buffer;
908 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
909 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
910 &get_bitstream_buffer_cb));
911 ASSERT_FALSE(get_bitstream_buffer_cb.called());
913 ResourceMessageCallParams buffer_params(encoder.get(), 0);
914 SendBitstreamBufferReady(buffer_params, kBitstreamBufferCount - 1, 10, true);
916 ASSERT_TRUE(get_bitstream_buffer_cb.called());
917 ASSERT_EQ(PP_OK, get_bitstream_buffer_cb.result());
919 CallRecycleBitstreamBuffer(encoder.get(), bitstream_buffer);
921 ResourceMessageCallParams recycle_params;
922 uint32_t buffer_id;
923 ASSERT_TRUE(CheckRecycleBitstreamBufferMsg(&recycle_params, &buffer_id));
924 ASSERT_EQ(kBitstreamBufferCount - 1, buffer_id);
927 TEST_F(VideoEncoderResourceTest, RequestEncodingParametersChange) {
928 // Check encoding parameter changes are correctly sent to the
929 // renderer.
930 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
932 CallRequestEncodingParametersChange(encoder.get(), 1, 2);
933 ResourceMessageCallParams params;
934 uint32_t bitrate, framerate;
935 ASSERT_TRUE(
936 CheckRequestEncodingParametersChangeMsg(&params, &bitrate, &framerate));
937 ASSERT_EQ(1U, bitrate);
938 ASSERT_EQ(2U, framerate);
941 TEST_F(VideoEncoderResourceTest, NotifyError) {
943 // Check an error from the encoder aborts GetVideoFrame and
944 // GetBitstreamBuffer callbacks.
945 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
947 MockCompletionCallback get_frame_cb;
948 PP_Resource video_frame;
949 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
950 CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
951 ASSERT_FALSE(get_frame_cb.called());
953 MockCompletionCallback get_bitstream_buffer_cb;
954 PP_BitstreamBuffer bitstream_buffer;
955 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
956 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
957 &get_bitstream_buffer_cb));
959 ResourceMessageCallParams error_params(encoder.get(), 0);
960 SendNotifyError(error_params, PP_ERROR_FAILED);
962 ASSERT_TRUE(get_frame_cb.called());
963 ASSERT_EQ(PP_ERROR_FAILED, get_frame_cb.result());
964 ASSERT_TRUE(get_bitstream_buffer_cb.called());
965 ASSERT_EQ(PP_ERROR_FAILED, get_bitstream_buffer_cb.result());
968 // Check an error from the encoder aborts Encode and GetBitstreamBuffer
969 // callbacks.
970 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
972 MockCompletionCallback get_frame_cb, encode_cb1, encode_cb2;
973 PP_Resource video_frame1, video_frame2;
974 ASSERT_EQ(
975 PP_OK_COMPLETIONPENDING,
976 CallFirstGetVideoFrame(encoder.get(), &video_frame1, &get_frame_cb));
977 ASSERT_TRUE(get_frame_cb.called());
978 ASSERT_EQ(PP_OK, get_frame_cb.result());
980 get_frame_cb.Reset();
981 ASSERT_EQ(
982 PP_OK_COMPLETIONPENDING,
983 CallFirstGetVideoFrame(encoder.get(), &video_frame2, &get_frame_cb));
984 ASSERT_TRUE(get_frame_cb.called());
985 ASSERT_EQ(PP_OK, get_frame_cb.result());
987 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
988 CallEncode(encoder.get(), video_frame1, PP_FALSE, &encode_cb1));
989 ASSERT_FALSE(encode_cb1.called());
990 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
991 CallEncode(encoder.get(), video_frame2, PP_FALSE, &encode_cb2));
992 ASSERT_FALSE(encode_cb2.called());
994 MockCompletionCallback get_bitstream_buffer_cb;
995 PP_BitstreamBuffer bitstream_buffer;
996 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
997 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
998 &get_bitstream_buffer_cb));
1000 ResourceMessageCallParams error_params(encoder.get(), 0);
1001 SendNotifyError(error_params, PP_ERROR_FAILED);
1003 ASSERT_TRUE(encode_cb1.called());
1004 ASSERT_EQ(PP_ERROR_FAILED, encode_cb1.result());
1005 ASSERT_TRUE(encode_cb2.called());
1006 ASSERT_EQ(PP_ERROR_FAILED, encode_cb2.result());
1007 ASSERT_TRUE(get_bitstream_buffer_cb.called());
1008 ASSERT_EQ(PP_ERROR_FAILED, get_bitstream_buffer_cb.result());
1012 TEST_F(VideoEncoderResourceTest, Close) {
1014 // Check closing the encoder aborts GetVideoFrame and
1015 // GetBitstreamBuffer callbacks.
1016 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
1018 MockCompletionCallback get_frame_cb;
1019 PP_Resource video_frame;
1020 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1021 CallGetVideoFrame(encoder.get(), &video_frame, &get_frame_cb));
1022 ASSERT_FALSE(get_frame_cb.called());
1024 MockCompletionCallback get_bitstream_buffer_cb;
1025 PP_BitstreamBuffer bitstream_buffer;
1026 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1027 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
1028 &get_bitstream_buffer_cb));
1030 CallClose(encoder.get());
1032 ASSERT_TRUE(get_frame_cb.called());
1033 ASSERT_EQ(PP_ERROR_ABORTED, get_frame_cb.result());
1034 ASSERT_TRUE(get_bitstream_buffer_cb.called());
1035 ASSERT_EQ(PP_ERROR_ABORTED, get_bitstream_buffer_cb.result());
1038 // Check closing the encoder aborts Encode and GetBitstreamBuffer
1039 // callbacks.
1040 LockingResourceReleaser encoder(CreateAndInitializeEncoder());
1042 MockCompletionCallback get_frame_cb, encode_cb1, encode_cb2;
1043 PP_Resource video_frame1, video_frame2;
1044 ASSERT_EQ(
1045 PP_OK_COMPLETIONPENDING,
1046 CallFirstGetVideoFrame(encoder.get(), &video_frame1, &get_frame_cb));
1047 ASSERT_TRUE(get_frame_cb.called());
1048 ASSERT_EQ(PP_OK, get_frame_cb.result());
1050 get_frame_cb.Reset();
1051 ASSERT_EQ(
1052 PP_OK_COMPLETIONPENDING,
1053 CallFirstGetVideoFrame(encoder.get(), &video_frame2, &get_frame_cb));
1054 ASSERT_TRUE(get_frame_cb.called());
1055 ASSERT_EQ(PP_OK, get_frame_cb.result());
1057 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1058 CallEncode(encoder.get(), video_frame1, PP_FALSE, &encode_cb1));
1059 ASSERT_FALSE(encode_cb1.called());
1060 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1061 CallEncode(encoder.get(), video_frame2, PP_FALSE, &encode_cb2));
1062 ASSERT_FALSE(encode_cb2.called());
1064 MockCompletionCallback get_bitstream_buffer_cb;
1065 PP_BitstreamBuffer bitstream_buffer;
1066 ASSERT_EQ(PP_OK_COMPLETIONPENDING,
1067 CallGetBitstreamBuffer(encoder.get(), &bitstream_buffer,
1068 &get_bitstream_buffer_cb));
1070 CallClose(encoder.get());
1072 ASSERT_TRUE(encode_cb1.called());
1073 ASSERT_EQ(PP_ERROR_ABORTED, encode_cb1.result());
1074 ASSERT_TRUE(encode_cb2.called());
1075 ASSERT_EQ(PP_ERROR_ABORTED, encode_cb2.result());
1076 ASSERT_TRUE(get_bitstream_buffer_cb.called());
1077 ASSERT_EQ(PP_ERROR_ABORTED, get_bitstream_buffer_cb.result());
1081 } // namespace proxy
1082 } // namespace ppapi