| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 encrypted_media_init_data_cb, | 111 encrypted_media_init_data_cb, |
| 112 const NewTextTrackCB& new_text_track_cb); | 112 const NewTextTrackCB& new_text_track_cb); |
| 113 | 113 |
| 114 // Appends new data to the StreamParser. | 114 // Appends new data to the StreamParser. |
| 115 // Returns true if the data was successfully appended. Returns false if an | 115 // Returns true if the data was successfully appended. Returns false if an |
| 116 // error occurred. |*timestamp_offset| is used and possibly updated by the | 116 // error occurred. |*timestamp_offset| is used and possibly updated by the |
| 117 // append. |append_window_start| and |append_window_end| correspond to the MSE | 117 // append. |append_window_start| and |append_window_end| correspond to the MSE |
| 118 // spec's similarly named source buffer attributes that are used in coded | 118 // spec's similarly named source buffer attributes that are used in coded |
| 119 // frame processing. |init_segment_received_cb| is run for each new fully | 119 // frame processing. |init_segment_received_cb| is run for each new fully |
| 120 // parsed initialization segment. | 120 // parsed initialization segment. |
| 121 bool Append(const uint8* data, | 121 bool Append(const uint8_t* data, |
| 122 size_t length, | 122 size_t length, |
| 123 TimeDelta append_window_start, | 123 TimeDelta append_window_start, |
| 124 TimeDelta append_window_end, | 124 TimeDelta append_window_end, |
| 125 TimeDelta* timestamp_offset, | 125 TimeDelta* timestamp_offset, |
| 126 const InitSegmentReceivedCB& init_segment_received_cb); | 126 const InitSegmentReceivedCB& init_segment_received_cb); |
| 127 | 127 |
| 128 // Aborts the current append sequence and resets the parser. | 128 // Aborts the current append sequence and resets the parser. |
| 129 void ResetParserState(TimeDelta append_window_start, | 129 void ResetParserState(TimeDelta append_window_start, |
| 130 TimeDelta append_window_end, | 130 TimeDelta append_window_end, |
| 131 TimeDelta* timestamp_offset); | 131 TimeDelta* timestamp_offset); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 318 } |
| 319 | 319 |
| 320 void SourceState::SetGroupStartTimestampIfInSequenceMode( | 320 void SourceState::SetGroupStartTimestampIfInSequenceMode( |
| 321 base::TimeDelta timestamp_offset) { | 321 base::TimeDelta timestamp_offset) { |
| 322 DCHECK(!parsing_media_segment_); | 322 DCHECK(!parsing_media_segment_); |
| 323 | 323 |
| 324 frame_processor_->SetGroupStartTimestampIfInSequenceMode(timestamp_offset); | 324 frame_processor_->SetGroupStartTimestampIfInSequenceMode(timestamp_offset); |
| 325 } | 325 } |
| 326 | 326 |
| 327 bool SourceState::Append( | 327 bool SourceState::Append( |
| 328 const uint8* data, | 328 const uint8_t* data, |
| 329 size_t length, | 329 size_t length, |
| 330 TimeDelta append_window_start, | 330 TimeDelta append_window_start, |
| 331 TimeDelta append_window_end, | 331 TimeDelta append_window_end, |
| 332 TimeDelta* timestamp_offset, | 332 TimeDelta* timestamp_offset, |
| 333 const InitSegmentReceivedCB& init_segment_received_cb) { | 333 const InitSegmentReceivedCB& init_segment_received_cb) { |
| 334 DCHECK(timestamp_offset); | 334 DCHECK(timestamp_offset); |
| 335 DCHECK(!timestamp_offset_during_append_); | 335 DCHECK(!timestamp_offset_during_append_); |
| 336 DCHECK(!init_segment_received_cb.is_null()); | 336 DCHECK(!init_segment_received_cb.is_null()); |
| 337 DCHECK(init_segment_received_cb_.is_null()); | 337 DCHECK(init_segment_received_cb_.is_null()); |
| 338 append_window_start_during_append_ = append_window_start; | 338 append_window_start_during_append_ = append_window_start; |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 SourceStateMap::const_iterator itr = source_state_map_.find(id); | 1446 SourceStateMap::const_iterator itr = source_state_map_.find(id); |
| 1447 if (itr == source_state_map_.end()) { | 1447 if (itr == source_state_map_.end()) { |
| 1448 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found"; | 1448 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found"; |
| 1449 return false; | 1449 return false; |
| 1450 } | 1450 } |
| 1451 return itr->second->EvictCodedFrames(media_time_dts, newDataSize); | 1451 return itr->second->EvictCodedFrames(media_time_dts, newDataSize); |
| 1452 } | 1452 } |
| 1453 | 1453 |
| 1454 void ChunkDemuxer::AppendData( | 1454 void ChunkDemuxer::AppendData( |
| 1455 const std::string& id, | 1455 const std::string& id, |
| 1456 const uint8* data, | 1456 const uint8_t* data, |
| 1457 size_t length, | 1457 size_t length, |
| 1458 TimeDelta append_window_start, | 1458 TimeDelta append_window_start, |
| 1459 TimeDelta append_window_end, | 1459 TimeDelta append_window_end, |
| 1460 TimeDelta* timestamp_offset, | 1460 TimeDelta* timestamp_offset, |
| 1461 const InitSegmentReceivedCB& init_segment_received_cb) { | 1461 const InitSegmentReceivedCB& init_segment_received_cb) { |
| 1462 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; | 1462 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; |
| 1463 | 1463 |
| 1464 DCHECK(!id.empty()); | 1464 DCHECK(!id.empty()); |
| 1465 DCHECK(timestamp_offset); | 1465 DCHECK(timestamp_offset); |
| 1466 DCHECK(!init_segment_received_cb.is_null()); | 1466 DCHECK(!init_segment_received_cb.is_null()); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 DCHECK_GE(duration, 0); | 1587 DCHECK_GE(duration, 0); |
| 1588 | 1588 |
| 1589 if (duration == GetDuration_Locked()) | 1589 if (duration == GetDuration_Locked()) |
| 1590 return; | 1590 return; |
| 1591 | 1591 |
| 1592 // Compute & bounds check the TimeDelta representation of duration. | 1592 // Compute & bounds check the TimeDelta representation of duration. |
| 1593 // This can be different if the value of |duration| doesn't fit the range or | 1593 // This can be different if the value of |duration| doesn't fit the range or |
| 1594 // precision of TimeDelta. | 1594 // precision of TimeDelta. |
| 1595 TimeDelta min_duration = TimeDelta::FromInternalValue(1); | 1595 TimeDelta min_duration = TimeDelta::FromInternalValue(1); |
| 1596 // Don't use TimeDelta::Max() here, as we want the largest finite time delta. | 1596 // Don't use TimeDelta::Max() here, as we want the largest finite time delta. |
| 1597 TimeDelta max_duration = TimeDelta::FromInternalValue(kint64max - 1); | 1597 TimeDelta max_duration = |
| 1598 TimeDelta::FromInternalValue(std::numeric_limits<int64_t>::max() - 1); |
| 1598 double min_duration_in_seconds = min_duration.InSecondsF(); | 1599 double min_duration_in_seconds = min_duration.InSecondsF(); |
| 1599 double max_duration_in_seconds = max_duration.InSecondsF(); | 1600 double max_duration_in_seconds = max_duration.InSecondsF(); |
| 1600 | 1601 |
| 1601 TimeDelta duration_td; | 1602 TimeDelta duration_td; |
| 1602 if (duration == std::numeric_limits<double>::infinity()) { | 1603 if (duration == std::numeric_limits<double>::infinity()) { |
| 1603 duration_td = media::kInfiniteDuration(); | 1604 duration_td = media::kInfiniteDuration(); |
| 1604 } else if (duration < min_duration_in_seconds) { | 1605 } else if (duration < min_duration_in_seconds) { |
| 1605 duration_td = min_duration; | 1606 duration_td = min_duration; |
| 1606 } else if (duration > max_duration_in_seconds) { | 1607 } else if (duration > max_duration_in_seconds) { |
| 1607 duration_td = max_duration; | 1608 duration_td = max_duration; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 } | 1965 } |
| 1965 | 1966 |
| 1966 void ChunkDemuxer::ShutdownAllStreams() { | 1967 void ChunkDemuxer::ShutdownAllStreams() { |
| 1967 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1968 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
| 1968 itr != source_state_map_.end(); ++itr) { | 1969 itr != source_state_map_.end(); ++itr) { |
| 1969 itr->second->Shutdown(); | 1970 itr->second->Shutdown(); |
| 1970 } | 1971 } |
| 1971 } | 1972 } |
| 1972 | 1973 |
| 1973 } // namespace media | 1974 } // namespace media |
| OLD | NEW |