recording_service_test_api.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2021 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 ASH_SERVICES_RECORDING_RECORDING_SERVICE_TEST_API_H_
  5. #define ASH_SERVICES_RECORDING_RECORDING_SERVICE_TEST_API_H_
  6. #include "ash/services/recording/public/mojom/recording_service.mojom.h"
  7. #include "ash/services/recording/recording_service.h"
  8. #include "base/callback_forward.h"
  9. #include "base/callback_helpers.h"
  10. #include "media/base/video_frame.h"
  11. #include "mojo/public/cpp/bindings/pending_receiver.h"
  12. #include "ui/gfx/image/image_skia.h"
  13. namespace recording {
  14. // Defines an API to test the internals of the recording service. The recording
  15. // service instance is created (in-process) and owned by this class.
  16. class RecordingServiceTestApi {
  17. public:
  18. explicit RecordingServiceTestApi(
  19. mojo::PendingReceiver<mojom::RecordingService> receiver);
  20. RecordingServiceTestApi(const RecordingServiceTestApi&) = delete;
  21. RecordingServiceTestApi& operator=(const RecordingServiceTestApi&) = delete;
  22. ~RecordingServiceTestApi() = default;
  23. // Gets the current frame sink id being captured by the service.
  24. viz::FrameSinkId GetCurrentFrameSinkId() const;
  25. // Gets the device scale factor value used by the recording service. This
  26. // value will always be 1.f when recording at the DIPs sizes, and equal to the
  27. // current DSF value of the display being recorded when recording at the pixel
  28. // sizes (see |ash::features::kRecordAtPixelSize|).
  29. float GetCurrentDeviceScaleFactor() const;
  30. // Gets the current size of the frame sink being recorded in pixels.
  31. gfx::Size GetCurrentFrameSinkSizeInPixels() const;
  32. // Gets the current video size being captured by the service. This matches the
  33. // the pixel size of the target being recorded.
  34. gfx::Size GetCurrentVideoSize() const;
  35. // Gets the thumbnail image that will be used by the service to provide it to
  36. // the client.
  37. gfx::ImageSkia GetVideoThumbnail() const;
  38. // Gets the number of times the video encoder was reconfigured (not counting
  39. // the first time it was configured) as a result of a change in the video
  40. // size.
  41. int GetNumberOfVideoEncoderReconfigures() const;
  42. // Requests a video frame from the video capturer and waits for it to be
  43. // delivered to the service. If the caller provided a non-null
  44. // |verify_frame_callback| it will be called before this function returns.
  45. using VerifyVideoFrameCallback =
  46. base::OnceCallback<void(const media::VideoFrame& frame,
  47. const gfx::Rect& content_rect)>;
  48. void RequestAndWaitForVideoFrame(
  49. VerifyVideoFrameCallback verify_frame_callback = base::NullCallback());
  50. private:
  51. // The actual recording service instance.
  52. RecordingService recording_service_;
  53. };
  54. } // namespace recording
  55. #endif // ASH_SERVICES_RECORDING_RECORDING_SERVICE_TEST_API_H_