Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / media / video / capture / mac / coremedia_glue.mm
index f94256b..1bb4b8d 100644 (file)
@@ -19,6 +19,11 @@ class CoreMediaLibraryInternal {
   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
@@ -38,6 +43,16 @@ class CoreMediaLibraryInternal {
         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_; }
@@ -45,10 +60,22 @@ class CoreMediaLibraryInternal {
       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);
 };
@@ -58,13 +85,30 @@ class CoreMediaLibraryInternal {
 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);
+}