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/formats/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 (*subsamples)[i].clear_bytes += nalu_size_diff; | 359 (*subsamples)[i].clear_bytes += nalu_size_diff; |
360 } | 360 } |
361 | 361 |
362 if (runs_->is_keyframe()) { | 362 if (runs_->is_keyframe()) { |
363 // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of | 363 // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of |
364 // a frame. If subsample info is present, we also update the clear byte | 364 // a frame. If subsample info is present, we also update the clear byte |
365 // count for that first subsample. | 365 // count for that first subsample. |
366 RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf, subsamples)); | 366 RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf, subsamples)); |
367 } | 367 } |
368 | 368 |
369 DCHECK(AVC::IsValidAnnexB(*frame_buf)); | 369 // TODO(acolwell): Improve IsValidAnnexB() so it can handle encrypted content. |
| 370 DCHECK(runs_->is_encrypted() || AVC::IsValidAnnexB(*frame_buf)); |
370 return true; | 371 return true; |
371 } | 372 } |
372 | 373 |
373 bool MP4StreamParser::PrepareAACBuffer( | 374 bool MP4StreamParser::PrepareAACBuffer( |
374 const AAC& aac_config, std::vector<uint8>* frame_buf, | 375 const AAC& aac_config, std::vector<uint8>* frame_buf, |
375 std::vector<SubsampleEntry>* subsamples) const { | 376 std::vector<SubsampleEntry>* subsamples) const { |
376 // Append an ADTS header to every audio sample. | 377 // Append an ADTS header to every audio sample. |
377 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); | 378 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); |
378 | 379 |
379 // As above, adjust subsample information to account for the headers. AAC is | 380 // As above, adjust subsample information to account for the headers. AAC is |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return !err; | 570 return !err; |
570 } | 571 } |
571 | 572 |
572 void MP4StreamParser::ChangeState(State new_state) { | 573 void MP4StreamParser::ChangeState(State new_state) { |
573 DVLOG(2) << "Changing state: " << new_state; | 574 DVLOG(2) << "Changing state: " << new_state; |
574 state_ = new_state; | 575 state_ = new_state; |
575 } | 576 } |
576 | 577 |
577 } // namespace mp4 | 578 } // namespace mp4 |
578 } // namespace media | 579 } // namespace media |
OLD | NEW |