OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <CoreVideo/CoreVideo.h> | 5 #include <CoreVideo/CoreVideo.h> |
6 #include <OpenGL/CGLIOSurface.h> | 6 #include <OpenGL/CGLIOSurface.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | |
9 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
10 #include "content/common/gpu/media/vt_video_decode_accelerator.h" | 11 #include "content/common/gpu/media/vt_video_decode_accelerator.h" |
12 #include "content/public/common/content_switches.h" | |
11 #include "media/filters/h264_parser.h" | 13 #include "media/filters/h264_parser.h" |
12 | 14 |
13 using content_common_gpu_media::kModuleVt; | 15 using content_common_gpu_media::kModuleVt; |
14 using content_common_gpu_media::InitializeStubs; | 16 using content_common_gpu_media::InitializeStubs; |
15 using content_common_gpu_media::IsVtInitialized; | 17 using content_common_gpu_media::IsVtInitialized; |
16 using content_common_gpu_media::StubPathMap; | 18 using content_common_gpu_media::StubPathMap; |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 | 21 |
20 // Size of length headers prepended to NALUs in MPEG-4 framing. (1, 2, or 4.) | 22 // Size of length headers prepended to NALUs in MPEG-4 framing. (1, 2, or 4.) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 bool VTVideoDecodeAccelerator::Initialize( | 57 bool VTVideoDecodeAccelerator::Initialize( |
56 media::VideoCodecProfile profile, | 58 media::VideoCodecProfile profile, |
57 Client* client) { | 59 Client* client) { |
58 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
59 client_ = client; | 61 client_ = client; |
60 | 62 |
61 // Only H.264 is supported. | 63 // Only H.264 is supported. |
62 if (profile < media::H264PROFILE_MIN || profile > media::H264PROFILE_MAX) | 64 if (profile < media::H264PROFILE_MIN || profile > media::H264PROFILE_MAX) |
63 return false; | 65 return false; |
64 | 66 |
65 // TODO(sandersd): Move VideoToolbox library loading to sandbox startup; | 67 // Require --no-sandbox until VideoToolbox library loading is part of sandbox |
66 // until then, --no-sandbox is required. | 68 // startup (and this VDA is ready for regular users). |
69 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoSandbox)) | |
70 return false; | |
71 | |
67 if (!IsVtInitialized()) { | 72 if (!IsVtInitialized()) { |
68 StubPathMap paths; | 73 StubPathMap paths; |
69 // CoreVideo is also required, but the loader stops after the first | 74 // CoreVideo is also required, but the loader stops after the first |
70 // path is loaded. Instead we rely on the transitive dependency from | 75 // path is loaded. Instead we rely on the transitive dependency from |
71 // VideoToolbox to CoreVideo. | 76 // VideoToolbox to CoreVideo. |
72 // TODO(sandersd): Fallback to PrivateFrameworks for VideoToolbox. | 77 // TODO(sandersd): Fallback to PrivateFrameworks for VideoToolbox. |
73 paths[kModuleVt].push_back(FILE_PATH_LITERAL( | 78 paths[kModuleVt].push_back(FILE_PATH_LITERAL( |
74 "/System/Library/Frameworks/VideoToolbox.framework/VideoToolbox")); | 79 "/System/Library/Frameworks/VideoToolbox.framework/VideoToolbox")); |
75 if (!InitializeStubs(paths)) | 80 if (!InitializeStubs(paths)) |
76 return false; | 81 return false; |
77 } | 82 } |
78 | 83 |
79 // Spawn a thread to handle parsing and calling VideoToolbox. | 84 // Spawn a thread to handle parsing and calling VideoToolbox. |
80 if (!decoder_thread_.Start()) | 85 if (!decoder_thread_.Start()) |
81 return false; | 86 return false; |
82 | 87 |
83 // Note that --ignore-gpu-blacklist is still required to get here. | |
84 return true; | 88 return true; |
85 } | 89 } |
86 | 90 |
87 // TODO(sandersd): Proper error reporting instead of CHECKs. | 91 // TODO(sandersd): Proper error reporting instead of CHECKs. |
88 void VTVideoDecodeAccelerator::ConfigureDecoder( | 92 void VTVideoDecodeAccelerator::ConfigureDecoder( |
89 const std::vector<const uint8_t*>& nalu_data_ptrs, | 93 const std::vector<const uint8_t*>& nalu_data_ptrs, |
90 const std::vector<size_t>& nalu_data_sizes) { | 94 const std::vector<size_t>& nalu_data_sizes) { |
91 format_.reset(); | 95 format_.reset(); |
92 CHECK(!CMVideoFormatDescriptionCreateFromH264ParameterSets( | 96 CHECK(!CMVideoFormatDescriptionCreateFromH264ParameterSets( |
93 kCFAllocatorDefault, | 97 kCFAllocatorDefault, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 CFDictionarySetValue( | 136 CFDictionarySetValue( |
133 image_config, kCVPixelBufferPixelFormatTypeKey, cf_pixel_format); | 137 image_config, kCVPixelBufferPixelFormatTypeKey, cf_pixel_format); |
134 CFDictionarySetValue(image_config, kCVPixelBufferWidthKey, cf_width); | 138 CFDictionarySetValue(image_config, kCVPixelBufferWidthKey, cf_width); |
135 CFDictionarySetValue(image_config, kCVPixelBufferHeightKey, cf_height); | 139 CFDictionarySetValue(image_config, kCVPixelBufferHeightKey, cf_height); |
136 CFDictionarySetValue( | 140 CFDictionarySetValue( |
137 image_config, kCVPixelBufferOpenGLCompatibilityKey, kCFBooleanTrue); | 141 image_config, kCVPixelBufferOpenGLCompatibilityKey, kCFBooleanTrue); |
138 | 142 |
139 // TODO(sandersd): Skip if the session is compatible. | 143 // TODO(sandersd): Skip if the session is compatible. |
140 // TODO(sandersd): Flush frames when resetting. | 144 // TODO(sandersd): Flush frames when resetting. |
141 session_.reset(); | 145 session_.reset(); |
142 CHECK(!VTDecompressionSessionCreate( | 146 CHECK(!VTDecompressionSessionCreate( |
scherkus (not reviewing)
2014/07/23 20:30:54
FYI the crash reports are hitting this CHECK()
I
sandersd (OOO until July 31)
2014/07/23 20:36:47
I can confirm that initialization can succeed insi
| |
143 kCFAllocatorDefault, | 147 kCFAllocatorDefault, |
144 format_, // video_format_description | 148 format_, // video_format_description |
145 decoder_config, // video_decoder_specification | 149 decoder_config, // video_decoder_specification |
146 image_config, // destination_image_buffer_attributes | 150 image_config, // destination_image_buffer_attributes |
147 &callback_, // output_callback | 151 &callback_, // output_callback |
148 session_.InitializeInto() | 152 session_.InitializeInto() |
149 )); | 153 )); |
150 DVLOG(2) << "Created VTDecompressionSession"; | 154 DVLOG(2) << "Created VTDecompressionSession"; |
151 } | 155 } |
152 | 156 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 DCHECK(CalledOnValidThread()); | 233 DCHECK(CalledOnValidThread()); |
230 // TODO(sandersd): Trigger flush, discarding frames, and wait for them. | 234 // TODO(sandersd): Trigger flush, discarding frames, and wait for them. |
231 delete this; | 235 delete this; |
232 } | 236 } |
233 | 237 |
234 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { | 238 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { |
235 return false; | 239 return false; |
236 } | 240 } |
237 | 241 |
238 } // namespace content | 242 } // namespace content |
OLD | NEW |