Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1994)

Unified Diff: content/renderer/pepper/pepper_video_encoder_host.cc

Issue 956893002: content: pepper: VideoEncoder: add software encoder support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5ba91fbe556ce5984c92fbb435313d7b99b1901e 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"
@@ -290,7 +291,15 @@ int32_t PepperVideoEncoderHost::OnHostMsgInitialize(
error = PP_ERROR_FAILED;
}
- // TODO(llandwerlin): Software encoder.
+ if (acceleration == PP_HARDWAREACCELERATION_NONE ||
+ acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK) {
bbudge 2015/02/25 17:58:22 nit: The acceleration enum contains every possibil
llandwerlin-old 2015/02/26 13:02:13 Done.
+ if (InitializeSoftware(media_input_format_, input_size, media_profile,
+ initial_bitrate))
+ 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));
}
bool PepperVideoEncoderHost::IsInitializationValid(
@@ -529,6 +542,16 @@ bool PepperVideoEncoderHost::InitializeHardware(
return true;
}
+bool PepperVideoEncoderHost::InitializeSoftware(
+ media::VideoFrame::Format input_format,
+ const gfx::Size& input_visible_size,
+ media::VideoCodecProfile output_profile,
+ uint32_t initial_bitrate) {
+ encoder_.reset(new VideoEncoderShim(this));
bbudge 2015/02/25 17:58:22 DCHECK(!encoder_); Or simply inline this method at
llandwerlin-old 2015/02/26 13:02:13 Done.
+ return encoder_->Initialize(input_format, input_visible_size, output_profile,
+ initial_bitrate, this);
+}
+
void PepperVideoEncoderHost::Close() {
DCHECK(RenderThreadImpl::current());
@@ -649,4 +672,10 @@ void PepperVideoEncoderHost::NotifyPepperError(int32_t error) {
PpapiPluginMsg_VideoEncoder_NotifyError(encoder_last_error_));
}
+uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32 buffer_id) {
+ DCHECK(RenderThreadImpl::current());
+ DCHECK_LT(buffer_id, static_cast<int32>(shm_buffers_.size()));
bbudge 2015/02/25 17:58:22 since buffer_id is signed, you should check that i
llandwerlin-old 2015/02/26 13:02:13 Done.
+ return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698