OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 10 #include "media/base/data_source.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 | |
12 // TODO(acolwell): Remove include once DataSource & Preload are moved | |
13 // out of "media/base/filters.h" and Stop() is converted to use new callbacks. | |
14 #include "media/base/filters.h" | |
15 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
| 14 #include "media/base/preload.h" |
16 | 15 |
17 namespace media { | 16 namespace media { |
18 | 17 |
19 class FilterHost; | 18 class MEDIA_EXPORT DemuxerHost : public DataSourceHost { |
| 19 public: |
| 20 virtual ~DemuxerHost(); |
| 21 |
| 22 // Get the duration of the media in microseconds. If the duration has not |
| 23 // been determined yet, then returns 0. |
| 24 virtual void SetDuration(base::TimeDelta duration) = 0; |
| 25 |
| 26 // Set the approximate amount of playable data buffered so far in micro- |
| 27 // seconds. |
| 28 virtual void SetBufferedTime(base::TimeDelta buffered_time) = 0; |
| 29 |
| 30 // Sets the byte offset at which the client is requesting the video. |
| 31 virtual void SetCurrentReadPosition(int64 offset) = 0; |
| 32 |
| 33 // Stops execution of the pipeline due to a fatal error. Do not call this |
| 34 // method with PIPELINE_OK. |
| 35 virtual void OnDemuxerError(PipelineStatus error) = 0; |
| 36 }; |
20 | 37 |
21 class MEDIA_EXPORT Demuxer | 38 class MEDIA_EXPORT Demuxer |
22 : public base::RefCountedThreadSafe<Demuxer> { | 39 : public base::RefCountedThreadSafe<Demuxer> { |
23 public: | 40 public: |
| 41 Demuxer(); |
| 42 |
24 // Sets the private member |host_|. This is the first method called by | 43 // Sets the private member |host_|. This is the first method called by |
25 // the FilterHost after a demuxer is created. The host holds a strong | 44 // the DemuxerHost after a demuxer is created. The host holds a strong |
26 // reference to the demuxer. The reference held by the host is guaranteed | 45 // reference to the demuxer. The reference held by the host is guaranteed |
27 // to be released before the host object is destroyed by the pipeline. | 46 // to be released before the host object is destroyed by the pipeline. |
28 // | 47 virtual void set_host(DemuxerHost* host); |
29 // TODO(acolwell): Change this to a narrow DemuxerHost interface. | |
30 virtual void set_host(FilterHost* host); | |
31 | 48 |
32 // The pipeline playback rate has been changed. Demuxers may implement this | 49 // The pipeline playback rate has been changed. Demuxers may implement this |
33 // method if they need to respond to this call. | 50 // method if they need to respond to this call. |
34 virtual void SetPlaybackRate(float playback_rate); | 51 virtual void SetPlaybackRate(float playback_rate); |
35 | 52 |
36 // Carry out any actions required to seek to the given time, executing the | 53 // Carry out any actions required to seek to the given time, executing the |
37 // callback upon completion. | 54 // callback upon completion. |
38 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback); | 55 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback); |
39 | 56 |
40 // The pipeline is being stopped either as a result of an error or because | 57 // The pipeline is being stopped either as a result of an error or because |
(...skipping 21 matching lines...) Expand all Loading... |
62 virtual int GetBitrate() = 0; | 79 virtual int GetBitrate() = 0; |
63 | 80 |
64 // Returns true if the source is from a local file or stream (such as a | 81 // Returns true if the source is from a local file or stream (such as a |
65 // webcam stream), false otherwise. | 82 // webcam stream), false otherwise. |
66 virtual bool IsLocalSource() = 0; | 83 virtual bool IsLocalSource() = 0; |
67 | 84 |
68 // Returns true if seeking is possible; false otherwise. | 85 // Returns true if seeking is possible; false otherwise. |
69 virtual bool IsSeekable() = 0; | 86 virtual bool IsSeekable() = 0; |
70 | 87 |
71 protected: | 88 protected: |
72 Demuxer(); | 89 // Only allow derived objects access to the DemuxerHost. This is |
73 FilterHost* host() { return host_; } | 90 // 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 |
| 92 // the state presented to the host is always consistent with its own |
| 93 // state. |
| 94 DemuxerHost* host() { return host_; } |
74 | 95 |
75 friend class base::RefCountedThreadSafe<Demuxer>; | 96 friend class base::RefCountedThreadSafe<Demuxer>; |
76 virtual ~Demuxer(); | 97 virtual ~Demuxer(); |
77 | 98 |
78 private: | 99 private: |
79 FilterHost* host_; | 100 DemuxerHost* host_; |
80 | 101 |
81 DISALLOW_COPY_AND_ASSIGN(Demuxer); | 102 DISALLOW_COPY_AND_ASSIGN(Demuxer); |
82 }; | 103 }; |
83 | 104 |
84 } // namespace media | 105 } // namespace media |
85 | 106 |
86 #endif // MEDIA_BASE_DEMUXER_H_ | 107 #endif // MEDIA_BASE_DEMUXER_H_ |
OLD | NEW |