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