summaryrefslogtreecommitdiffstats
path: root/media/mojo/interfaces/media_renderer.mojom
blob: 798e809ac608e0d7d4b8331eae45a8ba02589193 (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
// Copyright 2014 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 mojo;

import "media/mojo/interfaces/demuxer_stream.mojom";
import "media/mojo/interfaces/media_types.mojom";

interface MediaRenderer {
  // Initializes the Renderer with one or both of an audio and video stream,
  // executing the callback with whether the initialization succeeded.
  Initialize(MediaRendererClient client,
             DemuxerStream? audio,
             DemuxerStream? video) => (bool success);

  // Discards any buffered data, executing callback when completed.
  // NOTE: If an error occurs, MediaRendererClient::OnError() can be called
  // before the callback is executed.
  Flush() => ();

  // Starts rendering from |time_usec|.
  StartPlayingFrom(int64 time_usec);

  // Updates the current playback rate. The default playback rate should be 1.
  SetPlaybackRate(double playback_rate);

  // Sets the output volume. The default volume should be 1.
  SetVolume(float volume);

  // Attaches the CDM associated with |cdm_id| to the renderer service,
  // executing the callback with whether the CDM was successfully attached.
  SetCdm(int32 cdm_id) => (bool success);
};

interface MediaRendererClient {
  // Called to report media time advancement by |time_usec|.
  // |time_usec| and |max_time_usec| can be used to interpolate time between
  // calls to OnTimeUpdate().
  // |max_time_usec| is typically the media timestamp of the last audio frame
  //     buffered by the audio hardware.
  // |max_time_usec| must be greater or equal to |time_usec|.
  OnTimeUpdate(int64 time_usec, int64 max_time_usec);

  // Called to report buffering state changes, see media_types.mojom.
  OnBufferingStateChange(BufferingState state);

  // Executed when rendering has reached the end of stream.
  OnEnded();

  // Executed if any error was encountered during decode or rendering. If
  // this error happens during an operation that has a completion callback,
  // OnError() will be called before firing the completion callback.
  OnError();
};