| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "media/base/filter_host.h" | 7 #include "media/base/filter_host.h" |
| 8 #include "media/base/filters.h" | 8 #include "media/base/filters.h" |
| 9 #include "media/base/pipeline.h" | 9 #include "media/base/pipeline.h" |
| 10 #include "media/filters/file_data_source.h" | 10 #include "media/filters/file_data_source.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 26 FilePath file_path(UTF8ToWide(url)); | 26 FilePath file_path(UTF8ToWide(url)); |
| 27 #else | 27 #else |
| 28 FilePath file_path(url); | 28 FilePath file_path(url); |
| 29 #endif | 29 #endif |
| 30 if (file_util::GetFileSize(file_path, &file_size_)) { | 30 if (file_util::GetFileSize(file_path, &file_size_)) { |
| 31 file_ = file_util::OpenFile(file_path, "rb"); | 31 file_ = file_util::OpenFile(file_path, "rb"); |
| 32 } | 32 } |
| 33 if (!file_) { | 33 if (!file_) { |
| 34 file_size_ = 0; | 34 file_size_ = 0; |
| 35 host_->Error(PIPELINE_ERROR_URL_NOT_FOUND); | 35 host()->Error(PIPELINE_ERROR_URL_NOT_FOUND); |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 media_format_.SetAsString(MediaFormat::kMimeType, | 38 media_format_.SetAsString(MediaFormat::kMimeType, |
| 39 mime_type::kApplicationOctetStream); | 39 mime_type::kApplicationOctetStream); |
| 40 media_format_.SetAsString(MediaFormat::kURL, url); | 40 media_format_.SetAsString(MediaFormat::kURL, url); |
| 41 host_->SetTotalBytes(file_size_); | 41 host()->SetTotalBytes(file_size_); |
| 42 host_->SetBufferedBytes(file_size_); | 42 host()->SetBufferedBytes(file_size_); |
| 43 host_->InitializationComplete(); | 43 host()->InitializationComplete(); |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void FileDataSource::Stop() { | 47 void FileDataSource::Stop() { |
| 48 AutoLock l(lock_); | 48 AutoLock l(lock_); |
| 49 if (file_) { | 49 if (file_) { |
| 50 file_util::CloseFile(file_); | 50 file_util::CloseFile(file_); |
| 51 file_ = NULL; | 51 file_ = NULL; |
| 52 file_size_ = 0; | 52 file_size_ = 0; |
| 53 } | 53 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 *size_out = file_size_; | 110 *size_out = file_size_; |
| 111 return (NULL != file_); | 111 return (NULL != file_); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool FileDataSource::IsSeekable() { | 114 bool FileDataSource::IsSeekable() { |
| 115 // A file data source is always seekable. | 115 // A file data source is always seekable. |
| 116 return true; | 116 return true; |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace media | 119 } // namespace media |
| OLD | NEW |