| 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 "media/filters/pipeline_integration_test_base.h" | 5 #include "media/filters/pipeline_integration_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "media/base/test_data_util.h" | 8 #include "media/base/test_data_util.h" |
| 9 #include "media/filters/chunk_demuxer_client.h" | 9 #include "media/filters/chunk_demuxer_client.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace media { |
| 12 | 12 |
| 13 // Key ID of the video track in test file "bear-320x240-encrypted.webm". | 13 // Key ID of the video track in test file "bear-320x240-encrypted.webm". |
| 14 static const unsigned char kKeyId[] = | 14 static const unsigned char kKeyId[] = |
| 15 "\x11\xa5\x18\x37\xc4\x73\x84\x03\xe5\xe6\x57\xed\x8e\x06\xd9\x7c"; | 15 "\x11\xa5\x18\x37\xc4\x73\x84\x03\xe5\xe6\x57\xed\x8e\x06\xd9\x7c"; |
| 16 | 16 |
| 17 static const char* kSourceId = "SourceId"; |
| 18 static const char* kDefaultSourceType = "video/webm; codecs=\"vp8, vorbis\""; |
| 19 |
| 17 // Helper class that emulates calls made on the ChunkDemuxer by the | 20 // Helper class that emulates calls made on the ChunkDemuxer by the |
| 18 // Media Source API. | 21 // Media Source API. |
| 19 class MockMediaSource : public ChunkDemuxerClient { | 22 class MockMediaSource : public ChunkDemuxerClient { |
| 20 public: | 23 public: |
| 21 MockMediaSource(const std::string& filename, int initial_append_size) | 24 MockMediaSource(const std::string& filename, int initial_append_size) |
| 22 : url_(GetTestDataURL(filename)), | 25 : url_(GetTestDataURL(filename)), |
| 23 current_position_(0), | 26 current_position_(0), |
| 24 initial_append_size_(initial_append_size) { | 27 initial_append_size_(initial_append_size) { |
| 25 ReadTestDataFile(filename, &file_data_, &file_data_size_); | 28 ReadTestDataFile(filename, &file_data_, &file_data_size_); |
| 26 | 29 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 DCHECK_LT(new_position, file_data_size_); | 42 DCHECK_LT(new_position, file_data_size_); |
| 40 current_position_ = new_position; | 43 current_position_ = new_position; |
| 41 | 44 |
| 42 AppendData(seek_append_size); | 45 AppendData(seek_append_size); |
| 43 } | 46 } |
| 44 | 47 |
| 45 void AppendData(int size) { | 48 void AppendData(int size) { |
| 46 DCHECK(chunk_demuxer_.get()); | 49 DCHECK(chunk_demuxer_.get()); |
| 47 DCHECK_LT(current_position_, file_data_size_); | 50 DCHECK_LT(current_position_, file_data_size_); |
| 48 DCHECK_LE(current_position_ + size, file_data_size_); | 51 DCHECK_LE(current_position_ + size, file_data_size_); |
| 49 chunk_demuxer_->AppendData(file_data_.get() + current_position_, size); | 52 CHECK(chunk_demuxer_->AppendData(kSourceId, |
| 53 file_data_.get() + current_position_, |
| 54 size)); |
| 50 current_position_ += size; | 55 current_position_ += size; |
| 51 } | 56 } |
| 52 | 57 |
| 53 void EndOfStream() { | 58 void EndOfStream() { |
| 54 chunk_demuxer_->EndOfStream(PIPELINE_OK); | 59 chunk_demuxer_->EndOfStream(PIPELINE_OK); |
| 55 } | 60 } |
| 56 | 61 |
| 57 void Abort() { | 62 void Abort() { |
| 58 if (!chunk_demuxer_.get()) | 63 if (!chunk_demuxer_.get()) |
| 59 return; | 64 return; |
| 60 chunk_demuxer_->Shutdown(); | 65 chunk_demuxer_->Shutdown(); |
| 61 } | 66 } |
| 62 | 67 |
| 63 // ChunkDemuxerClient methods. | 68 // ChunkDemuxerClient methods. |
| 64 virtual void DemuxerOpened(ChunkDemuxer* demuxer) { | 69 virtual void DemuxerOpened(ChunkDemuxer* demuxer) { |
| 65 chunk_demuxer_ = demuxer; | 70 chunk_demuxer_ = demuxer; |
| 71 chunk_demuxer_->AddId(kSourceId, kDefaultSourceType); |
| 66 AppendData(initial_append_size_); | 72 AppendData(initial_append_size_); |
| 67 } | 73 } |
| 68 | 74 |
| 69 virtual void DemuxerClosed() { | 75 virtual void DemuxerClosed() { |
| 70 chunk_demuxer_ = NULL; | 76 chunk_demuxer_ = NULL; |
| 71 } | 77 } |
| 72 | 78 |
| 73 private: | 79 private: |
| 74 std::string url_; | 80 std::string url_; |
| 75 scoped_array<uint8> file_data_; | 81 scoped_array<uint8> file_data_; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 212 |
| 207 // Verify video decoder & renderer can handle aborted demuxer reads. | 213 // Verify video decoder & renderer can handle aborted demuxer reads. |
| 208 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 214 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
| 209 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, | 215 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, |
| 210 base::TimeDelta::FromMilliseconds(200), | 216 base::TimeDelta::FromMilliseconds(200), |
| 211 base::TimeDelta::FromMilliseconds(1668), | 217 base::TimeDelta::FromMilliseconds(1668), |
| 212 0x1C896, 65536)); | 218 0x1C896, 65536)); |
| 213 } | 219 } |
| 214 | 220 |
| 215 } // namespace media | 221 } // namespace media |
| OLD | NEW |