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

Unified Diff: media/base/media_resource.h

Issue 2491043003: MediaResource refactoring to support multiple streams (Closed)
Patch Set: Added a TODO about DemuxerStream enabled/set_enabled methods Created 3 years, 10 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
« no previous file with comments | « media/base/fake_text_track_stream.cc ('k') | media/base/media_resource.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/media_resource.h
diff --git a/media/base/media_resource.h b/media/base/media_resource.h
index 2cd90192c013d892759f7ee2f939dfa31280d60f..3b65dae159d7def28d28cd58c365f8fbbce98378 100644
--- a/media/base/media_resource.h
+++ b/media/base/media_resource.h
@@ -5,7 +5,11 @@
#ifndef MEDIA_BASE_MEDIA_RESOURCE_H_
#define MEDIA_BASE_MEDIA_RESOURCE_H_
+#include <vector>
+
+#include "base/callback.h"
#include "base/macros.h"
+#include "base/time/time.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_export.h"
#include "media/base/media_url_params.h"
@@ -13,6 +17,14 @@
namespace media {
+// The callback that is used to notify clients about streams being enabled and
+// disabled. The first parameter is the DemuxerStream whose status changed. The
+// second parameter is a bool indicating whether the stream got enabled or
+// disabled. The third parameter specifies the media playback position at the
+// time the status change happened.
+using StreamStatusChangeCB =
+ base::RepeatingCallback<void(DemuxerStream*, bool, base::TimeDelta)>;
+
// Abstract class that defines how to retrieve "media resources" in
// DemuxerStream form (for most cases) or URL form (for the MediaPlayerRenderer
// case).
@@ -22,17 +34,17 @@ namespace media {
class MEDIA_EXPORT MediaResource {
public:
enum Type {
- STREAM, // Indicates GetStreams() should be used
+ STREAM, // Indicates GetAllStreams() or GetFirstStream() should be used
URL, // Indicates GetUrl() should be used
};
MediaResource();
virtual ~MediaResource();
+ virtual MediaResource::Type GetType() const;
+
// For Type::STREAM:
- // Returns the first stream of the given stream type (which is not allowed
- // to be DemuxerStream::TEXT), or NULL if that type of stream is not
- // present.
+ // Returns a collection of available DemuxerStream objects.
// NOTE: Once a DemuxerStream pointer is returned from GetStream it is
// guaranteed to stay valid for as long as the Demuxer/MediaResource
// is alive. But make no assumption that once GetStream returned a non-null
@@ -40,9 +52,15 @@ class MEDIA_EXPORT MediaResource {
// non-null pointer for the same stream type. In MSE Javascript code can
// remove SourceBuffer from a MediaSource at any point and this will make
// some previously existing streams inaccessible/unavailable.
- // Other types:
- // Should not be called.
- virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0;
+ virtual std::vector<DemuxerStream*> GetAllStreams() = 0;
+
+ // A helper function that return the first stream of the given |type| if one
+ // exists or a null pointer if there is no streams of that type.
+ DemuxerStream* GetFirstStream(DemuxerStream::Type type);
+
+ // The StreamStatusChangeCB allows clients to receive notifications about one
+ // of the streams being disabled or enabled.
+ virtual void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) = 0;
// For Type::URL:
// Returns the URL parameters of the media to play. Empty URLs are legal,
@@ -51,8 +69,6 @@ class MEDIA_EXPORT MediaResource {
// Should not be called.
virtual MediaUrlParams GetMediaUrlParams() const;
- virtual MediaResource::Type GetType() const;
-
private:
DISALLOW_COPY_AND_ASSIGN(MediaResource);
};
« no previous file with comments | « media/base/fake_text_track_stream.cc ('k') | media/base/media_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698