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/media_recorder/video_track_recorder.h" | 5 #include "content/renderer/media_recorder/video_track_recorder.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 static CodecEnumerator* enumerator = new CodecEnumerator(); | 102 static CodecEnumerator* enumerator = new CodecEnumerator(); |
103 return enumerator; | 103 return enumerator; |
104 } | 104 } |
105 | 105 |
106 CodecEnumerator::CodecEnumerator() { | 106 CodecEnumerator::CodecEnumerator() { |
107 #if defined(OS_CHROMEOS) | 107 #if defined(OS_CHROMEOS) |
108 // See https://crbug.com/616659. | 108 // See https://crbug.com/616659. |
109 return; | 109 return; |
110 #endif | 110 #endif |
111 | 111 |
112 #if defined(OS_ANDROID) | |
113 // See https://crbug.com/653864. | |
114 return; | |
115 #endif | |
116 | |
117 content::RenderThreadImpl* const render_thread_impl = | 112 content::RenderThreadImpl* const render_thread_impl = |
118 content::RenderThreadImpl::current(); | 113 content::RenderThreadImpl::current(); |
119 if (!render_thread_impl) { | 114 if (!render_thread_impl) { |
120 DVLOG(2) << "Couldn't access the render thread"; | 115 DVLOG(2) << "Couldn't access the render thread"; |
121 return; | 116 return; |
122 } | 117 } |
123 | 118 |
124 media::GpuVideoAcceleratorFactories* const gpu_factories = | 119 media::GpuVideoAcceleratorFactories* const gpu_factories = |
125 render_thread_impl->GetGpuFactories(); | 120 render_thread_impl->GetGpuFactories(); |
126 if (!gpu_factories || !gpu_factories->IsGpuVideoAcceleratorEnabled()) { | 121 if (!gpu_factories || !gpu_factories->IsGpuVideoAcceleratorEnabled()) { |
127 DVLOG(2) << "Couldn't initialize GpuVideoAcceleratorFactories"; | 122 DVLOG(2) << "Couldn't initialize GpuVideoAcceleratorFactories"; |
128 return; | 123 return; |
129 } | 124 } |
130 | 125 |
131 const auto vea_supported_profiles = | 126 const auto vea_supported_profiles = |
132 gpu_factories->GetVideoEncodeAcceleratorSupportedProfiles(); | 127 gpu_factories->GetVideoEncodeAcceleratorSupportedProfiles(); |
133 for (const auto& supported_profile : vea_supported_profiles) { | 128 for (const auto& supported_profile : vea_supported_profiles) { |
| 129 const media::VideoCodecProfile codec = supported_profile.profile; |
| 130 #if defined(OS_ANDROID) |
| 131 // TODO(mcasas): enable other codecs, https://crbug.com/638664. |
| 132 if (codec < media::VP8PROFILE_MIN || codec > media::VP8PROFILE_MAX) |
| 133 continue; |
| 134 #endif |
134 for (auto& codec_id_and_profile : kPreferredCodecIdAndVEAProfiles) { | 135 for (auto& codec_id_and_profile : kPreferredCodecIdAndVEAProfiles) { |
135 if (supported_profile.profile >= codec_id_and_profile.min_profile && | 136 if (codec >= codec_id_and_profile.min_profile && |
136 supported_profile.profile <= codec_id_and_profile.max_profile) { | 137 codec <= codec_id_and_profile.max_profile) { |
137 DVLOG(2) << "Accelerated codec found: " | 138 DVLOG(2) << "Accelerated codec found: " << media::GetProfileName(codec); |
138 << media::GetProfileName(supported_profile.profile); | 139 codec_id_to_profile_.insert( |
139 codec_id_to_profile_.insert(std::make_pair( | 140 std::make_pair(codec_id_and_profile.codec_id, codec)); |
140 codec_id_and_profile.codec_id, supported_profile.profile)); | |
141 } | 141 } |
142 } | 142 } |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 CodecId CodecEnumerator::GetPreferredCodecId() { | 146 CodecId CodecEnumerator::GetPreferredCodecId() { |
147 if (codec_id_to_profile_.empty()) | 147 if (codec_id_to_profile_.empty()) |
148 return CodecId::VP8; | 148 return CodecId::VP8; |
149 return codec_id_to_profile_.begin()->first; | 149 return codec_id_to_profile_.begin()->first; |
150 } | 150 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 MediaStreamVideoSink::DisconnectFromTrack(); | 458 MediaStreamVideoSink::DisconnectFromTrack(); |
459 encoder_ = nullptr; | 459 encoder_ = nullptr; |
460 MediaStreamVideoSink::ConnectToTrack( | 460 MediaStreamVideoSink::ConnectToTrack( |
461 track_, | 461 track_, |
462 media::BindToCurrentLoop(base::Bind(initialize_encoder_callback_, | 462 media::BindToCurrentLoop(base::Bind(initialize_encoder_callback_, |
463 false /*allow_vea_encoder*/)), | 463 false /*allow_vea_encoder*/)), |
464 false); | 464 false); |
465 } | 465 } |
466 | 466 |
467 } // namespace content | 467 } // namespace content |
OLD | NEW |