summaryrefslogtreecommitdiff
path: root/chromium/media/capture/video/video_capture_buffer_tracker_factory_impl.cc
blob: 92c2a96d7b10abb3068a519a7407459c77bfd81c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 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/capture/video/video_capture_buffer_tracker_factory_impl.h"

#include <memory>
#include "build/chromeos_buildflags.h"

#include "build/build_config.h"
#include "media/capture/video/shared_memory_buffer_tracker.h"

#if BUILDFLAG(IS_ASH)
#include "media/capture/video/chromeos/gpu_memory_buffer_tracker.h"
#endif

#if defined(OS_MAC)
#include "media/capture/video/mac/gpu_memory_buffer_tracker_mac.h"
#endif

namespace media {

std::unique_ptr<VideoCaptureBufferTracker>
VideoCaptureBufferTrackerFactoryImpl::CreateTracker(
    VideoCaptureBufferType buffer_type) {
  switch (buffer_type) {
    case VideoCaptureBufferType::kGpuMemoryBuffer:
#if BUILDFLAG(IS_ASH)
      return std::make_unique<GpuMemoryBufferTracker>();
#elif defined(OS_MAC)
      return std::make_unique<GpuMemoryBufferTrackerMac>();
#else
      return nullptr;
#endif
    default:
      return std::make_unique<SharedMemoryBufferTracker>();
  }
}

std::unique_ptr<VideoCaptureBufferTracker>
VideoCaptureBufferTrackerFactoryImpl::CreateTrackerForExternalGpuMemoryBuffer(
    const gfx::GpuMemoryBufferHandle& handle) {
#if defined(OS_MAC)
  return std::make_unique<GpuMemoryBufferTrackerMac>(handle.io_surface);
#else
  return nullptr;
#endif
}

}  // namespace media