// 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 media.interfaces; import "media/mojo/interfaces/demuxer_stream.mojom"; import "media/mojo/interfaces/media_types.mojom"; interface Renderer { // Initializes the Renderer with one or both of an audio and video stream, // executing the callback with whether the initialization succeeded. Initialize(RendererClient client, DemuxerStream? audio, DemuxerStream? video) => (bool success); // Discards any buffered data, executing callback when completed. // NOTE: If an error occurs, RendererClient::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 RendererClient { // 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(); };