 Chromium Code Reviews
 Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/callback.h" | 5 #include "base/callback.h" | 
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" | 
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" | 
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" | 
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" | 
| 10 #include "base/time.h" | 10 #include "base/time.h" | 
| 11 #include "media/base/filter_host.h" | 11 #include "media/base/filter_host.h" | 
| 12 #include "media/base/limits.h" | |
| 12 #include "media/base/media_switches.h" | 13 #include "media/base/media_switches.h" | 
| 13 #include "media/ffmpeg/ffmpeg_common.h" | 14 #include "media/ffmpeg/ffmpeg_common.h" | 
| 14 #include "media/ffmpeg/ffmpeg_util.h" | 15 #include "media/ffmpeg/ffmpeg_util.h" | 
| 15 #include "media/filters/bitstream_converter.h" | 16 #include "media/filters/bitstream_converter.h" | 
| 16 #include "media/filters/ffmpeg_demuxer.h" | 17 #include "media/filters/ffmpeg_demuxer.h" | 
| 17 #include "media/filters/ffmpeg_glue.h" | 18 #include "media/filters/ffmpeg_glue.h" | 
| 18 | 19 | 
| 19 namespace media { | 20 namespace media { | 
| 20 | 21 | 
| 21 // | 22 // | 
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 callback->Run(); | 463 callback->Run(); | 
| 463 return; | 464 return; | 
| 464 } | 465 } | 
| 465 if (format_context_->duration != static_cast<int64_t>(AV_NOPTS_VALUE)) { | 466 if (format_context_->duration != static_cast<int64_t>(AV_NOPTS_VALUE)) { | 
| 466 // If there is a duration value in the container use that to find the | 467 // If there is a duration value in the container use that to find the | 
| 467 // maximum between it and the duration from A/V streams. | 468 // maximum between it and the duration from A/V streams. | 
| 468 const AVRational av_time_base = {1, AV_TIME_BASE}; | 469 const AVRational av_time_base = {1, AV_TIME_BASE}; | 
| 469 max_duration = | 470 max_duration = | 
| 470 std::max(max_duration, | 471 std::max(max_duration, | 
| 471 ConvertTimestamp(av_time_base, format_context_->duration)); | 472 ConvertTimestamp(av_time_base, format_context_->duration)); | 
| 473 } else { | |
| 474 // If the duration is not a valid value. Assume that this is a live stream | |
| 475 // and we set duration to the maximum int64 number to represent infinity. | |
| 476 max_duration = base::TimeDelta::FromMicroseconds( | |
| 477 Limits::kMaxTimeInMicroseconds); | |
| 472 } | 478 } | 
| 479 | |
| 
fgalligan1
2010/08/03 14:17:38
Would it be better to check if max_duration == AV_
 | |
| 473 // Good to go: set the duration and notify we're done initializing. | 480 // Good to go: set the duration and notify we're done initializing. | 
| 474 host()->SetDuration(max_duration); | 481 host()->SetDuration(max_duration); | 
| 475 callback->Run(); | 482 callback->Run(); | 
| 476 } | 483 } | 
| 477 | 484 | 
| 478 void FFmpegDemuxer::SeekTask(base::TimeDelta time, FilterCallback* callback) { | 485 void FFmpegDemuxer::SeekTask(base::TimeDelta time, FilterCallback* callback) { | 
| 479 DCHECK_EQ(MessageLoop::current(), message_loop()); | 486 DCHECK_EQ(MessageLoop::current(), message_loop()); | 
| 480 scoped_ptr<FilterCallback> c(callback); | 487 scoped_ptr<FilterCallback> c(callback); | 
| 481 | 488 | 
| 482 // Tell streams to flush buffers due to seeking. | 489 // Tell streams to flush buffers due to seeking. | 
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 read_event_.Wait(); | 625 read_event_.Wait(); | 
| 619 return last_read_bytes_; | 626 return last_read_bytes_; | 
| 620 } | 627 } | 
| 621 | 628 | 
| 622 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 629 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 
| 623 last_read_bytes_ = size; | 630 last_read_bytes_ = size; | 
| 624 read_event_.Signal(); | 631 read_event_.Signal(); | 
| 625 } | 632 } | 
| 626 | 633 | 
| 627 } // namespace media | 634 } // namespace media | 
| OLD | NEW |