1 // Copyright 2018 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 MEDIA_GPU_VAAPI_VAAPI_DMABUF_VIDEO_FRAME_MAPPER_H_
6 #define MEDIA_GPU_VAAPI_VAAPI_DMABUF_VIDEO_FRAME_MAPPER_H_
7 
8 #include <memory>
9 
10 #include "media/gpu/media_gpu_export.h"
11 #include "media/gpu/video_frame_mapper.h"
12 
13 namespace media {
14 
15 class VaapiWrapper;
16 
17 // VideoFrameMapper that provides access to the memory referred by DMABuf-backed
18 // video frames using VA-API.
19 // VaapiDmaBufVideoFrameMapper creates a new VaapiPicture from the given
20 // VideoFrame and use the VaapiWrapper to access the memory there.
21 class MEDIA_GPU_EXPORT VaapiDmaBufVideoFrameMapper : public VideoFrameMapper {
22  public:
23   static std::unique_ptr<VideoFrameMapper> Create(VideoPixelFormat format);
24 
25   ~VaapiDmaBufVideoFrameMapper() override;
26 
27   // VideoFrameMapper override.
28   scoped_refptr<VideoFrame> Map(
29       scoped_refptr<const VideoFrame> video_frame) const override;
30 
31  private:
32   explicit VaapiDmaBufVideoFrameMapper(VideoPixelFormat format);
33 
34   // Vaapi components for mapping.
35   const scoped_refptr<VaapiWrapper> vaapi_wrapper_;
36 
37   DISALLOW_COPY_AND_ASSIGN(VaapiDmaBufVideoFrameMapper);
38 };
39 
40 }  // namespace media
41 
42 #endif  // MEDIA_GPU_VAAPI_VAAPI_DMABUF_VIDEO_FRAME_MAPPER_H_
43