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

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

Issue 611513005: Pass initDataType instead of contentType on OnNeedKey(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Again. 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 // TODO(xhwang): Figure out the init data type appropriately once it's spec'ed. 25 static const char kCencInitDataType[] = "cenc";
26 static const char kMp4InitDataType[] = "video/mp4";
27 26
28 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types, 27 MP4StreamParser::MP4StreamParser(const std::set<int>& audio_object_types,
29 bool has_sbr) 28 bool has_sbr)
30 : state_(kWaitingForInit), 29 : state_(kWaitingForInit),
31 moof_head_(0), 30 moof_head_(0),
32 mdat_tail_(0), 31 mdat_tail_(0),
33 highest_end_offset_(0), 32 highest_end_offset_(0),
34 has_audio_(false), 33 has_audio_(false),
35 has_video_(false), 34 has_video_(false),
36 audio_track_id_(0), 35 audio_track_id_(0),
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 for (size_t i = 0; i < headers.size(); i++) 346 for (size_t i = 0; i < headers.size(); i++)
348 total_size += headers[i].raw_box.size(); 347 total_size += headers[i].raw_box.size();
349 348
350 std::vector<uint8> init_data(total_size); 349 std::vector<uint8> init_data(total_size);
351 size_t pos = 0; 350 size_t pos = 0;
352 for (size_t i = 0; i < headers.size(); i++) { 351 for (size_t i = 0; i < headers.size(); i++) {
353 memcpy(&init_data[pos], &headers[i].raw_box[0], 352 memcpy(&init_data[pos], &headers[i].raw_box[0],
354 headers[i].raw_box.size()); 353 headers[i].raw_box.size());
355 pos += headers[i].raw_box.size(); 354 pos += headers[i].raw_box.size();
356 } 355 }
357 need_key_cb_.Run(kMp4InitDataType, init_data); 356 need_key_cb_.Run(kCencInitDataType, init_data);
358 } 357 }
359 358
360 bool MP4StreamParser::PrepareAVCBuffer( 359 bool MP4StreamParser::PrepareAVCBuffer(
361 const AVCDecoderConfigurationRecord& avc_config, 360 const AVCDecoderConfigurationRecord& avc_config,
362 std::vector<uint8>* frame_buf, 361 std::vector<uint8>* frame_buf,
363 std::vector<SubsampleEntry>* subsamples) const { 362 std::vector<SubsampleEntry>* subsamples) const {
364 // Convert the AVC NALU length fields to Annex B headers, as expected by 363 // Convert the AVC NALU length fields to Annex B headers, as expected by
365 // decoding libraries. Since this may enlarge the size of the buffer, we also 364 // decoding libraries. Since this may enlarge the size of the buffer, we also
366 // update the clear byte count for each subsample if encryption is used to 365 // update the clear byte count for each subsample if encryption is used to
367 // account for the difference in size between the length prefix and Annex B 366 // 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
626 runs.AdvanceSample(); 625 runs.AdvanceSample();
627 } 626 }
628 runs.AdvanceRun(); 627 runs.AdvanceRun();
629 } 628 }
630 629
631 return true; 630 return true;
632 } 631 }
633 632
634 } // namespace mp4 633 } // namespace mp4
635 } // namespace media 634 } // 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