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

Side by Side Diff: media/base/media_resource.h

Issue 2667283002: Refactor MediaResource to be multi-stream capable (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « media/base/fake_text_track_stream.cc ('k') | media/base/media_url_demuxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_MEDIA_RESOURCE_H_ 5 #ifndef MEDIA_BASE_MEDIA_RESOURCE_H_
6 #define MEDIA_BASE_MEDIA_RESOURCE_H_ 6 #define MEDIA_BASE_MEDIA_RESOURCE_H_
7 7
8 #include <vector>
9
10 #include "base/callback.h"
8 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/time/time.h"
9 #include "media/base/demuxer_stream.h" 13 #include "media/base/demuxer_stream.h"
10 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
11 #include "media/base/media_url_params.h" 15 #include "media/base/media_url_params.h"
12 #include "url/gurl.h" 16 #include "url/gurl.h"
13 17
14 namespace media { 18 namespace media {
15 19
20 // The callback that is used to notify clients about streams being enabled and
21 // disabled. The first parameter is the DemuxerStream whose status changed. The
22 // second parameter is a bool indicating whether the stream got enabled or
23 // disabled. The third parameter specifies the media playback position at the
24 // time the status change happened.
25 using StreamStatusChangeCB =
26 base::RepeatingCallback<void(DemuxerStream*, bool, base::TimeDelta)>;
27
16 // Abstract class that defines how to retrieve "media resources" in 28 // Abstract class that defines how to retrieve "media resources" in
17 // DemuxerStream form (for most cases) or URL form (for the MediaPlayerRenderer 29 // DemuxerStream form (for most cases) or URL form (for the MediaPlayerRenderer
18 // case). 30 // case).
19 // 31 //
20 // The derived classes must return a non-null value for the getter method 32 // The derived classes must return a non-null value for the getter method
21 // associated with their type, and return a null/empty value for other getters. 33 // associated with their type, and return a null/empty value for other getters.
22 class MEDIA_EXPORT MediaResource { 34 class MEDIA_EXPORT MediaResource {
23 public: 35 public:
24 enum Type { 36 enum Type {
25 STREAM, // Indicates GetStreams() should be used 37 STREAM, // Indicates GetStreams() should be used
26 URL, // Indicates GetUrl() should be used 38 URL, // Indicates GetUrl() should be used
27 }; 39 };
28 40
29 MediaResource(); 41 MediaResource();
30 virtual ~MediaResource(); 42 virtual ~MediaResource();
31 43
32 // For Type::STREAM: 44 // For Type::STREAM:
33 // Returns the first stream of the given stream type (which is not allowed 45 // Returns a collection of available DemuxerStream objects. Note that some of
34 // to be DemuxerStream::TEXT), or NULL if that type of stream is not 46 // those streams might be in disabled state (check DemuxerStream::enabled() ).
35 // present.
36 // NOTE: Once a DemuxerStream pointer is returned from GetStream it is 47 // NOTE: Once a DemuxerStream pointer is returned from GetStream it is
37 // guaranteed to stay valid for as long as the Demuxer/MediaResource 48 // guaranteed to stay valid for as long as the Demuxer/MediaResource
38 // is alive. But make no assumption that once GetStream returned a non-null 49 // is alive. But make no assumption that once GetStream returned a non-null
39 // pointer for some stream type then all subsequent calls will also return 50 // pointer for some stream type then all subsequent calls will also return
40 // non-null pointer for the same stream type. In MSE Javascript code can 51 // non-null pointer for the same stream type. In MSE Javascript code can
41 // remove SourceBuffer from a MediaSource at any point and this will make 52 // remove SourceBuffer from a MediaSource at any point and this will make
42 // some previously existing streams inaccessible/unavailable. 53 // some previously existing streams inaccessible/unavailable.
43 // Other types: 54 virtual std::vector<DemuxerStream*> GetStreams() = 0;
44 // Should not be called.
45 virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0;
46 55
47 // For Type::URL: 56 // For Type::URL:
48 // Returns the URL parameters of the media to play. Empty URLs are legal, 57 // Returns the URL parameters of the media to play. Empty URLs are legal,
49 // and should be handled appropriately by the caller. 58 // and should be handled appropriately by the caller.
50 // Other types: 59 // Other types:
51 // Should not be called. 60 // Should not be called.
52 virtual MediaUrlParams GetMediaUrlParams() const; 61 virtual MediaUrlParams GetMediaUrlParams() const;
53 62
54 virtual MediaResource::Type GetType() const; 63 virtual MediaResource::Type GetType() const;
55 64
65 // The StreamStatusChangeCB allows clients to receive notifications about one
66 // of the streams being disabled or enabled.
67 virtual void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) = 0;
68
56 private: 69 private:
57 DISALLOW_COPY_AND_ASSIGN(MediaResource); 70 DISALLOW_COPY_AND_ASSIGN(MediaResource);
58 }; 71 };
59 72
60 } // namespace media 73 } // namespace media
61 74
62 #endif // MEDIA_BASE_MEDIA_RESOURCE_H_ 75 #endif // MEDIA_BASE_MEDIA_RESOURCE_H_
OLDNEW
« no previous file with comments | « media/base/fake_text_track_stream.cc ('k') | media/base/media_url_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698