Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: media/formats/mp4/mp4_stream_parser.cc

Issue 616183002: Revert of Pass initDataType instead of contentType on OnNeedKey(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "media/base/audio_decoder_config.h" 11 #include "media/base/audio_decoder_config.h"
12 #include "media/base/stream_parser_buffer.h" 12 #include "media/base/stream_parser_buffer.h"
13 #include "media/base/text_track_config.h" 13 #include "media/base/text_track_config.h"
14 #include "media/base/video_decoder_config.h" 14 #include "media/base/video_decoder_config.h"
15 #include "media/base/video_util.h" 15 #include "media/base/video_util.h"
16 #include "media/formats/mp4/box_definitions.h" 16 #include "media/formats/mp4/box_definitions.h"
17 #include "media/formats/mp4/box_reader.h" 17 #include "media/formats/mp4/box_reader.h"
18 #include "media/formats/mp4/es_descriptor.h" 18 #include "media/formats/mp4/es_descriptor.h"
19 #include "media/formats/mp4/rcheck.h" 19 #include "media/formats/mp4/rcheck.h"
20 #include "media/formats/mpeg/adts_constants.h" 20 #include "media/formats/mpeg/adts_constants.h"
21 21
22 namespace media { 22 namespace media {
23 namespace mp4 { 23 namespace mp4 {
24 24
25 static const char kCencInitDataType[] = "cenc"; 25 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed.
26 static const char kMp4InitDataType[] = "video/mp4";
26 27
27 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, 28 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
28 bool has_sbr) 29 bool has_sbr)
29 : state_(kWaitingForInit), 30 : state_(kWaitingForInit),
30 moof_head_(0), 31 moof_head_(0),
31 mdat_tail_(0), 32 mdat_tail_(0),
32 highest_end_offset_(0), 33 highest_end_offset_(0),
33 has_audio_(false), 34 has_audio_(false),
34 has_video_(false), 35 has_video_(false),
35 audio_track_id_(0), 36 audio_track_id_(0),
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 for (size_t i = 0; i < headers.size(); i++) 347 for (size_t i = 0; i < headers.size(); i++)
347 total_size += headers[i].raw_box.size(); 348 total_size += headers[i].raw_box.size();
348 349
349 std::vector<uint8> init_data(total_size); 350 std::vector<uint8> init_data(total_size);
350 size_t pos = 0; 351 size_t pos = 0;
351 for (size_t i = 0; i < headers.size(); i++) { 352 for (size_t i = 0; i < headers.size(); i++) {
352 memcpy(&init_data[pos], &headers[i].raw_box[0], 353 memcpy(&init_data[pos], &headers[i].raw_box[0],
353 headers[i].raw_box.size()); 354 headers[i].raw_box.size());
354 pos += headers[i].raw_box.size(); 355 pos += headers[i].raw_box.size();
355 } 356 }
356 need_key_cb_.Run(kCencInitDataType, init_data); 357 need_key_cb_.Run(kMp4InitDataType, init_data);
357 } 358 }
358 359
359 bool MP4StreamParser::PrepareAVCBuffer( 360 bool MP4StreamParser::PrepareAVCBuffer(
360 const AVCDecoderConfigurationRecord& avc_config, 361 const AVCDecoderConfigurationRecord& avc_config,
361 std::vector<uint8>* frame_buf, 362 std::vector<uint8>* frame_buf,
362 std::vector<SubsampleEntry>* subsamples) const { 363 std::vector<SubsampleEntry>* subsamples) const {
363 // Convert the AVC NALU length fields to Annex B headers, as expected by 364 // Convert the AVC NALU length fields to Annex B headers, as expected by
364 // decoding libraries. Since this may enlarge the size of the buffer, we also 365 // decoding libraries. Since this may enlarge the size of the buffer, we also
365 // update the clear byte count for each subsample if encryption is used to 366 // update the clear byte count for each subsample if encryption is used to
366 // account for the difference in size between the length prefix and Annex B 367 // account for the difference in size between the length prefix and Annex B
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 runs.AdvanceSample(); 626 runs.AdvanceSample();
626 } 627 }
627 runs.AdvanceRun(); 628 runs.AdvanceRun();
628 } 629 }
629 630
630 return true; 631 return true;
631 } 632 }
632 633
633 } // namespace mp4 634 } // namespace mp4
634 } // namespace media 635 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/pipeline_integration_test.cc ('k') | media/formats/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698