| 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" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "media/base/data_source.h" | 10 #include "media/base/data_source.h" |
| 11 #include "media/base/demuxer_stream.h" | 11 #include "media/base/demuxer_stream.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
| 14 #include "media/base/preload.h" | |
| 15 | 14 |
| 16 namespace media { | 15 namespace media { |
| 17 | 16 |
| 18 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { | 17 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { |
| 19 public: | 18 public: |
| 20 virtual ~DemuxerHost(); | 19 virtual ~DemuxerHost(); |
| 21 | 20 |
| 22 // Get the duration of the media in microseconds. If the duration has not | 21 // Get the duration of the media in microseconds. If the duration has not |
| 23 // been determined yet, then returns 0. | 22 // been determined yet, then returns 0. |
| 24 virtual void SetDuration(base::TimeDelta duration) = 0; | 23 virtual void SetDuration(base::TimeDelta duration) = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 : public base::RefCountedThreadSafe<Demuxer> { | 38 : public base::RefCountedThreadSafe<Demuxer> { |
| 40 public: | 39 public: |
| 41 Demuxer(); | 40 Demuxer(); |
| 42 | 41 |
| 43 // Sets the private member |host_|. This is the first method called by | 42 // Sets the private member |host_|. This is the first method called by |
| 44 // the DemuxerHost after a demuxer is created. The host holds a strong | 43 // the DemuxerHost after a demuxer is created. The host holds a strong |
| 45 // reference to the demuxer. The reference held by the host is guaranteed | 44 // reference to the demuxer. The reference held by the host is guaranteed |
| 46 // to be released before the host object is destroyed by the pipeline. | 45 // to be released before the host object is destroyed by the pipeline. |
| 47 virtual void set_host(DemuxerHost* host); | 46 virtual void set_host(DemuxerHost* host); |
| 48 | 47 |
| 48 // Completes initialization of the demuxer. |
| 49 // |
| 50 // TODO(scherkus): pass in DemuxerHost here instead of using set_host(), |
| 51 // see http://crbug.com/111585 |
| 52 virtual void Initialize(const PipelineStatusCB& status_cb) = 0; |
| 53 |
| 49 // The pipeline playback rate has been changed. Demuxers may implement this | 54 // The pipeline playback rate has been changed. Demuxers may implement this |
| 50 // method if they need to respond to this call. | 55 // method if they need to respond to this call. |
| 51 virtual void SetPlaybackRate(float playback_rate); | 56 virtual void SetPlaybackRate(float playback_rate); |
| 52 | 57 |
| 53 // Carry out any actions required to seek to the given time, executing the | 58 // Carry out any actions required to seek to the given time, executing the |
| 54 // callback upon completion. | 59 // callback upon completion. |
| 55 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb); | 60 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb); |
| 56 | 61 |
| 57 // The pipeline is being stopped either as a result of an error or because | 62 // The pipeline is being stopped either as a result of an error or because |
| 58 // the client called Stop(). | 63 // the client called Stop(). |
| 59 virtual void Stop(const base::Closure& callback); | 64 virtual void Stop(const base::Closure& callback); |
| 60 | 65 |
| 61 // This method is called from the pipeline when the audio renderer | 66 // This method is called from the pipeline when the audio renderer |
| 62 // is disabled. Demuxers can ignore the notification if they do not | 67 // is disabled. Demuxers can ignore the notification if they do not |
| 63 // need to react to this event. | 68 // need to react to this event. |
| 64 // | 69 // |
| 65 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). | 70 // TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type). |
| 66 virtual void OnAudioRendererDisabled(); | 71 virtual void OnAudioRendererDisabled(); |
| 67 | 72 |
| 68 // Returns the given stream type, or NULL if that type is not present. | 73 // Returns the given stream type, or NULL if that type is not present. |
| 69 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0; | 74 virtual scoped_refptr<DemuxerStream> GetStream(DemuxerStream::Type type) = 0; |
| 70 | 75 |
| 71 // Alert the Demuxer that the video preload value has been changed. | |
| 72 virtual void SetPreload(Preload preload) = 0; | |
| 73 | |
| 74 // Returns the starting time for the media file. | 76 // Returns the starting time for the media file. |
| 75 virtual base::TimeDelta GetStartTime() const = 0; | 77 virtual base::TimeDelta GetStartTime() const = 0; |
| 76 | 78 |
| 77 // Returns the content bitrate. May be obtained from container or | 79 // Returns the content bitrate. May be obtained from container or |
| 78 // approximated. Returns 0 if it is unknown. | 80 // approximated. Returns 0 if it is unknown. |
| 79 virtual int GetBitrate() = 0; | 81 virtual int GetBitrate() = 0; |
| 80 | 82 |
| 81 // Returns true if the source is from a local file or stream (such as a | 83 // Returns true if the source is from a local file or stream (such as a |
| 82 // webcam stream), false otherwise. | 84 // webcam stream), false otherwise. |
| 85 // |
| 86 // TODO(scherkus): See http://crbug.com/120426 on why we should remove this. |
| 83 virtual bool IsLocalSource() = 0; | 87 virtual bool IsLocalSource() = 0; |
| 84 | 88 |
| 85 // Returns true if seeking is possible; false otherwise. | 89 // Returns true if seeking is possible; false otherwise. |
| 86 virtual bool IsSeekable() = 0; | 90 virtual bool IsSeekable() = 0; |
| 87 | 91 |
| 88 protected: | 92 protected: |
| 89 // Only allow derived objects access to the DemuxerHost. This is | 93 // Only allow derived objects access to the DemuxerHost. This is |
| 90 // kept out of the public interface because demuxers need to be | 94 // kept out of the public interface because demuxers need to be |
| 91 // aware of all calls made to the host object so they can insure | 95 // aware of all calls made to the host object so they can insure |
| 92 // the state presented to the host is always consistent with its own | 96 // the state presented to the host is always consistent with its own |
| 93 // state. | 97 // state. |
| 94 DemuxerHost* host() { return host_; } | 98 DemuxerHost* host() { return host_; } |
| 95 | 99 |
| 96 friend class base::RefCountedThreadSafe<Demuxer>; | 100 friend class base::RefCountedThreadSafe<Demuxer>; |
| 97 virtual ~Demuxer(); | 101 virtual ~Demuxer(); |
| 98 | 102 |
| 99 private: | 103 private: |
| 100 DemuxerHost* host_; | 104 DemuxerHost* host_; |
| 101 | 105 |
| 102 DISALLOW_COPY_AND_ASSIGN(Demuxer); | 106 DISALLOW_COPY_AND_ASSIGN(Demuxer); |
| 103 }; | 107 }; |
| 104 | 108 |
| 105 } // namespace media | 109 } // namespace media |
| 106 | 110 |
| 107 #endif // MEDIA_BASE_DEMUXER_H_ | 111 #endif // MEDIA_BASE_DEMUXER_H_ |
| OLD | NEW |