| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 subsamples->size() * nalu_size_diff; | 356 subsamples->size() * nalu_size_diff; |
| 357 RCHECK(frame_buf->size() == expected_size); | 357 RCHECK(frame_buf->size() == expected_size); |
| 358 for (size_t i = 0; i < subsamples->size(); i++) | 358 for (size_t i = 0; i < subsamples->size(); i++) |
| 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 std::vector<uint8> param_sets; | 366 RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf, subsamples)); |
| 367 RCHECK(AVC::ConvertConfigToAnnexB(avc_config, ¶m_sets)); | |
| 368 frame_buf->insert(frame_buf->begin(), | |
| 369 param_sets.begin(), param_sets.end()); | |
| 370 if (!subsamples->empty()) | |
| 371 (*subsamples)[0].clear_bytes += param_sets.size(); | |
| 372 } | 367 } |
| 368 |
| 369 DCHECK(AVC::IsValidAnnexB(*frame_buf)); |
| 373 return true; | 370 return true; |
| 374 } | 371 } |
| 375 | 372 |
| 376 bool MP4StreamParser::PrepareAACBuffer( | 373 bool MP4StreamParser::PrepareAACBuffer( |
| 377 const AAC& aac_config, std::vector<uint8>* frame_buf, | 374 const AAC& aac_config, std::vector<uint8>* frame_buf, |
| 378 std::vector<SubsampleEntry>* subsamples) const { | 375 std::vector<SubsampleEntry>* subsamples) const { |
| 379 // Append an ADTS header to every audio sample. | 376 // Append an ADTS header to every audio sample. |
| 380 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); | 377 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); |
| 381 | 378 |
| 382 // As above, adjust subsample information to account for the headers. AAC is | 379 // As above, adjust subsample information to account for the headers. AAC is |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 return !err; | 570 return !err; |
| 574 } | 571 } |
| 575 | 572 |
| 576 void MP4StreamParser::ChangeState(State new_state) { | 573 void MP4StreamParser::ChangeState(State new_state) { |
| 577 DVLOG(2) << "Changing state: " << new_state; | 574 DVLOG(2) << "Changing state: " << new_state; |
| 578 state_ = new_state; | 575 state_ = new_state; |
| 579 } | 576 } |
| 580 | 577 |
| 581 } // namespace mp4 | 578 } // namespace mp4 |
| 582 } // namespace media | 579 } // namespace media |
| OLD | NEW |