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/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 // Default cluster to append after kDefaultFirstCluster() | 172 // Default cluster to append after kDefaultFirstCluster() |
173 // has been appended. This cluster starts with blocks that | 173 // has been appended. This cluster starts with blocks that |
174 // have timestamps consistent with the end times of the blocks | 174 // have timestamps consistent with the end times of the blocks |
175 // in kDefaultFirstCluster() so that these two clusters represent | 175 // in kDefaultFirstCluster() so that these two clusters represent |
176 // a continuous region. | 176 // a continuous region. |
177 std::unique_ptr<Cluster> kDefaultSecondCluster() { | 177 std::unique_ptr<Cluster> kDefaultSecondCluster() { |
178 return GenerateCluster(46, 66, 5); | 178 return GenerateCluster(46, 66, 5); |
179 } | 179 } |
180 | 180 |
181 ChunkDemuxerTest() | 181 ChunkDemuxerTest() : append_window_end_for_next_append_(kInfiniteDuration) { |
182 : media_log_(new StrictMock<MockMediaLog>()), | |
183 append_window_end_for_next_append_(kInfiniteDuration) { | |
184 init_segment_received_cb_ = base::Bind( | 182 init_segment_received_cb_ = base::Bind( |
185 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this)); | 183 &ChunkDemuxerTest::InitSegmentReceived, base::Unretained(this)); |
186 CreateNewDemuxer(); | 184 CreateNewDemuxer(); |
187 } | 185 } |
188 | 186 |
189 void CreateNewDemuxer() { | 187 void CreateNewDemuxer() { |
190 base::Closure open_cb = | 188 base::Closure open_cb = |
191 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); | 189 base::Bind(&ChunkDemuxerTest::DemuxerOpened, base::Unretained(this)); |
192 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( | 190 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = base::Bind( |
193 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); | 191 &ChunkDemuxerTest::OnEncryptedMediaInitData, base::Unretained(this)); |
194 demuxer_.reset( | 192 demuxer_.reset( |
195 new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, media_log_)); | 193 new ChunkDemuxer(open_cb, encrypted_media_init_data_cb, &media_log_)); |
196 } | 194 } |
197 | 195 |
198 virtual ~ChunkDemuxerTest() { | 196 virtual ~ChunkDemuxerTest() { |
199 ShutdownDemuxer(); | 197 ShutdownDemuxer(); |
200 } | 198 } |
201 | 199 |
202 void CreateInitSegment(int stream_flags, | 200 void CreateInitSegment(int stream_flags, |
203 bool is_audio_encrypted, | 201 bool is_audio_encrypted, |
204 bool is_video_encrypted, | 202 bool is_video_encrypted, |
205 std::unique_ptr<uint8_t[]>* buffer, | 203 std::unique_ptr<uint8_t[]>* buffer, |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 | 1289 |
1292 bool SetTimestampOffset(const std::string& id, | 1290 bool SetTimestampOffset(const std::string& id, |
1293 base::TimeDelta timestamp_offset) { | 1291 base::TimeDelta timestamp_offset) { |
1294 if (demuxer_->IsParsingMediaSegment(id)) | 1292 if (demuxer_->IsParsingMediaSegment(id)) |
1295 return false; | 1293 return false; |
1296 | 1294 |
1297 timestamp_offset_map_[id] = timestamp_offset; | 1295 timestamp_offset_map_[id] = timestamp_offset; |
1298 return true; | 1296 return true; |
1299 } | 1297 } |
1300 | 1298 |
| 1299 StrictMock<MockMediaLog> media_log_; |
| 1300 |
1301 base::MessageLoop message_loop_; | 1301 base::MessageLoop message_loop_; |
1302 MockDemuxerHost host_; | 1302 MockDemuxerHost host_; |
1303 | 1303 |
1304 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | |
1305 | |
1306 std::unique_ptr<ChunkDemuxer> demuxer_; | 1304 std::unique_ptr<ChunkDemuxer> demuxer_; |
1307 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_; | 1305 Demuxer::MediaTracksUpdatedCB init_segment_received_cb_; |
1308 | 1306 |
1309 base::TimeDelta append_window_start_for_next_append_; | 1307 base::TimeDelta append_window_start_for_next_append_; |
1310 base::TimeDelta append_window_end_for_next_append_; | 1308 base::TimeDelta append_window_end_for_next_append_; |
1311 | 1309 |
1312 // Map of source id to timestamp offset to use for the next AppendData() | 1310 // Map of source id to timestamp offset to use for the next AppendData() |
1313 // operation for that source id. | 1311 // operation for that source id. |
1314 std::map<std::string, base::TimeDelta> timestamp_offset_map_; | 1312 std::map<std::string, base::TimeDelta> timestamp_offset_map_; |
1315 | 1313 |
(...skipping 3476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4792 | 4790 |
4793 EXPECT_EQ(demuxer_->AddId("source_id", "video/mp4", "vp09.00.10.08"), | 4791 EXPECT_EQ(demuxer_->AddId("source_id", "video/mp4", "vp09.00.10.08"), |
4794 expected); | 4792 expected); |
4795 } | 4793 } |
4796 | 4794 |
4797 INSTANTIATE_TEST_CASE_P(EnableDisableMp4Vp9Demuxing, | 4795 INSTANTIATE_TEST_CASE_P(EnableDisableMp4Vp9Demuxing, |
4798 ChunkDemuxerMp4Vp9Test, | 4796 ChunkDemuxerMp4Vp9Test, |
4799 ::testing::Bool()); | 4797 ::testing::Bool()); |
4800 | 4798 |
4801 } // namespace media | 4799 } // namespace media |
OLD | NEW |