| 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 16 matching lines...) Expand all Loading... |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 FilePath file_path(UTF8ToWide(url)); | 28 FilePath file_path(UTF8ToWide(url)); |
| 29 #else | 29 #else |
| 30 FilePath file_path(url); | 30 FilePath file_path(url); |
| 31 #endif | 31 #endif |
| 32 if (file_util::GetFileSize(file_path, &file_size_)) { | 32 if (file_util::GetFileSize(file_path, &file_size_)) { |
| 33 file_ = file_util::OpenFile(file_path, "rb"); | 33 file_ = file_util::OpenFile(file_path, "rb"); |
| 34 } | 34 } |
| 35 if (!file_) { | 35 if (!file_) { |
| 36 file_size_ = 0; | 36 file_size_ = 0; |
| 37 host()->Error(PIPELINE_ERROR_URL_NOT_FOUND); | 37 host()->SetError(PIPELINE_ERROR_URL_NOT_FOUND); |
| 38 callback->Run(); | 38 callback->Run(); |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 media_format_.SetAsString(MediaFormat::kMimeType, | 41 media_format_.SetAsString(MediaFormat::kMimeType, |
| 42 mime_type::kApplicationOctetStream); | 42 mime_type::kApplicationOctetStream); |
| 43 media_format_.SetAsString(MediaFormat::kURL, url); | 43 media_format_.SetAsString(MediaFormat::kURL, url); |
| 44 host()->SetTotalBytes(file_size_); | 44 host()->SetTotalBytes(file_size_); |
| 45 host()->SetBufferedBytes(file_size_); | 45 host()->SetBufferedBytes(file_size_); |
| 46 callback->Run(); | 46 callback->Run(); |
| 47 } | 47 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 *size_out = file_size_; | 112 *size_out = file_size_; |
| 113 return (NULL != file_); | 113 return (NULL != file_); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool FileDataSource::IsSeekable() { | 116 bool FileDataSource::IsSeekable() { |
| 117 // A file data source is always seekable. | 117 // A file data source is always seekable. |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace media | 121 } // namespace media |
| OLD | NEW |