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 "webkit/media/buffered_data_source.h" | 5 #include "webkit/media/buffered_data_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "media/base/filter_host.h" | 8 #include "media/base/filter_host.h" |
9 #include "media/base/media_log.h" | 9 #include "media/base/media_log.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "webkit/media/web_data_source_factory.h" | 11 #include "webkit/media/web_data_source_factory.h" |
12 #include "webkit/glue/webkit_glue.h" | |
13 | 12 |
14 using WebKit::WebFrame; | 13 using WebKit::WebFrame; |
15 | 14 |
16 namespace webkit_media { | 15 namespace webkit_media { |
17 | 16 |
18 // BufferedDataSource has an intermediate buffer, this value governs the initial | 17 // BufferedDataSource has an intermediate buffer, this value governs the initial |
19 // size of that buffer. It is set to 32KB because this is a typical read size | 18 // size of that buffer. It is set to 32KB because this is a typical read size |
20 // of FFmpeg. | 19 // of FFmpeg. |
21 static const int kInitialReadBufferSize = 32768; | 20 static const int kInitialReadBufferSize = 32768; |
22 | 21 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 97 |
99 void BufferedDataSource::Initialize(const std::string& url, | 98 void BufferedDataSource::Initialize(const std::string& url, |
100 const media::PipelineStatusCB& callback) { | 99 const media::PipelineStatusCB& callback) { |
101 // Saves the url. | 100 // Saves the url. |
102 url_ = GURL(url); | 101 url_ = GURL(url); |
103 | 102 |
104 // This data source doesn't support data:// protocol so reject it. | 103 // This data source doesn't support data:// protocol so reject it. |
105 if (url_.SchemeIs(kDataScheme)) { | 104 if (url_.SchemeIs(kDataScheme)) { |
106 callback.Run(media::DATASOURCE_ERROR_URL_NOT_SUPPORTED); | 105 callback.Run(media::DATASOURCE_ERROR_URL_NOT_SUPPORTED); |
107 return; | 106 return; |
108 } else if (!webkit_glue::IsProtocolSupportedForMedia(url_)) { | |
109 callback.Run(media::PIPELINE_ERROR_NETWORK); | |
110 return; | |
111 } | 107 } |
112 | 108 |
113 DCHECK(!callback.is_null()); | 109 DCHECK(!callback.is_null()); |
114 { | 110 { |
115 base::AutoLock auto_lock(lock_); | 111 base::AutoLock auto_lock(lock_); |
116 initialize_cb_ = callback; | 112 initialize_cb_ = callback; |
117 } | 113 } |
118 | 114 |
119 // Post a task to complete the initialization task. | 115 // Post a task to complete the initialization task. |
120 render_loop_->PostTask(FROM_HERE, | 116 render_loop_->PostTask(FROM_HERE, |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 661 |
666 if (streaming_) | 662 if (streaming_) |
667 filter_host->SetStreaming(true); | 663 filter_host->SetStreaming(true); |
668 | 664 |
669 if (total_bytes_ != kPositionNotSpecified) | 665 if (total_bytes_ != kPositionNotSpecified) |
670 filter_host->SetTotalBytes(total_bytes_); | 666 filter_host->SetTotalBytes(total_bytes_); |
671 filter_host->SetBufferedBytes(buffered_bytes_); | 667 filter_host->SetBufferedBytes(buffered_bytes_); |
672 } | 668 } |
673 | 669 |
674 } // namespace webkit_media | 670 } // namespace webkit_media |
OLD | NEW |