media_foundation_renderer_extension.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2020 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_RENDERERS_WIN_MEDIA_FOUNDATION_RENDERER_EXTENSION_H_
  5. #define MEDIA_RENDERERS_WIN_MEDIA_FOUNDATION_RENDERER_EXTENSION_H_
  6. #include "base/callback.h"
  7. #include "base/win/scoped_handle.h"
  8. #include "media/base/media_export.h"
  9. #include "media/renderers/win/media_foundation_rendering_mode.h"
  10. #include "ui/gfx/geometry/rect.h"
  11. namespace media {
  12. // C++ interface equivalent to mojom::MediaFoundationRendererExtension.
  13. // This interface allows MediaFoundationRenderer to support video rendering
  14. // using Direct Compositon.
  15. class MEDIA_EXPORT MediaFoundationRendererExtension {
  16. public:
  17. virtual ~MediaFoundationRendererExtension() = default;
  18. // TODO(frankli): naming: Change DComp into DirectComposition for interface
  19. // method names in a separate CL.
  20. // Enables Direct Composition video rendering and returns the Direct
  21. // Composition Surface handle. On failure, `error` explains the error reason.
  22. using GetDCompSurfaceCB = base::OnceCallback<void(base::win::ScopedHandle,
  23. const std::string& error)>;
  24. virtual void GetDCompSurface(GetDCompSurfaceCB callback) = 0;
  25. // Notifies renderer whether video is enabled.
  26. virtual void SetVideoStreamEnabled(bool enabled) = 0;
  27. // Notifies renderer of output composition parameters.
  28. using SetOutputRectCB = base::OnceCallback<void(bool)>;
  29. virtual void SetOutputRect(const ::gfx::Rect& rect,
  30. SetOutputRectCB callback) = 0;
  31. // Notify that the frame has been displayed and can be reused.
  32. virtual void NotifyFrameReleased(
  33. const base::UnguessableToken& frame_token) = 0;
  34. // Request a new frame to be provided to the client.
  35. virtual void RequestNextFrameBetweenTimestamps(
  36. base::TimeTicks deadline_min,
  37. base::TimeTicks deadline_max) = 0;
  38. // Change which mode we are using for video frame rendering.
  39. virtual void SetMediaFoundationRenderingMode(
  40. MediaFoundationRenderingMode mode) = 0;
  41. };
  42. } // namespace media
  43. #endif // MEDIA_RENDERERS_WIN_MEDIA_FOUNDATION_RENDERER_EXTENSION_H_