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 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync | 5 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync |
6 // callback adapter). | 6 // callback adapter). |
7 | 7 |
8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ | 8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ |
9 #define MEDIA_BASE_PIPELINE_IMPL_H_ | 9 #define MEDIA_BASE_PIPELINE_IMPL_H_ |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Initialization is a series of state transitions from "Created" through each | 89 // Initialization is a series of state transitions from "Created" through each |
90 // filter initialization state. When all filter initialization states have | 90 // filter initialization state. When all filter initialization states have |
91 // completed, we are implicitly in a "Paused" state. At that point we simulate | 91 // completed, we are implicitly in a "Paused" state. At that point we simulate |
92 // a Seek() to the beginning of the media to give filters a chance to preroll. | 92 // a Seek() to the beginning of the media to give filters a chance to preroll. |
93 // From then on the normal Seek() transitions are carried out and we start | 93 // From then on the normal Seek() transitions are carried out and we start |
94 // playing the media. | 94 // playing the media. |
95 // | 95 // |
96 // If any error ever happens, this object will transition to the "Error" state | 96 // If any error ever happens, this object will transition to the "Error" state |
97 // from any state. If Stop() is ever called, this object will transition to | 97 // from any state. If Stop() is ever called, this object will transition to |
98 // "Stopped" state. | 98 // "Stopped" state. |
99 class MEDIA_EXPORT PipelineImpl : public Pipeline, public FilterHost { | 99 class MEDIA_EXPORT PipelineImpl |
| 100 : public Pipeline, |
| 101 public FilterHost, |
| 102 public DemuxerHost { |
100 public: | 103 public: |
101 explicit PipelineImpl(MessageLoop* message_loop, MediaLog* media_log); | 104 explicit PipelineImpl(MessageLoop* message_loop, MediaLog* media_log); |
102 | 105 |
103 // Pipeline implementation. | 106 // Pipeline implementation. |
104 virtual void Init(const PipelineStatusCB& ended_callback, | 107 virtual void Init(const PipelineStatusCB& ended_callback, |
105 const PipelineStatusCB& error_callback, | 108 const PipelineStatusCB& error_callback, |
106 const NetworkEventCB& network_callback) OVERRIDE; | 109 const NetworkEventCB& network_callback) OVERRIDE; |
107 virtual bool Start(FilterCollection* filter_collection, | 110 virtual bool Start(FilterCollection* filter_collection, |
108 const std::string& uri, | 111 const std::string& uri, |
109 const PipelineStatusCB& start_callback) OVERRIDE; | 112 const PipelineStatusCB& start_callback) OVERRIDE; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // initialization. | 186 // initialization. |
184 void FinishInitialization(); | 187 void FinishInitialization(); |
185 | 188 |
186 // Returns true if the given state is one that transitions to a new state | 189 // Returns true if the given state is one that transitions to a new state |
187 // after iterating through each filter. | 190 // after iterating through each filter. |
188 static bool TransientState(State state); | 191 static bool TransientState(State state); |
189 | 192 |
190 // Given the current state, returns the next state. | 193 // Given the current state, returns the next state. |
191 State FindNextState(State current); | 194 State FindNextState(State current); |
192 | 195 |
| 196 // DataSourceHost (by way of DemuxerHost) implementation. |
| 197 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; |
| 198 virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; |
| 199 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; |
| 200 |
| 201 // DemuxerHost implementaion. |
| 202 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
| 203 virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; |
| 204 virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; |
| 205 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; |
| 206 |
193 // FilterHost implementation. | 207 // FilterHost implementation. |
194 virtual void SetError(PipelineStatus error) OVERRIDE; | 208 virtual void SetError(PipelineStatus error) OVERRIDE; |
195 virtual base::TimeDelta GetTime() const OVERRIDE; | 209 virtual base::TimeDelta GetTime() const OVERRIDE; |
196 virtual base::TimeDelta GetDuration() const OVERRIDE; | 210 virtual base::TimeDelta GetDuration() const OVERRIDE; |
197 virtual void SetTime(base::TimeDelta time) OVERRIDE; | 211 virtual void SetTime(base::TimeDelta time) OVERRIDE; |
198 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | |
199 virtual void SetBufferedTime(base::TimeDelta buffered_time) OVERRIDE; | |
200 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | |
201 virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; | |
202 virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; | 212 virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; |
203 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; | |
204 virtual void NotifyEnded() OVERRIDE; | 213 virtual void NotifyEnded() OVERRIDE; |
205 virtual void DisableAudioRenderer() OVERRIDE; | 214 virtual void DisableAudioRenderer() OVERRIDE; |
206 virtual void SetCurrentReadPosition(int64 offset) OVERRIDE; | |
207 virtual int64 GetCurrentReadPosition() OVERRIDE; | |
208 | 215 |
209 // Callbacks executed by filters upon completing initialization. | 216 // Callbacks executed by filters upon completing initialization. |
210 void OnFilterInitialize(PipelineStatus status); | 217 void OnFilterInitialize(PipelineStatus status); |
211 | 218 |
212 // Callback executed by filters upon completing Play(), Pause(), or Stop(). | 219 // Callback executed by filters upon completing Play(), Pause(), or Stop(). |
213 void OnFilterStateTransition(); | 220 void OnFilterStateTransition(); |
214 | 221 |
215 // Callback executed by filters upon completing Seek(). | 222 // Callback executed by filters upon completing Seek(). |
216 void OnFilterStateTransitionWithStatus(PipelineStatus status); | 223 void OnFilterStateTransitionWithStatus(PipelineStatus status); |
217 | 224 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 bool is_downloading_data_; | 501 bool is_downloading_data_; |
495 | 502 |
496 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); | 503 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); |
497 | 504 |
498 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 505 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
499 }; | 506 }; |
500 | 507 |
501 } // namespace media | 508 } // namespace media |
502 | 509 |
503 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 510 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
OLD | NEW |