OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 8 #include "base/message_loop.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 | 11 |
12 using WebKit::WebFrame; | 12 using WebKit::WebFrame; |
13 | 13 |
14 namespace webkit_media { | 14 namespace webkit_media { |
15 | 15 |
16 // BufferedDataSource has an intermediate buffer, this value governs the initial | 16 // BufferedDataSource has an intermediate buffer, this value governs the initial |
17 // size of that buffer. It is set to 32KB because this is a typical read size | 17 // size of that buffer. It is set to 32KB because this is a typical read size |
18 // of FFmpeg. | 18 // of FFmpeg. |
19 static const int kInitialReadBufferSize = 32768; | 19 static const int kInitialReadBufferSize = 32768; |
20 | 20 |
21 // Number of cache misses we allow for a single Read() before signalling an | 21 // Number of cache misses we allow for a single Read() before signalling an |
22 // error. | 22 // error. |
23 static const int kNumCacheMissRetries = 3; | 23 static const int kNumCacheMissRetries = 3; |
24 | 24 |
25 BufferedDataSource::BufferedDataSource( | 25 BufferedDataSource::BufferedDataSource( |
26 MessageLoop* render_loop, | 26 MessageLoop* render_loop, |
27 WebFrame* frame, | 27 WebFrame* frame, |
28 media::MediaLog* media_log) | 28 media::MediaLog* media_log) |
29 : total_bytes_(kPositionNotSpecified), | 29 : cors_mode_(BufferedResourceLoader::kUnspecified), |
| 30 total_bytes_(kPositionNotSpecified), |
30 buffered_bytes_(0), | 31 buffered_bytes_(0), |
31 streaming_(false), | 32 streaming_(false), |
32 frame_(frame), | 33 frame_(frame), |
33 loader_(NULL), | 34 loader_(NULL), |
34 is_downloading_data_(false), | 35 is_downloading_data_(false), |
35 read_size_(0), | 36 read_size_(0), |
36 read_buffer_(NULL), | 37 read_buffer_(NULL), |
37 last_read_start_(0), | 38 last_read_start_(0), |
38 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]), | 39 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]), |
39 intermediate_read_buffer_size_(kInitialReadBufferSize), | 40 intermediate_read_buffer_size_(kInitialReadBufferSize), |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 return; | 588 return; |
588 | 589 |
589 if (total_bytes_ != kPositionNotSpecified) | 590 if (total_bytes_ != kPositionNotSpecified) |
590 host()->SetTotalBytes(total_bytes_); | 591 host()->SetTotalBytes(total_bytes_); |
591 int64 start = loader_->first_byte_position(); | 592 int64 start = loader_->first_byte_position(); |
592 if (buffered_bytes_ > start) | 593 if (buffered_bytes_ > start) |
593 host()->AddBufferedByteRange(start, buffered_bytes_); | 594 host()->AddBufferedByteRange(start, buffered_bytes_); |
594 } | 595 } |
595 | 596 |
596 } // namespace webkit_media | 597 } // namespace webkit_media |
OLD | NEW |