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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 const AVRational& time_base, int64 timestamp) { | 270 const AVRational& time_base, int64 timestamp) { |
271 if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) | 271 if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) |
272 return kNoTimestamp; | 272 return kNoTimestamp; |
273 | 273 |
274 return ConvertFromTimeBase(time_base, timestamp); | 274 return ConvertFromTimeBase(time_base, timestamp); |
275 } | 275 } |
276 | 276 |
277 // | 277 // |
278 // FFmpegDemuxer | 278 // FFmpegDemuxer |
279 // | 279 // |
280 FFmpegDemuxer::FFmpegDemuxer(MessageLoop* message_loop) | 280 FFmpegDemuxer::FFmpegDemuxer(MessageLoop* message_loop, bool local_source) |
281 : message_loop_(message_loop), | 281 : message_loop_(message_loop), |
| 282 local_source_(local_source), |
282 format_context_(NULL), | 283 format_context_(NULL), |
283 read_event_(false, false), | 284 read_event_(false, false), |
284 read_has_failed_(false), | 285 read_has_failed_(false), |
285 last_read_bytes_(0), | 286 last_read_bytes_(0), |
286 read_position_(0), | 287 read_position_(0), |
287 max_duration_(base::TimeDelta::FromMicroseconds(-1)), | 288 max_duration_(base::TimeDelta::FromMicroseconds(-1)), |
288 deferred_status_(PIPELINE_OK), | 289 deferred_status_(PIPELINE_OK), |
289 first_seek_hack_(true), | 290 first_seek_hack_(true), |
290 start_time_(kNoTimestamp) { | 291 start_time_(kNoTimestamp) { |
291 DCHECK(message_loop_); | 292 DCHECK(message_loop_); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 max_duration_.InMicroseconds() < Limits::kMaxTimeInMicroseconds) { | 565 max_duration_.InMicroseconds() < Limits::kMaxTimeInMicroseconds) { |
565 int64 filesize_in_bytes; | 566 int64 filesize_in_bytes; |
566 if (GetSize(&filesize_in_bytes)) | 567 if (GetSize(&filesize_in_bytes)) |
567 return 8000 * filesize_in_bytes / max_duration_.InMilliseconds(); | 568 return 8000 * filesize_in_bytes / max_duration_.InMilliseconds(); |
568 } | 569 } |
569 | 570 |
570 // Bitrate could not be determined. | 571 // Bitrate could not be determined. |
571 return 0; | 572 return 0; |
572 } | 573 } |
573 | 574 |
| 575 bool FFmpegDemuxer::IsLocalSource() { |
| 576 return local_source_; |
| 577 } |
| 578 |
| 579 bool FFmpegDemuxer::IsSeekable() { |
| 580 return !IsStreaming(); |
| 581 } |
| 582 |
574 void FFmpegDemuxer::SeekTask(base::TimeDelta time, const FilterStatusCB& cb) { | 583 void FFmpegDemuxer::SeekTask(base::TimeDelta time, const FilterStatusCB& cb) { |
575 DCHECK_EQ(MessageLoop::current(), message_loop_); | 584 DCHECK_EQ(MessageLoop::current(), message_loop_); |
576 | 585 |
577 // TODO(scherkus): remove this by separating Seek() from Flush() from | 586 // TODO(scherkus): remove this by separating Seek() from Flush() from |
578 // Preroll() states (i.e., the implicit Seek(0) should really be a Preroll()). | 587 // Preroll() states (i.e., the implicit Seek(0) should really be a Preroll()). |
579 if (first_seek_hack_) { | 588 if (first_seek_hack_) { |
580 first_seek_hack_ = false; | 589 first_seek_hack_ = false; |
581 | 590 |
582 if (time == start_time_) { | 591 if (time == start_time_) { |
583 cb.Run(PIPELINE_OK); | 592 cb.Run(PIPELINE_OK); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 read_event_.Wait(); | 732 read_event_.Wait(); |
724 return last_read_bytes_; | 733 return last_read_bytes_; |
725 } | 734 } |
726 | 735 |
727 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 736 void FFmpegDemuxer::SignalReadCompleted(size_t size) { |
728 last_read_bytes_ = size; | 737 last_read_bytes_ = size; |
729 read_event_.Signal(); | 738 read_event_.Signal(); |
730 } | 739 } |
731 | 740 |
732 } // namespace media | 741 } // namespace media |
OLD | NEW |