[M120 Migration][MM] Framerate calculation
[platform/framework/web/chromium-efl.git] / media / mojo / mojom / media_player.mojom
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 module media.mojom;
6
7 import "media/mojo/mojom/media_types.mojom";
8 import "mojo/public/mojom/base/time.mojom";
9 import "services/media_session/public/mojom/media_session.mojom";
10 import "ui/gfx/geometry/mojom/geometry.mojom";
11
12 // Implemented by HTMLMediaElement in the renderer process to allow the
13 // browser to control media playback.
14 interface MediaPlayer {
15   // Requests the media player to start or resume media playback.
16   RequestPlay();
17
18   // Requests the media player to pause media playback.
19   RequestPause(bool triggered_by_user);
20
21   // Requests the media player to move forward the media playback position.
22   RequestSeekForward(mojo_base.mojom.TimeDelta seek_time);
23
24   // Requests the media player to move backward the media playback position.
25   RequestSeekBackward(mojo_base.mojom.TimeDelta seek_time);
26
27   // Requests the media player to move to a specific time.
28   RequestSeekTo(mojo_base.mojom.TimeDelta seek_time);
29
30   // Requests the media player to enter the Picture-in-Picture mode.
31   RequestEnterPictureInPicture();
32
33   // Requests the media player to mute or unmute.
34   RequestMute(bool mute);
35
36   // Set the volume multiplier to control audio ducking.
37   // Output volume should be set to |player_volume| * |multiplier|. The range
38   // of |multiplier| is [0, 1], where 1 indicates normal (non-ducked) playback.
39   SetVolumeMultiplier(double multiplier);
40
41   // Set the player as the persistent video. Persistent video should hide its
42   // controls and go fullscreen.
43   SetPersistentState(bool persistent);
44
45   // Notify the player that it is now eligible to start recording power
46   // measurements if |state| is true, else it is no longer eligible.
47   SetPowerExperimentState(bool enabled);
48
49   // Set the media player sink id to |sink_id|.
50   SetAudioSinkId(string sink_id);
51
52   // Suspends the media player when the host frame is closed.
53   SuspendForFrameClosed();
54
55   // Request the media player to start Media Remoting when there are available
56   // sinks.
57   RequestMediaRemoting();
58 };
59
60 // Implemented by the MediaWebContentsObserver. The remote lives in the renderer
61 // process and the receiver lives in the browser process.
62 interface MediaPlayerObserverClient {
63   // Gets a flag indicating whether media has been played before.
64   GetHasPlayedBefore() => (bool has_played_before);
65 };
66
67 // Implemented by MediaWebContentsObserver::MediaPlayerObserverHostImpl in the
68 // browser process.
69 interface MediaPlayerObserver {
70   // Notifies that the media player started playing content.
71   OnMediaPlaying();
72
73   // Notifies that the media player stopped playing content,
74   // indicating in |stream_ended| if playback has reached the end of the stream.
75   OnMediaPaused(bool stream_ended);
76
77   // Notifies that the muted status of the media player has changed.
78   OnMutedStatusChanged(bool muted);
79
80   // Notifies that the media metadata of the media player has changed, along
81   // with the kind of tracks the media player has, and the type of content.
82   OnMediaMetadataChanged(
83       bool has_audio, bool has_video, MediaContentType content_type);
84
85   // Notifies the browser process that the media playback position has changed,
86   // and reports the new current position via |media_position|.
87   OnMediaPositionStateChanged(media_session.mojom.MediaPosition media_position);
88
89   // Notifies that the player has entered fullscreen.
90   // This does not differentiate native controls fullscreen and custom controls
91   // fullscreen. |status| is used by MediaWebContentsObserver to trigger
92   // automatically Picture-in-Picture for fullscreen videos.
93   OnMediaEffectivelyFullscreenChanged(FullscreenVideoStatus status);
94
95   // Notifies that the size of the media player has changed.
96   OnMediaSizeChanged(gfx.mojom.Size size);
97
98   // Notifies the browser process of PictureinPicture playback's availability.
99   OnPictureInPictureAvailabilityChanged(bool available);
100
101   // Notifies that the audio output sink has changed.
102   OnAudioOutputSinkChanged(string hashed_device_id);
103
104   // Notifies that the playback starts/stops using AudioService.
105   OnUseAudioServiceChanged(bool uses_audio_service);
106
107   // Notifies the browser process that the ability to switch audio output
108   // devices for the associated media player has been disabled.
109   OnAudioOutputSinkChangingDisabled();
110
111   // Notifies that the RemotePlayback metadata of the media player has changed.
112   OnRemotePlaybackMetadataChange(media_session.mojom.RemotePlaybackMetadata
113                              remote_playback_metadata);
114 };
115
116 // Implemented by MediaWebContentsObserver::MediaPlayerHostImpl in the browser
117 // process.
118 interface MediaPlayerHost {
119   // Sends a message to the browser notifying the render frame associated to the
120   // document owning the HTMLMediaElement that a new MediaPlayer is available,
121   // passing a pending remote (i.e. |player_remote|) that will be used in the
122   // browser process to establish a channel with the HTMLMediaElement.
123   // |observer| starts observing the MediaPlayer as soon as the player is
124   // created.
125   OnMediaPlayerAdded(pending_associated_remote<MediaPlayer> player_remote,
126                      pending_associated_receiver<MediaPlayerObserver> observer,
127                      int32 player_id);
128 };