Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 2477513003: media: Increase preloading and max buffer for high-bitrate videos (Closed)
Patch Set: logic simplified, test added Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/multibuffer_data_source.cc ('k') | media/blink/multibuffer_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 int64_t preload_high() { 460 int64_t preload_high() {
461 CHECK(loader()); 461 CHECK(loader());
462 return loader()->preload_high(); 462 return loader()->preload_high();
463 } 463 }
464 int64_t preload_low() { 464 int64_t preload_low() {
465 CHECK(loader()); 465 CHECK(loader());
466 return loader()->preload_low(); 466 return loader()->preload_low();
467 } 467 }
468 int data_source_bitrate() { return data_source_->bitrate_; } 468 int data_source_bitrate() { return data_source_->bitrate_; }
469 int64_t max_buffer_forward() { return loader()->max_buffer_forward_; }
470 int64_t max_buffer_backward() { return loader()->max_buffer_backward_; }
471 int64_t buffer_size() {
472 return loader()->current_buffer_size_ * 32768 /* block size */;
473 }
469 double data_source_playback_rate() { return data_source_->playback_rate_; } 474 double data_source_playback_rate() { return data_source_->playback_rate_; }
470 bool is_local_source() { return data_source_->assume_fully_buffered(); } 475 bool is_local_source() { return data_source_->assume_fully_buffered(); }
471 scoped_refptr<UrlData> url_data() { return data_source_->url_data_; } 476 scoped_refptr<UrlData> url_data() { return data_source_->url_data_; }
472 void set_might_be_reused_from_cache_in_future(bool value) { 477 void set_might_be_reused_from_cache_in_future(bool value) {
473 url_data()->set_cacheable(value); 478 url_data()->set_cacheable(value);
474 } 479 }
475 480
476 protected: 481 protected:
477 blink::WebFrameClient client_; 482 blink::WebFrameClient client_;
478 WebView* view_; 483 WebView* view_;
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 WebURLResponse response = response_generator_->Generate206(0); 1536 WebURLResponse response = response_generator_->Generate206(0);
1532 const std::string etag("\"arglebargle glop-glyf?\""); 1537 const std::string etag("\"arglebargle glop-glyf?\"");
1533 response.setHTTPHeaderField(WebString::fromUTF8("Etag"), 1538 response.setHTTPHeaderField(WebString::fromUTF8("Etag"),
1534 WebString::fromUTF8(etag)); 1539 WebString::fromUTF8(etag));
1535 Respond(response); 1540 Respond(response);
1536 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); 1541 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
1537 ReceiveData(kDataSize); 1542 ReceiveData(kDataSize);
1538 1543
1539 EXPECT_EQ(url_data()->etag(), etag); 1544 EXPECT_EQ(url_data()->etag(), etag);
1540 } 1545 }
1546
1547 TEST_F(MultibufferDataSourceTest, CheckBufferSizes) {
1548 InitializeWith206Response();
1549
1550 data_source_->SetBitrate(1 << 20); // 1 mbit / s
1551 base::RunLoop().RunUntilIdle();
1552 EXPECT_EQ(1 << 20, data_source_bitrate());
1553 EXPECT_EQ(2 << 20, preload_low());
1554 EXPECT_EQ(3 << 20, preload_high());
1555 EXPECT_EQ(25 << 20, max_buffer_forward());
1556 EXPECT_EQ(2 << 20, max_buffer_backward());
1557 EXPECT_EQ(1572864 /* 1.5Mb */, buffer_size());
1558
1559 data_source_->SetBitrate(8 << 20); // 8 mbit / s
1560 base::RunLoop().RunUntilIdle();
1561 EXPECT_EQ(8 << 20, data_source_bitrate());
1562 EXPECT_EQ(10 << 20, preload_low());
1563 EXPECT_EQ(11 << 20, preload_high());
1564 EXPECT_EQ(25 << 20, max_buffer_forward());
1565 EXPECT_EQ(2 << 20, max_buffer_backward());
1566 EXPECT_EQ(12 << 20, buffer_size());
1567
1568 data_source_->SetBitrate(16 << 20); // 16 mbit / s
1569 base::RunLoop().RunUntilIdle();
1570 EXPECT_EQ(16 << 20, data_source_bitrate());
1571 EXPECT_EQ(20 << 20, preload_low());
1572 EXPECT_EQ(21 << 20, preload_high());
1573 EXPECT_EQ(25 << 20, max_buffer_forward());
1574 EXPECT_EQ(4 << 20, max_buffer_backward());
1575 EXPECT_EQ(24 << 20, buffer_size());
1576
1577 data_source_->SetBitrate(32 << 20); // 32 mbit / s
1578 base::RunLoop().RunUntilIdle();
1579 EXPECT_EQ(32 << 20, data_source_bitrate());
1580 EXPECT_EQ(40 << 20, preload_low());
1581 EXPECT_EQ(41 << 20, preload_high());
1582 EXPECT_EQ(41 << 20, max_buffer_forward());
1583 EXPECT_EQ(8 << 20, max_buffer_backward());
1584 EXPECT_EQ(48 << 20, buffer_size());
1585
1586 data_source_->SetBitrate(80 << 20); // 80 mbit / s
1587 base::RunLoop().RunUntilIdle();
1588 EXPECT_EQ(80 << 20, data_source_bitrate());
1589 EXPECT_EQ(50 << 20, preload_low());
1590 EXPECT_EQ(51 << 20, preload_high());
1591 EXPECT_EQ(51 << 20, max_buffer_forward());
1592 EXPECT_EQ(20 << 20, max_buffer_backward());
1593 EXPECT_EQ(71 << 20, buffer_size());
1594 }
1595
1541 } // namespace media 1596 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source.cc ('k') | media/blink/multibuffer_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698