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

Unified Diff: content/common/gpu/media/vt_support.h

Issue 340933002: Add VTSupport for dynamically linking VideoToolbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/gpu/media/vt_support.cc » ('j') | content/common/gpu/media/vt_support.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/vt_support.h
diff --git a/content/common/gpu/media/vt_support.h b/content/common/gpu/media/vt_support.h
new file mode 100644
index 0000000000000000000000000000000000000000..822cc0d5be16b8ddc1b8e71e774943d0e0c491e9
--- /dev/null
+++ b/content/common/gpu/media/vt_support.h
@@ -0,0 +1,140 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_MEDIA_VT_SUPPORT_H_
+#define CONTENT_COMMON_GPU_MEDIA_VT_SUPPORT_H_
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreVideo/CVImageBuffer.h>
+
+#include "base/basictypes.h"
+
+template<typename T> struct DefaultSingletonTraits;
+
+// Declarations adapted from <CoreMedia/CoreMedia.h>
+typedef struct OpaqueCMBlockBuffer* CMBlockBufferRef;
+typedef struct OpaqueCMFormatDescription* CMFormatDescriptionRef;
+typedef struct OpaqueCMFormatDescription* CMVideoFormatDescriptionRef;
+typedef struct OpaqueCMSampleBuffer* CMSampleBufferRef;
+typedef uint32_t CMBlockBufferFlags;
+typedef int64_t CMItemCount;
+typedef OSStatus (*CMSampleBufferMakeDataReadyCallback)(
+ CMSampleBufferRef sbuf,
+ void *make_data_ready_refcon);
+
+struct CMBlockBufferCustomBlockSource;
+struct CMSampleTimingInfo;
+struct CMTime {
mcasas 2014/06/19 12:04:24 This is also defined here: https://code.google.com
+ int64_t value;
+ int32_t timescale;
+ uint32_t flags;
+ int64_t epoch;
+};
+
+// Declarations adapted from <VideoToolbox/VideoToolbox.h>
+typedef struct OpaqueVTDecompressionSession* VTDecompressionSessionRef;
+typedef uint32_t VTDecodeFrameFlags;
+typedef uint32_t VTDecodeInfoFlags;
+typedef void (*VTDecompressionOutputCallback)(
+ void* decompression_output_refcon,
+ void* source_frame_refcon,
+ OSStatus status,
+ VTDecodeInfoFlags info_flags,
+ CVImageBufferRef image_buffer,
+ CMTime presentation_timestamp,
+ CMTime presentation_duration);
+
+struct VTDecompressionOutputCallbackRecord {
+ VTDecompressionOutputCallback decompression_output_callback;
+ void* decompression_output_refcon;
+};
+
+namespace content {
+
+// This Mac OS X-specific class provides dynamically-linked access to
+// CoreMedia and VideoToolbox, which are only available on 10.8 and later.
+class VTSupport {
mcasas 2014/06/19 12:04:24 - Looking at src/media/video/capture/mac/, this cl
+ public:
+ // Returns an instance of the VTSupport class if the operating system supports
+ // it, NULL otherwise. It is safe to call this multiple times.
+ static VTSupport* GetInstance();
+
+ bool Initialized();
+
+ typedef OSStatus (*CMBlockBufferCreateWithMemoryBlockPtr)(
+ CFAllocatorRef structure_allocator,
+ void* memory_block,
+ size_t block_length,
+ CFAllocatorRef block_allocator,
+ const CMBlockBufferCustomBlockSource* custom_block_source,
+ size_t offset_to_data,
+ size_t data_length,
+ CMBlockBufferFlags flags,
+ CMBlockBufferRef* new_block_buffer_out);
+
+ typedef CFDictionaryRef (*CMFormatDescriptionGetExtensionsPtr)(
+ CMFormatDescriptionRef desc);
+
+ typedef OSStatus (*CMSampleBufferCreatePtr)(
+ CFAllocatorRef allocator,
+ CMBlockBufferRef data_buffer,
+ Boolean data_ready,
+ CMSampleBufferMakeDataReadyCallback make_data_ready_callback,
+ void* make_data_ready_refcon,
+ CMFormatDescriptionRef format_description,
+ CMItemCount num_samples,
+ CMItemCount num_sample_timing_entries,
+ const CMSampleTimingInfo* sample_timing_array,
+ CMItemCount num_sample_size_entries,
+ const size_t* sample_size_array,
+ CMSampleBufferRef* s_buf_out);
+
+ typedef OSStatus (*CMVideoFormatDescriptionCreateFromH264ParameterSetsPtr)(
+ CFAllocatorRef allocator,
+ size_t parameter_set_count,
+ const uint8_t* const* parameter_set_pointers,
+ const size_t* parameter_set_sizes,
+ int nal_unit_header_length,
+ CMFormatDescriptionRef *format_description_out);
+
+ typedef OSStatus (*VTDecompressionSessionCreatePtr)(
+ CFAllocatorRef allocator,
+ CMVideoFormatDescriptionRef video_format_description,
+ CFDictionaryRef video_decoder_specification,
+ CFDictionaryRef destination_image_buffer_attributes,
+ const VTDecompressionOutputCallbackRecord* output_callback,
+ VTDecompressionSessionRef* decompression_session_out);
+
+ typedef OSStatus (*VTDecompressionSessionDecodeFramePtr)(
+ VTDecompressionSessionRef session,
+ CMSampleBufferRef sample_buffer,
+ VTDecodeFrameFlags decode_flags,
+ void* source_frame_refcon,
+ VTDecodeInfoFlags* info_flags_out);
+
+ CMBlockBufferCreateWithMemoryBlockPtr CMBlockBufferCreateWithMemoryBlock;
+ CMFormatDescriptionGetExtensionsPtr CMFormatDescriptionGetExtensions;
+ CMSampleBufferCreatePtr CMSampleBufferCreate;
+ CMVideoFormatDescriptionCreateFromH264ParameterSetsPtr
+ CMVideoFormatDescriptionCreateFromH264ParameterSets;
+
+ VTDecompressionSessionDecodeFramePtr VTDecompressionSessionDecodeFrame;
+ VTDecompressionSessionCreatePtr VTDecompressionSessionCreate;
+
+ private:
+ VTSupport();
+ ~VTSupport();
+ void CloseLibraryHandles();
+
+ void* cm_handle_;
+ void* vt_handle_;
+ bool initialized_;
+
+ friend struct DefaultSingletonTraits<VTSupport>;
+ DISALLOW_COPY_AND_ASSIGN(VTSupport);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_MEDIA_VT_SUPPORT_H_
« no previous file with comments | « no previous file | content/common/gpu/media/vt_support.cc » ('j') | content/common/gpu/media/vt_support.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698