| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  * | 9  * | 
| 10  */ | 10  */ | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 99   decode_params->callback->Decoded(decoded_frame); | 99   decode_params->callback->Decoded(decoded_frame); | 
| 100 } | 100 } | 
| 101 | 101 | 
| 102 }  // namespace internal | 102 }  // namespace internal | 
| 103 | 103 | 
| 104 namespace webrtc { | 104 namespace webrtc { | 
| 105 | 105 | 
| 106 H264VideoToolboxDecoder::H264VideoToolboxDecoder() | 106 H264VideoToolboxDecoder::H264VideoToolboxDecoder() | 
| 107     : callback_(nullptr), | 107     : callback_(nullptr), | 
| 108       video_format_(nullptr), | 108       video_format_(nullptr), | 
| 109       decompression_session_(nullptr) { | 109       decompression_session_(nullptr) {} | 
| 110 } |  | 
| 111 | 110 | 
| 112 H264VideoToolboxDecoder::~H264VideoToolboxDecoder() { | 111 H264VideoToolboxDecoder::~H264VideoToolboxDecoder() { | 
| 113   DestroyDecompressionSession(); | 112   DestroyDecompressionSession(); | 
| 114   SetVideoFormat(nullptr); | 113   SetVideoFormat(nullptr); | 
| 115 } | 114 } | 
| 116 | 115 | 
| 117 int H264VideoToolboxDecoder::InitDecode(const VideoCodec* video_codec, | 116 int H264VideoToolboxDecoder::InitDecode(const VideoCodec* video_codec, | 
| 118                                         int number_of_cores) { | 117                                         int number_of_cores) { | 
| 119   return WEBRTC_VIDEO_CODEC_OK; | 118   return WEBRTC_VIDEO_CODEC_OK; | 
| 120 } | 119 } | 
| 121 | 120 | 
| 122 int H264VideoToolboxDecoder::Decode( | 121 int H264VideoToolboxDecoder::Decode( | 
| 123     const EncodedImage& input_image, | 122     const EncodedImage& input_image, | 
| 124     bool missing_frames, | 123     bool missing_frames, | 
| 125     const RTPFragmentationHeader* fragmentation, | 124     const RTPFragmentationHeader* fragmentation, | 
| 126     const CodecSpecificInfo* codec_specific_info, | 125     const CodecSpecificInfo* codec_specific_info, | 
| 127     int64_t render_time_ms) { | 126     int64_t render_time_ms) { | 
| 128   RTC_DCHECK(input_image._buffer); | 127   RTC_DCHECK(input_image._buffer); | 
| 129 | 128 | 
| 130   CMSampleBufferRef sample_buffer = nullptr; | 129   CMSampleBufferRef sample_buffer = nullptr; | 
| 131   if (!H264AnnexBBufferToCMSampleBuffer(input_image._buffer, | 130   if (!H264AnnexBBufferToCMSampleBuffer(input_image._buffer, | 
| 132                                         input_image._length, | 131                                         input_image._length, video_format_, | 
| 133                                         video_format_, |  | 
| 134                                         &sample_buffer)) { | 132                                         &sample_buffer)) { | 
| 135     return WEBRTC_VIDEO_CODEC_ERROR; | 133     return WEBRTC_VIDEO_CODEC_ERROR; | 
| 136   } | 134   } | 
| 137   RTC_DCHECK(sample_buffer); | 135   RTC_DCHECK(sample_buffer); | 
| 138   // Check if the video format has changed, and reinitialize decoder if needed. | 136   // Check if the video format has changed, and reinitialize decoder if needed. | 
| 139   CMVideoFormatDescriptionRef description = | 137   CMVideoFormatDescriptionRef description = | 
| 140       CMSampleBufferGetFormatDescription(sample_buffer); | 138       CMSampleBufferGetFormatDescription(sample_buffer); | 
| 141   if (!CMFormatDescriptionEqual(description, video_format_)) { | 139   if (!CMFormatDescriptionEqual(description, video_format_)) { | 
| 142     SetVideoFormat(description); | 140     SetVideoFormat(description); | 
| 143     ResetDecompressionSession(); | 141     ResetDecompressionSession(); | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 199     kCVPixelBufferOpenGLCompatibilityKey, | 197     kCVPixelBufferOpenGLCompatibilityKey, | 
| 200 #endif | 198 #endif | 
| 201     kCVPixelBufferIOSurfacePropertiesKey, | 199     kCVPixelBufferIOSurfacePropertiesKey, | 
| 202     kCVPixelBufferPixelFormatTypeKey | 200     kCVPixelBufferPixelFormatTypeKey | 
| 203   }; | 201   }; | 
| 204   CFDictionaryRef io_surface_value = | 202   CFDictionaryRef io_surface_value = | 
| 205       internal::CreateCFDictionary(nullptr, nullptr, 0); | 203       internal::CreateCFDictionary(nullptr, nullptr, 0); | 
| 206   int64_t nv12type = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange; | 204   int64_t nv12type = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange; | 
| 207   CFNumberRef pixel_format = | 205   CFNumberRef pixel_format = | 
| 208       CFNumberCreate(nullptr, kCFNumberLongType, &nv12type); | 206       CFNumberCreate(nullptr, kCFNumberLongType, &nv12type); | 
| 209   CFTypeRef values[attributes_size] = { | 207   CFTypeRef values[attributes_size] = {kCFBooleanTrue, io_surface_value, | 
| 210     kCFBooleanTrue, | 208                                        pixel_format}; | 
| 211     io_surface_value, |  | 
| 212     pixel_format |  | 
| 213   }; |  | 
| 214   CFDictionaryRef attributes = | 209   CFDictionaryRef attributes = | 
| 215       internal::CreateCFDictionary(keys, values, attributes_size); | 210       internal::CreateCFDictionary(keys, values, attributes_size); | 
| 216   if (io_surface_value) { | 211   if (io_surface_value) { | 
| 217     CFRelease(io_surface_value); | 212     CFRelease(io_surface_value); | 
| 218     io_surface_value = nullptr; | 213     io_surface_value = nullptr; | 
| 219   } | 214   } | 
| 220   if (pixel_format) { | 215   if (pixel_format) { | 
| 221     CFRelease(pixel_format); | 216     CFRelease(pixel_format); | 
| 222     pixel_format = nullptr; | 217     pixel_format = nullptr; | 
| 223   } | 218   } | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 266   } | 261   } | 
| 267 } | 262 } | 
| 268 | 263 | 
| 269 const char* H264VideoToolboxDecoder::ImplementationName() const { | 264 const char* H264VideoToolboxDecoder::ImplementationName() const { | 
| 270   return "VideoToolbox"; | 265   return "VideoToolbox"; | 
| 271 } | 266 } | 
| 272 | 267 | 
| 273 }  // namespace webrtc | 268 }  // namespace webrtc | 
| 274 | 269 | 
| 275 #endif  // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 270 #endif  // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 
| OLD | NEW | 
|---|