Index: content/renderer/pepper/pepper_video_encoder_host.cc |
diff --git a/content/renderer/pepper/pepper_video_encoder_host.cc b/content/renderer/pepper/pepper_video_encoder_host.cc |
index bacbfe0b309fda372a7f92eb4064d0bf96770abe..66cbe997f2b914d6e413848545a2e65129ed7472 100644 |
--- a/content/renderer/pepper/pepper_video_encoder_host.cc |
+++ b/content/renderer/pepper/pepper_video_encoder_host.cc |
@@ -11,6 +11,7 @@ |
#include "content/renderer/pepper/gfx_conversion.h" |
#include "content/renderer/pepper/host_globals.h" |
#include "content/renderer/pepper/pepper_video_encoder_host.h" |
+#include "content/renderer/pepper/video_encoder_shim.h" |
#include "content/renderer/render_thread_impl.h" |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/video_frame.h" |
@@ -166,6 +167,8 @@ PP_VideoProfileDescription PP_FromVideoEncodeAcceleratorSupportedProfile( |
bool PP_HardwareAccelerationCompatible(PP_HardwareAcceleration supply, |
PP_HardwareAcceleration demand) { |
+ // TODO(llandwerlin): Change API to use bool instead of |
+ // PP_HardwareAcceleration |
switch (supply) { |
case PP_HARDWAREACCELERATION_ONLY: |
return (demand == PP_HARDWAREACCELERATION_ONLY || |
@@ -280,8 +283,7 @@ int32_t PepperVideoEncoderHost::OnHostMsgInitialize( |
int32_t error = PP_ERROR_NOTSUPPORTED; |
initialize_reply_context_ = context->MakeReplyMessageContext(); |
- if (acceleration == PP_HARDWAREACCELERATION_ONLY || |
- acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK) { |
+ if (acceleration != PP_HARDWAREACCELERATION_NONE) { |
if (InitializeHardware(media_input_format_, input_size, media_profile, |
initial_bitrate)) |
return PP_OK_COMPLETIONPENDING; |
@@ -290,7 +292,14 @@ int32_t PepperVideoEncoderHost::OnHostMsgInitialize( |
error = PP_ERROR_FAILED; |
} |
- // TODO(llandwerlin): Software encoder. |
+ if (acceleration != PP_HARDWAREACCELERATION_ONLY) { |
+ encoder_.reset(new VideoEncoderShim(this)); |
+ if (encoder_->Initialize(media_input_format_, input_size, media_profile, |
+ initial_bitrate, this)) |
+ return PP_OK_COMPLETIONPENDING; |
+ error = PP_ERROR_FAILED; |
+ } |
+ |
initialize_reply_context_ = ppapi::host::ReplyMessageContext(); |
Close(); |
return error; |
@@ -454,7 +463,11 @@ void PepperVideoEncoderHost::GetSupportedProfiles( |
pp_profiles->push_back(PP_FromVideoEncodeAcceleratorSupportedProfile( |
profile, PP_HARDWAREACCELERATION_ONLY)); |
- // TODO(llandwerlin): add software supported profiles. |
+ VideoEncoderShim software_encoder(this); |
+ profiles = software_encoder.GetSupportedProfiles(); |
+ for (media::VideoEncodeAccelerator::SupportedProfile profile : profiles) |
+ pp_profiles->push_back(PP_FromVideoEncodeAcceleratorSupportedProfile( |
+ profile, PP_HARDWAREACCELERATION_NONE)); |
bbudge
2015/03/16 18:27:48
use brackets here please.
llandwerlin-old
2015/03/16 19:08:09
Done.
|
} |
bool PepperVideoEncoderHost::IsInitializationValid( |
@@ -649,4 +662,11 @@ void PepperVideoEncoderHost::NotifyPepperError(int32_t error) { |
PpapiPluginMsg_VideoEncoder_NotifyError(encoder_last_error_)); |
} |
+uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) { |
+ DCHECK(RenderThreadImpl::current()); |
+ DCHECK_GE(buffer_id, 0); |
+ DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size())); |
+ return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
+} |
+ |
} // namespace content |