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

Side by Side Diff: media/formats/mp2t/es_parser_h264.cc

Issue 2783703002: Declare intent to use sample-aes later in the stream. (Closed)
Patch Set: tweak needed for flush Created 3 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
« no previous file with comments | « media/formats/mp2t/es_parser_adts.cc ('k') | media/formats/mp2t/mp2t_stream_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/mp2t/es_parser_h264.h" 5 #include "media/formats/mp2t/es_parser_h264.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 // Emit a frame. 430 // Emit a frame.
431 DVLOG(LOG_LEVEL_ES) << "Emit frame: stream_pos=" << current_access_unit_pos_ 431 DVLOG(LOG_LEVEL_ES) << "Emit frame: stream_pos=" << current_access_unit_pos_
432 << " size=" << access_unit_size; 432 << " size=" << access_unit_size;
433 int es_size; 433 int es_size;
434 const uint8_t* es; 434 const uint8_t* es;
435 es_queue_->PeekAt(current_access_unit_pos_, &es, &es_size); 435 es_queue_->PeekAt(current_access_unit_pos_, &es, &es_size);
436 CHECK_GE(es_size, access_unit_size); 436 CHECK_GE(es_size, access_unit_size);
437 437
438 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) 438 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
439 const DecryptConfig* base_decrypt_config = nullptr;
440 if (use_hls_sample_aes_) {
441 DCHECK(!get_decrypt_config_cb_.is_null());
442 base_decrypt_config = get_decrypt_config_cb_.Run();
443 }
444
439 std::unique_ptr<uint8_t[]> adjusted_au; 445 std::unique_ptr<uint8_t[]> adjusted_au;
440 std::vector<SubsampleEntry> subsamples; 446 std::vector<SubsampleEntry> subsamples;
441 if (use_hls_sample_aes_) { 447 if (use_hls_sample_aes_ && base_decrypt_config) {
442 adjusted_au = AdjustAUForSampleAES(es, &access_unit_size, protected_blocks_, 448 adjusted_au = AdjustAUForSampleAES(es, &access_unit_size, protected_blocks_,
443 &subsamples); 449 &subsamples);
444 protected_blocks_.clear(); 450 protected_blocks_.clear();
445 if (adjusted_au) 451 if (adjusted_au)
446 es = adjusted_au.get(); 452 es = adjusted_au.get();
447 } 453 }
448 #endif 454 #endif
449 455
450 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId 456 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId
451 // type and allow multiple video tracks. See https://crbug.com/341581. 457 // type and allow multiple video tracks. See https://crbug.com/341581.
452 scoped_refptr<StreamParserBuffer> stream_parser_buffer = 458 scoped_refptr<StreamParserBuffer> stream_parser_buffer =
453 StreamParserBuffer::CopyFrom(es, access_unit_size, is_key_frame, 459 StreamParserBuffer::CopyFrom(es, access_unit_size, is_key_frame,
454 DemuxerStream::VIDEO, kMp2tVideoTrackId); 460 DemuxerStream::VIDEO, kMp2tVideoTrackId);
455 stream_parser_buffer->SetDecodeTimestamp(current_timing_desc.dts); 461 stream_parser_buffer->SetDecodeTimestamp(current_timing_desc.dts);
456 stream_parser_buffer->set_timestamp(current_timing_desc.pts); 462 stream_parser_buffer->set_timestamp(current_timing_desc.pts);
457 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES) 463 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
458 if (use_hls_sample_aes_) { 464 if (use_hls_sample_aes_ && base_decrypt_config) {
459 DCHECK(!get_decrypt_config_cb_.is_null());
460 const DecryptConfig* base_decrypt_config = get_decrypt_config_cb_.Run();
461 RCHECK(base_decrypt_config);
462 std::unique_ptr<DecryptConfig> decrypt_config(new DecryptConfig( 465 std::unique_ptr<DecryptConfig> decrypt_config(new DecryptConfig(
463 base_decrypt_config->key_id(), base_decrypt_config->iv(), subsamples)); 466 base_decrypt_config->key_id(), base_decrypt_config->iv(), subsamples));
464 stream_parser_buffer->set_decrypt_config(std::move(decrypt_config)); 467 stream_parser_buffer->set_decrypt_config(std::move(decrypt_config));
465 } 468 }
466 #endif 469 #endif
467 return es_adapter_.OnNewBuffer(stream_parser_buffer); 470 return es_adapter_.OnNewBuffer(stream_parser_buffer);
468 } 471 }
469 472
470 bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps, 473 bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps,
471 const EncryptionScheme& scheme) { 474 const EncryptionScheme& scheme) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 << " height=" << sps->sar_height; 518 << " height=" << sps->sar_height;
516 last_video_decoder_config_ = video_decoder_config; 519 last_video_decoder_config_ = video_decoder_config;
517 es_adapter_.OnConfigChanged(video_decoder_config); 520 es_adapter_.OnConfigChanged(video_decoder_config);
518 } 521 }
519 522
520 return true; 523 return true;
521 } 524 }
522 525
523 } // namespace mp2t 526 } // namespace mp2t
524 } // namespace media 527 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_adts.cc ('k') | media/formats/mp2t/mp2t_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698