OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_GPU_MEDIA_VT_SUPPORT_H_ | |
6 #define CONTENT_COMMON_GPU_MEDIA_VT_SUPPORT_H_ | |
7 | |
8 #include <CoreFoundation/CoreFoundation.h> | |
9 #include <CoreVideo/CVImageBuffer.h> | |
10 | |
11 #include "base/basictypes.h" | |
12 | |
13 template<typename T> struct DefaultSingletonTraits; | |
14 | |
15 // Declarations adapted from <CoreMedia/CoreMedia.h> | |
16 typedef struct OpaqueCMBlockBuffer* CMBlockBufferRef; | |
17 typedef struct OpaqueCMFormatDescription* CMFormatDescriptionRef; | |
18 typedef struct OpaqueCMFormatDescription* CMVideoFormatDescriptionRef; | |
19 typedef struct OpaqueCMSampleBuffer* CMSampleBufferRef; | |
20 typedef uint32_t CMBlockBufferFlags; | |
21 typedef int64_t CMItemCount; | |
22 typedef OSStatus (*CMSampleBufferMakeDataReadyCallback)( | |
23 CMSampleBufferRef sbuf, | |
24 void *make_data_ready_refcon); | |
25 | |
26 struct CMBlockBufferCustomBlockSource; | |
27 struct CMSampleTimingInfo; | |
28 struct CMTime { | |
mcasas
2014/06/19 12:04:24
This is also defined here:
https://code.google.com
| |
29 int64_t value; | |
30 int32_t timescale; | |
31 uint32_t flags; | |
32 int64_t epoch; | |
33 }; | |
34 | |
35 // Declarations adapted from <VideoToolbox/VideoToolbox.h> | |
36 typedef struct OpaqueVTDecompressionSession* VTDecompressionSessionRef; | |
37 typedef uint32_t VTDecodeFrameFlags; | |
38 typedef uint32_t VTDecodeInfoFlags; | |
39 typedef void (*VTDecompressionOutputCallback)( | |
40 void* decompression_output_refcon, | |
41 void* source_frame_refcon, | |
42 OSStatus status, | |
43 VTDecodeInfoFlags info_flags, | |
44 CVImageBufferRef image_buffer, | |
45 CMTime presentation_timestamp, | |
46 CMTime presentation_duration); | |
47 | |
48 struct VTDecompressionOutputCallbackRecord { | |
49 VTDecompressionOutputCallback decompression_output_callback; | |
50 void* decompression_output_refcon; | |
51 }; | |
52 | |
53 namespace content { | |
54 | |
55 // This Mac OS X-specific class provides dynamically-linked access to | |
56 // CoreMedia and VideoToolbox, which are only available on 10.8 and later. | |
57 class VTSupport { | |
mcasas
2014/06/19 12:04:24
- Looking at src/media/video/capture/mac/, this cl
| |
58 public: | |
59 // Returns an instance of the VTSupport class if the operating system supports | |
60 // it, NULL otherwise. It is safe to call this multiple times. | |
61 static VTSupport* GetInstance(); | |
62 | |
63 bool Initialized(); | |
64 | |
65 typedef OSStatus (*CMBlockBufferCreateWithMemoryBlockPtr)( | |
66 CFAllocatorRef structure_allocator, | |
67 void* memory_block, | |
68 size_t block_length, | |
69 CFAllocatorRef block_allocator, | |
70 const CMBlockBufferCustomBlockSource* custom_block_source, | |
71 size_t offset_to_data, | |
72 size_t data_length, | |
73 CMBlockBufferFlags flags, | |
74 CMBlockBufferRef* new_block_buffer_out); | |
75 | |
76 typedef CFDictionaryRef (*CMFormatDescriptionGetExtensionsPtr)( | |
77 CMFormatDescriptionRef desc); | |
78 | |
79 typedef OSStatus (*CMSampleBufferCreatePtr)( | |
80 CFAllocatorRef allocator, | |
81 CMBlockBufferRef data_buffer, | |
82 Boolean data_ready, | |
83 CMSampleBufferMakeDataReadyCallback make_data_ready_callback, | |
84 void* make_data_ready_refcon, | |
85 CMFormatDescriptionRef format_description, | |
86 CMItemCount num_samples, | |
87 CMItemCount num_sample_timing_entries, | |
88 const CMSampleTimingInfo* sample_timing_array, | |
89 CMItemCount num_sample_size_entries, | |
90 const size_t* sample_size_array, | |
91 CMSampleBufferRef* s_buf_out); | |
92 | |
93 typedef OSStatus (*CMVideoFormatDescriptionCreateFromH264ParameterSetsPtr)( | |
94 CFAllocatorRef allocator, | |
95 size_t parameter_set_count, | |
96 const uint8_t* const* parameter_set_pointers, | |
97 const size_t* parameter_set_sizes, | |
98 int nal_unit_header_length, | |
99 CMFormatDescriptionRef *format_description_out); | |
100 | |
101 typedef OSStatus (*VTDecompressionSessionCreatePtr)( | |
102 CFAllocatorRef allocator, | |
103 CMVideoFormatDescriptionRef video_format_description, | |
104 CFDictionaryRef video_decoder_specification, | |
105 CFDictionaryRef destination_image_buffer_attributes, | |
106 const VTDecompressionOutputCallbackRecord* output_callback, | |
107 VTDecompressionSessionRef* decompression_session_out); | |
108 | |
109 typedef OSStatus (*VTDecompressionSessionDecodeFramePtr)( | |
110 VTDecompressionSessionRef session, | |
111 CMSampleBufferRef sample_buffer, | |
112 VTDecodeFrameFlags decode_flags, | |
113 void* source_frame_refcon, | |
114 VTDecodeInfoFlags* info_flags_out); | |
115 | |
116 CMBlockBufferCreateWithMemoryBlockPtr CMBlockBufferCreateWithMemoryBlock; | |
117 CMFormatDescriptionGetExtensionsPtr CMFormatDescriptionGetExtensions; | |
118 CMSampleBufferCreatePtr CMSampleBufferCreate; | |
119 CMVideoFormatDescriptionCreateFromH264ParameterSetsPtr | |
120 CMVideoFormatDescriptionCreateFromH264ParameterSets; | |
121 | |
122 VTDecompressionSessionDecodeFramePtr VTDecompressionSessionDecodeFrame; | |
123 VTDecompressionSessionCreatePtr VTDecompressionSessionCreate; | |
124 | |
125 private: | |
126 VTSupport(); | |
127 ~VTSupport(); | |
128 void CloseLibraryHandles(); | |
129 | |
130 void* cm_handle_; | |
131 void* vt_handle_; | |
132 bool initialized_; | |
133 | |
134 friend struct DefaultSingletonTraits<VTSupport>; | |
135 DISALLOW_COPY_AND_ASSIGN(VTSupport); | |
136 }; | |
137 | |
138 } // namespace content | |
139 | |
140 #endif // CONTENT_COMMON_GPU_MEDIA_VT_SUPPORT_H_ | |
OLD | NEW |