| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/media/cast_rtp_stream.h" | 5 #include "chrome/renderer/media/cast_rtp_stream.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool IsHardwareH264EncodingSupported() { | 117 bool IsHardwareH264EncodingSupported() { |
| 118 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 118 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 119 if (cmd_line->HasSwitch(switches::kDisableCastStreamingHWEncoding)) { | 119 if (cmd_line->HasSwitch(switches::kDisableCastStreamingHWEncoding)) { |
| 120 DVLOG(1) << "Disabled hardware h264 support for Cast Streaming."; | 120 DVLOG(1) << "Disabled hardware h264 support for Cast Streaming."; |
| 121 return false; | 121 return false; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Query for hardware H.264 encoder support. | 124 // Query for hardware H.264 encoder support. |
| 125 // |
| 126 // TODO(miu): Look into why H.264 hardware encoder on MacOS is broken. |
| 127 // http://crbug.com/596674 |
| 128 #if !defined(OS_MACOSX) |
| 125 const std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 129 const std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 126 vea_profiles = content::GetSupportedVideoEncodeAcceleratorProfiles(); | 130 vea_profiles = content::GetSupportedVideoEncodeAcceleratorProfiles(); |
| 127 for (const auto& vea_profile : vea_profiles) { | 131 for (const auto& vea_profile : vea_profiles) { |
| 128 if (vea_profile.profile >= media::H264PROFILE_MIN && | 132 if (vea_profile.profile >= media::H264PROFILE_MIN && |
| 129 vea_profile.profile <= media::H264PROFILE_MAX) { | 133 vea_profile.profile <= media::H264PROFILE_MAX) { |
| 130 return true; | 134 return true; |
| 131 } | 135 } |
| 132 } | 136 } |
| 137 #endif // !defined(OS_MACOSX) |
| 133 return false; | 138 return false; |
| 134 } | 139 } |
| 135 | 140 |
| 136 int NumberOfEncodeThreads() { | 141 int NumberOfEncodeThreads() { |
| 137 // Do not saturate CPU utilization just for encoding. On a lower-end system | 142 // Do not saturate CPU utilization just for encoding. On a lower-end system |
| 138 // with only 1 or 2 cores, use only one thread for encoding. On systems with | 143 // with only 1 or 2 cores, use only one thread for encoding. On systems with |
| 139 // more cores, allow half of the cores to be used for encoding. | 144 // more cores, allow half of the cores to be used for encoding. |
| 140 return std::min(8, (base::SysInfo::NumberOfProcessors() + 1) / 2); | 145 return std::min(8, (base::SysInfo::NumberOfProcessors() + 1) / 2); |
| 141 } | 146 } |
| 142 | 147 |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 DCHECK(content::RenderThread::Get()); | 648 DCHECK(content::RenderThread::Get()); |
| 644 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " | 649 DVLOG(1) << "CastRtpStream::DidEncounterError(" << message << ") = " |
| 645 << (IsAudio() ? "audio" : "video"); | 650 << (IsAudio() ? "audio" : "video"); |
| 646 // Save the WeakPtr first because the error callback might delete this object. | 651 // Save the WeakPtr first because the error callback might delete this object. |
| 647 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); | 652 base::WeakPtr<CastRtpStream> ptr = weak_factory_.GetWeakPtr(); |
| 648 error_callback_.Run(message); | 653 error_callback_.Run(message); |
| 649 base::ThreadTaskRunnerHandle::Get()->PostTask( | 654 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 650 FROM_HERE, | 655 FROM_HERE, |
| 651 base::Bind(&CastRtpStream::Stop, ptr)); | 656 base::Bind(&CastRtpStream::Stop, ptr)); |
| 652 } | 657 } |
| OLD | NEW |