| 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/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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 if (web_video_frame) { | 634 if (web_video_frame) { |
| 635 scoped_refptr<media::VideoFrame> video_frame( | 635 scoped_refptr<media::VideoFrame> video_frame( |
| 636 WebVideoFrameImpl::toVideoFrame(web_video_frame)); | 636 WebVideoFrameImpl::toVideoFrame(web_video_frame)); |
| 637 proxy_->PutCurrentFrame(video_frame); | 637 proxy_->PutCurrentFrame(video_frame); |
| 638 delete web_video_frame; | 638 delete web_video_frame; |
| 639 } else { | 639 } else { |
| 640 proxy_->PutCurrentFrame(NULL); | 640 proxy_->PutCurrentFrame(NULL); |
| 641 } | 641 } |
| 642 } | 642 } |
| 643 | 643 |
| 644 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \ |
| 645 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayer::webkit_name) == \ |
| 646 static_cast<int>(media::ChunkDemuxer::chromium_name), \ |
| 647 mismatching_status_enums) |
| 648 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusOk, kOk); |
| 649 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusNotSupported, kNotSupported); |
| 650 COMPILE_ASSERT_MATCHING_STATUS_ENUM(AddIdStatusReachedIdLimit, kReachedIdLimit); |
| 651 |
| 652 WebKit::WebMediaPlayer::AddIdStatus WebMediaPlayerImpl::sourceAddId( |
| 653 const WebKit::WebString& id, |
| 654 const WebKit::WebString& type) { |
| 655 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 656 return static_cast<WebKit::WebMediaPlayer::AddIdStatus>( |
| 657 proxy_->DemuxerAddId(id.utf8().data(), type.utf8().data())); |
| 658 } |
| 659 |
| 660 bool WebMediaPlayerImpl::sourceRemoveId(const WebKit::WebString& id) { |
| 661 DCHECK(!id.isEmpty()); |
| 662 return proxy_->DemuxerRemoveId(id.utf8().data()); |
| 663 } |
| 664 |
| 644 bool WebMediaPlayerImpl::sourceAppend(const unsigned char* data, | 665 bool WebMediaPlayerImpl::sourceAppend(const unsigned char* data, |
| 645 unsigned length) { | 666 unsigned length) { |
| 667 return sourceAppend(WebKit::WebString::fromUTF8("DefaultSourceId"), |
| 668 data, length); |
| 669 } |
| 670 |
| 671 bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, |
| 672 const unsigned char* data, |
| 673 unsigned length) { |
| 646 DCHECK_EQ(main_loop_, MessageLoop::current()); | 674 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 647 return proxy_->DemuxerAppend(data, length); | 675 return proxy_->DemuxerAppend(id.utf8().data(), data, length); |
| 648 } | 676 } |
| 649 | 677 |
| 650 void WebMediaPlayerImpl::sourceEndOfStream( | 678 void WebMediaPlayerImpl::sourceEndOfStream( |
| 651 WebMediaPlayer::EndOfStreamStatus status) { | 679 WebMediaPlayer::EndOfStreamStatus status) { |
| 652 DCHECK_EQ(main_loop_, MessageLoop::current()); | 680 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 653 media::PipelineStatus pipeline_status = media::PIPELINE_OK; | 681 media::PipelineStatus pipeline_status = media::PIPELINE_OK; |
| 654 | 682 |
| 655 switch(status) { | 683 switch(status) { |
| 656 case WebMediaPlayer::EndOfStreamStatusNoError: | 684 case WebMediaPlayer::EndOfStreamStatusNoError: |
| 657 break; | 685 break; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 return audio_source_provider_; | 940 return audio_source_provider_; |
| 913 } | 941 } |
| 914 | 942 |
| 915 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 943 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 916 DCHECK_EQ(main_loop_, MessageLoop::current()); | 944 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 917 incremented_externally_allocated_memory_ = true; | 945 incremented_externally_allocated_memory_ = true; |
| 918 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 946 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 919 } | 947 } |
| 920 | 948 |
| 921 } // namespace webkit_media | 949 } // namespace webkit_media |
| OLD | NEW |