decode_surface_handler.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_DECODE_SURFACE_HANDLER_H_
  5. #define MEDIA_GPU_DECODE_SURFACE_HANDLER_H_
  6. #include "base/memory/scoped_refptr.h"
  7. #include "ui/gfx/geometry/rect.h"
  8. namespace media {
  9. class VideoColorSpace;
  10. // Interface representing {V4L2,Vaapi}DecodeSurface operations, i.e. a client
  11. // gets a T to work with by calling CreateSurface() and returns it when finished
  12. // by calling SurfaceReady(). Class T has to be ref-counted. No assumptions are
  13. // made about threading.
  14. template <class T>
  15. class DecodeSurfaceHandler {
  16. public:
  17. DecodeSurfaceHandler() = default;
  18. DecodeSurfaceHandler(const DecodeSurfaceHandler&) = delete;
  19. DecodeSurfaceHandler& operator=(const DecodeSurfaceHandler&) = delete;
  20. virtual ~DecodeSurfaceHandler() = default;
  21. // Returns a T for decoding into, if available, or nullptr.
  22. virtual scoped_refptr<T> CreateSurface() = 0;
  23. // Called by the client to indicate that |dec_surface| is ready to be
  24. // outputted. This can actually be called before decode is finished in
  25. // hardware; this method must guarantee that |dec_surface|s are processed in
  26. // the same order as SurfaceReady() is called. (On Intel, this order doesn't
  27. // need to be explicitly maintained since the driver will enforce it, together
  28. // with any necessary dependencies).
  29. virtual void SurfaceReady(scoped_refptr<T> dec_surface,
  30. int32_t bitstream_id,
  31. const gfx::Rect& visible_rect,
  32. const VideoColorSpace& color_space) = 0;
  33. };
  34. } // namespace media
  35. #endif // MEDIA_GPU_DECODE_SURFACE_HANDLER_H_