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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 bool WebMediaPlayerImpl::sourceAppend(const unsigned char* data, | 672 bool WebMediaPlayerImpl::sourceAppend(const unsigned char* data, |
673 unsigned length) { | 673 unsigned length) { |
674 return sourceAppend(WebKit::WebString::fromUTF8("DefaultSourceId"), | 674 return sourceAppend(WebKit::WebString::fromUTF8("DefaultSourceId"), |
675 data, length); | 675 data, length); |
676 } | 676 } |
677 | 677 |
678 bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, | 678 bool WebMediaPlayerImpl::sourceAppend(const WebKit::WebString& id, |
679 const unsigned char* data, | 679 const unsigned char* data, |
680 unsigned length) { | 680 unsigned length) { |
681 DCHECK_EQ(main_loop_, MessageLoop::current()); | 681 DCHECK_EQ(main_loop_, MessageLoop::current()); |
682 return proxy_->DemuxerAppend(id.utf8().data(), data, length); | 682 |
| 683 float old_duration = duration(); |
| 684 if (!proxy_->DemuxerAppend(id.utf8().data(), data, length)) |
| 685 return false; |
| 686 |
| 687 if (old_duration != duration()) |
| 688 GetClient()->durationChanged(); |
| 689 |
| 690 return true; |
683 } | 691 } |
684 | 692 |
685 bool WebMediaPlayerImpl::sourceAbort(const WebKit::WebString& id) { | 693 bool WebMediaPlayerImpl::sourceAbort(const WebKit::WebString& id) { |
686 proxy_->DemuxerAbort(id.utf8().data()); | 694 proxy_->DemuxerAbort(id.utf8().data()); |
687 return true; | 695 return true; |
688 } | 696 } |
689 | 697 |
690 void WebMediaPlayerImpl::sourceEndOfStream( | 698 void WebMediaPlayerImpl::sourceEndOfStream( |
691 WebMediaPlayer::EndOfStreamStatus status) { | 699 WebMediaPlayer::EndOfStreamStatus status) { |
692 DCHECK_EQ(main_loop_, MessageLoop::current()); | 700 DCHECK_EQ(main_loop_, MessageLoop::current()); |
693 media::PipelineStatus pipeline_status = media::PIPELINE_OK; | 701 media::PipelineStatus pipeline_status = media::PIPELINE_OK; |
694 | 702 |
695 switch (status) { | 703 switch (status) { |
696 case WebMediaPlayer::EndOfStreamStatusNoError: | 704 case WebMediaPlayer::EndOfStreamStatusNoError: |
697 break; | 705 break; |
698 case WebMediaPlayer::EndOfStreamStatusNetworkError: | 706 case WebMediaPlayer::EndOfStreamStatusNetworkError: |
699 pipeline_status = media::PIPELINE_ERROR_NETWORK; | 707 pipeline_status = media::PIPELINE_ERROR_NETWORK; |
700 break; | 708 break; |
701 case WebMediaPlayer::EndOfStreamStatusDecodeError: | 709 case WebMediaPlayer::EndOfStreamStatusDecodeError: |
702 pipeline_status = media::PIPELINE_ERROR_DECODE; | 710 pipeline_status = media::PIPELINE_ERROR_DECODE; |
703 break; | 711 break; |
704 default: | 712 default: |
705 NOTIMPLEMENTED(); | 713 NOTIMPLEMENTED(); |
706 } | 714 } |
707 | 715 |
| 716 float old_duration = duration(); |
708 proxy_->DemuxerEndOfStream(pipeline_status); | 717 proxy_->DemuxerEndOfStream(pipeline_status); |
| 718 |
| 719 if (old_duration != duration()) |
| 720 GetClient()->durationChanged(); |
709 } | 721 } |
710 | 722 |
711 WebKit::WebMediaPlayer::MediaKeyException | 723 WebKit::WebMediaPlayer::MediaKeyException |
712 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, | 724 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, |
713 const unsigned char* init_data, | 725 const unsigned char* init_data, |
714 unsigned init_data_length) { | 726 unsigned init_data_length) { |
715 if (!IsSupportedKeySystem(key_system)) | 727 if (!IsSupportedKeySystem(key_system)) |
716 return WebKit::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 728 return WebKit::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
717 | 729 |
718 // We do not support run-time switching between key systems for now. | 730 // We do not support run-time switching between key systems for now. |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 return audio_source_provider_; | 1064 return audio_source_provider_; |
1053 } | 1065 } |
1054 | 1066 |
1055 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 1067 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
1056 DCHECK_EQ(main_loop_, MessageLoop::current()); | 1068 DCHECK_EQ(main_loop_, MessageLoop::current()); |
1057 incremented_externally_allocated_memory_ = true; | 1069 incremented_externally_allocated_memory_ = true; |
1058 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 1070 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
1059 } | 1071 } |
1060 | 1072 |
1061 } // namespace webkit_media | 1073 } // namespace webkit_media |
OLD | NEW |