Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: media/base/mac/coremedia_glue.mm

Issue 1421583007: Mac Video Capture: Sending the timestamps provided by the driver to the capture pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alignment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "media/base/mac/coremedia_glue.h" 5 #include "media/base/mac/coremedia_glue.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 typedef CoreMediaGlue::CMBlockBufferRef (*CMSampleBufferGetDataBufferMethod)( 44 typedef CoreMediaGlue::CMBlockBufferRef (*CMSampleBufferGetDataBufferMethod)(
45 CoreMediaGlue::CMSampleBufferRef); 45 CoreMediaGlue::CMSampleBufferRef);
46 typedef CoreMediaGlue::CMFormatDescriptionRef ( 46 typedef CoreMediaGlue::CMFormatDescriptionRef (
47 *CMSampleBufferGetFormatDescriptionMethod)( 47 *CMSampleBufferGetFormatDescriptionMethod)(
48 CoreMediaGlue::CMSampleBufferRef); 48 CoreMediaGlue::CMSampleBufferRef);
49 typedef CVImageBufferRef (*CMSampleBufferGetImageBufferMethod)( 49 typedef CVImageBufferRef (*CMSampleBufferGetImageBufferMethod)(
50 CoreMediaGlue::CMSampleBufferRef); 50 CoreMediaGlue::CMSampleBufferRef);
51 typedef CFArrayRef (*CMSampleBufferGetSampleAttachmentsArrayMethod)( 51 typedef CFArrayRef (*CMSampleBufferGetSampleAttachmentsArrayMethod)(
52 CoreMediaGlue::CMSampleBufferRef, 52 CoreMediaGlue::CMSampleBufferRef,
53 Boolean); 53 Boolean);
54 typedef CoreMediaGlue::CMTime (*CMSampleBufferGetPresentationTimeStampMethod)(
55 CoreMediaGlue::CMSampleBufferRef);
54 56
55 typedef FourCharCode (*CMFormatDescriptionGetMediaSubTypeMethod)( 57 typedef FourCharCode (*CMFormatDescriptionGetMediaSubTypeMethod)(
56 CoreMediaGlue::CMFormatDescriptionRef desc); 58 CoreMediaGlue::CMFormatDescriptionRef desc);
57 typedef CoreMediaGlue::CMVideoDimensions 59 typedef CoreMediaGlue::CMVideoDimensions
58 (*CMVideoFormatDescriptionGetDimensionsMethod)( 60 (*CMVideoFormatDescriptionGetDimensionsMethod)(
59 CoreMediaGlue::CMVideoFormatDescriptionRef videoDesc); 61 CoreMediaGlue::CMVideoFormatDescriptionRef videoDesc);
60 typedef OSStatus (*CMVideoFormatDescriptionGetH264ParameterSetAtIndexMethod)( 62 typedef OSStatus (*CMVideoFormatDescriptionGetH264ParameterSetAtIndexMethod)(
61 CoreMediaGlue::CMFormatDescriptionRef, 63 CoreMediaGlue::CMFormatDescriptionRef,
62 size_t, 64 size_t,
63 const uint8_t**, 65 const uint8_t**,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 dlsym(library_handle, "CMSampleBufferGetFormatDescription")); 107 dlsym(library_handle, "CMSampleBufferGetFormatDescription"));
106 CHECK(cm_sample_buffer_get_format_description_method_) << dlerror(); 108 CHECK(cm_sample_buffer_get_format_description_method_) << dlerror();
107 cm_sample_buffer_get_image_buffer_method_ = 109 cm_sample_buffer_get_image_buffer_method_ =
108 reinterpret_cast<CMSampleBufferGetImageBufferMethod>( 110 reinterpret_cast<CMSampleBufferGetImageBufferMethod>(
109 dlsym(library_handle, "CMSampleBufferGetImageBuffer")); 111 dlsym(library_handle, "CMSampleBufferGetImageBuffer"));
110 CHECK(cm_sample_buffer_get_image_buffer_method_) << dlerror(); 112 CHECK(cm_sample_buffer_get_image_buffer_method_) << dlerror();
111 cm_sample_buffer_get_sample_attachments_array_method_ = 113 cm_sample_buffer_get_sample_attachments_array_method_ =
112 reinterpret_cast<CMSampleBufferGetSampleAttachmentsArrayMethod>( 114 reinterpret_cast<CMSampleBufferGetSampleAttachmentsArrayMethod>(
113 dlsym(library_handle, "CMSampleBufferGetSampleAttachmentsArray")); 115 dlsym(library_handle, "CMSampleBufferGetSampleAttachmentsArray"));
114 CHECK(cm_sample_buffer_get_sample_attachments_array_method_) << dlerror(); 116 CHECK(cm_sample_buffer_get_sample_attachments_array_method_) << dlerror();
117 cm_sample_buffer_get_presentation_timestamp_method_ =
118 reinterpret_cast<CMSampleBufferGetPresentationTimeStampMethod>(
119 dlsym(library_handle, "CMSampleBufferGetPresentationTimeStamp"));
120 CHECK(cm_sample_buffer_get_presentation_timestamp_method_) << dlerror();
115 k_cm_sample_attachment_key_not_sync_ = reinterpret_cast<CFStringRef*>( 121 k_cm_sample_attachment_key_not_sync_ = reinterpret_cast<CFStringRef*>(
116 dlsym(library_handle, "kCMSampleAttachmentKey_NotSync")); 122 dlsym(library_handle, "kCMSampleAttachmentKey_NotSync"));
117 CHECK(k_cm_sample_attachment_key_not_sync_) << dlerror(); 123 CHECK(k_cm_sample_attachment_key_not_sync_) << dlerror();
118 124
119 cm_format_description_get_media_sub_type_method_ = 125 cm_format_description_get_media_sub_type_method_ =
120 reinterpret_cast<CMFormatDescriptionGetMediaSubTypeMethod>( 126 reinterpret_cast<CMFormatDescriptionGetMediaSubTypeMethod>(
121 dlsym(library_handle, "CMFormatDescriptionGetMediaSubType")); 127 dlsym(library_handle, "CMFormatDescriptionGetMediaSubType"));
122 CHECK(cm_format_description_get_media_sub_type_method_) << dlerror(); 128 CHECK(cm_format_description_get_media_sub_type_method_) << dlerror();
123 cm_video_format_description_get_dimensions_method_ = 129 cm_video_format_description_get_dimensions_method_ =
124 reinterpret_cast<CMVideoFormatDescriptionGetDimensionsMethod>( 130 reinterpret_cast<CMVideoFormatDescriptionGetDimensionsMethod>(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return cm_sample_buffer_get_format_description_method_; 167 return cm_sample_buffer_get_format_description_method_;
162 } 168 }
163 const CMSampleBufferGetImageBufferMethod& 169 const CMSampleBufferGetImageBufferMethod&
164 cm_sample_buffer_get_image_buffer_method() const { 170 cm_sample_buffer_get_image_buffer_method() const {
165 return cm_sample_buffer_get_image_buffer_method_; 171 return cm_sample_buffer_get_image_buffer_method_;
166 } 172 }
167 const CMSampleBufferGetSampleAttachmentsArrayMethod& 173 const CMSampleBufferGetSampleAttachmentsArrayMethod&
168 cm_sample_buffer_get_sample_attachments_array_method() const { 174 cm_sample_buffer_get_sample_attachments_array_method() const {
169 return cm_sample_buffer_get_sample_attachments_array_method_; 175 return cm_sample_buffer_get_sample_attachments_array_method_;
170 } 176 }
177 const CMSampleBufferGetPresentationTimeStampMethod&
178 cm_sample_buffer_get_presentation_timestamp_method() const {
179 return cm_sample_buffer_get_presentation_timestamp_method_;
180 }
171 CFStringRef* const& k_cm_sample_attachment_key_not_sync() const { 181 CFStringRef* const& k_cm_sample_attachment_key_not_sync() const {
172 return k_cm_sample_attachment_key_not_sync_; 182 return k_cm_sample_attachment_key_not_sync_;
173 } 183 }
174 184
175 const CMFormatDescriptionGetMediaSubTypeMethod& 185 const CMFormatDescriptionGetMediaSubTypeMethod&
176 cm_format_description_get_media_sub_type_method() const { 186 cm_format_description_get_media_sub_type_method() const {
177 return cm_format_description_get_media_sub_type_method_; 187 return cm_format_description_get_media_sub_type_method_;
178 } 188 }
179 const CMVideoFormatDescriptionGetDimensionsMethod& 189 const CMVideoFormatDescriptionGetDimensionsMethod&
180 cm_video_format_description_get_dimensions_method() const { 190 cm_video_format_description_get_dimensions_method() const {
(...skipping 20 matching lines...) Expand all
201 CMSampleBufferGetSampleAttachmentsArrayMethod 211 CMSampleBufferGetSampleAttachmentsArrayMethod
202 cm_sample_buffer_get_sample_attachments_array_method_; 212 cm_sample_buffer_get_sample_attachments_array_method_;
203 CFStringRef* k_cm_sample_attachment_key_not_sync_; 213 CFStringRef* k_cm_sample_attachment_key_not_sync_;
204 214
205 CMFormatDescriptionGetMediaSubTypeMethod 215 CMFormatDescriptionGetMediaSubTypeMethod
206 cm_format_description_get_media_sub_type_method_; 216 cm_format_description_get_media_sub_type_method_;
207 CMVideoFormatDescriptionGetDimensionsMethod 217 CMVideoFormatDescriptionGetDimensionsMethod
208 cm_video_format_description_get_dimensions_method_; 218 cm_video_format_description_get_dimensions_method_;
209 CMVideoFormatDescriptionGetH264ParameterSetAtIndexMethod 219 CMVideoFormatDescriptionGetH264ParameterSetAtIndexMethod
210 cm_video_format_description_get_h264_parameter_set_at_index_method_; 220 cm_video_format_description_get_h264_parameter_set_at_index_method_;
221 CMSampleBufferGetPresentationTimeStampMethod
222 cm_sample_buffer_get_presentation_timestamp_method_;
211 223
212 DISALLOW_COPY_AND_ASSIGN(CoreMediaLibraryInternal); 224 DISALLOW_COPY_AND_ASSIGN(CoreMediaLibraryInternal);
213 }; 225 };
214 226
215 } // namespace 227 } // namespace
216 228
217 static base::LazyInstance<CoreMediaLibraryInternal> g_coremedia_handle = 229 static base::LazyInstance<CoreMediaLibraryInternal> g_coremedia_handle =
218 LAZY_INSTANCE_INITIALIZER; 230 LAZY_INSTANCE_INITIALIZER;
219 231
220 // static 232 // static
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // static 306 // static
295 CFArrayRef CoreMediaGlue::CMSampleBufferGetSampleAttachmentsArray( 307 CFArrayRef CoreMediaGlue::CMSampleBufferGetSampleAttachmentsArray(
296 CMSampleBufferRef sbuf, 308 CMSampleBufferRef sbuf,
297 Boolean createIfNecessary) { 309 Boolean createIfNecessary) {
298 return g_coremedia_handle.Get() 310 return g_coremedia_handle.Get()
299 .cm_sample_buffer_get_sample_attachments_array_method()( 311 .cm_sample_buffer_get_sample_attachments_array_method()(
300 sbuf, createIfNecessary); 312 sbuf, createIfNecessary);
301 } 313 }
302 314
303 // static 315 // static
316 CoreMediaGlue::CMTime CoreMediaGlue::CMSampleBufferGetPresentationTimeStamp(
317 CMSampleBufferRef sbuf) {
318 return g_coremedia_handle.Get()
319 .cm_sample_buffer_get_presentation_timestamp_method()(sbuf);
320 }
321
322 // static
304 CFStringRef CoreMediaGlue::kCMSampleAttachmentKey_NotSync() { 323 CFStringRef CoreMediaGlue::kCMSampleAttachmentKey_NotSync() {
305 return *g_coremedia_handle.Get().k_cm_sample_attachment_key_not_sync(); 324 return *g_coremedia_handle.Get().k_cm_sample_attachment_key_not_sync();
306 } 325 }
307 326
308 // static 327 // static
309 FourCharCode CoreMediaGlue::CMFormatDescriptionGetMediaSubType( 328 FourCharCode CoreMediaGlue::CMFormatDescriptionGetMediaSubType(
310 CMFormatDescriptionRef desc) { 329 CMFormatDescriptionRef desc) {
311 return g_coremedia_handle.Get() 330 return g_coremedia_handle.Get()
312 .cm_format_description_get_media_sub_type_method()(desc); 331 .cm_format_description_get_media_sub_type_method()(desc);
313 } 332 }
(...skipping 16 matching lines...) Expand all
330 int* NALUnitHeaderLengthOut) { 349 int* NALUnitHeaderLengthOut) {
331 return g_coremedia_handle.Get() 350 return g_coremedia_handle.Get()
332 .cm_video_format_description_get_h264_parameter_set_at_index_method()( 351 .cm_video_format_description_get_h264_parameter_set_at_index_method()(
333 videoDesc, 352 videoDesc,
334 parameterSetIndex, 353 parameterSetIndex,
335 parameterSetPointerOut, 354 parameterSetPointerOut,
336 parameterSetSizeOut, 355 parameterSetSizeOut,
337 parameterSetCountOut, 356 parameterSetCountOut,
338 NALUnitHeaderLengthOut); 357 NALUnitHeaderLengthOut);
339 } 358 }
OLDNEW
« no previous file with comments | « media/base/mac/coremedia_glue.h ('k') | media/capture/video/mac/video_capture_device_avfoundation_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698