| 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/mp4/mp4_stream_parser.h" | 5 #include "media/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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // TODO(strobe): ensure that the value of init_data (all PSSH headers | 332 // TODO(strobe): ensure that the value of init_data (all PSSH headers |
| 333 // concatenated in arbitrary order) matches the EME spec. | 333 // concatenated in arbitrary order) matches the EME spec. |
| 334 // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=17673. | 334 // See https://www.w3.org/Bugs/Public/show_bug.cgi?id=17673. |
| 335 if (headers.empty()) | 335 if (headers.empty()) |
| 336 return; | 336 return; |
| 337 | 337 |
| 338 size_t total_size = 0; | 338 size_t total_size = 0; |
| 339 for (size_t i = 0; i < headers.size(); i++) | 339 for (size_t i = 0; i < headers.size(); i++) |
| 340 total_size += headers[i].raw_box.size(); | 340 total_size += headers[i].raw_box.size(); |
| 341 | 341 |
| 342 scoped_ptr<uint8[]> init_data(new uint8[total_size]); | 342 std::vector<uint8> init_data(total_size); |
| 343 size_t pos = 0; | 343 size_t pos = 0; |
| 344 for (size_t i = 0; i < headers.size(); i++) { | 344 for (size_t i = 0; i < headers.size(); i++) { |
| 345 memcpy(&init_data.get()[pos], &headers[i].raw_box[0], | 345 memcpy(&init_data[pos], &headers[i].raw_box[0], |
| 346 headers[i].raw_box.size()); | 346 headers[i].raw_box.size()); |
| 347 pos += headers[i].raw_box.size(); | 347 pos += headers[i].raw_box.size(); |
| 348 } | 348 } |
| 349 need_key_cb_.Run(kMp4InitDataType, init_data.Pass(), total_size); | 349 need_key_cb_.Run(kMp4InitDataType, init_data); |
| 350 } | 350 } |
| 351 | 351 |
| 352 bool MP4StreamParser::PrepareAVCBuffer( | 352 bool MP4StreamParser::PrepareAVCBuffer( |
| 353 const AVCDecoderConfigurationRecord& avc_config, | 353 const AVCDecoderConfigurationRecord& avc_config, |
| 354 std::vector<uint8>* frame_buf, | 354 std::vector<uint8>* frame_buf, |
| 355 std::vector<SubsampleEntry>* subsamples) const { | 355 std::vector<SubsampleEntry>* subsamples) const { |
| 356 // Convert the AVC NALU length fields to Annex B headers, as expected by | 356 // Convert the AVC NALU length fields to Annex B headers, as expected by |
| 357 // decoding libraries. Since this may enlarge the size of the buffer, we also | 357 // decoding libraries. Since this may enlarge the size of the buffer, we also |
| 358 // update the clear byte count for each subsample if encryption is used to | 358 // update the clear byte count for each subsample if encryption is used to |
| 359 // account for the difference in size between the length prefix and Annex B | 359 // account for the difference in size between the length prefix and Annex B |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 return !err; | 568 return !err; |
| 569 } | 569 } |
| 570 | 570 |
| 571 void MP4StreamParser::ChangeState(State new_state) { | 571 void MP4StreamParser::ChangeState(State new_state) { |
| 572 DVLOG(2) << "Changing state: " << new_state; | 572 DVLOG(2) << "Changing state: " << new_state; |
| 573 state_ = new_state; | 573 state_ = new_state; |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace mp4 | 576 } // namespace mp4 |
| 577 } // namespace media | 577 } // namespace media |
| OLD | NEW |