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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 10837118: Dead code elimination: scythe.chrome_functions:segment.path %media% edition, round 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months 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 | Annotate | Revision Log
OLDNEW
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/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 return pipeline_->GetTotalBytes(); 507 return pipeline_->GetTotalBytes();
508 } 508 }
509 509
510 void WebMediaPlayerImpl::setSize(const WebSize& size) { 510 void WebMediaPlayerImpl::setSize(const WebSize& size) {
511 DCHECK_EQ(main_loop_, MessageLoop::current()); 511 DCHECK_EQ(main_loop_, MessageLoop::current());
512 512
513 // Don't need to do anything as we use the dimensions passed in via paint(). 513 // Don't need to do anything as we use the dimensions passed in via paint().
514 } 514 }
515 515
516 // This variant (without alpha) is just present during staging of this API
517 // change. Later we will again only have one virtual paint().
518 void WebMediaPlayerImpl::paint(WebKit::WebCanvas* canvas,
519 const WebKit::WebRect& rect) {
520 paint(canvas, rect, 0xFF);
521 }
522
523 void WebMediaPlayerImpl::paint(WebCanvas* canvas, 516 void WebMediaPlayerImpl::paint(WebCanvas* canvas,
524 const WebRect& rect, 517 const WebRect& rect,
525 uint8_t alpha) { 518 uint8_t alpha) {
526 DCHECK_EQ(main_loop_, MessageLoop::current()); 519 DCHECK_EQ(main_loop_, MessageLoop::current());
527 DCHECK(proxy_); 520 DCHECK(proxy_);
528 521
529 if (!accelerated_compositing_reported_) { 522 if (!accelerated_compositing_reported_) {
530 accelerated_compositing_reported_ = true; 523 accelerated_compositing_reported_ = true;
531 // Normally paint() is only called in non-accelerated rendering, but there 524 // Normally paint() is only called in non-accelerated rendering, but there
532 // are exceptions such as webgl where compositing is used in the WebView but 525 // are exceptions such as webgl where compositing is used in the WebView but
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \ 611 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \
619 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayer::webkit_name) == \ 612 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayer::webkit_name) == \
620 static_cast<int>(media::ChunkDemuxer::chromium_name), \ 613 static_cast<int>(media::ChunkDemuxer::chromium_name), \
621 mismatching_status_enums) 614 mismatching_status_enums)
622 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusOk, kOk); 615 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusOk, kOk);
623 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusNotSupported, kNotSupported); 616 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusNotSupported, kNotSupported);
624 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusReachedIdLimit, kReachedIdLimit); 617 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusReachedIdLimit, kReachedIdLimit);
625 618
626 WebKit::WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId( 619 WebKit::WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId(
627 const WebKit::WebString& id, 620 const WebKit::WebString& id,
628 const WebKit::WebString& type) {
629 DCHECK_EQ(main_loop_, MessageLoop::current());
630
631 WebKit::WebString kDefaultSourceType("video/webm; codecs=\"vp8, vorbis\"");
632
633 if (type != kDefaultSourceType)
634 return WebKit::WebMediaPlayer::AddIdStatusNotSupported;
635
636 WebKit::WebVector<WebKit::WebString> codecs(static_cast<size_t>(2));
637 codecs[0] = "vp8";
638 codecs[1] = "vorbis";
639 return sourceAddId(id, "video/webm", codecs);
640 }
641
642 WebKit::WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId(
643 const WebKit::WebString& id,
644 const WebKit::WebString& type, 621 const WebKit::WebString& type,
645 const WebKit::WebVector<WebKit::WebString>& codecs) { 622 const WebKit::WebVector<WebKit::WebString>& codecs) {
646 DCHECK_EQ(main_loop_, MessageLoop::current()); 623 DCHECK_EQ(main_loop_, MessageLoop::current());
647 std::vector<std::string> new_codecs(codecs.size()); 624 std::vector<std::string> new_codecs(codecs.size());
648 for (size_t i = 0; i < codecs.size(); ++i) 625 for (size_t i = 0; i < codecs.size(); ++i)
649 new_codecs[i] = codecs[i].utf8().data(); 626 new_codecs[i] = codecs[i].utf8().data();
650 627
651 return static_cast<WebKit::WebMediaPlayer::AddIdStatus>( 628 return static_cast<WebKit::WebMediaPlayer::AddIdStatus>(
652 proxy_->DemuxerAddId(id.utf8().data(), type.utf8().data(), 629 proxy_->DemuxerAddId(id.utf8().data(), type.utf8().data(),
653 new_codecs)); 630 new_codecs));
654 } 631 }
655 632
656 bool WebMediaPlayerImpl::sourceTimestampOffset(
657 const WebKit::WebString& id, double offset) {
658 return proxy_->DemuxerSetTimestampOffset(id.utf8().data(), offset);
659 }
660
661 bool WebMediaPlayerImpl::sourceRemoveId(const WebKit::WebString& id) { 633 bool WebMediaPlayerImpl::sourceRemoveId(const WebKit::WebString& id) {
662 DCHECK(!id.isEmpty()); 634 DCHECK(!id.isEmpty());
663 proxy_->DemuxerRemoveId(id.utf8().data()); 635 proxy_->DemuxerRemoveId(id.utf8().data());
664 return true; 636 return true;
665 } 637 }
666 638
667 WebKit::WebTimeRanges WebMediaPlayerImpl::sourceBuffered( 639 WebKit::WebTimeRanges WebMediaPlayerImpl::sourceBuffered(
668 const WebKit::WebString& id) { 640 const WebKit::WebString& id) {
669 return ConvertToWebTimeRanges(proxy_->DemuxerBufferedRange(id.utf8().data())); 641 return ConvertToWebTimeRanges(proxy_->DemuxerBufferedRange(id.utf8().data()));
670 } 642 }
671 643
672 bool WebMediaPlayerImpl::sourceAppend(const unsigned char* data,
673 unsigned length) {
674 return sourceAppend(WebKit::WebString::fromUTF8("DefaultSourceId"),
675 data, length);
676 }
677
678 bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, 644 bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id,
679 const unsigned char* data, 645 const unsigned char* data,
680 unsigned length) { 646 unsigned length) {
681 DCHECK_EQ(main_loop_, MessageLoop::current()); 647 DCHECK_EQ(main_loop_, MessageLoop::current());
682 648
683 float old_duration = duration(); 649 float old_duration = duration();
684 if (!proxy_->DemuxerAppend(id.utf8().data(), data, length)) 650 if (!proxy_->DemuxerAppend(id.utf8().data(), data, length))
685 return false; 651 return false;
686 652
687 if (old_duration != duration()) 653 if (old_duration != duration())
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 return audio_source_provider_; 1030 return audio_source_provider_;
1065 } 1031 }
1066 1032
1067 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 1033 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
1068 DCHECK_EQ(main_loop_, MessageLoop::current()); 1034 DCHECK_EQ(main_loop_, MessageLoop::current());
1069 incremented_externally_allocated_memory_ = true; 1035 incremented_externally_allocated_memory_ = true;
1070 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 1036 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
1071 } 1037 }
1072 1038
1073 } // namespace webkit_media 1039 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698