| 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_PIPELINE_H_ | 5 #ifndef MEDIA_BASE_PIPELINE_H_ |
| 6 #define MEDIA_BASE_PIPELINE_H_ | 6 #define MEDIA_BASE_PIPELINE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(PipelineStatusNotification); | 60 DISALLOW_COPY_AND_ASSIGN(PipelineStatusNotification); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Pipeline runs the media pipeline. Filters are created and called on the | 63 // Pipeline runs the media pipeline. Filters are created and called on the |
| 64 // message loop injected into this object. Pipeline works like a state | 64 // message loop injected into this object. Pipeline works like a state |
| 65 // machine to perform asynchronous initialization, pausing, seeking and playing. | 65 // machine to perform asynchronous initialization, pausing, seeking and playing. |
| 66 // | 66 // |
| 67 // Here's a state diagram that describes the lifetime of this object. | 67 // Here's a state diagram that describes the lifetime of this object. |
| 68 // | 68 // |
| 69 // [ *Created ] [ Stopped ] | 69 // [ *Created ] [ Any State ] |
| 70 // | Start() ^ | 70 // | Start() | Stop() / SetError() |
| 71 // V SetError() | | 71 // V V |
| 72 // [ InitXXX (for each filter) ] -------->[ Stopping (for each filter) ] | 72 // [ InitXXX (for each filter) ] [ Stopping ] |
| 73 // | ^ | 73 // | | |
| 74 // V | if Stop | 74 // V V |
| 75 // [ Seeking (for each filter) ] <--------[ Flushing (for each filter) ] | 75 // [ InitPreroll ] [ Stopped ] |
| 76 // | if Seek ^ | 76 // | |
| 77 // V | | 77 // V |
| 78 // [ Starting (for each filter) ] | | 78 // [ Starting ] <-- [ Seeking ] |
| 79 // | | | 79 // | ^ |
| 80 // V Seek()/Stop() | | 80 // V | |
| 81 // [ Started ] -------------------------> [ Pausing (for each filter) ] | 81 // [ Started ] ----------' |
| 82 // ^ SetError() | 82 // Seek() |
| 83 // | | |
| 84 // [ Any State Other Than InitXXX ] | |
| 85 // | 83 // |
| 86 // Initialization is a series of state transitions from "Created" through each | 84 // Initialization is a series of state transitions from "Created" through each |
| 87 // filter initialization state. When all filter initialization states have | 85 // filter initialization state. When all filter initialization states have |
| 88 // completed, we are implicitly in a "Paused" state. At that point we simulate | 86 // completed, we are implicitly in a "Paused" state. At that point we simulate |
| 89 // a Seek() to the beginning of the media to give filters a chance to preroll. | 87 // a Seek() to the beginning of the media to give filters a chance to preroll. |
| 90 // From then on the normal Seek() transitions are carried out and we start | 88 // From then on the normal Seek() transitions are carried out and we start |
| 91 // playing the media. | 89 // playing the media. |
| 92 // | 90 // |
| 93 // If any error ever happens, this object will transition to the "Error" state | 91 // If any error ever happens, this object will transition to the "Error" state |
| 94 // from any state. If Stop() is ever called, this object will transition to | 92 // from any state. If Stop() is ever called, this object will transition to |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 friend class base::RefCountedThreadSafe<Pipeline>; | 223 friend class base::RefCountedThreadSafe<Pipeline>; |
| 226 virtual ~Pipeline(); | 224 virtual ~Pipeline(); |
| 227 | 225 |
| 228 // Pipeline states, as described above. | 226 // Pipeline states, as described above. |
| 229 enum State { | 227 enum State { |
| 230 kCreated, | 228 kCreated, |
| 231 kInitDemuxer, | 229 kInitDemuxer, |
| 232 kInitAudioDecoder, | 230 kInitAudioDecoder, |
| 233 kInitAudioRenderer, | 231 kInitAudioRenderer, |
| 234 kInitVideoRenderer, | 232 kInitVideoRenderer, |
| 235 kPausing, | 233 kInitPrerolling, |
| 236 kSeeking, | 234 kSeeking, |
| 237 kFlushing, | |
| 238 kStarting, | 235 kStarting, |
| 239 kStarted, | 236 kStarted, |
| 240 kStopping, | 237 kStopping, |
| 241 kStopped, | 238 kStopped, |
| 242 }; | 239 }; |
| 243 | 240 |
| 244 // Updates |state_|. All state transitions should use this call. | 241 // Updates |state_|. All state transitions should use this call. |
| 245 void SetState(State next_state); | 242 void SetState(State next_state); |
| 246 | 243 |
| 247 // Simple method used to make sure the pipeline is running normally. | 244 static const char* GetStateString(State state); |
| 248 bool IsPipelineOk(); | 245 State GetNextState() const; |
| 249 | |
| 250 // Helper method to tell whether we are in transition to seek state. | |
| 251 bool IsPipelineSeeking(); | |
| 252 | 246 |
| 253 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_| | 247 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_| |
| 254 // and |seek_pending_|. | 248 // and |seek_pending_|. |
| 255 void FinishSeek(); | 249 void FinishSeek(); |
| 256 | 250 |
| 257 // Returns true if the given state is one that transitions to a new state | |
| 258 // after iterating through each filter. | |
| 259 static bool TransientState(State state); | |
| 260 | |
| 261 // Given the current state, returns the next state. | |
| 262 State FindNextState(State current); | |
| 263 | |
| 264 // DataSourceHost (by way of DemuxerHost) implementation. | 251 // DataSourceHost (by way of DemuxerHost) implementation. |
| 265 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | 252 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; |
| 266 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | 253 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; |
| 267 virtual void AddBufferedTimeRange(base::TimeDelta start, | 254 virtual void AddBufferedTimeRange(base::TimeDelta start, |
| 268 base::TimeDelta end) OVERRIDE; | 255 base::TimeDelta end) OVERRIDE; |
| 269 | 256 |
| 270 // DemuxerHost implementaion. | 257 // DemuxerHost implementaion. |
| 271 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | 258 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
| 272 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; | 259 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; |
| 273 | 260 |
| 274 // Initiates teardown sequence in response to a runtime error. | 261 // Initiates teardown sequence in response to a runtime error. |
| 275 // | 262 // |
| 276 // Safe to call from any thread. | 263 // Safe to call from any thread. |
| 277 void SetError(PipelineStatus error); | 264 void SetError(PipelineStatus error); |
| 278 | 265 |
| 279 // Callback executed when the natural size of the video has changed. | 266 // Callback executed when the natural size of the video has changed. |
| 280 void OnNaturalVideoSizeChanged(const gfx::Size& size); | 267 void OnNaturalVideoSizeChanged(const gfx::Size& size); |
| 281 | 268 |
| 282 // Callbacks executed when a renderer has ended. | 269 // Callbacks executed when a renderer has ended. |
| 283 void OnAudioRendererEnded(); | 270 void OnAudioRendererEnded(); |
| 284 void OnVideoRendererEnded(); | 271 void OnVideoRendererEnded(); |
| 285 | 272 |
| 286 // Callbacks executed by filters upon completing initialization. | |
| 287 void OnFilterInitialize(PipelineStatus status); | |
| 288 | |
| 289 // Callback executed by filters upon completing Play(), Pause(), Flush(), | |
| 290 // Seek() or Stop(). | |
| 291 void OnFilterStateTransition(PipelineStatus status); | |
| 292 | |
| 293 // Callback executed by filters when completing teardown operations. | |
| 294 void OnTeardownStateTransition(PipelineStatus status); | |
| 295 | |
| 296 // Callback executed by filters to update statistics. | 273 // Callback executed by filters to update statistics. |
| 297 void OnUpdateStatistics(const PipelineStatistics& stats); | 274 void OnUpdateStatistics(const PipelineStatistics& stats); |
| 298 | 275 |
| 299 // Callback executed by audio renderer when it has been disabled. | 276 // Callback executed by audio renderer when it has been disabled. |
| 300 void OnAudioDisabled(); | 277 void OnAudioDisabled(); |
| 301 | 278 |
| 302 // Callback executed by audio renderer to update clock time. | 279 // Callback executed by audio renderer to update clock time. |
| 303 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); | 280 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time); |
| 304 | 281 |
| 305 // Callback executed by video renderer to update clock time. | 282 // Callback executed by video renderer to update clock time. |
| 306 void OnVideoTimeUpdate(base::TimeDelta max_time); | 283 void OnVideoTimeUpdate(base::TimeDelta max_time); |
| 307 | 284 |
| 308 // The following "task" methods correspond to the public methods, but these | 285 // The following "task" methods correspond to the public methods, but these |
| 309 // methods are run as the result of posting a task to the PipelineInternal's | 286 // methods are run as the result of posting a task to the PipelineInternal's |
| 310 // message loop. | 287 // message loop. |
| 311 void StartTask(scoped_ptr<FilterCollection> filter_collection, | 288 void StartTask(scoped_ptr<FilterCollection> filter_collection, |
| 312 const PipelineStatusCB& ended_cb, | 289 const PipelineStatusCB& ended_cb, |
| 313 const PipelineStatusCB& error_cb, | 290 const PipelineStatusCB& error_cb, |
| 314 const PipelineStatusCB& seek_cb, | 291 const PipelineStatusCB& seek_cb, |
| 315 const BufferingStateCB& buffering_state_cb); | 292 const BufferingStateCB& buffering_state_cb); |
| 316 | 293 |
| 317 // InitializeTask() performs initialization in multiple passes. It is executed | |
| 318 // as a result of calling Start() or InitializationComplete() that advances | |
| 319 // initialization to the next state. It works as a hub of state transition for | |
| 320 // initialization. One stage communicates its status to the next through | |
| 321 // |last_stage_status|. | |
| 322 void InitializeTask(PipelineStatus last_stage_status); | |
| 323 | |
| 324 // Stops and destroys all filters, placing the pipeline in the kStopped state. | 294 // Stops and destroys all filters, placing the pipeline in the kStopped state. |
| 325 void StopTask(const base::Closure& stop_cb); | 295 void StopTask(const base::Closure& stop_cb); |
| 326 | 296 |
| 327 // Carries out stopping and destroying all filters, placing the pipeline in | 297 // Carries out stopping and destroying all filters, placing the pipeline in |
| 328 // the kStopped state. | 298 // the kStopped state. |
| 329 void ErrorChangedTask(PipelineStatus error); | 299 void ErrorChangedTask(PipelineStatus error); |
| 330 | 300 |
| 331 // Carries out notifying filters that the playback rate has changed. | 301 // Carries out notifying filters that the playback rate has changed. |
| 332 void PlaybackRateChangedTask(float playback_rate); | 302 void PlaybackRateChangedTask(float playback_rate); |
| 333 | 303 |
| 334 // Carries out notifying filters that the volume has changed. | 304 // Carries out notifying filters that the volume has changed. |
| 335 void VolumeChangedTask(float volume); | 305 void VolumeChangedTask(float volume); |
| 336 | 306 |
| 337 // Carries out notifying filters that we are seeking to a new timestamp. | 307 // Carries out notifying filters that we are seeking to a new timestamp. |
| 338 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb); | 308 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_cb); |
| 339 | 309 |
| 340 // Handles audio/video ended logic and running |ended_cb_|. | 310 // Handles audio/video ended logic and running |ended_cb_|. |
| 341 void DoAudioRendererEnded(); | 311 void DoAudioRendererEnded(); |
| 342 void DoVideoRendererEnded(); | 312 void DoVideoRendererEnded(); |
| 343 void RunEndedCallbackIfNeeded(); | 313 void RunEndedCallbackIfNeeded(); |
| 344 | 314 |
| 345 // Carries out disabling the audio renderer. | 315 // Carries out disabling the audio renderer. |
| 346 void AudioDisabledTask(); | 316 void AudioDisabledTask(); |
| 347 | 317 |
| 348 // Carries out advancing to the next filter during Play()/Pause()/Seek(). | 318 // Kicks off initialization for each media object, executing |done_cb| with |
| 349 void FilterStateTransitionTask(); | 319 // the result when completed. |
| 350 | 320 void InitializeDemuxer(const PipelineStatusCB& done_cb); |
| 351 // Carries out advancing to the next teardown operation. | 321 void InitializeAudioDecoder(const PipelineStatusCB& done_cb); |
| 352 void TeardownStateTransitionTask(); | 322 void InitializeAudioRenderer(const PipelineStatusCB& done_cb); |
| 353 | 323 void InitializeVideoRenderer(const PipelineStatusCB& done_cb); |
| 354 // Carries out stopping filter threads, deleting filters, running | |
| 355 // appropriate callbacks, and setting the appropriate pipeline state | |
| 356 // depending on whether we performing Stop() or SetError(). | |
| 357 // Called after all filters have been stopped. | |
| 358 void FinishDestroyingFiltersTask(); | |
| 359 | |
| 360 // Internal methods used in the implementation of the pipeline thread. All | |
| 361 // of these methods are only called on the pipeline thread. | |
| 362 | |
| 363 // The following initialize methods are used to select a specific type of | |
| 364 // object from FilterCollection and initialize it asynchronously. | |
| 365 void InitializeDemuxer(); | |
| 366 void OnDemuxerInitialized(PipelineStatus status); | |
| 367 | |
| 368 // Returns true if the asynchronous action of creating decoder has started. | |
| 369 // Returns false if this method did nothing because the corresponding | |
| 370 // audio stream does not exist. | |
| 371 bool InitializeAudioDecoder(const scoped_refptr<Demuxer>& demuxer); | |
| 372 | |
| 373 // Initializes a renderer and connects it with decoder. Returns true if the | |
| 374 // asynchronous action of creating renderer has started. Returns | |
| 375 // false if this method did nothing because the corresponding audio/video | |
| 376 // stream does not exist. | |
| 377 bool InitializeAudioRenderer(const scoped_refptr<AudioDecoder>& decoder); | |
| 378 bool InitializeVideoRenderer( | |
| 379 const scoped_refptr<DemuxerStream>& stream); | |
| 380 | 324 |
| 381 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask(). | 325 // Kicks off destroying filters. Called by StopTask() and ErrorChangedTask(). |
| 382 // When we start to tear down the pipeline, we will consider two cases: | 326 // When we start to tear down the pipeline, we will consider two cases: |
| 383 // 1. when pipeline has not been initialized, we will transit to stopping | 327 // 1. when pipeline has not been initialized, we will transit to stopping |
| 384 // state first. | 328 // state first. |
| 385 // 2. when pipeline has been initialized, we will first transit to pausing | 329 // 2. when pipeline has been initialized, we will first transit to pausing |
| 386 // => flushing => stopping => stopped state. | 330 // => flushing => stopping => stopped state. |
| 387 // This will remove the race condition during stop between filters. | 331 // This will remove the race condition during stop between filters. |
| 388 void TearDownPipeline(); | 332 void TearDownPipeline(); |
| 389 | 333 |
| 390 // Compute the time corresponding to a byte offset. | 334 // Compute the time corresponding to a byte offset. |
| 391 base::TimeDelta TimeForByteOffset_Locked(int64 byte_offset) const; | 335 base::TimeDelta TimeForByteOffset_Locked(int64 byte_offset) const; |
| 392 | 336 |
| 393 // Initiates an asynchronous Pause/Seek/Play/Stop() call sequence executing | 337 void OnStateTransition(PipelineStatus status); |
| 394 // |done_cb| when completed. | 338 void StateTransitionTask(PipelineStatus status); |
| 395 void DoPause(const PipelineStatusCB& done_cb); | |
| 396 void DoFlush(const PipelineStatusCB& done_cb); | |
| 397 void DoPlay(const PipelineStatusCB& done_cb); | |
| 398 void DoStop(const PipelineStatusCB& done_cb); | |
| 399 | 339 |
| 400 // Initiates an asynchronous Seek() and preroll call sequence executing | 340 // Initiates an asynchronous preroll call sequence executing |done_cb| |
| 401 // |done_cb| with the final status when completed. If |skip_demuxer_seek| is | 341 // with the final status when completed. |
| 402 // true then only renderers will attempt to preroll. | 342 void DoInitialPreroll(const PipelineStatusCB& done_cb); |
| 343 |
| 344 // Initiates an asynchronous pause-flush-seek-preroll call sequence |
| 345 // executing |done_cb| with the final status when completed. |
| 403 // | 346 // |
| 404 // TODO(scherkus): Prerolling should be separate from seeking so we can report | 347 // TODO(scherkus): Prerolling should be separate from seeking so we can report |
| 405 // finer grained ready states (HAVE_CURRENT_DATA vs. HAVE_FUTURE_DATA) | 348 // finer grained ready states (HAVE_CURRENT_DATA vs. HAVE_FUTURE_DATA) |
| 406 // indepentent from seeking. | 349 // indepentent from seeking. |
| 407 void DoSeek(base::TimeDelta seek_timestamp, bool skip_demuxer_seek, | 350 void DoSeek(base::TimeDelta seek_timestamp, const PipelineStatusCB& done_cb); |
| 408 const PipelineStatusCB& done_cb); | 351 |
| 352 // Updates playback rate and volume and initiates an asynchronous play call |
| 353 // sequence executing |done_cb| with the final status when completed. |
| 354 void DoPlay(const PipelineStatusCB& done_cb); |
| 355 |
| 356 // Initiates an asynchronous pause-flush-stop call sequence executing |
| 357 // |done_cb| when completed. |
| 358 void DoStop(const PipelineStatusCB& done_cb); |
| 359 void OnStopCompleted(PipelineStatus status); |
| 409 | 360 |
| 410 void OnAudioUnderflow(); | 361 void OnAudioUnderflow(); |
| 411 | 362 |
| 412 void StartClockIfWaitingForTimeUpdate_Locked(); | 363 void StartClockIfWaitingForTimeUpdate_Locked(); |
| 413 | 364 |
| 414 // Report pipeline |status| through |cb| avoiding duplicate error reporting. | |
| 415 void ReportStatus(const PipelineStatusCB& cb, PipelineStatus status); | |
| 416 | |
| 417 // Message loop used to execute pipeline tasks. | 365 // Message loop used to execute pipeline tasks. |
| 418 scoped_refptr<base::MessageLoopProxy> message_loop_; | 366 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 419 | 367 |
| 420 // MediaLog to which to log events. | 368 // MediaLog to which to log events. |
| 421 scoped_refptr<MediaLog> media_log_; | 369 scoped_refptr<MediaLog> media_log_; |
| 422 | 370 |
| 423 // Lock used to serialize access for the following data members. | 371 // Lock used to serialize access for the following data members. |
| 424 mutable base::Lock lock_; | 372 mutable base::Lock lock_; |
| 425 | 373 |
| 426 // Whether or not the pipeline is running. | 374 // Whether or not the pipeline is running. |
| 427 bool running_; | 375 bool running_; |
| 428 | 376 |
| 429 // Whether or not the pipeline is in transition for a seek operation. | |
| 430 bool seek_pending_; | |
| 431 | |
| 432 // Whether or not the pipeline is perform a stop operation. | |
| 433 bool tearing_down_; | |
| 434 | |
| 435 // Whether or not a playback rate change should be done once seeking is done. | |
| 436 bool playback_rate_change_pending_; | |
| 437 | |
| 438 // Amount of available buffered data. Set by filters. | 377 // Amount of available buffered data. Set by filters. |
| 439 Ranges<int64> buffered_byte_ranges_; | 378 Ranges<int64> buffered_byte_ranges_; |
| 440 Ranges<base::TimeDelta> buffered_time_ranges_; | 379 Ranges<base::TimeDelta> buffered_time_ranges_; |
| 441 | 380 |
| 442 // True when AddBufferedByteRange() has been called more recently than | 381 // True when AddBufferedByteRange() has been called more recently than |
| 443 // DidLoadingProgress(). | 382 // DidLoadingProgress(). |
| 444 mutable bool did_loading_progress_; | 383 mutable bool did_loading_progress_; |
| 445 | 384 |
| 446 // Total size of the media. Set by filters. | 385 // Total size of the media. Set by filters. |
| 447 int64 total_bytes_; | 386 int64 total_bytes_; |
| 448 | 387 |
| 449 // Video's natural width and height. Set by filters. | 388 // Video's natural width and height. Set by filters. |
| 450 gfx::Size natural_size_; | 389 gfx::Size natural_size_; |
| 451 | 390 |
| 452 // Current volume level (from 0.0f to 1.0f). This value is set immediately | 391 // Current volume level (from 0.0f to 1.0f). This value is set immediately |
| 453 // via SetVolume() and a task is dispatched on the message loop to notify the | 392 // via SetVolume() and a task is dispatched on the message loop to notify the |
| 454 // filters. | 393 // filters. |
| 455 float volume_; | 394 float volume_; |
| 456 | 395 |
| 457 // Current playback rate (>= 0.0f). This value is set immediately via | 396 // Current playback rate (>= 0.0f). This value is set immediately via |
| 458 // SetPlaybackRate() and a task is dispatched on the message loop to notify | 397 // SetPlaybackRate() and a task is dispatched on the message loop to notify |
| 459 // the filters. | 398 // the filters. |
| 460 float playback_rate_; | 399 float playback_rate_; |
| 461 | 400 |
| 462 // Playback rate to set when the current seek has finished. | |
| 463 float pending_playback_rate_; | |
| 464 | |
| 465 // Reference clock. Keeps track of current playback time. Uses system | 401 // Reference clock. Keeps track of current playback time. Uses system |
| 466 // clock and linear interpolation, but can have its time manually set | 402 // clock and linear interpolation, but can have its time manually set |
| 467 // by filters. | 403 // by filters. |
| 468 scoped_ptr<Clock> clock_; | 404 scoped_ptr<Clock> clock_; |
| 469 | 405 |
| 470 // If this value is set to true, then |clock_| is paused and we are waiting | 406 // If this value is set to true, then |clock_| is paused and we are waiting |
| 471 // for an update of the clock greater than or equal to the elapsed time to | 407 // for an update of the clock greater than or equal to the elapsed time to |
| 472 // start the clock. | 408 // start the clock. |
| 473 bool waiting_for_clock_update_; | 409 bool waiting_for_clock_update_; |
| 474 | 410 |
| 475 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that | 411 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that |
| 476 // the pipeline is operating correctly. Any other value indicates that the | 412 // the pipeline is operating correctly. Any other value indicates that the |
| 477 // pipeline is stopped or is stopping. Clients can call the Stop() method to | 413 // pipeline is stopped or is stopping. Clients can call the Stop() method to |
| 478 // reset the pipeline state, and restore this to PIPELINE_OK. | 414 // reset the pipeline state, and restore this to PIPELINE_OK. |
| 479 PipelineStatus status_; | 415 PipelineStatus status_; |
| 480 | 416 |
| 481 // Whether the media contains rendered audio and video streams. | 417 // Whether the media contains rendered audio and video streams. |
| 482 // TODO(fischman,scherkus): replace these with checks for | 418 // TODO(fischman,scherkus): replace these with checks for |
| 483 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the | 419 // {audio,video}_decoder_ once extraction of {Audio,Video}Decoder from the |
| 484 // Filter heirarchy is done. | 420 // Filter heirarchy is done. |
| 485 bool has_audio_; | 421 bool has_audio_; |
| 486 bool has_video_; | 422 bool has_video_; |
| 487 | 423 |
| 488 // The following data members are only accessed by tasks posted to | 424 // The following data members are only accessed by tasks posted to |
| 489 // |message_loop_|. | 425 // |message_loop_|. |
| 490 | 426 |
| 491 // Member that tracks the current state. | 427 // Member that tracks the current state. |
| 492 State state_; | 428 State state_; |
| 493 | 429 |
| 494 // For kSeeking we need to remember where we're seeking between filter | |
| 495 // replies. | |
| 496 base::TimeDelta seek_timestamp_; | |
| 497 | |
| 498 // Whether we've received the audio/video ended events. | 430 // Whether we've received the audio/video ended events. |
| 499 bool audio_ended_; | 431 bool audio_ended_; |
| 500 bool video_ended_; | 432 bool video_ended_; |
| 501 | 433 |
| 502 // Set to true in DisableAudioRendererTask(). | 434 // Set to true in DisableAudioRendererTask(). |
| 503 bool audio_disabled_; | 435 bool audio_disabled_; |
| 504 | 436 |
| 505 // Filter collection as passed in by Start(). | |
| 506 scoped_ptr<FilterCollection> filter_collection_; | 437 scoped_ptr<FilterCollection> filter_collection_; |
| 507 | 438 |
| 508 // Callbacks for various pipeline operations. | 439 // Temporary callback used for Start() and Seek(). |
| 509 PipelineStatusCB seek_cb_; | 440 PipelineStatusCB seek_cb_; |
| 441 |
| 442 // Temporary callback used for Stop(). |
| 510 base::Closure stop_cb_; | 443 base::Closure stop_cb_; |
| 444 |
| 445 // Permanent callbacks passed in via Start(). |
| 511 PipelineStatusCB ended_cb_; | 446 PipelineStatusCB ended_cb_; |
| 512 PipelineStatusCB error_cb_; | 447 PipelineStatusCB error_cb_; |
| 513 BufferingStateCB buffering_state_cb_; | 448 BufferingStateCB buffering_state_cb_; |
| 514 | 449 |
| 515 // Audio renderer reference used for setting the volume and determining | 450 // Audio renderer reference used for setting the volume and determining |
| 516 // when playback has finished. | 451 // when playback has finished. |
| 517 scoped_refptr<AudioRenderer> audio_renderer_; | 452 scoped_refptr<AudioRenderer> audio_renderer_; |
| 518 | 453 |
| 519 // Video Renderer reference used for determining when playback has finished | 454 // Video Renderer reference used for determining when playback has finished |
| 520 // and for signalling imminent shutdown. | 455 // and for signalling imminent shutdown. |
| 521 // The signalling imminent shutdown is a HACK necessary because | 456 // The signalling imminent shutdown is a HACK necessary because |
| 522 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage | 457 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage |
| 523 // until PipelineImpl::Stop() calls its callback. | 458 // until PipelineImpl::Stop() calls its callback. |
| 524 // http://crbug.com/110228 tracks removing this hack. | 459 // http://crbug.com/110228 tracks removing this hack. |
| 525 scoped_refptr<VideoRenderer> video_renderer_; | 460 scoped_refptr<VideoRenderer> video_renderer_; |
| 526 | 461 |
| 527 // Demuxer reference used for setting the preload value. | 462 // Demuxer reference used for setting the preload value. |
| 528 scoped_refptr<Demuxer> demuxer_; | 463 scoped_refptr<Demuxer> demuxer_; |
| 529 | 464 |
| 530 // Helper class that stores filter references during pipeline | 465 // Audio decoder reference used during initialization. |
| 531 // initialization. | 466 // |
| 532 struct PipelineInitState; | 467 // TODO(scherkus): Remove after renderers do initialization, see |
| 533 scoped_ptr<PipelineInitState> pipeline_init_state_; | 468 // http://crbug.com/145635 |
| 469 scoped_refptr<AudioDecoder> audio_decoder_; |
| 534 | 470 |
| 535 // Statistics. | |
| 536 PipelineStatistics statistics_; | 471 PipelineStatistics statistics_; |
| 472 |
| 537 // Time of pipeline creation; is non-zero only until the pipeline first | 473 // Time of pipeline creation; is non-zero only until the pipeline first |
| 538 // reaches "kStarted", at which point it is used & zeroed out. | 474 // reaches "kStarted", at which point it is used & zeroed out. |
| 539 base::Time creation_time_; | 475 base::Time creation_time_; |
| 540 | 476 |
| 541 scoped_ptr<SerialRunner> pending_callbacks_; | 477 scoped_ptr<SerialRunner> pending_callbacks_; |
| 542 | 478 |
| 543 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 479 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
| 544 }; | 480 }; |
| 545 | 481 |
| 546 } // namespace media | 482 } // namespace media |
| 547 | 483 |
| 548 #endif // MEDIA_BASE_PIPELINE_H_ | 484 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |