OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_processor.h" | 5 #include "media/filters/frame_processor.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 audio_preroll_buffer_ = NULL; | 286 audio_preroll_buffer_ = NULL; |
287 | 287 |
288 if (config.Matches(current_audio_config_)) | 288 if (config.Matches(current_audio_config_)) |
289 return; | 289 return; |
290 | 290 |
291 current_audio_config_ = config; | 291 current_audio_config_ = config; |
292 sample_duration_ = base::TimeDelta::FromSecondsD( | 292 sample_duration_ = base::TimeDelta::FromSecondsD( |
293 1.0 / current_audio_config_.samples_per_second()); | 293 1.0 / current_audio_config_.samples_per_second()); |
294 } | 294 } |
295 | 295 |
| 296 bool FrameProcessor::OnRangeRemoval(StreamParser::TrackId track_id, |
| 297 DecodeTimestamp start_dts, |
| 298 DecodeTimestamp end_dts) { |
| 299 DVLOG(2) << __FUNCTION__ << "(): track_id=" << track_id |
| 300 << "start_dts=" << start_dts << "end_dts=" << end_dts; |
| 301 |
| 302 if (start_dts < 0 || start_dts > end_dts) { |
| 303 DVLOG(2) << __FUNCTION__ << "(): start_dts or end_dts out of range"; |
| 304 return false; |
| 305 } |
| 306 |
| 307 MseTrackBuffer* track_buffer = FindTrack(track_id); |
| 308 DCHECK(track_buffer); |
| 309 if (!track_buffer) { |
| 310 DVLOG(2) << __FUNCTION__ << "(): unknown track_id " << track_id; |
| 311 return false; |
| 312 } |
| 313 |
| 314 DecodeTimestamp last_dts = track_buffer->last_decode_timestamp(); |
| 315 if (last_dts != kNoDecodeTimestamp && start_dts <= last_dts && |
| 316 end_dts >= last_dts) { |
| 317 // If mode equals "segments": Set group end timestamp to presentation |
| 318 // timestamp. |
| 319 // If mode equals "sequence": Set group start timestamp equal to the group |
| 320 // end timestamp. |
| 321 if (!sequence_mode_) { |
| 322 group_end_timestamp_ = presentation_timestamp; |
| 323 |
| 324 // BIG TODO: this needs fixing first!!! Will need to flush before further |
| 325 // buffers are sent to the track buffer in ProcessFrames(). |
| 326 // Probably need to rework this to be new_coded_frame_group_, held here. |
| 327 |
| 328 // This triggers a discontinuity so we need to treat the next frames |
| 329 // appended within the append window as if they were the beginning of |
| 330 // a new segment. |
| 331 *new_media_segment = true; |
| 332 } else { |
| 333 DVLOG(3) << __FUNCTION__ << " : Sequence mode discontinuity, GETS: " |
| 334 << group_end_timestamp_.InSecondsF(); |
| 335 DCHECK(kNoTimestamp() != group_end_timestamp_); |
| 336 group_start_timestamp_ = group_end_timestamp_; |
| 337 } |
| 338 |
| 339 Reset(); |
| 340 } |
| 341 |
| 342 return true; |
| 343 } |
| 344 |
296 MseTrackBuffer* FrameProcessor::FindTrack(StreamParser::TrackId id) { | 345 MseTrackBuffer* FrameProcessor::FindTrack(StreamParser::TrackId id) { |
297 TrackBufferMap::iterator itr = track_buffers_.find(id); | 346 TrackBufferMap::iterator itr = track_buffers_.find(id); |
298 if (itr == track_buffers_.end()) | 347 if (itr == track_buffers_.end()) |
299 return NULL; | 348 return NULL; |
300 | 349 |
301 return itr->second; | 350 return itr->second; |
302 } | 351 } |
303 | 352 |
304 void FrameProcessor::NotifyNewMediaSegmentStarting( | 353 void FrameProcessor::NotifyNewMediaSegmentStarting( |
305 DecodeTimestamp segment_timestamp) { | 354 DecodeTimestamp segment_timestamp) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 DCHECK(group_end_timestamp_ >= base::TimeDelta()); | 744 DCHECK(group_end_timestamp_ >= base::TimeDelta()); |
696 | 745 |
697 return true; | 746 return true; |
698 } | 747 } |
699 | 748 |
700 NOTREACHED(); | 749 NOTREACHED(); |
701 return false; | 750 return false; |
702 } | 751 } |
703 | 752 |
704 } // namespace media | 753 } // namespace media |
OLD | NEW |