summaryrefslogtreecommitdiff
path: root/chromium/media/mojo/mojom/media_player.mojom
blob: 727d298ed49158aabea2537ac07108e9efd0631d (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module media.mojom;

import "media/mojo/mojom/media_types.mojom";
import "mojo/public/mojom/base/time.mojom";
import "services/media_session/public/mojom/media_session.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";

// Implemented by HTMLMediaElement in the renderer process.
interface MediaPlayer {
  // Sends |observer| to the renderer process so that it can be established a
  // communication channel with the implementor of MediaPlayerObserver, and
  // allows multiple observers for more observers like PictureInPictureService.
  AddMediaPlayerObserver(
      pending_associated_remote<MediaPlayerObserver> observer);

  // Requests the media player to start or resume media playback.
  RequestPlay();

  // Requests the media player to pause media playback.
  RequestPause(bool triggered_by_user);

  // Requests the media player to move forward the media playback position.
  RequestSeekForward(mojo_base.mojom.TimeDelta seek_time);

  // Requests the media player to move backward the media playback position.
  RequestSeekBackward(mojo_base.mojom.TimeDelta seek_time);

  // Requests the media player to enter the Picture-in-Picture mode.
  RequestEnterPictureInPicture();

  // Requests the media player to exit the Picture-in-Picture mode.
  RequestExitPictureInPicture();

  // Set the media player sink id to |sink_id|.
  SetAudioSinkId(string sink_id);
};

// Implemented by MediaWebContentsObserver::MediaPlayerObserverHostImpl in the
// browser process.
interface MediaPlayerObserver {
  // Notifies that the media player started playing content.
  OnMediaPlaying();

  // Notifies that the media player stopped playing content,
  // indicating in |stream_ended| if playback has reached the end of the stream.
  OnMediaPaused(bool stream_ended);

  // Notifies that the muted status of the media player has changed.
  OnMutedStatusChanged(bool muted);

  // Notifies that the media metadata of the media player has changed, along
  // with the kind of tracks the media player has, and the type of content.
  OnMediaMetadataChanged(
      bool has_audio, bool has_video, MediaContentType content_type);

  // Notifies the browser process that the media playback position has changed,
  // and reports the new current position via |media_position|.
  OnMediaPositionStateChanged(media_session.mojom.MediaPosition media_position);

  // Notifies that the player has entered fullscreen.
  // This does not differentiate native controls fullscreen and custom controls
  // fullscreen. |status| is used by MediaWebContentsObserver to trigger
  // automatically Picture-in-Picture for fullscreen videos.
  OnMediaEffectivelyFullscreenChanged(FullscreenVideoStatus status);

  // Notifies that the size of the media player has changed.
  OnMediaSizeChanged(gfx.mojom.Size size);

  // Notifies the browser process of PictureinPicture playback's availability.
  OnPictureInPictureAvailabilityChanged(bool available);

  // Notifies that the audio output sink has changed.
  OnAudioOutputSinkChanged(string hashed_device_id);

  // Notifies the browser process that the ability to switch audio output
  // devices for the associated media player has been disabled.
  OnAudioOutputSinkChangingDisabled();

  // Notifies that a buffer underflow event happened for the media player.
  OnBufferUnderflow();

  // Notifies that a playback seek event happened for the media player.
  OnSeek();
};

// Implemented by MediaWebContentsObserver::MediaPlayerHostImpl in the browser
// process.
interface MediaPlayerHost {
  // Sends a message to the browser notifying the render frame associated to the
  // document owning the HTMLMediaElement that a new MediaPlayer is available,
  // passing a pending remote (i.e. |player_remote|) that will be used in the
  // browser process to establish a channel with the HTMLMediaElement.
  OnMediaPlayerAdded(pending_associated_remote<MediaPlayer> player_remote,
                     int32 player_id);
};