Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: media/base/renderer.h

Issue 418143005: media: Introduce Renderer interface and RendererImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix media/BUILD.gn Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/renderer.h
diff --git a/media/base/renderer.h b/media/base/renderer.h
new file mode 100644
index 0000000000000000000000000000000000000000..216195b9f1c3a1df5e9c45de5771631529573b8c
--- /dev/null
+++ b/media/base/renderer.h
@@ -0,0 +1,79 @@
+// 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.
+
+#ifndef MEDIA_BASE_RENDERER_H_
+#define MEDIA_BASE_RENDERER_H_
+
+#include "base/callback.h"
+#include "base/time/time.h"
+#include "media/base/buffering_state.h"
+#include "media/base/media_export.h"
+#include "media/base/pipeline_status.h"
+
+namespace media {
+
+class MediaKeys;
+class TimeDeltaInterpolator;
+
+class MEDIA_EXPORT Renderer {
damienv1 2014/08/06 21:43:47 Renderer seems to be too generic: Renderer is alre
xhwang 2014/08/07 05:46:49 Well, it's already in the media namespace... Perso
scherkus (not reviewing) 2014/08/21 21:17:00 agree with xhwang -- everything is namespaced
xhwang 2014/08/22 19:11:31 Acknowledged.
+ public:
+ typedef base::Callback<base::TimeDelta()> TimeDeltaCB;
+
+ Renderer();
+
+ // Stops rendering and fires any pending callbacks.
+ virtual ~Renderer();
+
+ // Initializes the Renderer, executing |init_cb| upon completion.
+ // TODO(xhwang): Provide a set of DemuxerStreams in Initialize().
+ // TODO(xhwang): Replace |init_cb|, |flush_cb| and |stop_cb| with Closures.
+ //
+ // Permanent callbacks:
+ // - |statistics_cb|: Executed periodically with rendering statistics.
+ // - |time_cb|: Executed whenever time has advanced through rendering.
+ // - |ended_cb|: Executed when rendering has reached the end of stream.
+ // - |error_cb|: Executed if any error was encountered during rendering.
+ virtual void Initialize(const PipelineStatusCB& init_cb,
+ const StatisticsCB& statistics_cb,
+ const base::Closure& ended_cb,
+ const PipelineStatusCB& error_cb,
+ const BufferingStateCB& buffering_state_cb,
+ const TimeDeltaCB& get_duration_cb) = 0;
+
+ // The following functions must be called after Initialize().
+
+ // Discards any buffered data, executing |done_cb| when completed.
scherkus (not reviewing) 2014/08/21 21:17:00 done_cb -> flush_cb? or flush_cb -> done_cb?
xhwang 2014/08/22 19:11:31 Done.
+ virtual void Flush(const base::Closure& flush_cb) = 0;
+
+ // Starts rendering from |timestamp|.
+ // TODO(xhwang): Switch to SetMediaTime() + StartPlaying() model?
+ virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0;
+
+ // Updates the current playback rate. The default playback rate should be 1.
+ virtual void SetPlaybackRate(float playback_rate) = 0;
+
+ // Sets the output volume. The default volume should be 1.
+ virtual void SetVolume(float volume) = 0;
+
+ virtual base::TimeDelta GetMediaTime() = 0;
scherkus (not reviewing) 2014/08/21 21:17:00 needs docs everywhere
xhwang 2014/08/22 19:11:31 Done.
+
+ virtual bool HasAudio() = 0;
+
+ virtual bool HasVideo() = 0;
+
+ // Associates the |cdm| with this Renderer.
+ virtual void SetCdm(MediaKeys* cdm) = 0;
+
+ // Helper functions for testing purposes. Must be called before Initialize().
+ virtual void DisableUnderflowForTesting();
scherkus (not reviewing) 2014/08/21 21:17:00 can these be moved to RendererImpl for tests?
xhwang 2014/08/22 19:11:31 Good point. Done.
+ virtual void SetTimeDeltaInterpolatorForTesting(
+ TimeDeltaInterpolator* interpolator);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Renderer);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_RENDERER_H_

Powered by Google App Engine
This is Rietveld 408576698