OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_TEST_MOCK_MEDIA_SOURCE_H_ |
| 6 #define MEDIA_TEST_MOCK_MEDIA_SOURCE_H_ |
| 7 |
| 8 #include "base/time/time.h" |
| 9 #include "media/base/demuxer.h" |
| 10 #include "media/base/pipeline_status.h" |
| 11 #include "media/filters/chunk_demuxer.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 // Indicates that the whole file should be appended. |
| 17 extern const size_t kAppendWholeFile; |
| 18 |
| 19 // Helper class that emulates calls made on the ChunkDemuxer by the |
| 20 // Media Source API. |
| 21 class MockMediaSource { |
| 22 public: |
| 23 MockMediaSource(const std::string& filename, |
| 24 const std::string& mimetype, |
| 25 size_t initial_append_size); |
| 26 ~MockMediaSource(); |
| 27 |
| 28 std::unique_ptr<Demuxer> GetDemuxer(); |
| 29 |
| 30 void set_encrypted_media_init_data_cb( |
| 31 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { |
| 32 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
| 33 } |
| 34 |
| 35 void set_demuxer_failure_cb(const PipelineStatusCB& demuxer_failure_cb) { |
| 36 demuxer_failure_cb_ = demuxer_failure_cb; |
| 37 } |
| 38 |
| 39 void Seek(base::TimeDelta seek_time, |
| 40 size_t new_position, |
| 41 size_t seek_append_size); |
| 42 void Seek(base::TimeDelta seek_time); |
| 43 void AppendData(size_t size); |
| 44 bool AppendAtTime(base::TimeDelta timestamp_offset, |
| 45 const uint8_t* pData, |
| 46 int size); |
| 47 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset, |
| 48 base::TimeDelta append_window_start, |
| 49 base::TimeDelta append_window_end, |
| 50 const uint8_t* pData, |
| 51 int size); |
| 52 void SetMemoryLimits(size_t limit_bytes); |
| 53 bool EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize); |
| 54 void RemoveRange(base::TimeDelta start, base::TimeDelta end); |
| 55 void EndOfStream(); |
| 56 void Shutdown(); |
| 57 void DemuxerOpened(); |
| 58 void DemuxerOpenedTask(); |
| 59 ChunkDemuxer::Status AddId(); |
| 60 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
| 61 const std::vector<uint8_t>& init_data); |
| 62 |
| 63 base::TimeDelta last_timestamp_offset() const { |
| 64 return last_timestamp_offset_; |
| 65 } |
| 66 |
| 67 void InitSegmentReceived(std::unique_ptr<MediaTracks> tracks); |
| 68 MOCK_METHOD1(InitSegmentReceivedMock, void(std::unique_ptr<MediaTracks>&)); |
| 69 |
| 70 private: |
| 71 MediaLog media_log_; |
| 72 scoped_refptr<DecoderBuffer> file_data_; |
| 73 size_t current_position_; |
| 74 size_t initial_append_size_; |
| 75 std::string mimetype_; |
| 76 ChunkDemuxer* chunk_demuxer_; |
| 77 std::unique_ptr<Demuxer> owned_chunk_demuxer_; |
| 78 PipelineStatusCB demuxer_failure_cb_; |
| 79 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; |
| 80 base::TimeDelta last_timestamp_offset_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(MockMediaSource); |
| 83 }; |
| 84 |
| 85 } // namespace media |
| 86 |
| 87 #endif // MEDIA_TEST_MOCK_MEDIA_SOURCE_H_ |
OLD | NEW |