media_status.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_BASE_MEDIA_STATUS_H_
  5. #define MEDIA_BASE_MEDIA_STATUS_H_
  6. #include "base/callback.h"
  7. #include "base/time/time.h"
  8. #include "media/base/media_export.h"
  9. namespace media {
  10. // Describes the current state of media being controlled via the MediaController
  11. // interface. This is a copy of the media_router.mojom.MediaStatus interface,
  12. // without the cast specific portions.
  13. // TODO(https://crbug.com/820277): Deduplicate media_router::MediaStatus.
  14. struct MEDIA_EXPORT MediaStatus {
  15. public:
  16. enum class State {
  17. UNKNOWN,
  18. PLAYING,
  19. PAUSED,
  20. BUFFERING,
  21. STOPPED,
  22. STATE_MAX = STOPPED,
  23. };
  24. MediaStatus();
  25. MediaStatus(const MediaStatus& other);
  26. ~MediaStatus();
  27. MediaStatus& operator=(const MediaStatus& other);
  28. bool operator==(const MediaStatus& other) const;
  29. // The main title of the media. For example, in a MediaStatus representing
  30. // a YouTube Cast session, this could be the title of the video.
  31. std::string title;
  32. // If this is true, the media can be played and paused.
  33. bool can_play_pause = false;
  34. // If this is true, the media can be muted and unmuted.
  35. bool can_mute = false;
  36. // If this is true, the media's volume can be changed.
  37. bool can_set_volume = false;
  38. // If this is true, the media's current playback position can be changed.
  39. bool can_seek = false;
  40. State state = State::UNKNOWN;
  41. bool is_muted = false;
  42. // Current volume of the media, with 1 being the highest and 0 being the
  43. // lowest/no sound. When |is_muted| is true, there should be no sound
  44. // regardless of |volume|.
  45. float volume = 0;
  46. // The length of the media. A value of zero indicates that this is a media
  47. // with no set duration (e.g. a live stream).
  48. base::TimeDelta duration;
  49. // Current playback position. Must be less than or equal to |duration|.
  50. base::TimeDelta current_time;
  51. // True if we have reached the end of stream.
  52. bool reached_end_of_stream = false;
  53. };
  54. using RemotePlayStateChangeCB =
  55. base::RepeatingCallback<void(MediaStatus::State)>;
  56. using RequestRemotePlayStateChangeCB =
  57. base::OnceCallback<void(RemotePlayStateChangeCB)>;
  58. } // namespace media
  59. #endif // MEDIA_BASE_MEDIA_STATUS_H_