Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: media/base/pipeline.h

Issue 10451049: Track buffered byte ranges correctly in media::Pipeline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/mock_demuxer_host.h ('k') | media/base/pipeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 // Get approximate time ranges of buffered media. 213 // Get approximate time ranges of buffered media.
214 Ranges<base::TimeDelta> GetBufferedTimeRanges(); 214 Ranges<base::TimeDelta> GetBufferedTimeRanges();
215 215
216 // Get the duration of the media in microseconds. If the duration has not 216 // Get the duration of the media in microseconds. If the duration has not
217 // been determined yet, then returns 0. 217 // been determined yet, then returns 0.
218 base::TimeDelta GetMediaDuration() const; 218 base::TimeDelta GetMediaDuration() const;
219 219
220 // Get the total number of bytes that are buffered on the client and ready to 220 // Get the total number of bytes that are buffered on the client and ready to
221 // be played. 221 // be played.
222 // TODO(fischman): this interface is only needed so WMPI can provide
223 // bytesLoaded() which is only present so that HTMLMediaElement can decide
224 // whether progress has been made. Bogus! http://webk.it/86113
222 int64 GetBufferedBytes() const; 225 int64 GetBufferedBytes() const;
223 226
224 // Get the total size of the media file. If the size has not yet been 227 // Get the total size of the media file. If the size has not yet been
225 // determined or can not be determined, this value is 0. 228 // determined or can not be determined, this value is 0.
226 int64 GetTotalBytes() const; 229 int64 GetTotalBytes() const;
227 230
228 // Gets the natural size of the video output in pixel units. If there is no 231 // Gets the natural size of the video output in pixel units. If there is no
229 // video or the video has not been rendered yet, the width and height will 232 // video or the video has not been rendered yet, the width and height will
230 // be 0. 233 // be 0.
231 void GetNaturalVideoSize(gfx::Size* out_size) const; 234 void GetNaturalVideoSize(gfx::Size* out_size) const;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 295
293 // Returns true if the given state is one that transitions to a new state 296 // Returns true if the given state is one that transitions to a new state
294 // after iterating through each filter. 297 // after iterating through each filter.
295 static bool TransientState(State state); 298 static bool TransientState(State state);
296 299
297 // Given the current state, returns the next state. 300 // Given the current state, returns the next state.
298 State FindNextState(State current); 301 State FindNextState(State current);
299 302
300 // DataSourceHost (by way of DemuxerHost) implementation. 303 // DataSourceHost (by way of DemuxerHost) implementation.
301 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; 304 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
302 virtual void SetBufferedBytes(int64 buffered_bytes) OVERRIDE; 305 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE;
303 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE; 306 virtual void SetNetworkActivity(bool is_downloading_data) OVERRIDE;
304 307
305 // DemuxerHost implementaion. 308 // DemuxerHost implementaion.
306 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; 309 virtual void SetDuration(base::TimeDelta duration) OVERRIDE;
307 virtual void SetCurrentReadPosition(int64 offset) OVERRIDE;
308 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; 310 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE;
309 311
310 // FilterHost implementation. 312 // FilterHost implementation.
311 virtual void SetError(PipelineStatus error) OVERRIDE; 313 virtual void SetError(PipelineStatus error) OVERRIDE;
312 virtual base::TimeDelta GetTime() const OVERRIDE; 314 virtual base::TimeDelta GetTime() const OVERRIDE;
313 virtual base::TimeDelta GetDuration() const OVERRIDE; 315 virtual base::TimeDelta GetDuration() const OVERRIDE;
314 virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE; 316 virtual void SetNaturalVideoSize(const gfx::Size& size) OVERRIDE;
315 virtual void NotifyEnded() OVERRIDE; 317 virtual void NotifyEnded() OVERRIDE;
316 virtual void DisableAudioRenderer() OVERRIDE; 318 virtual void DisableAudioRenderer() OVERRIDE;
317 319
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // state first. 418 // state first.
417 // 2. when pipeline has been initialized, we will first transit to pausing 419 // 2. when pipeline has been initialized, we will first transit to pausing
418 // => flushing => stopping => stopped state. 420 // => flushing => stopping => stopped state.
419 // This will remove the race condition during stop between filters. 421 // This will remove the race condition during stop between filters.
420 void TearDownPipeline(); 422 void TearDownPipeline();
421 423
422 // Compute the current time. Assumes that the lock has been acquired by the 424 // Compute the current time. Assumes that the lock has been acquired by the
423 // caller. 425 // caller.
424 base::TimeDelta GetCurrentTime_Locked() const; 426 base::TimeDelta GetCurrentTime_Locked() const;
425 427
426 // Update internal records of which time ranges are buffered. 428 // Compute the time corresponding to a byte offset.
427 void UpdateBufferedTimeRanges_Locked(); 429 base::TimeDelta TimeForByteOffset_Locked(int64 byte_offset) const;
428 430
429 // Initiates a Stop() on |demuxer_| & |pipeline_filter_|. |callback| 431 // Initiates a Stop() on |demuxer_| & |pipeline_filter_|. |callback|
430 // is called once both objects have been stopped. 432 // is called once both objects have been stopped.
431 void DoStop(const base::Closure& callback); 433 void DoStop(const base::Closure& callback);
432 434
433 // Called when |demuxer_| has stopped. This method calls Stop() 435 // Called when |demuxer_| has stopped. This method calls Stop()
434 // on |pipeline_filter_|. 436 // on |pipeline_filter_|.
435 void OnDemuxerStopDone(const base::Closure& callback); 437 void OnDemuxerStopDone(const base::Closure& callback);
436 438
437 // Initiates a Seek() on the |demuxer_| & |pipeline_filter_|. 439 // Initiates a Seek() on the |demuxer_| & |pipeline_filter_|.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 471
470 // Whether or not the pipeline is perform a stop operation. 472 // Whether or not the pipeline is perform a stop operation.
471 bool tearing_down_; 473 bool tearing_down_;
472 474
473 // Whether or not an error triggered the teardown. 475 // Whether or not an error triggered the teardown.
474 bool error_caused_teardown_; 476 bool error_caused_teardown_;
475 477
476 // Whether or not a playback rate change should be done once seeking is done. 478 // Whether or not a playback rate change should be done once seeking is done.
477 bool playback_rate_change_pending_; 479 bool playback_rate_change_pending_;
478 480
479 // Amount of available buffered data. Set by filters. 481 // Amount of available buffered data.
480 int64 buffered_bytes_; 482 Ranges<int64> buffered_byte_ranges_;
481
482 // Approximate time ranges of buffered media.
483 Ranges<base::TimeDelta> buffered_time_ranges_;
484 483
485 // Total size of the media. Set by filters. 484 // Total size of the media. Set by filters.
486 int64 total_bytes_; 485 int64 total_bytes_;
487 486
488 // Video's natural width and height. Set by filters. 487 // Video's natural width and height. Set by filters.
489 gfx::Size natural_size_; 488 gfx::Size natural_size_;
490 489
491 // Current volume level (from 0.0f to 1.0f). This value is set immediately 490 // Current volume level (from 0.0f to 1.0f). This value is set immediately
492 // via SetVolume() and a task is dispatched on the message loop to notify the 491 // via SetVolume() and a task is dispatched on the message loop to notify the
493 // filters. 492 // filters.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 // The following data members are only accessed by tasks posted to 526 // The following data members are only accessed by tasks posted to
528 // |message_loop_|. 527 // |message_loop_|.
529 528
530 // Member that tracks the current state. 529 // Member that tracks the current state.
531 State state_; 530 State state_;
532 531
533 // For kSeeking we need to remember where we're seeking between filter 532 // For kSeeking we need to remember where we're seeking between filter
534 // replies. 533 // replies.
535 base::TimeDelta seek_timestamp_; 534 base::TimeDelta seek_timestamp_;
536 535
537 // For GetCurrentBytes()/SetCurrentBytes() we need to know what byte we are
538 // currently reading.
539 int64 current_bytes_;
540
541 // Set to true in DisableAudioRendererTask(). 536 // Set to true in DisableAudioRendererTask().
542 bool audio_disabled_; 537 bool audio_disabled_;
543 538
544 // Filter collection as passed in by Start(). 539 // Filter collection as passed in by Start().
545 scoped_ptr<FilterCollection> filter_collection_; 540 scoped_ptr<FilterCollection> filter_collection_;
546 541
547 // Callbacks for various pipeline operations. 542 // Callbacks for various pipeline operations.
548 PipelineStatusCB seek_cb_; 543 PipelineStatusCB seek_cb_;
549 base::Closure stop_cb_; 544 base::Closure stop_cb_;
550 PipelineStatusCB ended_cb_; 545 PipelineStatusCB ended_cb_;
(...skipping 29 matching lines...) Expand all
580 // Time of pipeline creation; is non-zero only until the pipeline first 575 // Time of pipeline creation; is non-zero only until the pipeline first
581 // reaches "kStarted", at which point it is used & zeroed out. 576 // reaches "kStarted", at which point it is used & zeroed out.
582 base::Time creation_time_; 577 base::Time creation_time_;
583 578
584 DISALLOW_COPY_AND_ASSIGN(Pipeline); 579 DISALLOW_COPY_AND_ASSIGN(Pipeline);
585 }; 580 };
586 581
587 } // namespace media 582 } // namespace media
588 583
589 #endif // MEDIA_BASE_PIPELINE_H_ 584 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « media/base/mock_demuxer_host.h ('k') | media/base/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698