| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 const AVRational& time_base, int64 timestamp) { | 232 const AVRational& time_base, int64 timestamp) { |
| 233 if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) | 233 if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) |
| 234 return kNoTimestamp; | 234 return kNoTimestamp; |
| 235 | 235 |
| 236 return ConvertTimestamp(time_base, timestamp); | 236 return ConvertTimestamp(time_base, timestamp); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // | 239 // |
| 240 // FFmpegDemuxer | 240 // FFmpegDemuxer |
| 241 // | 241 // |
| 242 FFmpegDemuxer::FFmpegDemuxer() | 242 FFmpegDemuxer::FFmpegDemuxer(MessageLoop* message_loop) |
| 243 : format_context_(NULL), | 243 : message_loop_(message_loop), |
| 244 format_context_(NULL), |
| 244 read_event_(false, false), | 245 read_event_(false, false), |
| 245 read_has_failed_(false), | 246 read_has_failed_(false), |
| 246 last_read_bytes_(0), | 247 last_read_bytes_(0), |
| 247 read_position_(0) { | 248 read_position_(0) { |
| 249 DCHECK(message_loop_); |
| 248 } | 250 } |
| 249 | 251 |
| 250 FFmpegDemuxer::~FFmpegDemuxer() { | 252 FFmpegDemuxer::~FFmpegDemuxer() { |
| 251 // In this destructor, we clean up resources held by FFmpeg. It is ugly to | 253 // In this destructor, we clean up resources held by FFmpeg. It is ugly to |
| 252 // close the codec contexts here because the corresponding codecs are opened | 254 // close the codec contexts here because the corresponding codecs are opened |
| 253 // in the decoder filters. By reaching this point, all filters should have | 255 // in the decoder filters. By reaching this point, all filters should have |
| 254 // stopped, so this is the only safe place to do the global clean up. | 256 // stopped, so this is the only safe place to do the global clean up. |
| 255 // TODO(hclam): close the codecs in the corresponding decoders. | 257 // TODO(hclam): close the codecs in the corresponding decoders. |
| 256 if (!format_context_) | 258 if (!format_context_) |
| 257 return; | 259 return; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 386 |
| 385 return data_source_->GetSize(size_out); | 387 return data_source_->GetSize(size_out); |
| 386 } | 388 } |
| 387 | 389 |
| 388 bool FFmpegDemuxer::IsStreaming() { | 390 bool FFmpegDemuxer::IsStreaming() { |
| 389 DCHECK(data_source_); | 391 DCHECK(data_source_); |
| 390 | 392 |
| 391 return data_source_->IsStreaming(); | 393 return data_source_->IsStreaming(); |
| 392 } | 394 } |
| 393 | 395 |
| 396 MessageLoop* FFmpegDemuxer::message_loop() { |
| 397 return message_loop_; |
| 398 } |
| 399 |
| 394 void FFmpegDemuxer::InitializeTask(DataSource* data_source, | 400 void FFmpegDemuxer::InitializeTask(DataSource* data_source, |
| 395 FilterCallback* callback) { | 401 FilterCallback* callback) { |
| 396 DCHECK_EQ(MessageLoop::current(), message_loop()); | 402 DCHECK_EQ(MessageLoop::current(), message_loop()); |
| 397 scoped_ptr<FilterCallback> c(callback); | 403 scoped_ptr<FilterCallback> c(callback); |
| 398 | 404 |
| 399 data_source_ = data_source; | 405 data_source_ = data_source; |
| 400 | 406 |
| 401 // Add ourself to Protocol list and get our unique key. | 407 // Add ourself to Protocol list and get our unique key. |
| 402 std::string key = FFmpegGlue::GetInstance()->AddProtocol(this); | 408 std::string key = FFmpegGlue::GetInstance()->AddProtocol(this); |
| 403 | 409 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 read_event_.Wait(); | 620 read_event_.Wait(); |
| 615 return last_read_bytes_; | 621 return last_read_bytes_; |
| 616 } | 622 } |
| 617 | 623 |
| 618 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 624 void FFmpegDemuxer::SignalReadCompleted(size_t size) { |
| 619 last_read_bytes_ = size; | 625 last_read_bytes_ = size; |
| 620 read_event_.Signal(); | 626 read_event_.Signal(); |
| 621 } | 627 } |
| 622 | 628 |
| 623 } // namespace media | 629 } // namespace media |
| OLD | NEW |