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

Unified Diff: media/video/capture/mac/coremedia_glue.mm

Issue 518313003: Move Mac media glue code from media/video/capture/mac to media/base/mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sort header includes by path. Created 6 years, 3 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
Index: media/video/capture/mac/coremedia_glue.mm
diff --git a/media/video/capture/mac/coremedia_glue.mm b/media/video/capture/mac/coremedia_glue.mm
deleted file mode 100644
index 1bb4b8d0b0f05e265993c398829bb19f23cdef63..0000000000000000000000000000000000000000
--- a/media/video/capture/mac/coremedia_glue.mm
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2013 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.
-
-#include "media/video/capture/mac/coremedia_glue.h"
-
-#include <dlfcn.h>
-
-#include "base/logging.h"
-#include "base/lazy_instance.h"
-
-namespace {
-
-// This class is used to retrieve some CoreMedia library functions. It must be
-// used as a LazyInstance so that it is initialised once and in a thread-safe
-// way. Normally no work is done in constructors: LazyInstance is an exception.
-class CoreMediaLibraryInternal {
- public:
- typedef CoreMediaGlue::CMTime (*CMTimeMakeMethod)(int64_t, int32_t);
- typedef CVImageBufferRef (*CMSampleBufferGetImageBufferMethod)(
- CoreMediaGlue::CMSampleBufferRef);
- typedef FourCharCode (*CMFormatDescriptionGetMediaSubTypeMethod)(
- CoreMediaGlue::CMFormatDescriptionRef desc);
- typedef CoreMediaGlue::CMVideoDimensions
- (*CMVideoFormatDescriptionGetDimensionsMethod)(
- CoreMediaGlue::CMVideoFormatDescriptionRef videoDesc);
-
- CoreMediaLibraryInternal() {
- NSBundle* bundle = [NSBundle
- bundleWithPath:@"/System/Library/Frameworks/CoreMedia.framework"];
-
- const char* path = [[bundle executablePath] fileSystemRepresentation];
- CHECK(path);
- void* library_handle = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
- CHECK(library_handle) << dlerror();
-
- // Now extract the methods.
- cm_time_make_ = reinterpret_cast<CMTimeMakeMethod>(
- dlsym(library_handle, "CMTimeMake"));
- CHECK(cm_time_make_) << dlerror();
-
- cm_sample_buffer_get_image_buffer_method_ =
- reinterpret_cast<CMSampleBufferGetImageBufferMethod>(
- dlsym(library_handle, "CMSampleBufferGetImageBuffer"));
- CHECK(cm_sample_buffer_get_image_buffer_method_) << dlerror();
-
- cm_format_description_get_media_sub_type_method_ =
- reinterpret_cast<CMFormatDescriptionGetMediaSubTypeMethod>(
- dlsym(library_handle, "CMFormatDescriptionGetMediaSubType"));
- CHECK(cm_format_description_get_media_sub_type_method_) << dlerror();
-
- cm_video_format_description_get_dimensions_method_ =
- reinterpret_cast<CMVideoFormatDescriptionGetDimensionsMethod>(
- dlsym(library_handle, "CMVideoFormatDescriptionGetDimensions"));
- CHECK(cm_video_format_description_get_dimensions_method_) << dlerror();
- }
-
- const CMTimeMakeMethod& cm_time_make() const { return cm_time_make_; }
- const CMSampleBufferGetImageBufferMethod&
- cm_sample_buffer_get_image_buffer_method() const {
- return cm_sample_buffer_get_image_buffer_method_;
- }
- const CMFormatDescriptionGetMediaSubTypeMethod&
- cm_format_description_get_media_sub_type_method() const {
- return cm_format_description_get_media_sub_type_method_;
- }
- const CMVideoFormatDescriptionGetDimensionsMethod&
- cm_video_format_description_get_dimensions_method() const {
- return cm_video_format_description_get_dimensions_method_;
- }
-
- private:
- CMTimeMakeMethod cm_time_make_;
- CMSampleBufferGetImageBufferMethod cm_sample_buffer_get_image_buffer_method_;
- CMFormatDescriptionGetMediaSubTypeMethod
- cm_format_description_get_media_sub_type_method_;
- CMVideoFormatDescriptionGetDimensionsMethod
- cm_video_format_description_get_dimensions_method_;
-
- DISALLOW_COPY_AND_ASSIGN(CoreMediaLibraryInternal);
-};
-
-} // namespace
-
-static base::LazyInstance<CoreMediaLibraryInternal> g_coremedia_handle =
- LAZY_INSTANCE_INITIALIZER;
-
-// static
-CoreMediaGlue::CMTime CoreMediaGlue::CMTimeMake(int64_t value,
- int32_t timescale) {
- return g_coremedia_handle.Get().cm_time_make()(value, timescale);
-}
-
-// static
-CVImageBufferRef CoreMediaGlue::CMSampleBufferGetImageBuffer(
- CMSampleBufferRef buffer) {
- return g_coremedia_handle.Get().cm_sample_buffer_get_image_buffer_method()(
- buffer);
-}
-
-// static
-FourCharCode CoreMediaGlue::CMFormatDescriptionGetMediaSubType(
- CMFormatDescriptionRef desc) {
- return g_coremedia_handle.Get()
- .cm_format_description_get_media_sub_type_method()(desc);
-}
-
-// static
-CoreMediaGlue::CMVideoDimensions
- CoreMediaGlue::CMVideoFormatDescriptionGetDimensions(
- CMVideoFormatDescriptionRef videoDesc) {
- return g_coremedia_handle.Get()
- .cm_video_format_description_get_dimensions_method()(videoDesc);
-}
« no previous file with comments | « media/video/capture/mac/coremedia_glue.h ('k') | media/video/capture/mac/video_capture_device_avfoundation_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698