media_controller.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2019 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_PUBLIC_CPP_MEDIA_CONTROLLER_H_
  5. #define ASH_PUBLIC_CPP_MEDIA_CONTROLLER_H_
  6. #include "ash/public/cpp/ash_public_export.h"
  7. #include "ash/public/cpp/scoped_singleton_resetter_for_test.h"
  8. #include "base/containers/flat_map.h"
  9. #include "components/account_id/account_id.h"
  10. namespace ash {
  11. class MediaClient;
  12. // Describes whether media is currently being captured.
  13. enum class MediaCaptureState {
  14. kNone = 0,
  15. kAudio = 1,
  16. kVideo = 2,
  17. kAudioVideo = 3,
  18. };
  19. class ASH_PUBLIC_EXPORT MediaController {
  20. public:
  21. using ScopedResetterForTest = ScopedSingletonResetterForTest<MediaController>;
  22. // Gets the singleton MediaController instance.
  23. static MediaController* Get();
  24. // Sets the client.
  25. virtual void SetClient(MediaClient* client) = 0;
  26. // Forces media shortcut key handling in MediaClient instead of in ash. This
  27. // defaults to false and will be reset if the client encounters an error.
  28. virtual void SetForceMediaClientKeyHandling(bool enabled) = 0;
  29. // Called when the media capture state changes on the client, or in response
  30. // to a RequestCaptureState() request. Returns a map from AccountId to
  31. // MediaCaptureState representing every user's state.
  32. virtual void NotifyCaptureState(
  33. const base::flat_map<AccountId, MediaCaptureState>& capture_states) = 0;
  34. // Called when VMs' media capture notifications change. Each VM can have 0 or
  35. // 1 media notification. It can either be a "camera", "mic", or "camera and
  36. // mic" notification. Each of the argument is true if a notification of the
  37. // corresponding type is active.
  38. //
  39. // There is no `AccountId` in the argument because only the primary
  40. // account/profile can launch a VM.
  41. virtual void NotifyVmMediaNotificationState(bool camera,
  42. bool mic,
  43. bool camera_and_mic) = 0;
  44. protected:
  45. MediaController();
  46. virtual ~MediaController();
  47. };
  48. } // namespace ash
  49. #endif // ASH_PUBLIC_CPP_MEDIA_CONTROLLER_H_