video_frame_mapper.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef MEDIA_GPU_VIDEO_FRAME_MAPPER_H_
  5. #define MEDIA_GPU_VIDEO_FRAME_MAPPER_H_
  6. #include "base/memory/scoped_refptr.h"
  7. #include "media/base/video_frame.h"
  8. #include "media/base/video_types.h"
  9. #include "media/gpu/media_gpu_export.h"
  10. namespace media {
  11. // The VideoFrameMapper interface allows mapping video frames into memory so
  12. // that their contents can be accessed directly.
  13. // VideoFrameMapper should be created by using VideoFrameMapperFactory.
  14. class MEDIA_GPU_EXPORT VideoFrameMapper {
  15. public:
  16. VideoFrameMapper(const VideoFrameMapper&) = delete;
  17. VideoFrameMapper& operator=(const VideoFrameMapper&) = delete;
  18. virtual ~VideoFrameMapper() = default;
  19. // Maps data referred by |video_frame| and creates a VideoFrame whose dtor
  20. // unmap the mapped memory. The |permissions| parameter is a bitwise OR of the
  21. // permissions the mapping needs if it uses mmap. Valid flags for this
  22. // parameter are combinations of |PROT_READ| and |PROT_WRITE|.
  23. virtual scoped_refptr<VideoFrame> Map(
  24. scoped_refptr<const VideoFrame> video_frame,
  25. int permissions) const = 0;
  26. // Returns the allowed pixel format of video frames on Map().
  27. VideoPixelFormat pixel_format() const { return format_; }
  28. protected:
  29. explicit VideoFrameMapper(VideoPixelFormat format) : format_(format) {}
  30. // The allowed pixel format of video frames on Map().
  31. VideoPixelFormat format_;
  32. };
  33. } // namespace media
  34. #endif // MEDIA_GPU_VIDEO_FRAME_MAPPER_H_