| 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 | |
| 20 // Helper class that emulates calls made on the ChunkDemuxer by the | 17 // Helper class that emulates calls made on the ChunkDemuxer by the |
| 21 // Media Source API. | 18 // Media Source API. |
| 22 class MockMediaSource : public ChunkDemuxerClient { | 19 class MockMediaSource : public ChunkDemuxerClient { |
| 23 public: | 20 public: |
| 24 MockMediaSource(const std::string& filename, int initial_append_size) | 21 MockMediaSource(const std::string& filename, int initial_append_size) |
| 25 : url_(GetTestDataURL(filename)), | 22 : url_(GetTestDataURL(filename)), |
| 26 current_position_(0), | 23 current_position_(0), |
| 27 initial_append_size_(initial_append_size) { | 24 initial_append_size_(initial_append_size) { |
| 28 ReadTestDataFile(filename, &file_data_, &file_data_size_); | 25 ReadTestDataFile(filename, &file_data_, &file_data_size_); |
| 29 | 26 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 42 DCHECK_LT(new_position, file_data_size_); | 39 DCHECK_LT(new_position, file_data_size_); |
| 43 current_position_ = new_position; | 40 current_position_ = new_position; |
| 44 | 41 |
| 45 AppendData(seek_append_size); | 42 AppendData(seek_append_size); |
| 46 } | 43 } |
| 47 | 44 |
| 48 void AppendData(int size) { | 45 void AppendData(int size) { |
| 49 DCHECK(chunk_demuxer_.get()); | 46 DCHECK(chunk_demuxer_.get()); |
| 50 DCHECK_LT(current_position_, file_data_size_); | 47 DCHECK_LT(current_position_, file_data_size_); |
| 51 DCHECK_LE(current_position_ + size, file_data_size_); | 48 DCHECK_LE(current_position_ + size, file_data_size_); |
| 52 DCHECK(chunk_demuxer_->AppendData(kSourceId, | 49 chunk_demuxer_->AppendData(file_data_.get() + current_position_, size); |
| 53 file_data_.get() + current_position_, | |
| 54 size)); | |
| 55 current_position_ += size; | 50 current_position_ += size; |
| 56 } | 51 } |
| 57 | 52 |
| 58 void EndOfStream() { | 53 void EndOfStream() { |
| 59 chunk_demuxer_->EndOfStream(PIPELINE_OK); | 54 chunk_demuxer_->EndOfStream(PIPELINE_OK); |
| 60 } | 55 } |
| 61 | 56 |
| 62 void Abort() { | 57 void Abort() { |
| 63 if (!chunk_demuxer_.get()) | 58 if (!chunk_demuxer_.get()) |
| 64 return; | 59 return; |
| 65 chunk_demuxer_->Shutdown(); | 60 chunk_demuxer_->Shutdown(); |
| 66 } | 61 } |
| 67 | 62 |
| 68 // ChunkDemuxerClient methods. | 63 // ChunkDemuxerClient methods. |
| 69 virtual void DemuxerOpened(ChunkDemuxer* demuxer) { | 64 virtual void DemuxerOpened(ChunkDemuxer* demuxer) { |
| 70 chunk_demuxer_ = demuxer; | 65 chunk_demuxer_ = demuxer; |
| 71 DCHECK_EQ(chunk_demuxer_->AddId(kSourceId, kDefaultSourceType), | |
| 72 ChunkDemuxer::kOk); | |
| 73 AppendData(initial_append_size_); | 66 AppendData(initial_append_size_); |
| 74 } | 67 } |
| 75 | 68 |
| 76 virtual void DemuxerClosed() { | 69 virtual void DemuxerClosed() { |
| 77 chunk_demuxer_ = NULL; | 70 chunk_demuxer_ = NULL; |
| 78 } | 71 } |
| 79 | 72 |
| 80 private: | 73 private: |
| 81 std::string url_; | 74 std::string url_; |
| 82 scoped_array<uint8> file_data_; | 75 scoped_array<uint8> file_data_; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 206 |
| 214 // Verify video decoder & renderer can handle aborted demuxer reads. | 207 // Verify video decoder & renderer can handle aborted demuxer reads. |
| 215 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 208 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
| 216 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, | 209 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, |
| 217 base::TimeDelta::FromMilliseconds(200), | 210 base::TimeDelta::FromMilliseconds(200), |
| 218 base::TimeDelta::FromMilliseconds(1668), | 211 base::TimeDelta::FromMilliseconds(1668), |
| 219 0x1C896, 65536)); | 212 0x1C896, 65536)); |
| 220 } | 213 } |
| 221 | 214 |
| 222 } // namespace media | 215 } // namespace media |
| OLD | NEW |