| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "media/base/audio_decoder_config.h" | 7 #include "media/base/audio_decoder_config.h" |
| 8 #include "media/base/decoder_buffer.h" | 8 #include "media/base/decoder_buffer.h" |
| 9 #include "media/base/mock_callback.h" | 9 #include "media/base/mock_callback.h" |
| 10 #include "media/base/mock_demuxer_host.h" | 10 #include "media/base/mock_demuxer_host.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 static const int kAudioTrackNum = 2; | 51 static const int kAudioTrackNum = 2; |
| 52 | 52 |
| 53 static const int kAudioBlockDuration = 23; | 53 static const int kAudioBlockDuration = 23; |
| 54 static const int kVideoBlockDuration = 33; | 54 static const int kVideoBlockDuration = 33; |
| 55 | 55 |
| 56 static const char* kSourceId = "SourceId"; | 56 static const char* kSourceId = "SourceId"; |
| 57 static const char* kDefaultFirstClusterRange = "{ [0,46) }"; | 57 static const char* kDefaultFirstClusterRange = "{ [0,46) }"; |
| 58 static const int kDefaultFirstClusterEndTimestamp = 66; | 58 static const int kDefaultFirstClusterEndTimestamp = 66; |
| 59 static const int kDefaultSecondClusterEndTimestamp = 132; | 59 static const int kDefaultSecondClusterEndTimestamp = 132; |
| 60 | 60 |
| 61 static const char kWebMInitDataType[] = "video/webm"; |
| 62 |
| 61 base::TimeDelta kDefaultDuration() { | 63 base::TimeDelta kDefaultDuration() { |
| 62 return base::TimeDelta::FromMilliseconds(201224); | 64 return base::TimeDelta::FromMilliseconds(201224); |
| 63 } | 65 } |
| 64 | 66 |
| 65 // Write an integer into buffer in the form of vint that spans 8 bytes. | 67 // Write an integer into buffer in the form of vint that spans 8 bytes. |
| 66 // The data pointed by |buffer| should be at least 8 bytes long. | 68 // The data pointed by |buffer| should be at least 8 bytes long. |
| 67 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF. | 69 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF. |
| 68 static void WriteInt64(uint8* buffer, int64 number) { | 70 static void WriteInt64(uint8* buffer, int64 number) { |
| 69 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF)); | 71 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF)); |
| 70 buffer[0] = 0x01; | 72 buffer[0] = 0x01; |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 } | 727 } |
| 726 | 728 |
| 727 return true; | 729 return true; |
| 728 } | 730 } |
| 729 | 731 |
| 730 MOCK_METHOD0(DemuxerOpened, void()); | 732 MOCK_METHOD0(DemuxerOpened, void()); |
| 731 // TODO(xhwang): This is a workaround of the issue that move-only parameters | 733 // TODO(xhwang): This is a workaround of the issue that move-only parameters |
| 732 // are not supported in mocked methods. Remove this when the issue is fixed | 734 // are not supported in mocked methods. Remove this when the issue is fixed |
| 733 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use | 735 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use |
| 734 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). | 736 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). |
| 735 MOCK_METHOD2(NeedKeyMock, void(const uint8* init_data, int init_data_size)); | 737 MOCK_METHOD3(NeedKeyMock, void(const std::string& type, |
| 736 void DemuxerNeedKey(scoped_array<uint8> init_data, int init_data_size) { | 738 const uint8* init_data, int init_data_size)); |
| 737 NeedKeyMock(init_data.get(), init_data_size); | 739 void DemuxerNeedKey(const std::string& type, |
| 740 scoped_array<uint8> init_data, int init_data_size) { |
| 741 NeedKeyMock(type, init_data.get(), init_data_size); |
| 738 } | 742 } |
| 739 | 743 |
| 740 MessageLoop message_loop_; | 744 MessageLoop message_loop_; |
| 741 MockDemuxerHost host_; | 745 MockDemuxerHost host_; |
| 742 | 746 |
| 743 scoped_refptr<ChunkDemuxer> demuxer_; | 747 scoped_refptr<ChunkDemuxer> demuxer_; |
| 744 | 748 |
| 745 private: | 749 private: |
| 746 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); | 750 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); |
| 747 }; | 751 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 759 if ((!has_audio && is_audio_encrypted) || | 763 if ((!has_audio && is_audio_encrypted) || |
| 760 (!has_video && is_video_encrypted)) { | 764 (!has_video && is_video_encrypted)) { |
| 761 continue; | 765 continue; |
| 762 } | 766 } |
| 763 | 767 |
| 764 CreateNewDemuxer(); | 768 CreateNewDemuxer(); |
| 765 | 769 |
| 766 if (is_audio_encrypted || is_video_encrypted) { | 770 if (is_audio_encrypted || is_video_encrypted) { |
| 767 int need_key_count = (is_audio_encrypted ? 1 : 0) + | 771 int need_key_count = (is_audio_encrypted ? 1 : 0) + |
| 768 (is_video_encrypted ? 1 : 0); | 772 (is_video_encrypted ? 1 : 0); |
| 769 EXPECT_CALL(*this, NeedKeyMock(NotNull(), 16)) | 773 EXPECT_CALL(*this, NeedKeyMock(kWebMInitDataType, NotNull(), 16)) |
| 770 .Times(Exactly(need_key_count)); | 774 .Times(Exactly(need_key_count)); |
| 771 } | 775 } |
| 772 | 776 |
| 773 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( | 777 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( |
| 774 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); | 778 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); |
| 775 | 779 |
| 776 scoped_refptr<DemuxerStream> audio_stream = | 780 scoped_refptr<DemuxerStream> audio_stream = |
| 777 demuxer_->GetStream(DemuxerStream::AUDIO); | 781 demuxer_->GetStream(DemuxerStream::AUDIO); |
| 778 if (has_audio) { | 782 if (has_audio) { |
| 779 ASSERT_TRUE(audio_stream); | 783 ASSERT_TRUE(audio_stream); |
| (...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2424 | 2428 |
| 2425 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); | 2429 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); |
| 2426 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); | 2430 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); |
| 2427 | 2431 |
| 2428 EXPECT_CALL(host_, SetDuration( | 2432 EXPECT_CALL(host_, SetDuration( |
| 2429 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); | 2433 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); |
| 2430 demuxer_->EndOfStream(PIPELINE_OK); | 2434 demuxer_->EndOfStream(PIPELINE_OK); |
| 2431 } | 2435 } |
| 2432 | 2436 |
| 2433 } // namespace media | 2437 } // namespace media |
| OLD | NEW |