summaryrefslogtreecommitdiff
path: root/chromium/media/base/media_status.h
blob: 0612904880c6cec567defce2355507a9235f5636 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_MEDIA_STATUS_H_
#define MEDIA_BASE_MEDIA_STATUS_H_

#include "base/callback.h"
#include "base/time/time.h"
#include "media/base/media_export.h"

namespace media {

// Describes the current state of media being controlled via the MediaController
// interface. This is a copy of the media_router.mojom.MediaStatus interface,
// without the cast specific portions.
// TODO(https://crbug.com/820277): Deduplicate media_router::MediaStatus.
struct MEDIA_EXPORT MediaStatus {
 public:
  enum class State {
    UNKNOWN,
    PLAYING,
    PAUSED,
    BUFFERING,
    STOPPED,
    STATE_MAX = STOPPED,
  };

  MediaStatus();
  MediaStatus(const MediaStatus& other);
  ~MediaStatus();

  MediaStatus& operator=(const MediaStatus& other);
  bool operator==(const MediaStatus& other) const;

  // The main title of the media. For example, in a MediaStatus representing
  // a YouTube Cast session, this could be the title of the video.
  std::string title;

  // If this is true, the media can be played and paused.
  bool can_play_pause = false;

  // If this is true, the media can be muted and unmuted.
  bool can_mute = false;

  // If this is true, the media's volume can be changed.
  bool can_set_volume = false;

  // If this is true, the media's current playback position can be changed.
  bool can_seek = false;

  State state = State::UNKNOWN;

  bool is_muted = false;

  // Current volume of the media, with 1 being the highest and 0 being the
  // lowest/no sound. When |is_muted| is true, there should be no sound
  // regardless of |volume|.
  float volume = 0;

  // The length of the media. A value of zero indicates that this is a media
  // with no set duration (e.g. a live stream).
  base::TimeDelta duration;

  // Current playback position. Must be less than or equal to |duration|.
  base::TimeDelta current_time;

  // True if we have reached the end of stream.
  bool reached_end_of_stream = false;
};

using RemotePlayStateChangeCB =
    base::RepeatingCallback<void(MediaStatus::State)>;
using RequestRemotePlayStateChangeCB =
    base::OnceCallback<void(RemotePlayStateChangeCB)>;

}  // namespace media

#endif  // MEDIA_BASE_MEDIA_STATUS_H_