| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef MEDIA_BASE_DEMUXER_H_ |
| 6 #define MEDIA_BASE_DEMUXER_H_ | 6 #define MEDIA_BASE_DEMUXER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/time.h" | 8 #include "base/time.h" |
| 10 #include "media/base/data_source.h" | 9 #include "media/base/data_source.h" |
| 11 #include "media/base/demuxer_stream.h" | 10 #include "media/base/demuxer_stream.h" |
| 12 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 13 #include "media/base/pipeline_status.h" | 12 #include "media/base/pipeline_status.h" |
| 14 | 13 |
| 15 namespace media { | 14 namespace media { |
| 16 | 15 |
| 17 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { | 16 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { |
| 18 public: | 17 public: |
| 19 // Sets the duration of the media in microseconds. | 18 // Sets the duration of the media in microseconds. |
| 20 // Duration may be kInfiniteDuration() if the duration is not known. | 19 // Duration may be kInfiniteDuration() if the duration is not known. |
| 21 virtual void SetDuration(base::TimeDelta duration) = 0; | 20 virtual void SetDuration(base::TimeDelta duration) = 0; |
| 22 | 21 |
| 23 // Stops execution of the pipeline due to a fatal error. Do not call this | 22 // Stops execution of the pipeline due to a fatal error. Do not call this |
| 24 // method with PIPELINE_OK. | 23 // method with PIPELINE_OK. |
| 25 virtual void OnDemuxerError(PipelineStatus error) = 0; | 24 virtual void OnDemuxerError(PipelineStatus error) = 0; |
| 26 | 25 |
| 27 protected: | 26 protected: |
| 28 virtual ~DemuxerHost(); | 27 virtual ~DemuxerHost(); |
| 29 }; | 28 }; |
| 30 | 29 |
| 31 class MEDIA_EXPORT Demuxer : public base::RefCountedThreadSafe<Demuxer> { | 30 class MEDIA_EXPORT Demuxer { |
| 32 public: | 31 public: |
| 33 Demuxer(); | 32 Demuxer(); |
| 33 virtual ~Demuxer(); |
| 34 | 34 |
| 35 // Completes initialization of the demuxer. | 35 // Completes initialization of the demuxer. |
| 36 // | 36 // |
| 37 // The demuxer does not own |host| as it is guaranteed to outlive the | 37 // The demuxer does not own |host| as it is guaranteed to outlive the |
| 38 // lifetime of the demuxer. Don't delete it! | 38 // lifetime of the demuxer. Don't delete it! |
| 39 virtual void Initialize(DemuxerHost* host, | 39 virtual void Initialize(DemuxerHost* host, |
| 40 const PipelineStatusCB& status_cb) = 0; | 40 const PipelineStatusCB& status_cb) = 0; |
| 41 | 41 |
| 42 // The pipeline playback rate has been changed. Demuxers may implement this | 42 // The pipeline playback rate has been changed. Demuxers may implement this |
| 43 // method if they need to respond to this call. | 43 // method if they need to respond to this call. |
| 44 virtual void SetPlaybackRate(float playback_rate); | 44 virtual void SetPlaybackRate(float playback_rate); |
| 45 | 45 |
| 46 // Carry out any actions required to seek to the given time, executing the | 46 // Carry out any actions required to seek to the given time, executing the |
| 47 // callback upon completion. | 47 // callback upon completion. |
| 48 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb); | 48 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb); |
| 49 | 49 |
| 50 // The pipeline is being stopped either as a result of an error or because | 50 // The pipeline is being stopped either as a result of an error or because |
| 51 // the client called Stop(). | 51 // the client called Stop(). |
| 52 virtual void Stop(const base::Closure& callback); | 52 virtual void Stop(const base::Closure& callback); |
| 53 | 53 |
| 54 // This method is called from the pipeline when the audio renderer | 54 // This method is called from the pipeline when the audio renderer |
| 55 // is disabled. Demuxers can ignore the notification if they do not | 55 // is disabled. Demuxers can ignore the notification if they do not |
| 56 // need to react to this event. | 56 // need to react to this event. |
| 57 // | 57 // |
| 58 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). | 58 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). |
| 59 virtual void OnAudioRendererDisabled(); | 59 virtual void OnAudioRendererDisabled(); |
| 60 | 60 |
| 61 // Returns the given stream type, or NULL if that type is not present. | 61 // Returns the given stream type, or NULL if that type is not present. |
| 62 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0; | 62 virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0; |
| 63 | 63 |
| 64 // Returns the starting time for the media file. | 64 // Returns the starting time for the media file. |
| 65 virtual base::TimeDelta GetStartTime() const = 0; | 65 virtual base::TimeDelta GetStartTime() const = 0; |
| 66 | 66 |
| 67 protected: | |
| 68 friend class base::RefCountedThreadSafe<Demuxer>; | |
| 69 virtual ~Demuxer(); | |
| 70 | |
| 71 private: | 67 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(Demuxer); | 68 DISALLOW_COPY_AND_ASSIGN(Demuxer); |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 } // namespace media | 71 } // namespace media |
| 76 | 72 |
| 77 #endif // MEDIA_BASE_DEMUXER_H_ | 73 #endif // MEDIA_BASE_DEMUXER_H_ |
| OLD | NEW |