| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/pepper/pepper_video_encoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_encoder_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 PP_Bool hardware_accelerated) { | 157 PP_Bool hardware_accelerated) { |
| 158 PP_VideoProfileDescription pp_profile; | 158 PP_VideoProfileDescription pp_profile; |
| 159 pp_profile.profile = PP_FromMediaVideoProfile(profile.profile); | 159 pp_profile.profile = PP_FromMediaVideoProfile(profile.profile); |
| 160 pp_profile.max_resolution = PP_FromGfxSize(profile.max_resolution); | 160 pp_profile.max_resolution = PP_FromGfxSize(profile.max_resolution); |
| 161 pp_profile.max_framerate_numerator = profile.max_framerate_numerator; | 161 pp_profile.max_framerate_numerator = profile.max_framerate_numerator; |
| 162 pp_profile.max_framerate_denominator = profile.max_framerate_denominator; | 162 pp_profile.max_framerate_denominator = profile.max_framerate_denominator; |
| 163 pp_profile.hardware_accelerated = hardware_accelerated; | 163 pp_profile.hardware_accelerated = hardware_accelerated; |
| 164 return pp_profile; | 164 return pp_profile; |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool PP_HardwareAccelerationCompatible(bool accelerated, | 167 bool PP_HardwareAccelerationCompatibleVideo(bool accelerated, |
| 168 PP_HardwareAcceleration requested) { | 168 PP_HardwareAcceleration requested) { |
| 169 switch (requested) { | 169 switch (requested) { |
| 170 case PP_HARDWAREACCELERATION_ONLY: | 170 case PP_HARDWAREACCELERATION_ONLY: |
| 171 return accelerated; | 171 return accelerated; |
| 172 case PP_HARDWAREACCELERATION_NONE: | 172 case PP_HARDWAREACCELERATION_NONE: |
| 173 return !accelerated; | 173 return !accelerated; |
| 174 case PP_HARDWAREACCELERATION_WITHFALLBACK: | 174 case PP_HARDWAREACCELERATION_WITHFALLBACK: |
| 175 return true; | 175 return true; |
| 176 // No default case, to catch unhandled PP_HardwareAcceleration values. | 176 // No default case, to catch unhandled PP_HardwareAcceleration values. |
| 177 } | 177 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 PP_HardwareAcceleration acceleration) { | 502 PP_HardwareAcceleration acceleration) { |
| 503 DCHECK(RenderThreadImpl::current()); | 503 DCHECK(RenderThreadImpl::current()); |
| 504 | 504 |
| 505 std::vector<PP_VideoProfileDescription> profiles; | 505 std::vector<PP_VideoProfileDescription> profiles; |
| 506 GetSupportedProfiles(&profiles); | 506 GetSupportedProfiles(&profiles); |
| 507 | 507 |
| 508 for (const PP_VideoProfileDescription& profile : profiles) { | 508 for (const PP_VideoProfileDescription& profile : profiles) { |
| 509 if (output_profile == profile.profile && | 509 if (output_profile == profile.profile && |
| 510 input_size.width <= profile.max_resolution.width && | 510 input_size.width <= profile.max_resolution.width && |
| 511 input_size.height <= profile.max_resolution.height && | 511 input_size.height <= profile.max_resolution.height && |
| 512 PP_HardwareAccelerationCompatible( | 512 PP_HardwareAccelerationCompatibleVideo( |
| 513 profile.hardware_accelerated == PP_TRUE, acceleration)) | 513 profile.hardware_accelerated == PP_TRUE, acceleration)) |
| 514 return true; | 514 return true; |
| 515 } | 515 } |
| 516 | 516 |
| 517 return false; | 517 return false; |
| 518 } | 518 } |
| 519 | 519 |
| 520 bool PepperVideoEncoderHost::EnsureGpuChannel() { | 520 bool PepperVideoEncoderHost::EnsureGpuChannel() { |
| 521 DCHECK(RenderThreadImpl::current()); | 521 DCHECK(RenderThreadImpl::current()); |
| 522 | 522 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } | 680 } |
| 681 | 681 |
| 682 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { | 682 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { |
| 683 DCHECK(RenderThreadImpl::current()); | 683 DCHECK(RenderThreadImpl::current()); |
| 684 DCHECK_GE(buffer_id, 0); | 684 DCHECK_GE(buffer_id, 0); |
| 685 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); | 685 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); |
| 686 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 686 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
| 687 } | 687 } |
| 688 | 688 |
| 689 } // namespace content | 689 } // namespace content |
| OLD | NEW |