Client.h 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/HashMap.h>
  8. #include <ImageDecoder/ImageDecoderClientEndpoint.h>
  9. #include <ImageDecoder/ImageDecoderServerEndpoint.h>
  10. #include <LibIPC/ConnectionToServer.h>
  11. namespace ImageDecoderClient {
  12. struct Frame {
  13. NonnullRefPtr<Gfx::Bitmap> bitmap;
  14. u32 duration { 0 };
  15. };
  16. struct DecodedImage {
  17. bool is_animated { false };
  18. u32 loop_count { 0 };
  19. Vector<Frame> frames;
  20. };
  21. class Client final
  22. : public IPC::ConnectionToServer<ImageDecoderClientEndpoint, ImageDecoderServerEndpoint>
  23. , public ImageDecoderClientEndpoint {
  24. IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/image"sv);
  25. public:
  26. Client(NonnullOwnPtr<Core::LocalSocket>);
  27. Optional<DecodedImage> decode_image(ReadonlyBytes, Optional<DeprecatedString> mime_type = {});
  28. Function<void()> on_death;
  29. private:
  30. virtual void die() override;
  31. };
  32. }