Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_DEMUXER_STREAM_PROVIDER_H_ | 5 #ifndef MEDIA_BASE_MEDIA_RESOURCE_H_ |
| 6 #define MEDIA_BASE_DEMUXER_STREAM_PROVIDER_H_ | 6 #define MEDIA_BASE_MEDIA_RESOURCE_H_ |
| 7 | |
| 8 #include <vector> | |
| 7 | 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "media/base/demuxer_stream.h" | 11 #include "media/base/demuxer_stream.h" |
| 10 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 11 #include "media/base/media_url_params.h" | 13 #include "media/base/media_url_params.h" |
| 12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 13 | 15 |
| 14 namespace media { | 16 namespace media { |
| 15 | 17 |
| 18 using StreamStatusChangeCB = | |
| 19 base::Callback<void(DemuxerStream*, bool, base::TimeDelta)>; | |
|
xhwang
2017/02/01 18:26:03
Add include for base::Callback and TimeDelta
Plea
servolk
2017/02/01 22:29:11
Done.
| |
| 20 | |
| 16 // Abstract class that defines how to retrieve "media sources" in DemuxerStream | 21 // Abstract class that defines how to retrieve "media sources" in DemuxerStream |
|
xhwang
2017/02/01 18:26:03
nit: Does it make sense to s/sources/resource?
servolk
2017/02/01 22:29:17
Done.
| |
| 17 // form (for most cases) or URL form (for the MediaPlayerRenderer case). | 22 // form (for most cases) or URL form (for the MediaPlayerRenderer case). |
| 18 // | 23 // |
| 19 // The sub-classes do not stricly provide demuxer streams, but because all | |
| 20 // sub-classes are for the moment Demuxers, this class has not been renamed to | |
| 21 // "MediaProvider". This class would be a good candidate for renaming, if | |
| 22 // ever Pipeline were to support this class directly, instead of the Demuxer | |
| 23 // interface. | |
| 24 // TODO(tguilbert): Rename this class. See crbug.com/658062. | |
| 25 // | |
| 26 // The derived classes must return a non-null value for the getter method | 24 // The derived classes must return a non-null value for the getter method |
| 27 // associated with their type, and return a null/empty value for other getters. | 25 // associated with their type, and return a null/empty value for other getters. |
| 28 class MEDIA_EXPORT DemuxerStreamProvider { | 26 class MEDIA_EXPORT MediaResource { |
| 29 public: | 27 public: |
| 30 enum Type { | 28 enum Type { |
| 31 STREAM, // Indicates GetStream() should be used | 29 STREAM, // Indicates GetStream() should be used |
|
xhwang
2017/02/01 18:26:03
GetStreams
servolk
2017/02/01 22:29:12
Done (in the next CL)
| |
| 32 URL, // Indicates GetUrl() should be used | 30 URL, // Indicates GetUrl() should be used |
| 33 }; | 31 }; |
| 34 | 32 |
| 35 DemuxerStreamProvider(); | 33 MediaResource(); |
| 36 virtual ~DemuxerStreamProvider(); | 34 virtual ~MediaResource(); |
| 37 | 35 |
| 38 // For Type::STREAM: | 36 // Returns a collection of available DemuxerStream objects. Note that some of |
|
xhwang
2017/02/01 18:26:03
Do you want to keep the
For Type::STREAM:
part
servolk
2017/02/01 22:29:11
Done (in the next CL)
| |
| 39 // Returns the first stream of the given stream type (which is not allowed | 37 // those streams might be in disabled state (check DemuxerStream::enabled() ). |
|
xhwang
2017/02/01 18:26:03
I thought we agreed that disabled streams should n
servolk
2017/02/01 22:29:17
Yes. Although I haven't done that yet in this CL,
| |
| 40 // to be DemuxerStream::TEXT), or NULL if that type of stream is not | |
| 41 // present. | |
| 42 // NOTE: Once a DemuxerStream pointer is returned from GetStream it is | 38 // NOTE: Once a DemuxerStream pointer is returned from GetStream it is |
| 43 // guaranteed to stay valid for as long as the Demuxer/DemuxerStreamProvider | 39 // guaranteed to stay valid for as long as the Demuxer/MediaResource |
| 44 // is alive. But make no assumption that once GetStream returned a non-null | 40 // is alive. But make no assumption that once GetStream returned a non-null |
| 45 // pointer for some stream type then all subsequent calls will also return | 41 // pointer for some stream type then all subsequent calls will also return |
| 46 // non-null pointer for the same stream type. In MSE Javascript code can | 42 // non-null pointer for the same stream type. In MSE Javascript code can |
| 47 // remove SourceBuffer from a MediaSource at any point and this will make | 43 // remove SourceBuffer from a MediaSource at any point and this will make |
| 48 // some previously existing streams inaccessible/unavailable. | 44 // some previously existing streams inaccessible/unavailable. |
| 49 // Other types: | 45 virtual std::vector<DemuxerStream*> GetStreams() = 0; |
| 50 // Should not be called. | |
| 51 virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0; | |
| 52 | 46 |
| 53 // For Type::URL: | 47 // For Type::URL: |
| 54 // Returns the URL parameters of the media to play. Empty URLs are legal, | 48 // Returns the URL parameters of the media to play. Empty URLs are legal, |
| 55 // and should be handled appropriately by the caller. | 49 // and should be handled appropriately by the caller. |
| 56 // Other types: | 50 // Other types: |
| 57 // Should not be called. | 51 // Should not be called. |
| 58 virtual MediaUrlParams GetMediaUrlParams() const; | 52 virtual MediaUrlParams GetMediaUrlParams() const; |
| 59 | 53 |
| 60 virtual DemuxerStreamProvider::Type GetType() const; | 54 virtual MediaResource::Type GetType() const; |
| 55 | |
| 56 // The StreamStatusChangeCB allows clients to receive notifications about one | |
| 57 // of the streams being disabled or enabled. The first parameter is the stream | |
| 58 // and the second parameter is the playback position where the change occured. | |
|
xhwang
2017/02/01 18:26:03
Are these callback parameters? If so the comment s
servolk
2017/02/01 22:29:17
Moved the comment about params to the callback def
| |
| 59 virtual void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) = 0; | |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(DemuxerStreamProvider); | 62 DISALLOW_COPY_AND_ASSIGN(MediaResource); |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 } // namespace media | 65 } // namespace media |
| 67 | 66 |
| 68 #endif // MEDIA_BASE_DEMUXER_STREAM_PROVIDER_H_ | 67 #endif // MEDIA_BASE_MEDIA_RESOURCE_H_ |
| OLD | NEW |