From d1068964ae14bf562db93f26962390769b60c3c0 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Tue, 30 Sep 2014 14:52:21 -0700 Subject: [PATCH] Replace u?int(8|16|32|64) with u?int(8|16|32|64)_t u?int(8|16|32|64) are DEPRECATED per base/basictypes.h. The change was made using the below commands with some adjustments for pretty formatting: > find {media,app,mpd} -name '*.proto' -prune -o -type f -exec sed -r -i 's/\b(u?int[0-9]+)\b/\1_t/g' {} \; > git clang-format Change-Id: I99d2e5e0fbbdbc5d7b9eb121b4622de780413f53 --- app/packager_util.cc | 2 +- app/stream_descriptor.h | 2 +- media/base/aes_encryptor.cc | 94 ++-- media/base/aes_encryptor.h | 96 ++--- media/base/aes_encryptor_unittest.cc | 213 ++++----- media/base/audio_stream_info.cc | 17 +- media/base/audio_stream_info.h | 35 +- media/base/audio_timestamp_helper.cc | 31 +- media/base/audio_timestamp_helper.h | 23 +- media/base/audio_timestamp_helper_unittest.cc | 18 +- media/base/bit_reader.cc | 6 +- media/base/bit_reader.h | 10 +- media/base/bit_reader_unittest.cc | 14 +- media/base/buffer_reader.cc | 38 +- media/base/buffer_reader.h | 26 +- media/base/buffer_writer.cc | 42 +- media/base/buffer_writer.h | 26 +- media/base/buffer_writer_unittest.cc | 54 +-- media/base/byte_queue.cc | 12 +- media/base/byte_queue.h | 8 +- media/base/container_names.cc | 121 +++--- media/base/container_names.h | 2 +- media/base/container_names_unittest.cc | 44 +- media/base/decrypt_config.cc | 4 +- media/base/decrypt_config.h | 16 +- media/base/demuxer.cc | 9 +- media/base/demuxer.h | 4 +- media/base/fake_prng.cc | 2 +- media/base/http_fetcher.cc | 2 +- media/base/http_fetcher.h | 4 +- media/base/http_fetcher_unittest.cc | 4 +- media/base/key_source.cc | 30 +- media/base/key_source.h | 20 +- media/base/media_parser.h | 6 +- media/base/media_sample.cc | 10 +- media/base/media_sample.h | 44 +- media/base/muxer.cc | 4 +- media/base/muxer.h | 6 +- media/base/muxer_options.h | 2 +- media/base/muxer_util.cc | 16 +- media/base/muxer_util.h | 6 +- media/base/muxer_util_unittest.cc | 18 +- media/base/network_util.cc | 28 +- media/base/network_util.h | 6 +- media/base/offset_byte_queue.cc | 8 +- media/base/offset_byte_queue.h | 16 +- media/base/offset_byte_queue_unittest.cc | 8 +- media/base/producer_consumer_queue.h | 14 +- .../base/producer_consumer_queue_unittest.cc | 6 +- media/base/request_signer.cc | 4 +- media/base/rsa_key.cc | 38 +- media/base/rsa_test_data.cc | 16 +- media/base/stream_info.cc | 7 +- media/base/stream_info.h | 24 +- media/base/timestamp.h | 4 +- media/base/video_stream_info.cc | 23 +- media/base/video_stream_info.h | 30 +- media/base/widevine_key_source.cc | 41 +- media/base/widevine_key_source.h | 20 +- media/base/widevine_key_source_unittest.cc | 41 +- media/event/mpd_notify_muxer_listener.cc | 20 +- media/event/mpd_notify_muxer_listener.h | 20 +- media/event/muxer_listener.h | 19 +- media/event/muxer_listener_internal.cc | 32 +- media/event/muxer_listener_internal.h | 12 +- .../vod_media_info_dump_muxer_listener.cc | 18 +- .../vod_media_info_dump_muxer_listener.h | 18 +- ...media_info_dump_muxer_listener_unittest.cc | 54 +-- media/file/file.cc | 6 +- media/file/file.h | 8 +- media/file/local_file.cc | 8 +- media/file/local_file.h | 6 +- media/file/udp_file.cc | 22 +- media/file/udp_file.h | 6 +- media/filters/h264_bit_reader.cc | 2 +- media/filters/h264_bit_reader.h | 4 +- .../h264_byte_to_unit_stream_converter.cc | 33 +- .../h264_byte_to_unit_stream_converter.h | 12 +- ..._byte_to_unit_stream_converter_unittest.cc | 16 +- media/filters/h264_parser.cc | 12 +- media/filters/h264_parser.h | 14 +- media/formats/mp2t/adts_header.cc | 24 +- media/formats/mp2t/adts_header.h | 20 +- media/formats/mp2t/adts_header_unittest.cc | 21 +- media/formats/mp2t/es_parser.h | 15 +- media/formats/mp2t/es_parser_adts.cc | 41 +- media/formats/mp2t/es_parser_adts.h | 13 +- media/formats/mp2t/es_parser_h264.cc | 40 +- media/formats/mp2t/es_parser_h264.h | 27 +- media/formats/mp2t/es_parser_h264_unittest.cc | 24 +- media/formats/mp2t/mp2t_common.h | 2 +- media/formats/mp2t/mp2t_media_parser.cc | 8 +- media/formats/mp2t/mp2t_media_parser.h | 4 +- .../mp2t/mp2t_media_parser_unittest.cc | 21 +- media/formats/mp2t/ts_packet.cc | 12 +- media/formats/mp2t/ts_packet.h | 10 +- media/formats/mp2t/ts_section.h | 3 +- media/formats/mp2t/ts_section_pes.cc | 46 +- media/formats/mp2t/ts_section_pes.h | 9 +- media/formats/mp2t/ts_section_psi.cc | 13 +- media/formats/mp2t/ts_section_psi.h | 3 +- .../formats/mp4/aac_audio_specific_config.cc | 37 +- media/formats/mp4/aac_audio_specific_config.h | 32 +- .../mp4/aac_audio_specific_config_unittest.cc | 34 +- media/formats/mp4/box.cc | 4 +- media/formats/mp4/box.h | 8 +- media/formats/mp4/box_buffer.h | 24 +- media/formats/mp4/box_definitions.cc | 405 +++++++++--------- media/formats/mp4/box_definitions.h | 222 +++++----- media/formats/mp4/box_definitions_unittest.cc | 36 +- media/formats/mp4/box_reader.cc | 14 +- media/formats/mp4/box_reader.h | 10 +- media/formats/mp4/box_reader_unittest.cc | 62 +-- media/formats/mp4/cenc.cc | 21 +- media/formats/mp4/cenc.h | 8 +- media/formats/mp4/chunk_info_iterator.cc | 10 +- media/formats/mp4/chunk_info_iterator.h | 14 +- .../mp4/chunk_info_iterator_unittest.cc | 26 +- .../mp4/composition_offset_iterator.cc | 8 +- .../formats/mp4/composition_offset_iterator.h | 8 +- .../composition_offset_iterator_unittest.cc | 14 +- media/formats/mp4/decoding_time_iterator.cc | 14 +- media/formats/mp4/decoding_time_iterator.h | 8 +- .../mp4/decoding_time_iterator_unittest.cc | 16 +- media/formats/mp4/encrypting_fragmenter.cc | 14 +- media/formats/mp4/encrypting_fragmenter.h | 12 +- media/formats/mp4/es_descriptor.cc | 84 ++-- media/formats/mp4/es_descriptor.h | 14 +- media/formats/mp4/es_descriptor_unittest.cc | 48 +-- media/formats/mp4/fragmenter.cc | 8 +- media/formats/mp4/fragmenter.h | 16 +- media/formats/mp4/key_rotation_fragmenter.cc | 15 +- media/formats/mp4/key_rotation_fragmenter.h | 8 +- media/formats/mp4/mp4_media_parser.cc | 38 +- media/formats/mp4/mp4_media_parser.h | 12 +- .../formats/mp4/mp4_media_parser_unittest.cc | 20 +- media/formats/mp4/mp4_muxer.cc | 37 +- media/formats/mp4/mp4_muxer.h | 10 +- media/formats/mp4/multi_segment_segmenter.cc | 14 +- media/formats/mp4/multi_segment_segmenter.h | 2 +- media/formats/mp4/segmenter.cc | 28 +- media/formats/mp4/segmenter.h | 10 +- media/formats/mp4/single_segment_segmenter.cc | 10 +- media/formats/mp4/sync_sample_iterator.cc | 2 +- media/formats/mp4/sync_sample_iterator.h | 8 +- .../mp4/sync_sample_iterator_unittest.cc | 15 +- media/formats/mp4/track_run_iterator.cc | 70 +-- media/formats/mp4/track_run_iterator.h | 20 +- .../mp4/track_run_iterator_unittest.cc | 15 +- media/formats/wvm/wvm_media_parser.cc | 167 ++++---- media/formats/wvm/wvm_media_parser.h | 112 ++--- .../formats/wvm/wvm_media_parser_unittest.cc | 11 +- media/test/test_data_util.cc | 4 +- media/test/test_data_util.h | 2 +- mpd/base/bandwidth_estimator.cc | 12 +- mpd/base/bandwidth_estimator.h | 4 +- mpd/base/bandwidth_estimator_test.cc | 38 +- mpd/base/mpd_builder.cc | 62 ++- mpd/base/mpd_builder.h | 24 +- mpd/base/mpd_builder_unittest.cc | 199 +++++---- mpd/base/mpd_notifier.h | 12 +- mpd/base/segment_info.h | 6 +- mpd/base/simple_mpd_notifier.cc | 14 +- mpd/base/simple_mpd_notifier.h | 14 +- mpd/base/simple_vod_mpd_notifier.cc | 14 +- mpd/base/simple_vod_mpd_notifier.h | 14 +- mpd/base/xml/xml_node.cc | 20 +- mpd/base/xml/xml_node.h | 6 +- mpd/base/xml/xml_node_unittest.cc | 2 +- mpd/util/mpd_writer.cc | 2 +- 170 files changed, 2262 insertions(+), 2215 deletions(-) diff --git a/app/packager_util.cc b/app/packager_util.cc index 19dda74cb6..9cc9b725dc 100644 --- a/app/packager_util.cc +++ b/app/packager_util.cc @@ -70,7 +70,7 @@ scoped_ptr CreateEncryptionKeySource() { scoped_ptr encryption_key_source; if (FLAGS_enable_widevine_encryption) { scoped_ptr signer(CreateSigner()); - std::vector content_id; + std::vector content_id; if (!base::HexStringToBytes(FLAGS_content_id, &content_id)) { LOG(ERROR) << "Invalid content_id hex string specified."; return scoped_ptr(); diff --git a/app/stream_descriptor.h b/app/stream_descriptor.h index a9a91bc00a..e54d52aa63 100644 --- a/app/stream_descriptor.h +++ b/app/stream_descriptor.h @@ -25,7 +25,7 @@ struct StreamDescriptor { std::string input; std::string output; std::string segment_template; - uint32 bandwidth; + uint32_t bandwidth; }; class StreamDescriptorCompareFn { diff --git a/media/base/aes_encryptor.cc b/media/base/aes_encryptor.cc index b548933b3e..089e66b9ca 100644 --- a/media/base/aes_encryptor.cc +++ b/media/base/aes_encryptor.cc @@ -15,7 +15,7 @@ namespace { // Increment an 8-byte counter by 1. Return true if overflowed. -bool Increment64(uint8* counter) { +bool Increment64(uint8_t* counter) { DCHECK(counter); for (int i = 7; i >= 0; --i) if (++counter[i] != 0) @@ -33,7 +33,7 @@ bool IsKeySizeValidForAes(size_t key_size) { } // CENC protection scheme uses 128-bit keys in counter mode. -const uint32 kCencKeySize = 16; +const uint32_t kCencKeySize = 16; } // namespace @@ -50,9 +50,9 @@ AesCtrEncryptor::AesCtrEncryptor() AesCtrEncryptor::~AesCtrEncryptor() {} -bool AesCtrEncryptor::InitializeWithRandomIv(const std::vector& key, - uint8 iv_size) { - std::vector iv(iv_size, 0); +bool AesCtrEncryptor::InitializeWithRandomIv(const std::vector& key, + uint8_t iv_size) { + std::vector iv(iv_size, 0); if (RAND_bytes(&iv[0], iv_size) != 1) { LOG(ERROR) << "RAND_bytes failed with error: " << ERR_error_string(ERR_get_error(), NULL); @@ -61,8 +61,8 @@ bool AesCtrEncryptor::InitializeWithRandomIv(const std::vector& key, return InitializeWithIv(key, iv); } -bool AesCtrEncryptor::InitializeWithIv(const std::vector& key, - const std::vector& iv) { +bool AesCtrEncryptor::InitializeWithIv(const std::vector& key, + const std::vector& iv) { if (key.size() != kCencKeySize) { LOG(ERROR) << "Invalid key size of " << key.size() << " for CENC."; return false; @@ -77,9 +77,9 @@ bool AesCtrEncryptor::InitializeWithIv(const std::vector& key, return SetIv(iv); } -bool AesCtrEncryptor::Encrypt(const uint8* plaintext, +bool AesCtrEncryptor::Encrypt(const uint8_t* plaintext, size_t plaintext_size, - uint8* ciphertext) { + uint8_t* ciphertext) { DCHECK(plaintext); DCHECK(ciphertext); DCHECK(aes_key_); @@ -130,7 +130,7 @@ void AesCtrEncryptor::UpdateIv() { counter_overflow_ = false; } -bool AesCtrEncryptor::SetIv(const std::vector& iv) { +bool AesCtrEncryptor::SetIv(const std::vector& iv) { if (!IsIvSizeValid(iv.size())) { LOG(ERROR) << "Invalid IV size: " << iv.size(); return false; @@ -145,8 +145,8 @@ bool AesCtrEncryptor::SetIv(const std::vector& iv) { AesCbcPkcs5Encryptor::AesCbcPkcs5Encryptor() {} AesCbcPkcs5Encryptor::~AesCbcPkcs5Encryptor() {} -bool AesCbcPkcs5Encryptor::InitializeWithIv(const std::vector& key, - const std::vector& iv) { +bool AesCbcPkcs5Encryptor::InitializeWithIv(const std::vector& key, + const std::vector& iv) { if (!IsKeySizeValidForAes(key.size())) { LOG(ERROR) << "Invalid AES key size: " << key.size(); return false; @@ -175,16 +175,16 @@ void AesCbcPkcs5Encryptor::Encrypt(const std::string& plaintext, padded_text.append(num_padding_bytes, static_cast(num_padding_bytes)); ciphertext->resize(padded_text.size()); - std::vector iv(iv_); - AES_cbc_encrypt(reinterpret_cast(padded_text.data()), - reinterpret_cast(string_as_array(ciphertext)), + std::vector iv(iv_); + AES_cbc_encrypt(reinterpret_cast(padded_text.data()), + reinterpret_cast(string_as_array(ciphertext)), padded_text.size(), encrypt_key_.get(), &iv[0], AES_ENCRYPT); } -bool AesCbcPkcs5Encryptor::SetIv(const std::vector& iv) { +bool AesCbcPkcs5Encryptor::SetIv(const std::vector& iv) { if (iv.size() != AES_BLOCK_SIZE) { LOG(ERROR) << "Invalid IV size: " << iv.size(); return false; @@ -197,8 +197,8 @@ bool AesCbcPkcs5Encryptor::SetIv(const std::vector& iv) { AesCbcPkcs5Decryptor::AesCbcPkcs5Decryptor() {} AesCbcPkcs5Decryptor::~AesCbcPkcs5Decryptor() {} -bool AesCbcPkcs5Decryptor::InitializeWithIv(const std::vector& key, - const std::vector& iv) { +bool AesCbcPkcs5Decryptor::InitializeWithIv(const std::vector& key, + const std::vector& iv) { if (!IsKeySizeValidForAes(key.size())) { LOG(ERROR) << "Invalid AES key size: " << key.size(); return false; @@ -227,15 +227,15 @@ bool AesCbcPkcs5Decryptor::Decrypt(const std::string& ciphertext, DCHECK(decrypt_key_); plaintext->resize(ciphertext.size()); - AES_cbc_encrypt(reinterpret_cast(ciphertext.data()), - reinterpret_cast(string_as_array(plaintext)), + AES_cbc_encrypt(reinterpret_cast(ciphertext.data()), + reinterpret_cast(string_as_array(plaintext)), ciphertext.size(), decrypt_key_.get(), &iv_[0], AES_DECRYPT); // Strip off PKCS5 padding bytes. - const uint8 num_padding_bytes = (*plaintext)[plaintext->size() - 1]; + const uint8_t num_padding_bytes = (*plaintext)[plaintext->size() - 1]; if (num_padding_bytes > AES_BLOCK_SIZE) { LOG(ERROR) << "Padding length is too large : " << static_cast(num_padding_bytes); @@ -245,7 +245,7 @@ bool AesCbcPkcs5Decryptor::Decrypt(const std::string& ciphertext, return true; } -bool AesCbcPkcs5Decryptor::SetIv(const std::vector& iv) { +bool AesCbcPkcs5Decryptor::SetIv(const std::vector& iv) { if (iv.size() != AES_BLOCK_SIZE) { LOG(ERROR) << "Invalid IV size: " << iv.size(); return false; @@ -258,8 +258,8 @@ bool AesCbcPkcs5Decryptor::SetIv(const std::vector& iv) { AesCbcCtsEncryptor::AesCbcCtsEncryptor() {} AesCbcCtsEncryptor::~AesCbcCtsEncryptor() {} -bool AesCbcCtsEncryptor::InitializeWithIv(const std::vector& key, - const std::vector& iv) { +bool AesCbcCtsEncryptor::InitializeWithIv(const std::vector& key, + const std::vector& iv) { if (!IsKeySizeValidForAes(key.size())) { LOG(ERROR) << "Invalid AES key size: " << key.size(); return false; @@ -276,9 +276,9 @@ bool AesCbcCtsEncryptor::InitializeWithIv(const std::vector& key, return true; } -void AesCbcCtsEncryptor::Encrypt(const uint8* plaintext, +void AesCbcCtsEncryptor::Encrypt(const uint8_t* plaintext, size_t size, - uint8* ciphertext) { + uint8_t* ciphertext) { DCHECK(plaintext); DCHECK(ciphertext); @@ -288,7 +288,7 @@ void AesCbcCtsEncryptor::Encrypt(const uint8* plaintext, return; } - std::vector iv(iv_); + std::vector iv(iv_); size_t residual_block_size = size % AES_BLOCK_SIZE; size_t cbc_size = size - residual_block_size; @@ -305,8 +305,8 @@ void AesCbcCtsEncryptor::Encrypt(const uint8* plaintext, } // Zero-pad the residual block and encrypt using CBC. - std::vector residual_block(plaintext + size - residual_block_size, - plaintext + size); + std::vector residual_block(plaintext + size - residual_block_size, + plaintext + size); residual_block.resize(AES_BLOCK_SIZE, 0); AES_cbc_encrypt(&residual_block[0], &residual_block[0], @@ -320,7 +320,7 @@ void AesCbcCtsEncryptor::Encrypt(const uint8* plaintext, // encrypted block. It may appear that some encrypted bits of the last full // block are lost, but they are not, as they were used as the IV when // encrypting the zero-padded residual block. - uint8* residual_ciphertext_block = ciphertext + size - residual_block_size; + uint8_t* residual_ciphertext_block = ciphertext + size - residual_block_size; memcpy(residual_ciphertext_block, residual_ciphertext_block - AES_BLOCK_SIZE, residual_block_size); @@ -329,8 +329,8 @@ void AesCbcCtsEncryptor::Encrypt(const uint8* plaintext, AES_BLOCK_SIZE); } -void AesCbcCtsEncryptor::Encrypt(const std::vector& plaintext, - std::vector* ciphertext) { +void AesCbcCtsEncryptor::Encrypt(const std::vector& plaintext, + std::vector* ciphertext) { DCHECK(ciphertext); ciphertext->resize(plaintext.size(), 0); @@ -340,7 +340,7 @@ void AesCbcCtsEncryptor::Encrypt(const std::vector& plaintext, return Encrypt(plaintext.data(), plaintext.size(), &(*ciphertext)[0]); } -bool AesCbcCtsEncryptor::SetIv(const std::vector& iv) { +bool AesCbcCtsEncryptor::SetIv(const std::vector& iv) { if (iv.size() != AES_BLOCK_SIZE) { LOG(ERROR) << "Invalid IV size: " << iv.size(); return false; @@ -353,8 +353,8 @@ bool AesCbcCtsEncryptor::SetIv(const std::vector& iv) { AesCbcCtsDecryptor::AesCbcCtsDecryptor() {} AesCbcCtsDecryptor::~AesCbcCtsDecryptor() {} -bool AesCbcCtsDecryptor::InitializeWithIv(const std::vector& key, - const std::vector& iv) { +bool AesCbcCtsDecryptor::InitializeWithIv(const std::vector& key, + const std::vector& iv) { if (!IsKeySizeValidForAes(key.size())) { LOG(ERROR) << "Invalid AES key size: " << key.size(); return false; @@ -371,9 +371,9 @@ bool AesCbcCtsDecryptor::InitializeWithIv(const std::vector& key, return true; } -void AesCbcCtsDecryptor::Decrypt(const uint8* ciphertext, +void AesCbcCtsDecryptor::Decrypt(const uint8_t* ciphertext, size_t size, - uint8* plaintext) { + uint8_t* plaintext) { DCHECK(ciphertext); DCHECK(plaintext); @@ -383,7 +383,7 @@ void AesCbcCtsDecryptor::Decrypt(const uint8* ciphertext, return; } - std::vector iv(iv_); + std::vector iv(iv_); size_t residual_block_size = size % AES_BLOCK_SIZE; if (residual_block_size == 0) { @@ -410,8 +410,8 @@ void AesCbcCtsDecryptor::Decrypt(const uint8* ciphertext, // Determine what the last IV should be so that we can "skip ahead" in the // CBC decryption. - std::vector last_iv(ciphertext + size - residual_block_size, - ciphertext + size); + std::vector last_iv(ciphertext + size - residual_block_size, + ciphertext + size); last_iv.resize(AES_BLOCK_SIZE, 0); // Decrypt the next-to-last block using the IV determined above. This decrypts @@ -425,17 +425,17 @@ void AesCbcCtsDecryptor::Decrypt(const uint8* ciphertext, // Swap back the residual block bits and the next-to-last full block. if (plaintext == ciphertext) { - uint8* ptr1 = plaintext + size - residual_block_size; - uint8* ptr2 = plaintext + size - residual_block_size - AES_BLOCK_SIZE; + uint8_t* ptr1 = plaintext + size - residual_block_size; + uint8_t* ptr2 = plaintext + size - residual_block_size - AES_BLOCK_SIZE; for (size_t i = 0; i < residual_block_size; ++i) { - uint8 temp = *ptr1; + uint8_t temp = *ptr1; *ptr1 = *ptr2; *ptr2 = temp; ++ptr1; ++ptr2; } } else { - uint8* residual_plaintext_block = plaintext + size - residual_block_size; + uint8_t* residual_plaintext_block = plaintext + size - residual_block_size; memcpy(residual_plaintext_block, residual_plaintext_block - AES_BLOCK_SIZE, residual_block_size); @@ -453,8 +453,8 @@ void AesCbcCtsDecryptor::Decrypt(const uint8* ciphertext, AES_DECRYPT); } -void AesCbcCtsDecryptor::Decrypt(const std::vector& ciphertext, - std::vector* plaintext) { +void AesCbcCtsDecryptor::Decrypt(const std::vector& ciphertext, + std::vector* plaintext) { DCHECK(plaintext); plaintext->resize(ciphertext.size(), 0); @@ -464,7 +464,7 @@ void AesCbcCtsDecryptor::Decrypt(const std::vector& ciphertext, return Decrypt(ciphertext.data(), ciphertext.size(), &(*plaintext)[0]); } -bool AesCbcCtsDecryptor::SetIv(const std::vector& iv) { +bool AesCbcCtsDecryptor::SetIv(const std::vector& iv) { if (iv.size() != AES_BLOCK_SIZE) { LOG(ERROR) << "Invalid IV size: " << iv.size(); return false; diff --git a/media/base/aes_encryptor.h b/media/base/aes_encryptor.h index ffc017e5c0..23ee67d807 100644 --- a/media/base/aes_encryptor.h +++ b/media/base/aes_encryptor.h @@ -32,46 +32,46 @@ class AesCtrEncryptor { /// @param key should be 16 bytes in size as specified in CENC spec. /// @param iv_size should be either 8 or 16 as specified in CENC spec. /// @return true on successful initialization, false otherwise. - bool InitializeWithRandomIv(const std::vector& key, uint8 iv_size); + bool InitializeWithRandomIv(const std::vector& key, uint8_t iv_size); /// Initialize the encryptor with specified key and IV. block_offset() is /// reset to 0 on success. /// @param key should be 16 bytes in size as specified in CENC spec. /// @param iv should be 8 bytes or 16 bytes in size as specified in CENC spec. /// @return true on successful initialization, false otherwise. - bool InitializeWithIv(const std::vector& key, - const std::vector& iv); + bool InitializeWithIv(const std::vector& key, + const std::vector& iv); /// @name Various forms of encrypt calls. /// block_offset() will be updated according to input plaintext size. /// @{ - bool Encrypt(const uint8* plaintext, + bool Encrypt(const uint8_t* plaintext, size_t plaintext_size, - uint8* ciphertext); + uint8_t* ciphertext); - bool Encrypt(const std::vector& plaintext, - std::vector* ciphertext) { + bool Encrypt(const std::vector& plaintext, + std::vector* ciphertext) { ciphertext->resize(plaintext.size()); return Encrypt(&plaintext[0], plaintext.size(), &(*ciphertext)[0]); } bool Encrypt(const std::string& plaintext, std::string* ciphertext) { ciphertext->resize(plaintext.size()); - return Encrypt(reinterpret_cast(plaintext.data()), + return Encrypt(reinterpret_cast(plaintext.data()), plaintext.size(), - reinterpret_cast(string_as_array(ciphertext))); + reinterpret_cast(string_as_array(ciphertext))); } /// @} // For AES CTR, encryption and decryption are identical. - bool Decrypt(const uint8* ciphertext, + bool Decrypt(const uint8_t* ciphertext, size_t ciphertext_size, - uint8* plaintext) { + uint8_t* plaintext) { return Encrypt(ciphertext, ciphertext_size, plaintext); } - bool Decrypt(const std::vector& ciphertext, - std::vector* plaintext) { + bool Decrypt(const std::vector& ciphertext, + std::vector* plaintext) { return Encrypt(ciphertext, plaintext); } @@ -87,23 +87,23 @@ class AesCtrEncryptor { /// Set IV. @a block_offset_ is reset to 0 on success. /// @return true if successful, false if the input is invalid. - bool SetIv(const std::vector& iv); + bool SetIv(const std::vector& iv); - const std::vector& iv() const { return iv_; } + const std::vector& iv() const { return iv_; } - uint32 block_offset() const { return block_offset_; } + uint32_t block_offset() const { return block_offset_; } private: // Initialization vector, with size 8 or 16. - std::vector iv_; + std::vector iv_; // Current block offset. - uint32 block_offset_; + uint32_t block_offset_; // Openssl AES_KEY. scoped_ptr aes_key_; // Current AES-CTR counter. - std::vector counter_; + std::vector counter_; // Encrypted counter. - std::vector encrypted_counter_; + std::vector encrypted_counter_; // Keep track of whether the counter has overflowed. bool counter_overflow_; @@ -122,20 +122,20 @@ class AesCbcPkcs5Encryptor { /// in AES spec. /// @param iv should be 16 bytes in size. /// @return true on successful initialization, false otherwise. - bool InitializeWithIv(const std::vector& key, - const std::vector& iv); + bool InitializeWithIv(const std::vector& key, + const std::vector& iv); /// @param plaintext will be PKCS5 padded before being encrypted. /// @param ciphertext should not be NULL. void Encrypt(const std::string& plaintext, std::string* ciphertext); /// @return true if successful, false if the input is invalid. - bool SetIv(const std::vector& iv); + bool SetIv(const std::vector& iv); - const std::vector& iv() const { return iv_; } + const std::vector& iv() const { return iv_; } private: - std::vector iv_; + std::vector iv_; scoped_ptr encrypt_key_; DISALLOW_COPY_AND_ASSIGN(AesCbcPkcs5Encryptor); @@ -153,8 +153,8 @@ class AesCbcPkcs5Decryptor { /// in AES spec. /// @param iv should be 16 bytes in size. /// @return true on successful initialization, false otherwise. - bool InitializeWithIv(const std::vector& key, - const std::vector& iv); + bool InitializeWithIv(const std::vector& key, + const std::vector& iv); /// @param ciphertext is expected to be padded with PKCS5 padding. /// @param plaintext should not be NULL. @@ -162,12 +162,12 @@ class AesCbcPkcs5Decryptor { bool Decrypt(const std::string& ciphertext, std::string* plaintext); /// @return true if successful, false if the input is invalid. - bool SetIv(const std::vector& iv); + bool SetIv(const std::vector& iv); - const std::vector& iv() const { return iv_; } + const std::vector& iv() const { return iv_; } private: - std::vector iv_; + std::vector iv_; scoped_ptr decrypt_key_; DISALLOW_COPY_AND_ASSIGN(AesCbcPkcs5Decryptor); @@ -185,32 +185,30 @@ class AesCbcCtsEncryptor { /// in AES spec. /// @param iv should be 16 bytes in size. /// @return true on successful initialization, false otherwise. - bool InitializeWithIv(const std::vector& key, - const std::vector& iv); + bool InitializeWithIv(const std::vector& key, + const std::vector& iv); /// @param plaintext points to the data to be encrypted. /// @param size is the number of bytes to be encrypted. If less than 16 /// bytes, it will be copied in the clear. /// @param ciphertext should not be NULL. The buffer should be at least /// @a size bytes in length. - void Encrypt(const uint8* plaintext, - size_t size, - uint8* ciphertext); + void Encrypt(const uint8_t* plaintext, size_t size, uint8_t* ciphertext); /// @param plaintext contains the data to be encrypted. If less than 16 /// bytes in size, it will be copied in the clear. /// @param ciphertext should not be NULL. Caller retains ownership. - void Encrypt(const std::vector& plaintext, - std::vector* ciphertext); + void Encrypt(const std::vector& plaintext, + std::vector* ciphertext); /// @param iv is the initialization vector. Should be 16 bytes in size. /// @return true if successful, false if the input is invalid. - bool SetIv(const std::vector& iv); + bool SetIv(const std::vector& iv); - const std::vector& iv() const { return iv_; } + const std::vector& iv() const { return iv_; } private: - std::vector iv_; + std::vector iv_; scoped_ptr encrypt_key_; DISALLOW_COPY_AND_ASSIGN(AesCbcCtsEncryptor); @@ -228,31 +226,29 @@ class AesCbcCtsDecryptor { /// in AES spec. /// @param iv should be 16 bytes in size. /// @return true on successful initialization, false otherwise. - bool InitializeWithIv(const std::vector& key, - const std::vector& iv); + bool InitializeWithIv(const std::vector& key, + const std::vector& iv); /// @param ciphertext points to the data to be decrypted. /// @param size is the number of bytes to be decrypted. If less than 16 /// bytes, it will be copied in the clear. /// @param plaintext should not be NULL. The buffer should be at least /// @a size bytes in length. - void Decrypt(const uint8* ciphertext, - size_t size, - uint8* plaintext); + void Decrypt(const uint8_t* ciphertext, size_t size, uint8_t* plaintext); /// @param ciphertext contains the data to be decrypted. If less than 16 /// bytes in size, it will be copied in the clear. /// @param plaintext should not be NULL. Caller retains ownership. - void Decrypt(const std::vector& ciphertext, - std::vector* plaintext); + void Decrypt(const std::vector& ciphertext, + std::vector* plaintext); /// @return true if successful, false if the input is invalid. - bool SetIv(const std::vector& iv); + bool SetIv(const std::vector& iv); - const std::vector& iv() const { return iv_; } + const std::vector& iv() const { return iv_; } private: - std::vector iv_; + std::vector iv_; scoped_ptr decrypt_key_; DISALLOW_COPY_AND_ASSIGN(AesCbcCtsDecryptor); diff --git a/media/base/aes_encryptor_unittest.cc b/media/base/aes_encryptor_unittest.cc index 7765347818..6d6e057d33 100644 --- a/media/base/aes_encryptor_unittest.cc +++ b/media/base/aes_encryptor_unittest.cc @@ -13,17 +13,17 @@ namespace { -const uint32 kAesBlockSize = 16; +const uint32_t kAesBlockSize = 16; // From NIST SP 800-38a test case: - F.5.1 CTR-AES128.Encrypt // http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf -const uint8 kAesKey[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; +const uint8_t kAesKey[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; -const uint8 kAesIv[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff}; +const uint8_t kAesIv[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff}; -const uint8 kAesCtrPlaintext[] = { +const uint8_t kAesCtrPlaintext[] = { // Block #1 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, @@ -37,7 +37,7 @@ const uint8 kAesCtrPlaintext[] = { 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10}; -const uint8 kAesCtrCiphertext[] = { +const uint8_t kAesCtrCiphertext[] = { // Block #1 0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26, 0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce, @@ -53,20 +53,20 @@ const uint8 kAesCtrCiphertext[] = { // Subsample test cases. struct SubsampleTestCase { - const uint8* subsample_sizes; - uint32 subsample_count; + const uint8_t* subsample_sizes; + uint32_t subsample_count; }; -const uint8 kSubsampleTest1[] = {64}; -const uint8 kSubsampleTest2[] = {13, 51}; -const uint8 kSubsampleTest3[] = {52, 12}; -const uint8 kSubsampleTest4[] = {16, 48}; -const uint8 kSubsampleTest5[] = {3, 16, 45}; -const uint8 kSubsampleTest6[] = {18, 12, 34}; -const uint8 kSubsampleTest7[] = {8, 16, 2, 38}; -const uint8 kSubsampleTest8[] = {10, 1, 33, 20}; -const uint8 kSubsampleTest9[] = {7, 19, 6, 32}; -const uint8 kSubsampleTest10[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9}; +const uint8_t kSubsampleTest1[] = {64}; +const uint8_t kSubsampleTest2[] = {13, 51}; +const uint8_t kSubsampleTest3[] = {52, 12}; +const uint8_t kSubsampleTest4[] = {16, 48}; +const uint8_t kSubsampleTest5[] = {3, 16, 45}; +const uint8_t kSubsampleTest6[] = {18, 12, 34}; +const uint8_t kSubsampleTest7[] = {8, 16, 2, 38}; +const uint8_t kSubsampleTest8[] = {10, 1, 33, 20}; +const uint8_t kSubsampleTest9[] = {7, 19, 6, 32}; +const uint8_t kSubsampleTest10[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9}; const SubsampleTestCase kSubsampleTestCases[] = { {kSubsampleTest1, arraysize(kSubsampleTest1)}, @@ -81,29 +81,29 @@ const SubsampleTestCase kSubsampleTestCases[] = { {kSubsampleTest10, arraysize(kSubsampleTest10)}}; // IV test values. -const uint32 kTextSizeInBytes = 60; // 3 full blocks + 1 partial block. +const uint32_t kTextSizeInBytes = 60; // 3 full blocks + 1 partial block. -const uint8 kIv128Zero[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const uint8 kIv128Two[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}; -const uint8 kIv128Four[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}; -const uint8 kIv128Max64[] = {0, 0, 0, 0, 0, 0, 0, 0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -const uint8 kIv128OneAndThree[] = {0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 3}; -const uint8 kIv128MaxMinusOne[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfe}; +const uint8_t kIv128Zero[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t kIv128Two[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}; +const uint8_t kIv128Four[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}; +const uint8_t kIv128Max64[] = {0, 0, 0, 0, 0, 0, 0, 0, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +const uint8_t kIv128OneAndThree[] = {0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 3}; +const uint8_t kIv128MaxMinusOne[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe}; -const uint8 kIv64Zero[] = {0, 0, 0, 0, 0, 0, 0, 0}; -const uint8 kIv64One[] = {0, 0, 0, 0, 0, 0, 0, 1}; -const uint8 kIv64MaxMinusOne[] = {0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xfe}; -const uint8 kIv64Max[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +const uint8_t kIv64Zero[] = {0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t kIv64One[] = {0, 0, 0, 0, 0, 0, 0, 1}; +const uint8_t kIv64MaxMinusOne[] = {0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe}; +const uint8_t kIv64Max[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct IvTestCase { - const uint8* iv_test; - uint32 iv_size; - const uint8* iv_expected; + const uint8_t* iv_test; + uint32_t iv_size; + const uint8_t* iv_expected; }; // As recommended in ISO/IEC FDIS 23001-7: CENC spec, @@ -121,12 +121,12 @@ const IvTestCase kIvTestCases[] = { {kIv64Max, arraysize(kIv64Max), kIv64Zero}}; // We support AES 128, i.e. 16 bytes key only. -const uint8 kInvalidKey[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, - 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09}; +const uint8_t kInvalidKey[] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, + 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09}; // We support Iv of size 8 or 16 only as defined in CENC spec. -const uint8 kInvalidIv[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe}; +const uint8_t kInvalidIv[] = {0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe}; } // namespace @@ -147,26 +147,26 @@ class AesCtrEncryptorTest : public testing::Test { } protected: - std::vector key_; - std::vector iv_; - std::vector plaintext_; - std::vector ciphertext_; + std::vector key_; + std::vector iv_; + std::vector plaintext_; + std::vector ciphertext_; AesCtrEncryptor encryptor_; }; TEST_F(AesCtrEncryptorTest, NistTestCase) { - std::vector encrypted; + std::vector encrypted; EXPECT_TRUE(encryptor_.Encrypt(plaintext_, &encrypted)); EXPECT_EQ(ciphertext_, encrypted); EXPECT_TRUE(encryptor_.SetIv(iv_)); - std::vector decrypted; + std::vector decrypted; EXPECT_TRUE(encryptor_.Decrypt(encrypted, &decrypted)); EXPECT_EQ(plaintext_, decrypted); } TEST_F(AesCtrEncryptorTest, NistTestCaseInplaceEncryptionDecryption) { - std::vector buffer = plaintext_; + std::vector buffer = plaintext_; EXPECT_TRUE(encryptor_.Encrypt(&buffer[0], buffer.size(), &buffer[0])); EXPECT_EQ(ciphertext_, buffer); @@ -195,22 +195,22 @@ TEST_F(AesCtrEncryptorTest, 128BitIVBoundaryCaseEncryption) { // There are four blocks of text in |plaintext_|. The first block should be // encrypted with IV = kIv128Max64, the subsequent blocks should be encrypted // with iv 0 to 3. - std::vector iv_max64(kIv128Max64, - kIv128Max64 + arraysize(kIv128Max64)); + std::vector iv_max64(kIv128Max64, + kIv128Max64 + arraysize(kIv128Max64)); ASSERT_TRUE(encryptor_.InitializeWithIv(key_, iv_max64)); - std::vector encrypted; + std::vector encrypted; EXPECT_TRUE(encryptor_.Encrypt(plaintext_, &encrypted)); - std::vector iv_one_and_three( + std::vector iv_one_and_three( kIv128OneAndThree, kIv128OneAndThree + arraysize(kIv128OneAndThree)); encryptor_.UpdateIv(); EXPECT_EQ(iv_one_and_three, encryptor_.iv()); ASSERT_TRUE(encryptor_.InitializeWithIv(key_, iv_max64)); - std::vector encrypted_verify(plaintext_.size(), 0); + std::vector encrypted_verify(plaintext_.size(), 0); EXPECT_TRUE( encryptor_.Encrypt(&plaintext_[0], kAesBlockSize, &encrypted_verify[0])); - std::vector iv_zero(kIv128Zero, kIv128Zero + arraysize(kIv128Zero)); + std::vector iv_zero(kIv128Zero, kIv128Zero + arraysize(kIv128Zero)); ASSERT_TRUE(encryptor_.InitializeWithIv(key_, iv_zero)); EXPECT_TRUE(encryptor_.Encrypt(&plaintext_[kAesBlockSize], kAesBlockSize * 3, @@ -219,7 +219,7 @@ TEST_F(AesCtrEncryptorTest, 128BitIVBoundaryCaseEncryption) { } TEST_F(AesCtrEncryptorTest, InitWithRandomIv) { - const uint8 kIvSize = 8; + const uint8_t kIvSize = 8; ASSERT_TRUE(encryptor_.InitializeWithRandomIv(key_, kIvSize)); ASSERT_EQ(kIvSize, encryptor_.iv().size()); LOG(INFO) << "Random IV: " << base::HexEncode(&encryptor_.iv()[0], @@ -227,12 +227,12 @@ TEST_F(AesCtrEncryptorTest, InitWithRandomIv) { } TEST_F(AesCtrEncryptorTest, UnsupportedKeySize) { - std::vector key(kInvalidKey, kInvalidKey + arraysize(kInvalidKey)); + std::vector key(kInvalidKey, kInvalidKey + arraysize(kInvalidKey)); ASSERT_FALSE(encryptor_.InitializeWithIv(key, iv_)); } TEST_F(AesCtrEncryptorTest, UnsupportedIV) { - std::vector iv(kInvalidIv, kInvalidIv + arraysize(kInvalidIv)); + std::vector iv(kInvalidIv, kInvalidIv + arraysize(kInvalidIv)); ASSERT_FALSE(encryptor_.InitializeWithIv(key_, iv)); } @@ -247,9 +247,9 @@ class AesCtrEncryptorSubsampleTest TEST_P(AesCtrEncryptorSubsampleTest, NistTestCaseSubsamples) { const SubsampleTestCase* test_case = &GetParam(); - std::vector encrypted(plaintext_.size(), 0); - for (uint32 i = 0, offset = 0; i < test_case->subsample_count; ++i) { - uint32 len = test_case->subsample_sizes[i]; + std::vector encrypted(plaintext_.size(), 0); + for (uint32_t i = 0, offset = 0; i < test_case->subsample_count; ++i) { + uint32_t len = test_case->subsample_sizes[i]; EXPECT_TRUE( encryptor_.Encrypt(&plaintext_[offset], len, &encrypted[offset])); offset += len; @@ -258,9 +258,9 @@ TEST_P(AesCtrEncryptorSubsampleTest, NistTestCaseSubsamples) { EXPECT_EQ(ciphertext_, encrypted); EXPECT_TRUE(encryptor_.SetIv(iv_)); - std::vector decrypted(encrypted.size(), 0); - for (uint32 i = 0, offset = 0; i < test_case->subsample_count; ++i) { - uint32 len = test_case->subsample_sizes[i]; + std::vector decrypted(encrypted.size(), 0); + for (uint32_t i = 0, offset = 0; i < test_case->subsample_count; ++i) { + uint32_t len = test_case->subsample_sizes[i]; EXPECT_TRUE( encryptor_.Decrypt(&encrypted[offset], len, &decrypted[offset])); offset += len; @@ -277,18 +277,18 @@ class AesCtrEncryptorIvTest : public ::testing::TestWithParam {}; TEST_P(AesCtrEncryptorIvTest, IvTest) { // Some dummy key and plaintext. - std::vector key(16, 1); - std::vector plaintext(kTextSizeInBytes, 3); + std::vector key(16, 1); + std::vector plaintext(kTextSizeInBytes, 3); - std::vector iv_test(GetParam().iv_test, - GetParam().iv_test + GetParam().iv_size); - std::vector iv_expected(GetParam().iv_expected, - GetParam().iv_expected + GetParam().iv_size); + std::vector iv_test(GetParam().iv_test, + GetParam().iv_test + GetParam().iv_size); + std::vector iv_expected(GetParam().iv_expected, + GetParam().iv_expected + GetParam().iv_size); AesCtrEncryptor encryptor; ASSERT_TRUE(encryptor.InitializeWithIv(key, iv_test)); - std::vector encrypted; + std::vector encrypted; EXPECT_TRUE(encryptor.Encrypt(plaintext, &encrypted)); encryptor.UpdateIv(); EXPECT_EQ(iv_expected, encryptor.iv()); @@ -300,8 +300,8 @@ INSTANTIATE_TEST_CASE_P(IvTestCases, class AesCbcPkcs5EncryptorTestEncryptionDecryption : public testing::Test { public: - void TestEncryptionDecryption(const std::vector& key, - const std::vector& iv, + void TestEncryptionDecryption(const std::vector& key, + const std::vector& iv, const std::string& plaintext, const std::string& expected_ciphertext_hex) { AesCbcPkcs5Encryptor encryptor; @@ -323,14 +323,14 @@ class AesCbcPkcs5EncryptorTestEncryptionDecryption : public testing::Test { TEST_F(AesCbcPkcs5EncryptorTestEncryptionDecryption, EncryptAES256CBC) { // NIST SP 800-38A test vector F.2.5 CBC-AES256.Encrypt. - static const uint8 kAesCbcKey[] = { + static const uint8_t kAesCbcKey[] = { 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4}; - static const uint8 kAesCbcIv[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f}; - static const uint8 kAesCbcPlaintext[] = { + static const uint8_t kAesCbcIv[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f}; + static const uint8_t kAesCbcPlaintext[] = { // Block #1 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, @@ -343,7 +343,7 @@ TEST_F(AesCbcPkcs5EncryptorTestEncryptionDecryption, EncryptAES256CBC) { // Block #4 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10}; - static const uint8 kAesCbcCiphertext[] = { + static const uint8_t kAesCbcCiphertext[] = { // Block #1 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6, @@ -360,8 +360,9 @@ TEST_F(AesCbcPkcs5EncryptorTestEncryptionDecryption, EncryptAES256CBC) { 0x3f, 0x46, 0x17, 0x96, 0xd6, 0xb0, 0xd6, 0xb2, 0xe0, 0xc2, 0xa7, 0x2b, 0x4d, 0x80, 0xe6, 0x44}; - const std::vector key(kAesCbcKey, kAesCbcKey + arraysize(kAesCbcKey)); - const std::vector iv(kAesCbcIv, kAesCbcIv + arraysize(kAesCbcIv)); + const std::vector key(kAesCbcKey, + kAesCbcKey + arraysize(kAesCbcKey)); + const std::vector iv(kAesCbcIv, kAesCbcIv + arraysize(kAesCbcIv)); const std::string plaintext(reinterpret_cast(kAesCbcPlaintext), sizeof(kAesCbcPlaintext)); const std::string expected_ciphertext_hex = @@ -379,8 +380,8 @@ TEST_F(AesCbcPkcs5EncryptorTestEncryptionDecryption, EncryptAES128CBCRegression) "D4A67A0BA33C30F207344D81D1E944BBE65587C3D7D9939A" "C070C62B9C15A3EA312EA4AD1BC7929F4D3C16B03AD5ADA8"; - const std::vector key(kKey.begin(), kKey.end()); - const std::vector iv(kIv.begin(), kIv.end()); + const std::vector key(kKey.begin(), kKey.end()); + const std::vector iv(kIv.begin(), kIv.end()); TestEncryptionDecryption(key, iv, kPlaintext, kExpectedCiphertextHex); } @@ -391,8 +392,8 @@ TEST_F(AesCbcPkcs5EncryptorTestEncryptionDecryption, EncryptAES192CBCRegression) const std::string kPlaintext = "Small text"; const std::string kExpectedCiphertextHex = "78DE5D7C2714FC5C61346C5416F6C89A"; - const std::vector key(kKey.begin(), kKey.end()); - const std::vector iv(kIv.begin(), kIv.end()); + const std::vector key(kKey.begin(), kKey.end()); + const std::vector iv(kIv.begin(), kIv.end()); TestEncryptionDecryption(key, iv, kPlaintext, kExpectedCiphertextHex); } @@ -407,18 +408,18 @@ class AesCbcPkcs5EncryptorTest : public testing::Test { } protected: - std::vector key_; - std::vector iv_; + std::vector key_; + std::vector iv_; }; TEST_F(AesCbcPkcs5EncryptorTest, UnsupportedKeySize) { AesCbcPkcs5Encryptor encryptor; - EXPECT_FALSE(encryptor.InitializeWithIv(std::vector(15, 0), iv_)); + EXPECT_FALSE(encryptor.InitializeWithIv(std::vector(15, 0), iv_)); } TEST_F(AesCbcPkcs5EncryptorTest, UnsupportedIvSize) { AesCbcPkcs5Encryptor encryptor; - EXPECT_FALSE(encryptor.InitializeWithIv(key_, std::vector(14, 0))); + EXPECT_FALSE(encryptor.InitializeWithIv(key_, std::vector(14, 0))); } TEST_F(AesCbcPkcs5EncryptorTest, EmptyEncrypt) { @@ -448,27 +449,27 @@ class AesCbcCtsEncryptorDecryptorTest : public testing::Test { } void TestEncryptDecryptSeparateBuffers( - const std::vector& plaintext, - const std::vector& expected_ciphertext) { + const std::vector& plaintext, + const std::vector& expected_ciphertext) { ASSERT_TRUE(encryptor_.InitializeWithIv(key_, iv_)); ASSERT_TRUE(decryptor_.InitializeWithIv(key_, iv_)); - std::vector encrypted; + std::vector encrypted; encryptor_.Encrypt(plaintext, &encrypted); EXPECT_EQ(expected_ciphertext, encrypted); - std::vector decrypted; + std::vector decrypted; decryptor_.Decrypt(encrypted, &decrypted); EXPECT_EQ(plaintext, decrypted); } void TestEncryptDecryptInPlace( - const std::vector& plaintext, - const std::vector& expected_ciphertext) { + const std::vector& plaintext, + const std::vector& expected_ciphertext) { ASSERT_TRUE(encryptor_.InitializeWithIv(key_, iv_)); ASSERT_TRUE(decryptor_.InitializeWithIv(key_, iv_)); - std::vector buffer(plaintext); + std::vector buffer(plaintext); encryptor_.Encrypt(buffer, &buffer); EXPECT_EQ(expected_ciphertext, buffer); decryptor_.Decrypt(buffer, &buffer); @@ -476,20 +477,20 @@ class AesCbcCtsEncryptorDecryptorTest : public testing::Test { } protected: - std::vector key_; - std::vector iv_; + std::vector key_; + std::vector iv_; AesCbcCtsEncryptor encryptor_; AesCbcCtsDecryptor decryptor_; }; TEST_F(AesCbcCtsEncryptorDecryptorTest, TestWithResidualBytes) { - std::vector plaintext; + std::vector plaintext; ASSERT_TRUE(base::HexStringToBytes( "e0818f2dc7caaa9edf09285a0c1fca98d39e9b08a47ab6911c4bbdf27d94" "f917cdffc9ebb307141f23b0d3921e0ed7f86eb09381286f8e7a4f", &plaintext)); - std::vector ciphertext; + std::vector ciphertext; ASSERT_TRUE(base::HexStringToBytes( "b40a0b8704c74e22e8030cad6f272b34ace54cc7c9c64b2018bbcf23df018" "39b14899441cf74a9fb2f2b229a609146f31be8e8a826eb6e857e", @@ -500,13 +501,13 @@ TEST_F(AesCbcCtsEncryptorDecryptorTest, TestWithResidualBytes) { } TEST_F(AesCbcCtsEncryptorDecryptorTest, TestEvenBlocks) { - std::vector plaintext; + std::vector plaintext; ASSERT_TRUE(base::HexStringToBytes( "3f593e7a204a5e70f2814dca05aa49d36f2daddc9a24e0515802c539efc3" "1094b3ad6c26d6f5c0e387545ce6a4c2c14d", &plaintext)); - std::vector ciphertext; + std::vector ciphertext; ASSERT_TRUE(base::HexStringToBytes( "5f32cd0504b27b25ee04090d88d37d340c9c0a9fa50b05358b98fad4302ea" "480148d8aa091f4e7d186a7223df153f6f7", @@ -517,12 +518,12 @@ TEST_F(AesCbcCtsEncryptorDecryptorTest, TestEvenBlocks) { } TEST_F(AesCbcCtsEncryptorDecryptorTest, TestOneBlockAndAHalf) { - std::vector plaintext; + std::vector plaintext; ASSERT_TRUE(base::HexStringToBytes( "3f593e7a204a5e70f2814dca05aa49d36f2daddc9a4302ea", &plaintext)); - std::vector ciphertext; + std::vector ciphertext; ASSERT_TRUE(base::HexStringToBytes( "623fc113fe02ce85628deb58d652c6995f32cd0504b27b25", &ciphertext)); @@ -532,7 +533,7 @@ TEST_F(AesCbcCtsEncryptorDecryptorTest, TestOneBlockAndAHalf) { } TEST_F(AesCbcCtsEncryptorDecryptorTest, TestZeroEncryptedBlocks) { - std::vector plaintext; + std::vector plaintext; ASSERT_TRUE(base::HexStringToBytes("3f593e7a204a5e70f2", &plaintext)); TestEncryptDecryptSeparateBuffers(plaintext, plaintext); @@ -540,7 +541,7 @@ TEST_F(AesCbcCtsEncryptorDecryptorTest, TestZeroEncryptedBlocks) { } TEST_F(AesCbcCtsEncryptorDecryptorTest, TestZeroBytes) { - std::vector plaintext; + std::vector plaintext; TestEncryptDecryptSeparateBuffers(plaintext, plaintext); TestEncryptDecryptInPlace(plaintext, plaintext); diff --git a/media/base/audio_stream_info.cc b/media/base/audio_stream_info.cc index d3e7c3c5de..452a8d30e1 100644 --- a/media/base/audio_stream_info.cc +++ b/media/base/audio_stream_info.cc @@ -51,15 +51,15 @@ std::string AudioCodecToString(AudioCodec audio_codec) { } // namespace AudioStreamInfo::AudioStreamInfo(int track_id, - uint32 time_scale, - uint64 duration, + uint32_t time_scale, + uint64_t duration, AudioCodec codec, const std::string& codec_string, const std::string& language, - uint8 sample_bits, - uint8 num_channels, - uint32 sampling_frequency, - const uint8* extra_data, + uint8_t sample_bits, + uint8_t num_channels, + uint32_t sampling_frequency, + const uint8_t* extra_data, size_t extra_data_size, bool is_encrypted) : StreamInfo(kStreamAudio, @@ -74,7 +74,8 @@ AudioStreamInfo::AudioStreamInfo(int track_id, codec_(codec), sample_bits_(sample_bits), num_channels_(num_channels), - sampling_frequency_(sampling_frequency) {} + sampling_frequency_(sampling_frequency) { +} AudioStreamInfo::~AudioStreamInfo() {} @@ -98,7 +99,7 @@ std::string AudioStreamInfo::ToString() const { } std::string AudioStreamInfo::GetCodecString(AudioCodec codec, - uint8 audio_object_type) { + uint8_t audio_object_type) { switch (codec) { case kCodecVorbis: return "vorbis"; diff --git a/media/base/audio_stream_info.h b/media/base/audio_stream_info.h index 18d69fb464..b4190c6847 100644 --- a/media/base/audio_stream_info.h +++ b/media/base/audio_stream_info.h @@ -38,15 +38,15 @@ class AudioStreamInfo : public StreamInfo { public: /// Construct an initialized audio stream info object. AudioStreamInfo(int track_id, - uint32 time_scale, - uint64 duration, + uint32_t time_scale, + uint64_t duration, AudioCodec codec, const std::string& codec_string, const std::string& language, - uint8 sample_bits, - uint8 num_channels, - uint32 sampling_frequency, - const uint8* extra_data, + uint8_t sample_bits, + uint8_t num_channels, + uint32_t sampling_frequency, + const uint8_t* extra_data, size_t extra_data_size, bool is_encrypted); @@ -57,30 +57,31 @@ class AudioStreamInfo : public StreamInfo { /// @} AudioCodec codec() const { return codec_; } - uint8 sample_bits() const { return sample_bits_; } - uint8 sample_bytes() const { return sample_bits_ / 8; } - uint8 num_channels() const { return num_channels_; } - uint32 sampling_frequency() const { return sampling_frequency_; } - uint32 bytes_per_frame() const { - return static_cast(num_channels_) * sample_bits_ / 8; + uint8_t sample_bits() const { return sample_bits_; } + uint8_t sample_bytes() const { return sample_bits_ / 8; } + uint8_t num_channels() const { return num_channels_; } + uint32_t sampling_frequency() const { return sampling_frequency_; } + uint32_t bytes_per_frame() const { + return static_cast(num_channels_) * sample_bits_ / 8; } - void set_sampling_frequency(const uint32 sampling_frequency) { + void set_sampling_frequency(const uint32_t sampling_frequency) { sampling_frequency_ = sampling_frequency; } /// @param audio_object_type is only used by AAC Codec, ignored otherwise. /// @return The codec string. - static std::string GetCodecString(AudioCodec codec, uint8 audio_object_type); + static std::string GetCodecString(AudioCodec codec, + uint8_t audio_object_type); private: virtual ~AudioStreamInfo(); AudioCodec codec_; - uint8 sample_bits_; - uint8 num_channels_; - uint32 sampling_frequency_; + uint8_t sample_bits_; + uint8_t num_channels_; + uint32_t sampling_frequency_; // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler // generated copy constructor and assignment operator. Since the extra data is diff --git a/media/base/audio_timestamp_helper.cc b/media/base/audio_timestamp_helper.cc index 563097db83..5c84e6e91a 100644 --- a/media/base/audio_timestamp_helper.cc +++ b/media/base/audio_timestamp_helper.cc @@ -10,45 +10,44 @@ namespace edash_packager { namespace media { -AudioTimestampHelper::AudioTimestampHelper(uint32 timescale, - uint32 samples_per_second) - : base_timestamp_(kNoTimestamp), - frame_count_(0) { +AudioTimestampHelper::AudioTimestampHelper(uint32_t timescale, + uint32_t samples_per_second) + : base_timestamp_(kNoTimestamp), frame_count_(0) { DCHECK_GT(samples_per_second, 0u); double fps = samples_per_second; ticks_per_frame_ = timescale / fps; } -void AudioTimestampHelper::SetBaseTimestamp(int64 base_timestamp) { +void AudioTimestampHelper::SetBaseTimestamp(int64_t base_timestamp) { base_timestamp_ = base_timestamp; frame_count_ = 0; } -int64 AudioTimestampHelper::base_timestamp() const { +int64_t AudioTimestampHelper::base_timestamp() const { return base_timestamp_; } -void AudioTimestampHelper::AddFrames(int64 frame_count) { +void AudioTimestampHelper::AddFrames(int64_t frame_count) { DCHECK_GE(frame_count, 0); DCHECK(base_timestamp_ != kNoTimestamp); frame_count_ += frame_count; } -int64 AudioTimestampHelper::GetTimestamp() const { +int64_t AudioTimestampHelper::GetTimestamp() const { return ComputeTimestamp(frame_count_); } -int64 AudioTimestampHelper::GetFrameDuration(int64 frame_count) const { +int64_t AudioTimestampHelper::GetFrameDuration(int64_t frame_count) const { DCHECK_GE(frame_count, 0); - int64 end_timestamp = ComputeTimestamp(frame_count_ + frame_count); + int64_t end_timestamp = ComputeTimestamp(frame_count_ + frame_count); return end_timestamp - GetTimestamp(); } -int64 AudioTimestampHelper::GetFramesToTarget(int64 target) const { +int64_t AudioTimestampHelper::GetFramesToTarget(int64_t target) const { DCHECK(base_timestamp_ != kNoTimestamp); DCHECK(target >= base_timestamp_); - int64 delta_in_ticks = (target - GetTimestamp()); + int64_t delta_in_ticks = (target - GetTimestamp()); if (delta_in_ticks == 0) return 0; @@ -56,18 +55,16 @@ int64 AudioTimestampHelper::GetFramesToTarget(int64 target) const { // created from |frame_count_| are computed relative to this base. // This ensures that the time to frame computation here is the proper inverse // of the frame to time computation in ComputeTimestamp(). - int64 delta_from_base = target - base_timestamp_; + int64_t delta_from_base = target - base_timestamp_; // Compute frame count for the time delta. This computation rounds to // the nearest whole number of frames. double threshold = ticks_per_frame_ / 2; - int64 target_frame_count = - (delta_from_base + threshold) / ticks_per_frame_; + int64_t target_frame_count = (delta_from_base + threshold) / ticks_per_frame_; return target_frame_count - frame_count_; } -int64 AudioTimestampHelper::ComputeTimestamp( - int64 frame_count) const { +int64_t AudioTimestampHelper::ComputeTimestamp(int64_t frame_count) const { DCHECK_GE(frame_count, 0); DCHECK(base_timestamp_ != kNoTimestamp); double frames_ticks = ticks_per_frame_ * frame_count; diff --git a/media/base/audio_timestamp_helper.h b/media/base/audio_timestamp_helper.h index 12a35cf78c..36f3d0d9a5 100644 --- a/media/base/audio_timestamp_helper.h +++ b/media/base/audio_timestamp_helper.h @@ -27,42 +27,43 @@ namespace media { // accumulated frames to reach a target timestamp. class AudioTimestampHelper { public: - explicit AudioTimestampHelper(uint32 timescale, uint32 samples_per_second); + explicit AudioTimestampHelper(uint32_t timescale, + uint32_t samples_per_second); // Sets the base timestamp to |base_timestamp| and the sets count to 0. - void SetBaseTimestamp(int64 base_timestamp); + void SetBaseTimestamp(int64_t base_timestamp); - int64 base_timestamp() const; - int64 frame_count() const { return frame_count_; } + int64_t base_timestamp() const; + int64_t frame_count() const { return frame_count_; } // Adds |frame_count| to the frame counter. // Note: SetBaseTimestamp() must be called with a value other than // kNoTimestamp() before this method can be called. - void AddFrames(int64 frame_count); + void AddFrames(int64_t frame_count); // Get the current timestamp. This value is computed from the base_timestamp() // and the number of sample frames that have been added so far. - int64 GetTimestamp() const; + int64_t GetTimestamp() const; // Gets the duration if |frame_count| frames were added to the current // timestamp reported by GetTimestamp(). This method ensures that // (GetTimestamp() + GetFrameDuration(n)) will equal the timestamp that // GetTimestamp() will return if AddFrames(n) is called. - int64 GetFrameDuration(int64 frame_count) const; + int64_t GetFrameDuration(int64_t frame_count) const; // Returns the number of frames needed to reach the target timestamp. // Note: |target| must be >= |base_timestamp_|. - int64 GetFramesToTarget(int64 target) const; + int64_t GetFramesToTarget(int64_t target) const; private: - int64 ComputeTimestamp(int64 frame_count) const; + int64_t ComputeTimestamp(int64_t frame_count) const; double ticks_per_frame_; - int64 base_timestamp_; + int64_t base_timestamp_; // Number of frames accumulated by AddFrames() calls. - int64 frame_count_; + int64_t frame_count_; DISALLOW_IMPLICIT_CONSTRUCTORS(AudioTimestampHelper); }; diff --git a/media/base/audio_timestamp_helper_unittest.cc b/media/base/audio_timestamp_helper_unittest.cc index 4512de0997..6cb65d2f8f 100644 --- a/media/base/audio_timestamp_helper_unittest.cc +++ b/media/base/audio_timestamp_helper_unittest.cc @@ -10,8 +10,8 @@ namespace edash_packager { namespace media { -static const uint32 kDefaultSampleRate = 44100; -static const uint32 kTimescale = 1000000; +static const uint32_t kDefaultSampleRate = 44100; +static const uint32_t kTimescale = 1000000; class AudioTimestampHelperTest : public ::testing::Test { public: @@ -21,12 +21,12 @@ class AudioTimestampHelperTest : public ::testing::Test { // Adds frames to the helper and returns the current timestamp in // microseconds. - int64 AddFrames(int frames) { + int64_t AddFrames(int frames) { helper_.AddFrames(frames); return helper_.GetTimestamp(); } - int64 FramesToTarget(int target_in_microseconds) { + int64_t FramesToTarget(int target_in_microseconds) { return helper_.GetFramesToTarget(target_in_microseconds); } @@ -59,7 +59,7 @@ TEST_F(AudioTimestampHelperTest, Basic) { // Verify that adding frames one frame at a time matches the timestamp // returned if the same number of frames are added all at once. - int64 timestamp_1 = helper_.GetTimestamp(); + int64_t timestamp_1 = helper_.GetTimestamp(); helper_.SetBaseTimestamp(kNoTimestamp); EXPECT_TRUE(kNoTimestamp == helper_.base_timestamp()); helper_.SetBaseTimestamp(0); @@ -75,14 +75,14 @@ TEST_F(AudioTimestampHelperTest, GetDuration) { helper_.SetBaseTimestamp(100); int frame_count = 5; - int64 expected_durations[] = { 113, 113, 114, 113, 113, 114 }; + int64_t expected_durations[] = {113, 113, 114, 113, 113, 114}; for (size_t i = 0; i < arraysize(expected_durations); ++i) { - int64 duration = helper_.GetFrameDuration(frame_count); + int64_t duration = helper_.GetFrameDuration(frame_count); EXPECT_EQ(expected_durations[i], duration); - int64 timestamp_1 = helper_.GetTimestamp() + duration; + int64_t timestamp_1 = helper_.GetTimestamp() + duration; helper_.AddFrames(frame_count); - int64 timestamp_2 = helper_.GetTimestamp(); + int64_t timestamp_2 = helper_.GetTimestamp(); EXPECT_TRUE(timestamp_1 == timestamp_2); } } diff --git a/media/base/bit_reader.cc b/media/base/bit_reader.cc index f269eabc3d..5177953591 100644 --- a/media/base/bit_reader.cc +++ b/media/base/bit_reader.cc @@ -7,7 +7,7 @@ namespace edash_packager { namespace media { -BitReader::BitReader(const uint8* data, off_t size) +BitReader::BitReader(const uint8_t* data, off_t size) : data_(data), bytes_left_(size), num_remaining_bits_in_curr_byte_(0) { DCHECK(data_ != NULL && bytes_left_ > 0); @@ -37,7 +37,7 @@ bool BitReader::SkipBits(int num_bits) { // Less than 8 bits remaining to skip. Use ReadBitsInternal to verify // that the remaining bits we need exist, and adjust them as necessary // for subsequent operations. - uint64 not_needed; + uint64_t not_needed; return ReadBitsInternal(num_bits, ¬_needed); } @@ -45,7 +45,7 @@ int BitReader::bits_available() const { return 8 * bytes_left_ + num_remaining_bits_in_curr_byte_; } -bool BitReader::ReadBitsInternal(int num_bits, uint64* out) { +bool BitReader::ReadBitsInternal(int num_bits, uint64_t* out) { DCHECK_LE(num_bits, 64); *out = 0; diff --git a/media/base/bit_reader.h b/media/base/bit_reader.h index d24be365dc..8896ddef51 100644 --- a/media/base/bit_reader.h +++ b/media/base/bit_reader.h @@ -19,7 +19,7 @@ class BitReader { /// Initialize the BitReader object to read a data buffer. /// @param data points to the beginning of the buffer. /// @param size is the buffer size in bytes. - BitReader(const uint8* data, off_t size); + BitReader(const uint8_t* data, off_t size); ~BitReader(); /// Read a number of bits from stream. @@ -33,7 +33,7 @@ class BitReader { /// operations will always return false unless @a num_bits is 0. template bool ReadBits(int num_bits, T *out) { DCHECK_LE(num_bits, static_cast(sizeof(T) * 8)); - uint64 temp; + uint64_t temp; bool ret = ReadBitsInternal(num_bits, &temp); *out = static_cast(temp); return ret; @@ -52,7 +52,7 @@ class BitReader { private: // Help function used by ReadBits to avoid inlining the bit reading logic. - bool ReadBitsInternal(int num_bits, uint64* out); + bool ReadBitsInternal(int num_bits, uint64_t* out); // Advance to the next byte, loading it into curr_byte_. // If the num_remaining_bits_in_curr_byte_ is 0 after this function returns, @@ -60,14 +60,14 @@ class BitReader { void UpdateCurrByte(); // Pointer to the next unread (not in curr_byte_) byte in the stream. - const uint8* data_; + const uint8_t* data_; // Bytes left in the stream (without the curr_byte_). off_t bytes_left_; // Contents of the current byte; first unread bit starting at position // 8 - num_remaining_bits_in_curr_byte_ from MSB. - uint8 curr_byte_; + uint8_t curr_byte_; // Number of bits remaining in curr_byte_ int num_remaining_bits_in_curr_byte_; diff --git a/media/base/bit_reader_unittest.cc b/media/base/bit_reader_unittest.cc index c5b3e4cb88..94bb83bbaf 100644 --- a/media/base/bit_reader_unittest.cc +++ b/media/base/bit_reader_unittest.cc @@ -10,10 +10,10 @@ namespace edash_packager { namespace media { TEST(BitReaderTest, NormalOperationTest) { - uint8 value8; - uint64 value64; + uint8_t value8; + uint64_t value64; // 0101 0101 1001 1001 repeats 4 times - uint8 buffer[] = {0x55, 0x99, 0x55, 0x99, 0x55, 0x99, 0x55, 0x99}; + uint8_t buffer[] = {0x55, 0x99, 0x55, 0x99, 0x55, 0x99, 0x55, 0x99}; BitReader reader1(buffer, 6); // Initialize with 6 bytes only EXPECT_TRUE(reader1.ReadBits(1, &value8)); @@ -36,8 +36,8 @@ TEST(BitReaderTest, NormalOperationTest) { } TEST(BitReaderTest, ReadBeyondEndTest) { - uint8 value8; - uint8 buffer[] = {0x12}; + uint8_t value8; + uint8_t buffer[] = {0x12}; BitReader reader1(buffer, sizeof(buffer)); EXPECT_TRUE(reader1.ReadBits(4, &value8)); @@ -47,8 +47,8 @@ TEST(BitReaderTest, ReadBeyondEndTest) { } TEST(BitReaderTest, SkipBitsTest) { - uint8 value8; - uint8 buffer[] = { 0x0a, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + uint8_t value8; + uint8_t buffer[] = {0x0a, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; BitReader reader1(buffer, sizeof(buffer)); EXPECT_TRUE(reader1.SkipBits(2)); diff --git a/media/base/buffer_reader.cc b/media/base/buffer_reader.cc index 093e64101c..100ab71cb9 100644 --- a/media/base/buffer_reader.cc +++ b/media/base/buffer_reader.cc @@ -11,7 +11,7 @@ namespace edash_packager { namespace media { -bool BufferReader::Read1(uint8* v) { +bool BufferReader::Read1(uint8_t* v) { DCHECK(v != NULL); if (!HasBytes(1)) return false; @@ -19,20 +19,32 @@ bool BufferReader::Read1(uint8* v) { return true; } -bool BufferReader::Read2(uint16* v) { return Read(v); } -bool BufferReader::Read2s(int16* v) { return Read(v); } -bool BufferReader::Read4(uint32* v) { return Read(v); } -bool BufferReader::Read4s(int32* v) { return Read(v); } -bool BufferReader::Read8(uint64* v) { return Read(v); } -bool BufferReader::Read8s(int64* v) { return Read(v); } -bool BufferReader::ReadNBytesInto8(uint64* v, size_t num_bytes) { +bool BufferReader::Read2(uint16_t* v) { + return Read(v); +} +bool BufferReader::Read2s(int16_t* v) { + return Read(v); +} +bool BufferReader::Read4(uint32_t* v) { + return Read(v); +} +bool BufferReader::Read4s(int32_t* v) { + return Read(v); +} +bool BufferReader::Read8(uint64_t* v) { + return Read(v); +} +bool BufferReader::Read8s(int64_t* v) { + return Read(v); +} +bool BufferReader::ReadNBytesInto8(uint64_t* v, size_t num_bytes) { return ReadNBytes(v, num_bytes); } -bool BufferReader::ReadNBytesInto8s(int64* v, size_t num_bytes) { +bool BufferReader::ReadNBytesInto8s(int64_t* v, size_t num_bytes) { return ReadNBytes(v, num_bytes); } -bool BufferReader::ReadToVector(std::vector* vec, size_t count) { +bool BufferReader::ReadToVector(std::vector* vec, size_t count) { DCHECK(vec != NULL); if (!HasBytes(count)) return false; @@ -65,10 +77,10 @@ bool BufferReader::ReadNBytes(T* v, size_t num_bytes) { // T is a signed type. const bool sign_extension_required = num_bytes < sizeof(*v) && static_cast(-1) < 0; - // Perform sign extension by casting the byte value to int8, which will be + // Perform sign extension by casting the byte value to int8_t, which will be // sign extended automatically when it is implicitly converted to T. - T tmp = - sign_extension_required ? static_cast(buf_[pos_++]) : buf_[pos_++]; + T tmp = sign_extension_required ? static_cast(buf_[pos_++]) + : buf_[pos_++]; for (size_t i = 1; i < num_bytes; ++i) { tmp <<= 8; tmp |= buf_[pos_++]; diff --git a/media/base/buffer_reader.h b/media/base/buffer_reader.h index 7c22e9efd1..3d439097da 100644 --- a/media/base/buffer_reader.h +++ b/media/base/buffer_reader.h @@ -20,7 +20,7 @@ namespace media { class BufferReader { public: /// Create a BufferReader from a raw buffer. - BufferReader(const uint8* buf, size_t size) + BufferReader(const uint8_t* buf, size_t size) : buf_(buf), size_(size), pos_(0) {} ~BufferReader() {} @@ -32,13 +32,13 @@ class BufferReader { /// the stream pointer. /// @return false if there are not enough bytes in the buffer. /// @{ - bool Read1(uint8* v) WARN_UNUSED_RESULT; - bool Read2(uint16* v) WARN_UNUSED_RESULT; - bool Read2s(int16* v) WARN_UNUSED_RESULT; - bool Read4(uint32* v) WARN_UNUSED_RESULT; - bool Read4s(int32* v) WARN_UNUSED_RESULT; - bool Read8(uint64* v) WARN_UNUSED_RESULT; - bool Read8s(int64* v) WARN_UNUSED_RESULT; + bool Read1(uint8_t* v) WARN_UNUSED_RESULT; + bool Read2(uint16_t* v) WARN_UNUSED_RESULT; + bool Read2s(int16_t* v) WARN_UNUSED_RESULT; + bool Read4(uint32_t* v) WARN_UNUSED_RESULT; + bool Read4s(int32_t* v) WARN_UNUSED_RESULT; + bool Read8(uint64_t* v) WARN_UNUSED_RESULT; + bool Read8s(int64_t* v) WARN_UNUSED_RESULT; /// @} /// Read N-byte integer of the corresponding signedness and store it in the @@ -46,17 +46,17 @@ class BufferReader { /// @param num_bytes should not be larger than 8 bytes. /// @return false if there are not enough bytes in the buffer, true otherwise. /// @{ - bool ReadNBytesInto8(uint64* v, size_t num_bytes) WARN_UNUSED_RESULT; - bool ReadNBytesInto8s(int64* v, size_t num_bytes) WARN_UNUSED_RESULT; + bool ReadNBytesInto8(uint64_t* v, size_t num_bytes) WARN_UNUSED_RESULT; + bool ReadNBytesInto8s(int64_t* v, size_t num_bytes) WARN_UNUSED_RESULT; /// @} - bool ReadToVector(std::vector* t, size_t count) WARN_UNUSED_RESULT; + bool ReadToVector(std::vector* t, size_t count) WARN_UNUSED_RESULT; /// Advance the stream by this many bytes. /// @return false if there are not enough bytes in the buffer, true otherwise. bool SkipBytes(size_t num_bytes) WARN_UNUSED_RESULT; - const uint8* data() const { return buf_; } + const uint8_t* data() const { return buf_; } size_t size() const { return size_; } void set_size(size_t size) { size_ = size; } size_t pos() const { return pos_; } @@ -68,7 +68,7 @@ class BufferReader { template bool ReadNBytes(T* t, size_t num_bytes) WARN_UNUSED_RESULT; - const uint8* buf_; + const uint8_t* buf_; size_t size_; size_t pos_; diff --git a/media/base/buffer_writer.cc b/media/base/buffer_writer.cc index 7169e89b0e..9f487b1350 100644 --- a/media/base/buffer_writer.cc +++ b/media/base/buffer_writer.cc @@ -21,26 +21,40 @@ BufferWriter::BufferWriter(size_t reserved_size_in_bytes) { } BufferWriter::~BufferWriter() {} -void BufferWriter::AppendInt(uint8 v) { buf_.push_back(v); } -void BufferWriter::AppendInt(uint16 v) { AppendInternal(base::HostToNet16(v)); } -void BufferWriter::AppendInt(uint32 v) { AppendInternal(base::HostToNet32(v)); } -void BufferWriter::AppendInt(uint64 v) { AppendInternal(base::HostToNet64(v)); } -void BufferWriter::AppendInt(int16 v) { AppendInternal(base::HostToNet16(v)); } -void BufferWriter::AppendInt(int32 v) { AppendInternal(base::HostToNet32(v)); } -void BufferWriter::AppendInt(int64 v) { AppendInternal(base::HostToNet64(v)); } +void BufferWriter::AppendInt(uint8_t v) { + buf_.push_back(v); +} +void BufferWriter::AppendInt(uint16_t v) { + AppendInternal(base::HostToNet16(v)); +} +void BufferWriter::AppendInt(uint32_t v) { + AppendInternal(base::HostToNet32(v)); +} +void BufferWriter::AppendInt(uint64_t v) { + AppendInternal(base::HostToNet64(v)); +} +void BufferWriter::AppendInt(int16_t v) { + AppendInternal(base::HostToNet16(v)); +} +void BufferWriter::AppendInt(int32_t v) { + AppendInternal(base::HostToNet32(v)); +} +void BufferWriter::AppendInt(int64_t v) { + AppendInternal(base::HostToNet64(v)); +} -void BufferWriter::AppendNBytes(uint64 v, size_t num_bytes) { +void BufferWriter::AppendNBytes(uint64_t v, size_t num_bytes) { DCHECK_GE(sizeof(v), num_bytes); v = base::HostToNet64(v); - const uint8* data = reinterpret_cast(&v); + const uint8_t* data = reinterpret_cast(&v); AppendArray(&data[sizeof(v) - num_bytes], num_bytes); } -void BufferWriter::AppendVector(const std::vector& v) { +void BufferWriter::AppendVector(const std::vector& v) { buf_.insert(buf_.end(), v.begin(), v.end()); } -void BufferWriter::AppendArray(const uint8* buf, size_t size) { +void BufferWriter::AppendArray(const uint8_t* buf, size_t size) { buf_.insert(buf_.end(), buf, buf + size); } @@ -52,9 +66,9 @@ Status BufferWriter::WriteToFile(File* file) { DCHECK(file); size_t remaining_size = buf_.size(); - const uint8* buf = &buf_[0]; + const uint8_t* buf = &buf_[0]; while (remaining_size > 0) { - int64 size_written = file->Write(buf, remaining_size); + int64_t size_written = file->Write(buf, remaining_size); if (size_written <= 0) { return Status(error::FILE_FAILURE, "Fail to write to file in BufferWriter"); @@ -68,7 +82,7 @@ Status BufferWriter::WriteToFile(File* file) { template void BufferWriter::AppendInternal(T v) { - AppendArray(reinterpret_cast(&v), sizeof(T)); + AppendArray(reinterpret_cast(&v), sizeof(T)); } } // namespace media diff --git a/media/base/buffer_writer.h b/media/base/buffer_writer.h index ee4b04daf8..b5adedfe0f 100644 --- a/media/base/buffer_writer.h +++ b/media/base/buffer_writer.h @@ -32,31 +32,31 @@ class BufferWriter { /// These convenience functions append the integers (in network byte order, /// i.e. big endian) of various size and signedness to the end of the buffer. /// @{ - void AppendInt(uint8 v); - void AppendInt(uint16 v); - void AppendInt(uint32 v); - void AppendInt(uint64 v); - void AppendInt(int16 v); - void AppendInt(int32 v); - void AppendInt(int64 v); + void AppendInt(uint8_t v); + void AppendInt(uint16_t v); + void AppendInt(uint32_t v); + void AppendInt(uint64_t v); + void AppendInt(int16_t v); + void AppendInt(int32_t v); + void AppendInt(int64_t v); /// @} /// Append the least significant @a num_bytes of @a v to buffer. /// @param num_bytes should not be larger than sizeof(@a v), i.e. 8 on a /// 64-bit system. - void AppendNBytes(uint64 v, size_t num_bytes); + void AppendNBytes(uint64_t v, size_t num_bytes); - void AppendVector(const std::vector& v); - void AppendArray(const uint8* buf, size_t size); + void AppendVector(const std::vector& v); + void AppendArray(const uint8_t* buf, size_t size); void AppendBuffer(const BufferWriter& buffer); void Swap(BufferWriter* buffer) { buf_.swap(buffer->buf_); } - void SwapBuffer(std::vector* buffer) { buf_.swap(*buffer); } + void SwapBuffer(std::vector* buffer) { buf_.swap(*buffer); } void Clear() { buf_.clear(); } size_t Size() const { return buf_.size(); } /// @return Underlying buffer. Behavior is undefined if the buffer size is 0. - const uint8* Buffer() const { return vector_as_array(&buf_); } + const uint8_t* Buffer() const { return vector_as_array(&buf_); } /// Write the buffer to file. The internal buffer will be cleared after /// writing. @@ -69,7 +69,7 @@ class BufferWriter { template void AppendInternal(T v); - std::vector buf_; + std::vector buf_; DISALLOW_COPY_AND_ASSIGN(BufferWriter); }; diff --git a/media/base/buffer_writer_unittest.cc b/media/base/buffer_writer_unittest.cc index 9de3e432fe..d7a148f852 100644 --- a/media/base/buffer_writer_unittest.cc +++ b/media/base/buffer_writer_unittest.cc @@ -16,20 +16,20 @@ namespace { const int kReservedBufferCapacity = 1000; // Min values for various integers of different size. Min values for signed // integers are already defined in //base/basictypes.h. -const uint8 kuint8min = 0; -const uint16 kuint16min = 0; -const uint32 kuint32min = 0; -const uint64 kuint64min = 0; +const uint8_t kuint8min = 0; +const uint16_t kuint16min = 0; +const uint32_t kuint32min = 0; +const uint64_t kuint64min = 0; // Max values for various integers are already defined in //base/basictypes.h. // Other integer values. -const uint8 kuint8 = 10; -const uint16 kuint16 = 1000; -const int16 kint16 = -1000; -const uint32 kuint32 = 1000000; -const int32 kint32 = -1000000; -const uint64 kuint64 = 10000000000ULL; -const int64 kint64 = -10000000000LL; -const uint8 kuint8Array[] = {10, 1, 100, 5, 3, 60}; +const uint8_t kuint8 = 10; +const uint16_t kuint16 = 1000; +const int16_t kint16 = -1000; +const uint32_t kuint32 = 1000000; +const int32_t kint32 = -1000000; +const uint64_t kuint64 = 10000000000ULL; +const int64_t kint64 = -10000000000LL; +const uint8_t kuint8Array[] = {10, 1, 100, 5, 3, 60}; } // namespace namespace edash_packager { @@ -43,13 +43,13 @@ class BufferWriterTest : public testing::Test { reader_.reset(new BufferReader(writer_->Buffer(), writer_->Size())); } - bool ReadInt(uint8* v) { return reader_->Read1(v); } - bool ReadInt(uint16* v) { return reader_->Read2(v); } - bool ReadInt(int16* v) { return reader_->Read2s(v); } - bool ReadInt(uint32* v) { return reader_->Read4(v); } - bool ReadInt(int32* v) { return reader_->Read4s(v); } - bool ReadInt(uint64* v) { return reader_->Read8(v); } - bool ReadInt(int64* v) { return reader_->Read8s(v); } + bool ReadInt(uint8_t* v) { return reader_->Read1(v); } + bool ReadInt(uint16_t* v) { return reader_->Read2(v); } + bool ReadInt(int16_t* v) { return reader_->Read2s(v); } + bool ReadInt(uint32_t* v) { return reader_->Read4(v); } + bool ReadInt(int32_t* v) { return reader_->Read4s(v); } + bool ReadInt(uint64_t* v) { return reader_->Read8(v); } + bool ReadInt(int64_t* v) { return reader_->Read8s(v); } template void ReadAndExpect(T expectation) { @@ -89,26 +89,26 @@ TEST_F(BufferWriterTest, Append8s) { Verify(kint64min, kint64max, kint64); } TEST_F(BufferWriterTest, AppendNBytes) { // Write the least significant four bytes and verify the result. - writer_->AppendNBytes(kuint64, sizeof(uint32)); - ASSERT_EQ(sizeof(uint32), writer_->Size()); + writer_->AppendNBytes(kuint64, sizeof(uint32_t)); + ASSERT_EQ(sizeof(uint32_t), writer_->Size()); CreateReader(); - ReadAndExpect(static_cast(kuint64 & 0xFFFFFFFF)); + ReadAndExpect(static_cast(kuint64 & 0xFFFFFFFF)); } TEST_F(BufferWriterTest, AppendEmptyVector) { - std::vector v; + std::vector v; writer_->AppendVector(v); ASSERT_EQ(0u, writer_->Size()); } TEST_F(BufferWriterTest, AppendVector) { - std::vector v(kuint8Array, kuint8Array + sizeof(kuint8Array)); + std::vector v(kuint8Array, kuint8Array + sizeof(kuint8Array)); writer_->AppendVector(v); ASSERT_EQ(sizeof(kuint8Array), writer_->Size()); CreateReader(); - std::vector data_read; + std::vector data_read; ASSERT_TRUE(reader_->ReadToVector(&data_read, sizeof(kuint8Array))); ASSERT_EQ(v, data_read); } @@ -118,7 +118,7 @@ TEST_F(BufferWriterTest, AppendArray) { ASSERT_EQ(sizeof(kuint8Array), writer_->Size()); CreateReader(); - std::vector data_read; + std::vector data_read; ASSERT_TRUE(reader_->ReadToVector(&data_read, sizeof(kuint8Array))); for (size_t i = 0; i < sizeof(kuint8Array); ++i) EXPECT_EQ(kuint8Array[i], data_read[i]); @@ -177,7 +177,7 @@ TEST_F(BufferWriterTest, WriteToFile) { // Read the file and verify. File* const input_file = File::Open(path.value().c_str(), "r"); ASSERT_TRUE(input_file != NULL); - std::vector data_read(sizeof(kuint8Array), 0); + std::vector data_read(sizeof(kuint8Array), 0); EXPECT_EQ( sizeof(kuint8Array), static_cast(input_file->Read(&data_read[0], data_read.size()))); diff --git a/media/base/byte_queue.cc b/media/base/byte_queue.cc index 9d2785d6c4..d5155e6798 100644 --- a/media/base/byte_queue.cc +++ b/media/base/byte_queue.cc @@ -13,7 +13,7 @@ namespace media { enum { kDefaultQueueSize = 1024 }; ByteQueue::ByteQueue() - : buffer_(new uint8[kDefaultQueueSize]), + : buffer_(new uint8_t[kDefaultQueueSize]), size_(kDefaultQueueSize), offset_(0), used_(0) { @@ -26,7 +26,7 @@ void ByteQueue::Reset() { used_ = 0; } -void ByteQueue::Push(const uint8* data, int size) { +void ByteQueue::Push(const uint8_t* data, int size) { DCHECK(data); DCHECK_GT(size, 0); @@ -41,7 +41,7 @@ void ByteQueue::Push(const uint8* data, int size) { // Sanity check to make sure we didn't overflow. CHECK_GT(new_size, size_); - scoped_ptr new_buffer(new uint8[new_size]); + scoped_ptr new_buffer(new uint8_t[new_size]); // Copy the data from the old buffer to the start of the new one. if (used_ > 0) @@ -60,7 +60,7 @@ void ByteQueue::Push(const uint8* data, int size) { used_ += size; } -void ByteQueue::Peek(const uint8** data, int* size) const { +void ByteQueue::Peek(const uint8_t** data, int* size) const { DCHECK(data); DCHECK(size); *data = front(); @@ -80,7 +80,9 @@ void ByteQueue::Pop(int count) { } } -uint8* ByteQueue::front() const { return buffer_.get() + offset_; } +uint8_t* ByteQueue::front() const { + return buffer_.get() + offset_; +} } // namespace media } // namespace edash_packager diff --git a/media/base/byte_queue.h b/media/base/byte_queue.h index c96f89dcde..2c27d1d947 100644 --- a/media/base/byte_queue.h +++ b/media/base/byte_queue.h @@ -25,11 +25,11 @@ class ByteQueue { void Reset(); /// Append new bytes to the end of the queue. - void Push(const uint8* data, int size); + void Push(const uint8_t* data, int size); /// Get a pointer to the front of the queue and the queue size. /// These values are only valid until the next Push() or Pop() call. - void Peek(const uint8** data, int* size) const; + void Peek(const uint8_t** data, int* size) const; /// Remove a number of bytes from the front of the queue. /// @param count specifies number of bytes to be popped. @@ -37,9 +37,9 @@ class ByteQueue { private: // Returns a pointer to the front of the queue. - uint8* front() const; + uint8_t* front() const; - scoped_ptr buffer_; + scoped_ptr buffer_; // Size of |buffer_|. size_t size_; diff --git a/media/base/container_names.cc b/media/base/container_names.cc index c9111180b0..4f8a7ec6d0 100644 --- a/media/base/container_names.cc +++ b/media/base/container_names.cc @@ -14,11 +14,10 @@ namespace edash_packager { namespace media { -#define TAG(a, b, c, d) \ - ((static_cast(static_cast(a)) << 24) | \ - (static_cast(b) << 16) | \ - (static_cast(c) << 8) | \ - (static_cast(d))) +#define TAG(a, b, c, d) \ + ((static_cast(static_cast(a)) << 24) | \ + (static_cast(b) << 16) | (static_cast(c) << 8) | \ + (static_cast(d))) #define RCHECK(x) \ do { \ @@ -29,28 +28,28 @@ namespace media { #define UTF8_BYTE_ORDER_MARK "\xef\xbb\xbf" // Helper function to read 2 bytes (16 bits, big endian) from a buffer. -static int Read16(const uint8* p) { +static int Read16(const uint8_t* p) { return p[0] << 8 | p[1]; } // Helper function to read 3 bytes (24 bits, big endian) from a buffer. -static uint32 Read24(const uint8* p) { +static uint32_t Read24(const uint8_t* p) { return p[0] << 16 | p[1] << 8 | p[2]; } // Helper function to read 4 bytes (32 bits, big endian) from a buffer. -static uint32 Read32(const uint8* p) { +static uint32_t Read32(const uint8_t* p) { return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; } // Helper function to read 4 bytes (32 bits, little endian) from a buffer. -static uint32 Read32LE(const uint8* p) { +static uint32_t Read32LE(const uint8_t* p) { return p[3] << 24 | p[2] << 16 | p[1] << 8 | p[0]; } // Helper function to do buffer comparisons with a string without going off the // end of the buffer. -static bool StartsWith(const uint8* buffer, +static bool StartsWith(const uint8_t* buffer, size_t buffer_size, const char* prefix) { size_t prefix_size = strlen(prefix); @@ -60,19 +59,19 @@ static bool StartsWith(const uint8* buffer, // Helper function to do buffer comparisons with another buffer (to allow for // embedded \0 in the comparison) without going off the end of the buffer. -static bool StartsWith(const uint8* buffer, +static bool StartsWith(const uint8_t* buffer, size_t buffer_size, - const uint8* prefix, + const uint8_t* prefix, size_t prefix_size) { return (prefix_size <= buffer_size && memcmp(buffer, prefix, prefix_size) == 0); } // Helper function to read up to 64 bits from a bit stream. -static uint64 ReadBits(BitReader* reader, int num_bits) { +static uint64_t ReadBits(BitReader* reader, int num_bits) { DCHECK_GE(reader->bits_available(), num_bits); DCHECK((num_bits > 0) && (num_bits <= 64)); - uint64 value; + uint64_t value; reader->ReadBits(num_bits, &value); return value; } @@ -92,7 +91,7 @@ const int kAc3FrameSizeTable[38][3] = { }; // Checks for an ADTS AAC container. -static bool CheckAac(const uint8* buffer, int buffer_size) { +static bool CheckAac(const uint8_t* buffer, int buffer_size) { // Audio Data Transport Stream (ADTS) header is 7 or 9 bytes // (from http://wiki.multimedia.cx/index.php?title=ADTS) RCHECK(buffer_size > 6); @@ -128,10 +127,10 @@ static bool CheckAac(const uint8* buffer, int buffer_size) { return true; } -const uint16 kAc3SyncWord = 0x0b77; +const uint16_t kAc3SyncWord = 0x0b77; // Checks for an AC3 container. -static bool CheckAc3(const uint8* buffer, int buffer_size) { +static bool CheckAc3(const uint8_t* buffer, int buffer_size) { // Reference: ATSC Standard: Digital Audio Compression (AC-3, E-AC-3) // Doc. A/52:2012 // (http://www.atsc.org/cms/standards/A52-2012(12-17).pdf) @@ -166,7 +165,7 @@ static bool CheckAc3(const uint8* buffer, int buffer_size) { } // Checks for an EAC3 container (very similar to AC3) -static bool CheckEac3(const uint8* buffer, int buffer_size) { +static bool CheckEac3(const uint8_t* buffer, int buffer_size) { // Reference: ATSC Standard: Digital Audio Compression (AC-3, E-AC-3) // Doc. A/52:2012 // (http://www.atsc.org/cms/standards/A52-2012(12-17).pdf) @@ -204,7 +203,7 @@ static bool CheckEac3(const uint8* buffer, int buffer_size) { } // Additional checks for a BINK container. -static bool CheckBink(const uint8* buffer, int buffer_size) { +static bool CheckBink(const uint8_t* buffer, int buffer_size) { // Reference: http://wiki.multimedia.cx/index.php?title=Bink_Container RCHECK(buffer_size >= 44); @@ -230,7 +229,7 @@ static bool CheckBink(const uint8* buffer, int buffer_size) { } // Additional checks for a CAF container. -static bool CheckCaf(const uint8* buffer, int buffer_size) { +static bool CheckCaf(const uint8_t* buffer, int buffer_size) { // Reference: Apple Core Audio Format Specification 1.0 // (https://developer.apple.com/library/mac/#documentation/MusicAudio/Reference/CAFSpec/CAF_spec/CAF_spec.html) RCHECK(buffer_size >= 52); @@ -271,7 +270,7 @@ static bool kExtAudioIdValid[8] = { true, false, true, false, false, false, true, false }; // Additional checks for a DTS container. -static bool CheckDts(const uint8* buffer, int buffer_size) { +static bool CheckDts(const uint8_t* buffer, int buffer_size) { // Reference: ETSI TS 102 114 V1.3.1 (2011-08) // (http://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.03.01_60/ts_102114v010301p.pdf) RCHECK(buffer_size > 11); @@ -326,7 +325,7 @@ static bool CheckDts(const uint8* buffer, int buffer_size) { } // Checks for a DV container. -static bool CheckDV(const uint8* buffer, int buffer_size) { +static bool CheckDV(const uint8_t* buffer, int buffer_size) { // Reference: SMPTE 314M (Annex A has differences with IEC 61834). // (http://standards.smpte.org/content/978-1-61482-454-1/st-314-2005/SEC1.body.pdf) RCHECK(buffer_size > 11); @@ -389,7 +388,7 @@ static bool CheckDV(const uint8* buffer, int buffer_size) { // Checks for a GSM container. -static bool CheckGsm(const uint8* buffer, int buffer_size) { +static bool CheckGsm(const uint8_t* buffer, int buffer_size) { // Reference: ETSI EN 300 961 V8.1.1 // (http://www.etsi.org/deliver/etsi_en/300900_300999/300961/08.01.01_60/en_300961v080101p.pdf) // also http://tools.ietf.org/html/rfc3551#page-24 @@ -410,20 +409,20 @@ static bool CheckGsm(const uint8* buffer, int buffer_size) { // number of bytes that must remain in the buffer when |start_code| is found. // Returns true if start_code found (and enough space in the buffer after it), // false otherwise. -static bool AdvanceToStartCode(const uint8* buffer, +static bool AdvanceToStartCode(const uint8_t* buffer, int buffer_size, int* offset, int bytes_needed, int num_bits, - uint32 start_code) { + uint32_t start_code) { DCHECK_GE(bytes_needed, 3); DCHECK_LE(num_bits, 24); // Only supports up to 24 bits. // Create a mask to isolate |num_bits| bits, once shifted over. - uint32 bits_to_shift = 24 - num_bits; - uint32 mask = (1 << num_bits) - 1; + uint32_t bits_to_shift = 24 - num_bits; + uint32_t mask = (1 << num_bits) - 1; while (*offset + bytes_needed < buffer_size) { - uint32 next = Read24(buffer + *offset); + uint32_t next = Read24(buffer + *offset); if (((next >> bits_to_shift) & mask) == start_code) return true; ++(*offset); @@ -432,7 +431,7 @@ static bool AdvanceToStartCode(const uint8* buffer, } // Checks for an H.261 container. -static bool CheckH261(const uint8* buffer, int buffer_size) { +static bool CheckH261(const uint8_t* buffer, int buffer_size) { // Reference: ITU-T Recommendation H.261 (03/1993) // (http://www.itu.int/rec/T-REC-H.261-199303-I/en) RCHECK(buffer_size > 16); @@ -480,7 +479,7 @@ static bool CheckH261(const uint8* buffer, int buffer_size) { } // Checks for an H.263 container. -static bool CheckH263(const uint8* buffer, int buffer_size) { +static bool CheckH263(const uint8_t* buffer, int buffer_size) { // Reference: ITU-T Recommendation H.263 (01/2005) // (http://www.itu.int/rec/T-REC-H.263-200501-I/en) // header is PSC(22b) + TR(8b) + PTYPE(8+b). @@ -548,7 +547,7 @@ static bool CheckH263(const uint8* buffer, int buffer_size) { } // Checks for an H.264 container. -static bool CheckH264(const uint8* buffer, int buffer_size) { +static bool CheckH264(const uint8_t* buffer, int buffer_size) { // Reference: ITU-T Recommendation H.264 (01/2012) // (http://www.itu.int/rec/T-REC-H.264) // Section B.1: Byte stream NAL unit syntax and semantics. @@ -604,7 +603,7 @@ static const char kHls2[] = "#EXT-X-TARGETDURATION:"; static const char kHls3[] = "#EXT-X-MEDIA-SEQUENCE:"; // Additional checks for a HLS container. -static bool CheckHls(const uint8* buffer, int buffer_size) { +static bool CheckHls(const uint8_t* buffer, int buffer_size) { // HLS is simply a play list used for Apple HTTP Live Streaming. // Reference: Apple HTTP Live Streaming Overview // (http://goo.gl/MIwxj) @@ -630,7 +629,7 @@ static bool CheckHls(const uint8* buffer, int buffer_size) { } // Checks for a MJPEG stream. -static bool CheckMJpeg(const uint8* buffer, int buffer_size) { +static bool CheckMJpeg(const uint8_t* buffer, int buffer_size) { // Reference: ISO/IEC 10918-1 : 1993(E), Annex B // (http://www.w3.org/Graphics/JPEG/itu-t81.pdf) RCHECK(buffer_size >= 16); @@ -641,7 +640,7 @@ static bool CheckMJpeg(const uint8* buffer, int buffer_size) { while (offset + 5 < buffer_size) { // Marker codes are always a two byte code with the first byte xFF. RCHECK(buffer[offset] == 0xff); - uint8 code = buffer[offset + 1]; + uint8_t code = buffer[offset + 1]; RCHECK(code >= 0xc0 || code == 1); // Skip sequences of xFF. @@ -699,7 +698,7 @@ enum Mpeg2StartCodes { }; // Checks for a MPEG2 Program Stream. -static bool CheckMpeg2ProgramStream(const uint8* buffer, int buffer_size) { +static bool CheckMpeg2ProgramStream(const uint8_t* buffer, int buffer_size) { // Reference: ISO/IEC 13818-1 : 2000 (E) / ITU-T Rec. H.222.0 (2000 E). RCHECK(buffer_size > 14); @@ -794,10 +793,10 @@ static bool CheckMpeg2ProgramStream(const uint8* buffer, int buffer_size) { return true; } -const uint8 kMpeg2SyncWord = 0x47; +const uint8_t kMpeg2SyncWord = 0x47; // Checks for a MPEG2 Transport Stream. -static bool CheckMpeg2TransportStream(const uint8* buffer, int buffer_size) { +static bool CheckMpeg2TransportStream(const uint8_t* buffer, int buffer_size) { // Spec: ISO/IEC 13818-1 : 2000 (E) / ITU-T Rec. H.222.0 (2000 E). // Normal packet size is 188 bytes. However, some systems add various error // correction data at the end, resulting in packet of length 192/204/208 @@ -870,7 +869,7 @@ enum Mpeg4StartCodes { }; // Checks for a raw MPEG4 bitstream container. -static bool CheckMpeg4BitStream(const uint8* buffer, int buffer_size) { +static bool CheckMpeg4BitStream(const uint8_t* buffer, int buffer_size) { // Defined in ISO/IEC 14496-2:2001. // However, no length ... simply scan for start code values. // Note tags are very similar to H.264. @@ -946,7 +945,7 @@ static bool CheckMpeg4BitStream(const uint8* buffer, int buffer_size) { } // Additional checks for a MOV/QuickTime/MPEG4 container. -static bool CheckMov(const uint8* buffer, int buffer_size) { +static bool CheckMov(const uint8_t* buffer, int buffer_size) { // Reference: ISO/IEC 14496-12:2005(E). // (http://standards.iso.org/ittf/PubliclyAvailableStandards/c061988_ISO_IEC_14496-12_2012.zip) RCHECK(buffer_size > 8); @@ -954,7 +953,7 @@ static bool CheckMov(const uint8* buffer, int buffer_size) { int offset = 0; while (offset + 8 < buffer_size) { int atomsize = Read32(buffer + offset); - uint32 atomtype = Read32(buffer + offset + 4); + uint32_t atomtype = Read32(buffer + offset + 4); // Only need to check for ones that are valid at the top level. switch (atomtype) { case TAG('f','t','y','p'): @@ -1021,7 +1020,7 @@ static int kBitRateTableV2L1[16] = { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, static int kBitRateTableV2L23[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }; -static bool ValidMpegAudioFrameHeader(const uint8* header, +static bool ValidMpegAudioFrameHeader(const uint8_t* header, int header_size, int* framesize) { // Reference: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm. @@ -1081,7 +1080,7 @@ static bool ValidMpegAudioFrameHeader(const uint8* header, } // Extract a size encoded the MP3 way. -static int GetMp3HeaderSize(const uint8* buffer, int buffer_size) { +static int GetMp3HeaderSize(const uint8_t* buffer, int buffer_size) { DCHECK_GE(buffer_size, 9); int size = ((buffer[6] & 0x7f) << 21) + ((buffer[7] & 0x7f) << 14) + ((buffer[8] & 0x7f) << 7) + (buffer[9] & 0x7f) + 10; @@ -1091,7 +1090,7 @@ static int GetMp3HeaderSize(const uint8* buffer, int buffer_size) { } // Additional checks for a MP3 container. -static bool CheckMp3(const uint8* buffer, int buffer_size, bool seenHeader) { +static bool CheckMp3(const uint8_t* buffer, int buffer_size, bool seenHeader) { RCHECK(buffer_size >= 10); // Must be enough to read the initial header. int framesize; @@ -1122,7 +1121,7 @@ static bool CheckMp3(const uint8* buffer, int buffer_size, bool seenHeader) { // accepted is optional whitespace followed by 1 or more digits. |max_digits| // specifies the maximum number of digits to process. Returns true if a valid // number is found, false otherwise. -static bool VerifyNumber(const uint8* buffer, +static bool VerifyNumber(const uint8_t* buffer, int buffer_size, int* offset, int max_digits) { @@ -1150,7 +1149,7 @@ static bool VerifyNumber(const uint8* buffer, // Check that the next character in |buffer| is one of |c1| or |c2|. |c2| is // optional. Returns true if there is a match, false if no match or out of // space. -static inline bool VerifyCharacters(const uint8* buffer, +static inline bool VerifyCharacters(const uint8_t* buffer, int buffer_size, int* offset, char c1, @@ -1161,7 +1160,7 @@ static inline bool VerifyCharacters(const uint8* buffer, } // Checks for a SRT container. -static bool CheckSrt(const uint8* buffer, int buffer_size) { +static bool CheckSrt(const uint8_t* buffer, int buffer_size) { // Reference: http://en.wikipedia.org/wiki/SubRip RCHECK(buffer_size > 20); @@ -1222,7 +1221,7 @@ static int GetElementId(BitReader* reader) { } // Read a Matroska Unsigned Integer (VINT). -static uint64 GetVint(BitReader* reader) { +static uint64_t GetVint(BitReader* reader) { // Values are coded with the leading zero bits (max 7) determining size. // If it is an invalid coding or the end of the buffer is reached, // return something that will go off the end of the buffer. @@ -1244,7 +1243,7 @@ static uint64 GetVint(BitReader* reader) { } // Additional checks for a WEBM container. -static bool CheckWebm(const uint8* buffer, int buffer_size) { +static bool CheckWebm(const uint8_t* buffer, int buffer_size) { // Reference: http://www.matroska.org/technical/specs/index.html RCHECK(buffer_size > 12); @@ -1297,7 +1296,7 @@ enum VC1StartCodes { }; // Checks for a VC1 bitstream container. -static bool CheckVC1(const uint8* buffer, int buffer_size) { +static bool CheckVC1(const uint8_t* buffer, int buffer_size) { // Reference: SMPTE 421M // (http://standards.smpte.org/content/978-1-61482-555-5/st-421-2006/SEC1.body.pdf) // However, no length ... simply scan for start code values. @@ -1405,27 +1404,27 @@ static bool CheckVC1(const uint8* buffer, int buffer_size) { // For some formats the signature is a bunch of characters. They are defined // below. Note that the first 4 characters of the string may be used as a TAG // in LookupContainerByFirst4. For signatures that contain embedded \0, use -// uint8[]. +// uint8_t[]. static const char kAmrSignature[] = "#!AMR"; -static const uint8 kAsfSignature[] = { 0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, - 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, - 0xce, 0x6c }; +static const uint8_t kAsfSignature[] = {0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, + 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, + 0x00, 0x62, 0xce, 0x6c}; static const char kAssSignature[] = "[Script Info]"; static const char kAssBomSignature[] = UTF8_BYTE_ORDER_MARK "[Script Info]"; -static const uint8 kWtvSignature[] = { 0xb7, 0xd8, 0x00, 0x20, 0x37, 0x49, 0xda, - 0x11, 0xa6, 0x4e, 0x00, 0x07, 0xe9, 0x5e, - 0xad, 0x8d }; +static const uint8_t kWtvSignature[] = {0xb7, 0xd8, 0x00, 0x20, 0x37, 0x49, + 0xda, 0x11, 0xa6, 0x4e, 0x00, 0x07, + 0xe9, 0x5e, 0xad, 0x8d}; // Attempt to determine the container type from the buffer provided. This is // a simple pass, that uses the first 4 bytes of the buffer as an index to get // a rough idea of the container format. -static MediaContainerName LookupContainerByFirst4(const uint8* buffer, +static MediaContainerName LookupContainerByFirst4(const uint8_t* buffer, int buffer_size) { // Minimum size that the code expects to exist without checking size. if (buffer_size < 12) return CONTAINER_UNKNOWN; - uint32 first4 = Read32(buffer); + uint32_t first4 = Read32(buffer); switch (first4) { case 0x1a45dfa3: if (CheckWebm(buffer, buffer_size)) @@ -1580,7 +1579,7 @@ static MediaContainerName LookupContainerByFirst4(const uint8* buffer, // Now try a few different ones that look at something other // than the first 4 bytes. - uint32 first3 = first4 & 0xffffff00; + uint32_t first3 = first4 & 0xffffff00; switch (first3) { case TAG('C','W','S',0): case TAG('F','W','S',0): @@ -1593,7 +1592,7 @@ static MediaContainerName LookupContainerByFirst4(const uint8* buffer, } // Maybe the first 2 characters are something we can use. - uint32 first2 = Read16(buffer); + uint32_t first2 = Read16(buffer); switch (first2) { case kAc3SyncWord: if (CheckAc3(buffer, buffer_size)) @@ -1619,7 +1618,7 @@ static MediaContainerName LookupContainerByFirst4(const uint8* buffer, } // Attempt to determine the container name from the buffer provided. -MediaContainerName DetermineContainer(const uint8* buffer, int buffer_size) { +MediaContainerName DetermineContainer(const uint8_t* buffer, int buffer_size) { DCHECK(buffer); // Since MOV/QuickTime/MPEG4 streams are common, check for them first. diff --git a/media/base/container_names.h b/media/base/container_names.h index 410e47b70e..66bf716077 100644 --- a/media/base/container_names.h +++ b/media/base/container_names.h @@ -55,7 +55,7 @@ enum MediaContainerName { }; /// Determine the container type. -MediaContainerName DetermineContainer(const uint8* buffer, int buffer_size); +MediaContainerName DetermineContainer(const uint8_t* buffer, int buffer_size); } // namespace media } // namespace edash_packager diff --git a/media/base/container_names_unittest.cc b/media/base/container_names_unittest.cc index f812b8eb7b..6b8ba75b48 100644 --- a/media/base/container_names_unittest.cc +++ b/media/base/container_names_unittest.cc @@ -14,9 +14,9 @@ namespace media { // Using a macros to simplify tests. Since EXPECT_EQ outputs the second argument // as a string when it fails, this lets the output identify what item actually // failed. -#define VERIFY(buffer, name) \ - EXPECT_EQ(name, \ - DetermineContainer(reinterpret_cast(buffer), \ +#define VERIFY(buffer, name) \ + EXPECT_EQ(name, \ + DetermineContainer(reinterpret_cast(buffer), \ sizeof(buffer))) // Test that small buffers are handled correctly. @@ -57,30 +57,30 @@ TEST(ContainerNamesTest, CheckSmallBuffer) { // Note that the comparisons need at least 12 bytes, so make sure the buffer is // at least that size. const char kAmrBuffer[12] = "#!AMR"; -uint8 kAsfBuffer[] = { 0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, 0xa6, - 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }; +uint8_t kAsfBuffer[] = {0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, + 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; const char kAss1Buffer[] = "[Script Info]"; const char kAss2Buffer[] = BYTE_ORDER_MARK "[Script Info]"; -uint8 kCafBuffer[] = { 'c', 'a', 'f', 'f', 0, 1, 0, 0, 'd', 'e', 's', 'c', 0, 0, - 0, 0, 0, 0, 0, 32, 64, 229, 136, 128, 0, 0, 0, 0, 'a', - 'a', 'c', ' ', 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, - 0, 2, 0, 0, 0, 0 }; +uint8_t kCafBuffer[] = { + 'c', 'a', 'f', 'f', 0, 1, 0, 0, 'd', 'e', 's', 'c', 0, 0, 0, 0, 0, 0, 0, + 32, 64, 229, 136, 128, 0, 0, 0, 0, 'a', 'a', 'c', ' ', 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 4, 0, 0, 0, 0, 2, 0, 0, 0, 0}; const char kDtshdBuffer[12] = "DTSHDHDR"; const char kDxaBuffer[16] = "DEXA"; const char kFlacBuffer[12] = "fLaC"; -uint8 kFlvBuffer[12] = { 'F', 'L', 'V', 0, 0, 0, 0, 1, 0, 0, 0, 0 }; -uint8 kIrcamBuffer[] = { 0x64, 0xa3, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 }; +uint8_t kFlvBuffer[12] = {'F', 'L', 'V', 0, 0, 0, 0, 1, 0, 0, 0, 0}; +uint8_t kIrcamBuffer[] = {0x64, 0xa3, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1}; const char kRm1Buffer[12] = ".RMF\0\0"; const char kRm2Buffer[12] = ".ra\xfd"; -uint8 kWtvBuffer[] = { 0xb7, 0xd8, 0x00, 0x20, 0x37, 0x49, 0xda, 0x11, 0xa6, - 0x4e, 0x00, 0x07, 0xe9, 0x5e, 0xad, 0x8d }; -uint8 kBug263073Buffer[] = { - 0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x69, 0x73, 0x6f, 0x6d, 0x6d, 0x70, 0x34, 0x32, - 0x00, 0x00, 0x00, 0x01, 0x6d, 0x64, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00, - 0xaa, 0x2e, 0x22, 0xcf, 0x00, 0x00, 0x00, 0x37, 0x67, 0x64, 0x00, 0x28, - 0xac, 0x2c, 0xa4, 0x01, 0xe0, 0x08, 0x9f, 0x97, 0x01, 0x52, 0x02, 0x02, - 0x02, 0x80, 0x00, 0x01}; +uint8_t kWtvBuffer[] = {0xb7, 0xd8, 0x00, 0x20, 0x37, 0x49, 0xda, 0x11, + 0xa6, 0x4e, 0x00, 0x07, 0xe9, 0x5e, 0xad, 0x8d}; +uint8_t kBug263073Buffer[] = { + 0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, + 0x32, 0x00, 0x00, 0x00, 0x00, 0x69, 0x73, 0x6f, 0x6d, 0x6d, 0x70, + 0x34, 0x32, 0x00, 0x00, 0x00, 0x01, 0x6d, 0x64, 0x61, 0x74, 0x00, + 0x00, 0x00, 0x00, 0xaa, 0x2e, 0x22, 0xcf, 0x00, 0x00, 0x00, 0x37, + 0x67, 0x64, 0x00, 0x28, 0xac, 0x2c, 0xa4, 0x01, 0xe0, 0x08, 0x9f, + 0x97, 0x01, 0x52, 0x02, 0x02, 0x02, 0x80, 0x00, 0x01}; // Test that containers that start with fixed strings are handled correctly. // This is to verify that the TAG matches the first 4 characters of the string. @@ -108,14 +108,14 @@ void TestFile(MediaContainerName expected, const base::FilePath& filename) { // Windows implementation of ReadFile fails if file smaller than desired size, // so use file length if file less than 8192 bytes (http://crbug.com/243885). int read_size = sizeof(buffer); - int64 actual_size; + int64_t actual_size; if (base::GetFileSize(filename, &actual_size) && actual_size < read_size) read_size = actual_size; int read = base::ReadFile(filename, buffer, read_size); // Now verify the type. EXPECT_EQ(expected, - DetermineContainer(reinterpret_cast(buffer), read)) + DetermineContainer(reinterpret_cast(buffer), read)) << "Failure with file " << filename.value(); } diff --git a/media/base/decrypt_config.cc b/media/base/decrypt_config.cc index 52d5ccdc04..adcdd768bc 100644 --- a/media/base/decrypt_config.cc +++ b/media/base/decrypt_config.cc @@ -9,8 +9,8 @@ namespace edash_packager { namespace media { -DecryptConfig::DecryptConfig(const std::vector& key_id, - const std::vector& iv, +DecryptConfig::DecryptConfig(const std::vector& key_id, + const std::vector& iv, const int data_offset, const std::vector& subsamples) : key_id_(key_id), diff --git a/media/base/decrypt_config.h b/media/base/decrypt_config.h index 3808be6d6f..9a71a61315 100644 --- a/media/base/decrypt_config.h +++ b/media/base/decrypt_config.h @@ -24,8 +24,8 @@ namespace media { /// result, and then copying each byte from the decrypted block over the /// corresponding encrypted byte. struct SubsampleEntry { - uint16 clear_bytes; - uint32 cipher_bytes; + uint16_t clear_bytes; + uint32_t cipher_bytes; }; /// Contains all the information that a decryptor needs to decrypt a media @@ -44,22 +44,22 @@ class DecryptConfig { /// @param subsamples defines the clear and encrypted portions of the sample /// as described in SubsampleEntry. A decrypted buffer will be equal /// in size to the sum of the subsample sizes. - DecryptConfig(const std::vector& key_id, - const std::vector& iv, + DecryptConfig(const std::vector& key_id, + const std::vector& iv, const int data_offset, const std::vector& subsamples); ~DecryptConfig(); - const std::vector& key_id() const { return key_id_; } - const std::vector& iv() const { return iv_; } + const std::vector& key_id() const { return key_id_; } + const std::vector& iv() const { return iv_; } int data_offset() const { return data_offset_; } const std::vector& subsamples() const { return subsamples_; } private: - const std::vector key_id_; + const std::vector key_id_; // Initialization vector. - const std::vector iv_; + const std::vector iv_; // Amount of data to be discarded before applying subsample information. const int data_offset_; diff --git a/media/base/demuxer.cc b/media/base/demuxer.cc index b620996901..7c2f906b3d 100644 --- a/media/base/demuxer.cc +++ b/media/base/demuxer.cc @@ -31,7 +31,8 @@ Demuxer::Demuxer(const std::string& file_name) : file_name_(file_name), media_file_(NULL), init_event_received_(false), - buffer_(new uint8[kBufSize]) {} + buffer_(new uint8_t[kBufSize]) { +} Demuxer::~Demuxer() { if (media_file_) @@ -54,7 +55,7 @@ Status Demuxer::Initialize() { } // Determine media container. - int64 bytes_read = media_file_->Read(buffer_.get(), kBufSize); + int64_t bytes_read = media_file_->Read(buffer_.get(), kBufSize); if (bytes_read <= 0) return Status(error::FILE_FAILURE, "Cannot read file " + file_name_); MediaContainerName container = DetermineContainer(buffer_.get(), bytes_read); @@ -101,7 +102,7 @@ void Demuxer::ParserInitEvent( } } -bool Demuxer::NewSampleEvent(uint32 track_id, +bool Demuxer::NewSampleEvent(uint32_t track_id, const scoped_refptr& sample) { std::vector::iterator it = streams_.begin(); for (; it != streams_.end(); ++it) { @@ -146,7 +147,7 @@ Status Demuxer::Parse() { DCHECK(parser_); DCHECK(buffer_); - int64 bytes_read = media_file_->Read(buffer_.get(), kBufSize); + int64_t bytes_read = media_file_->Read(buffer_.get(), kBufSize); if (bytes_read <= 0) { if (media_file_->Eof()) { parser_->Flush(); diff --git a/media/base/demuxer.h b/media/base/demuxer.h index a296d49d07..fff1b2fee4 100644 --- a/media/base/demuxer.h +++ b/media/base/demuxer.h @@ -64,7 +64,7 @@ class Demuxer { private: // Parser event handlers. void ParserInitEvent(const std::vector >& streams); - bool NewSampleEvent(uint32 track_id, + bool NewSampleEvent(uint32_t track_id, const scoped_refptr& sample); std::string file_name_; @@ -72,7 +72,7 @@ class Demuxer { bool init_event_received_; scoped_ptr parser_; std::vector streams_; - scoped_ptr buffer_; + scoped_ptr buffer_; scoped_ptr key_source_; DISALLOW_COPY_AND_ASSIGN(Demuxer); diff --git a/media/base/fake_prng.cc b/media/base/fake_prng.cc index cd0fad3c10..0780da866c 100644 --- a/media/base/fake_prng.cc +++ b/media/base/fake_prng.cc @@ -19,7 +19,7 @@ FILE* g_rand_source_fp = NULL; const char kFakePrngDataFile[] = "fake_prng_data.bin"; // RAND_bytes and RAND_pseudorand implementation. -int FakeBytes(uint8* buf, int num) { +int FakeBytes(uint8_t* buf, int num) { DCHECK(buf); DCHECK(g_rand_source_fp); diff --git a/media/base/http_fetcher.cc b/media/base/http_fetcher.cc index 55ae881688..59d84db73a 100644 --- a/media/base/http_fetcher.cc +++ b/media/base/http_fetcher.cc @@ -47,7 +47,7 @@ SimpleHttpFetcher::SimpleHttpFetcher() : timeout_in_seconds_(0) { curl_global_init(CURL_GLOBAL_DEFAULT); } -SimpleHttpFetcher::SimpleHttpFetcher(uint32 timeout_in_seconds) +SimpleHttpFetcher::SimpleHttpFetcher(uint32_t timeout_in_seconds) : timeout_in_seconds_(timeout_in_seconds) { curl_global_init(CURL_GLOBAL_DEFAULT); } diff --git a/media/base/http_fetcher.h b/media/base/http_fetcher.h index c94dec4034..14fded317f 100644 --- a/media/base/http_fetcher.h +++ b/media/base/http_fetcher.h @@ -50,7 +50,7 @@ class SimpleHttpFetcher : public HttpFetcher { SimpleHttpFetcher(); /// Create a fetcher with timeout. /// @param timeout_in_seconds specifies the timeout in seconds. - SimpleHttpFetcher(uint32 timeout_in_seconds); + SimpleHttpFetcher(uint32_t timeout_in_seconds); virtual ~SimpleHttpFetcher(); /// @name HttpFetcher implementation overrides. @@ -72,7 +72,7 @@ class SimpleHttpFetcher : public HttpFetcher { Status FetchInternal(HttpMethod method, const std::string& url, const std::string& data, std::string* response); - const uint32 timeout_in_seconds_; + const uint32_t timeout_in_seconds_; DISALLOW_COPY_AND_ASSIGN(SimpleHttpFetcher); }; diff --git a/media/base/http_fetcher_unittest.cc b/media/base/http_fetcher_unittest.cc index ccbce5dd0e..644ffdc550 100644 --- a/media/base/http_fetcher_unittest.cc +++ b/media/base/http_fetcher_unittest.cc @@ -70,7 +70,7 @@ TEST(DISABLED_HttpFetcherTest, UrlWithPort) { } TEST(DISABLED_HttpFetcherTest, SmallTimeout) { - const uint32 kTimeoutInSeconds = 1; + const uint32_t kTimeoutInSeconds = 1; SimpleHttpFetcher fetcher(kTimeoutInSeconds); std::string response; Status status = fetcher.Post(kTestUrl, kDelayTwoSecs, &response); @@ -78,7 +78,7 @@ TEST(DISABLED_HttpFetcherTest, SmallTimeout) { } TEST(DISABLED_HttpFetcherTest, BigTimeout) { - const uint32 kTimeoutInSeconds = 5; + const uint32_t kTimeoutInSeconds = 5; SimpleHttpFetcher fetcher(kTimeoutInSeconds); std::string response; Status status = fetcher.Post(kTestUrl, kDelayTwoSecs, &response); diff --git a/media/base/key_source.cc b/media/base/key_source.cc index 428429979d..d68d131285 100644 --- a/media/base/key_source.cc +++ b/media/base/key_source.cc @@ -11,9 +11,9 @@ #include "media/base/buffer_writer.h" namespace { -const uint8 kWidevineSystemId[] = {0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6, - 0x4a, 0xce, 0xa3, 0xc8, 0x27, 0xdc, - 0xd5, 0x1d, 0x21, 0xed}; +const uint8_t kWidevineSystemId[] = {0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6, + 0x4a, 0xce, 0xa3, 0xc8, 0x27, 0xdc, + 0xd5, 0x1d, 0x21, 0xed}; } // namespace namespace edash_packager { @@ -24,13 +24,13 @@ EncryptionKey::~EncryptionKey() {} KeySource::~KeySource() {} -Status KeySource::FetchKeys(const std::vector& content_id, +Status KeySource::FetchKeys(const std::vector& content_id, const std::string& policy) { // Do nothing for fixed key decryption. return Status::OK; } -Status KeySource::FetchKeys(const std::vector& pssh_data) { +Status KeySource::FetchKeys(const std::vector& pssh_data) { // Do nothing for fixed key decryption. return Status::OK; } @@ -42,7 +42,7 @@ Status KeySource::GetKey(TrackType track_type, EncryptionKey* key) { return Status::OK; } -Status KeySource::GetKey(const std::vector& key_id, +Status KeySource::GetKey(const std::vector& key_id, EncryptionKey* key) { DCHECK(key); DCHECK(encryption_key_); @@ -55,7 +55,7 @@ Status KeySource::GetKey(const std::vector& key_id, return Status::OK; } -Status KeySource::GetCryptoPeriodKey(uint32 crypto_period_index, +Status KeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey* key) { NOTIMPLEMENTED(); @@ -79,7 +79,7 @@ scoped_ptr KeySource::CreateFromHexStrings( return scoped_ptr(); } - std::vector pssh_data; + std::vector pssh_data; if (!pssh_data_hex.empty() && !base::HexStringToBytes(pssh_data_hex, &pssh_data)) { LOG(ERROR) << "Cannot parse pssh_hex " << pssh_data_hex; @@ -124,13 +124,13 @@ std::string KeySource::TrackTypeToString(TrackType track_type) { } } -std::vector KeySource::PsshBoxFromPsshData( - const std::vector& pssh_data) { - const uint8 kPsshFourCC[] = {'p', 's', 's', 'h'}; - const uint32 kVersionAndFlags = 0; +std::vector KeySource::PsshBoxFromPsshData( + const std::vector& pssh_data) { + const uint8_t kPsshFourCC[] = {'p', 's', 's', 'h'}; + const uint32_t kVersionAndFlags = 0; - const uint32 pssh_data_size = pssh_data.size(); - const uint32 total_size = + const uint32_t pssh_data_size = pssh_data.size(); + const uint32_t total_size = sizeof(total_size) + sizeof(kPsshFourCC) + sizeof(kVersionAndFlags) + sizeof(kWidevineSystemId) + sizeof(pssh_data_size) + pssh_data_size; @@ -141,7 +141,7 @@ std::vector KeySource::PsshBoxFromPsshData( writer.AppendArray(kWidevineSystemId, sizeof(kWidevineSystemId)); writer.AppendInt(pssh_data_size); writer.AppendVector(pssh_data); - return std::vector(writer.Buffer(), writer.Buffer() + writer.Size()); + return std::vector(writer.Buffer(), writer.Buffer() + writer.Size()); } KeySource::KeySource() {} diff --git a/media/base/key_source.h b/media/base/key_source.h index c2f4482141..2f07498151 100644 --- a/media/base/key_source.h +++ b/media/base/key_source.h @@ -19,10 +19,10 @@ struct EncryptionKey { EncryptionKey(); ~EncryptionKey(); - std::vector key_id; - std::vector key; - std::vector pssh; - std::vector iv; + std::vector key_id; + std::vector key; + std::vector pssh; + std::vector iv; }; /// KeySource is responsible for encryption key acquisition. @@ -42,14 +42,14 @@ class KeySource { /// @param content_id the unique id identify the content. /// @param policy specifies the DRM content rights. /// @return OK on success, an error status otherwise. - virtual Status FetchKeys(const std::vector& content_id, + virtual Status FetchKeys(const std::vector& content_id, const std::string& policy); /// Fetch keys for CENC from the key server. /// @param pssh_data is the Data portion of the PSSH box for the content /// to be decrypted. /// @return OK on success, an error status otherwise. - virtual Status FetchKeys(const std::vector& pssh_data); + virtual Status FetchKeys(const std::vector& pssh_data); /// Get encryption key of the specified track type. /// @param track_type is the type of track for which retrieving the key. @@ -63,7 +63,7 @@ class KeySource { /// @param key is a pointer to the EncryptionKey which will hold the retrieved /// key. Owner retains ownership, and may not be NULL. /// @return OK on success, or an error status otherwise. - virtual Status GetKey(const std::vector& key_id, EncryptionKey* key); + virtual Status GetKey(const std::vector& key_id, EncryptionKey* key); /// Get encryption key of the specified track type at the specified index. /// @param crypto_period_index is the sequence number of the key rotation @@ -72,7 +72,7 @@ class KeySource { /// @param key is a pointer to the EncryptionKey which will hold the retrieved /// key. Owner retains ownership, and may not be NULL. /// @return OK on success, an error status otherwise. - virtual Status GetCryptoPeriodKey(uint32 crypto_period_index, + virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey* key); @@ -101,8 +101,8 @@ class KeySource { /// @return the raw bytes of the pssh box with system ID and box header /// included. - static std::vector PsshBoxFromPsshData( - const std::vector& pssh_data); + static std::vector PsshBoxFromPsshData( + const std::vector& pssh_data); private: explicit KeySource(scoped_ptr encryption_key); diff --git a/media/base/media_parser.h b/media/base/media_parser.h index 693807c320..23f651106d 100644 --- a/media/base/media_parser.h +++ b/media/base/media_parser.h @@ -38,8 +38,8 @@ class MediaParser { /// @param media_sample is the new media sample. /// @return true if the sample is accepted, false if something was wrong /// with the sample and a parsing error should be signaled. - typedef base::Callback< - bool(uint32 track_id, const scoped_refptr& media_sample)> + typedef base::Callback& media_sample)> NewSampleCB; /// Initialize the parser with necessary callbacks. Must be called before any @@ -59,7 +59,7 @@ class MediaParser { /// Should be called when there is new data to parse. /// @return true if successful. - virtual bool Parse(const uint8* buf, int size) = 0; + virtual bool Parse(const uint8_t* buf, int size) = 0; private: DISALLOW_COPY_AND_ASSIGN(MediaParser); diff --git a/media/base/media_sample.cc b/media/base/media_sample.cc index 326eb5ab2c..d3054ebe2c 100644 --- a/media/base/media_sample.cc +++ b/media/base/media_sample.cc @@ -14,9 +14,9 @@ namespace edash_packager { namespace media { -MediaSample::MediaSample(const uint8* data, +MediaSample::MediaSample(const uint8_t* data, size_t size, - const uint8* side_data, + const uint8_t* side_data, size_t side_data_size, bool is_key_frame) : dts_(0), pts_(0), duration_(0), is_key_frame_(is_key_frame) { @@ -38,7 +38,7 @@ MediaSample::MediaSample() : dts_(0), pts_(0), MediaSample::~MediaSample() {} // static -scoped_refptr MediaSample::CopyFrom(const uint8* data, +scoped_refptr MediaSample::CopyFrom(const uint8_t* data, size_t data_size, bool is_key_frame) { // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. @@ -48,9 +48,9 @@ scoped_refptr MediaSample::CopyFrom(const uint8* data, } // static -scoped_refptr MediaSample::CopyFrom(const uint8* data, +scoped_refptr MediaSample::CopyFrom(const uint8_t* data, size_t data_size, - const uint8* side_data, + const uint8_t* side_data, size_t side_data_size, bool is_key_frame) { // If you hit this CHECK you likely have a bug in a demuxer. Go fix it. diff --git a/media/base/media_sample.h b/media/base/media_sample.h index d79f623f74..2d2c3c4697 100644 --- a/media/base/media_sample.h +++ b/media/base/media_sample.h @@ -26,7 +26,7 @@ class MediaSample : public base::RefCountedThreadSafe { /// Must not be NULL. /// @param size indicates sample size in bytes. Must not be negative. /// @param is_key_frame indicates whether the sample is a key frame. - static scoped_refptr CopyFrom(const uint8* data, + static scoped_refptr CopyFrom(const uint8_t* data, size_t size, bool is_key_frame); @@ -40,9 +40,9 @@ class MediaSample : public base::RefCountedThreadSafe { /// @param side_data_size indicates additional sample data size in bytes. /// Must not be negative. /// @param is_key_frame indicates whether the sample is a key frame. - static scoped_refptr CopyFrom(const uint8* data, + static scoped_refptr CopyFrom(const uint8_t* data, size_t size, - const uint8* side_data, + const uint8_t* side_data, size_t side_data_size, bool is_key_frame); @@ -54,30 +54,26 @@ class MediaSample : public base::RefCountedThreadSafe { /// is disallowed. static scoped_refptr CreateEOSBuffer(); - int64 dts() const { + int64_t dts() const { DCHECK(!end_of_stream()); return dts_; } - void set_dts(int64 dts) { - dts_ = dts; - } + void set_dts(int64_t dts) { dts_ = dts; } - int64 pts() const { + int64_t pts() const { DCHECK(!end_of_stream()); return pts_; } - void set_pts(int64 pts) { - pts_ = pts; - } + void set_pts(int64_t pts) { pts_ = pts; } - int64 duration() const { + int64_t duration() const { DCHECK(!end_of_stream()); return duration_; } - void set_duration(int64 duration) { + void set_duration(int64_t duration) { DCHECK(!end_of_stream()); duration_ = duration; } @@ -87,12 +83,12 @@ class MediaSample : public base::RefCountedThreadSafe { return is_key_frame_; } - const uint8* data() const { + const uint8_t* data() const { DCHECK(!end_of_stream()); return &data_[0]; } - uint8* writable_data() { + uint8_t* writable_data() { DCHECK(!end_of_stream()); return &data_[0]; } @@ -102,7 +98,7 @@ class MediaSample : public base::RefCountedThreadSafe { return data_.size(); } - const uint8* side_data() const { + const uint8_t* side_data() const { DCHECK(!end_of_stream()); return &side_data_[0]; } @@ -112,7 +108,7 @@ class MediaSample : public base::RefCountedThreadSafe { return side_data_.size(); } - void set_data(const uint8* data, const size_t data_size) { + void set_data(const uint8_t* data, const size_t data_size) { data_.assign(data, data + data_size); } @@ -132,27 +128,27 @@ class MediaSample : public base::RefCountedThreadSafe { // Create a MediaSample. Buffer will be padded and aligned as necessary. // |data|,|side_data| can be NULL, which indicates an empty sample. // |size|,|side_data_size| should not be negative. - MediaSample(const uint8* data, + MediaSample(const uint8_t* data, size_t size, - const uint8* side_data, + const uint8_t* side_data, size_t side_data_size, bool is_key_frame); MediaSample(); virtual ~MediaSample(); // Decoding time stamp. - int64 dts_; + int64_t dts_; // Presentation time stamp. - int64 pts_; - int64 duration_; + int64_t pts_; + int64_t duration_; bool is_key_frame_; // Main buffer data. - std::vector data_; + std::vector data_; // Contain additional buffers to complete the main one. Needed by WebM // http://www.matroska.org/technical/specs/index.html BlockAdditional[A5]. // Not used by mp4 and other containers. - std::vector side_data_; + std::vector side_data_; DISALLOW_COPY_AND_ASSIGN(MediaSample); }; diff --git a/media/base/muxer.cc b/media/base/muxer.cc index c31ea84973..0b0b40d526 100644 --- a/media/base/muxer.cc +++ b/media/base/muxer.cc @@ -25,7 +25,7 @@ Muxer::Muxer(const MuxerOptions& options) Muxer::~Muxer() {} void Muxer::SetKeySource(KeySource* encryption_key_source, - uint32 max_sd_pixels, + uint32_t max_sd_pixels, double clear_lead_in_seconds, double crypto_period_duration_in_seconds) { DCHECK(encryption_key_source); @@ -54,7 +54,7 @@ Status Muxer::Run() { return status; } - uint32 current_stream_id = 0; + uint32_t current_stream_id = 0; while (status.ok()) { scoped_refptr sample; status = streams_[current_stream_id]->PullSample(&sample); diff --git a/media/base/muxer.h b/media/base/muxer.h index e135f806f7..3a34e71eaf 100644 --- a/media/base/muxer.h +++ b/media/base/muxer.h @@ -47,7 +47,7 @@ class Muxer { /// in seconds. A positive value means key rotation is enabled, the /// key source must support key rotation in this case. void SetKeySource(KeySource* encryption_key_source, - uint32 max_sd_pixels, + uint32_t max_sd_pixels, double clear_lead_in_seconds, double crypto_period_duration_in_seconds); @@ -78,7 +78,7 @@ class Muxer { KeySource* encryption_key_source() { return encryption_key_source_; } - uint32 max_sd_pixels() const { return max_sd_pixels_; } + uint32_t max_sd_pixels() const { return max_sd_pixels_; } double clear_lead_in_seconds() const { return clear_lead_in_seconds_; } double crypto_period_duration_in_seconds() const { return crypto_period_duration_in_seconds_; @@ -107,7 +107,7 @@ class Muxer { bool initialized_; std::vector streams_; KeySource* encryption_key_source_; - uint32 max_sd_pixels_; + uint32_t max_sd_pixels_; double clear_lead_in_seconds_; double crypto_period_duration_in_seconds_; diff --git a/media/base/muxer_options.h b/media/base/muxer_options.h index 71cc90d724..e77470a8dc 100644 --- a/media/base/muxer_options.h +++ b/media/base/muxer_options.h @@ -67,7 +67,7 @@ struct MuxerOptions { /// User-specified bit rate for the media stream. If zero, the muxer will /// attempt to estimate. - uint32 bandwidth; + uint32_t bandwidth; }; } // namespace media diff --git a/media/base/muxer_util.cc b/media/base/muxer_util.cc index 1b196bda8f..65d544d4e4 100644 --- a/media/base/muxer_util.cc +++ b/media/base/muxer_util.cc @@ -99,9 +99,9 @@ bool ValidateSegmentTemplate(const std::string& segment_template) { } std::string GetSegmentName(const std::string& segment_template, - uint64 segment_start_time, - uint32 segment_index, - uint32 bandwidth) { + uint64_t segment_start_time, + uint32_t segment_index, + uint32_t bandwidth) { DCHECK(ValidateSegmentTemplate(segment_template)); std::vector splits; @@ -131,23 +131,23 @@ std::string GetSegmentName(const std::string& segment_template, if (format_pos != std::string::npos) { format_tag = splits[i].substr(format_pos); DCHECK(ValidateFormatTag(format_tag)); - // Replace %d formatting to correctly format uint64. + // Replace %d formatting to correctly format uint64_t. format_tag = format_tag.substr(0, format_tag.size() - 1) + PRIu64; } else { - // Default format tag "%01d", modified to format uint64 correctly. + // Default format tag "%01d", modified to format uint64_t correctly. format_tag = "%01" PRIu64; } if (identifier == "Number") { // SegmentNumber starts from 1. segment_name += base::StringPrintf( - format_tag.c_str(), static_cast(segment_index + 1)); + format_tag.c_str(), static_cast(segment_index + 1)); } else if (identifier == "Time") { segment_name += base::StringPrintf(format_tag.c_str(), segment_start_time); } else if (identifier == "Bandwidth") { - segment_name += base::StringPrintf( - format_tag.c_str(), static_cast(bandwidth)); + segment_name += base::StringPrintf(format_tag.c_str(), + static_cast(bandwidth)); } } return segment_name; diff --git a/media/base/muxer_util.h b/media/base/muxer_util.h index 3ec8ce3087..bc180598d0 100644 --- a/media/base/muxer_util.h +++ b/media/base/muxer_util.h @@ -31,9 +31,9 @@ bool ValidateSegmentTemplate(const std::string& segment_template); /// @param bandwidth represents the bit rate, in bits/sec, of the stream. /// @return The segment name with identifier substituted. std::string GetSegmentName(const std::string& segment_template, - uint64 segment_start_time, - uint32 segment_index, - uint32 bandwidth); + uint64_t segment_start_time, + uint32_t segment_index, + uint32_t bandwidth); } // namespace media } // namespace edash_packager diff --git a/media/base/muxer_util_unittest.cc b/media/base/muxer_util_unittest.cc index a056c240cc..bc75a087a7 100644 --- a/media/base/muxer_util_unittest.cc +++ b/media/base/muxer_util_unittest.cc @@ -61,9 +61,9 @@ TEST(MuxerUtilTest, ValidateSegmentTemplateWithFormatTag) { } TEST(MuxerUtilTest, GetSegmentName) { - const uint64 kSegmentStartTime = 180180; - const uint32 kSegmentIndex = 11; - const uint32 kBandwidth = 1234; + const uint64_t kSegmentStartTime = 180180; + const uint32_t kSegmentIndex = 11; + const uint32_t kBandwidth = 1234; EXPECT_EQ("12", GetSegmentName("$Number$", kSegmentStartTime, kSegmentIndex, @@ -118,9 +118,9 @@ TEST(MuxerUtilTest, GetSegmentName) { } TEST(MuxerUtilTest, GetSegmentNameWithIndexZero) { - const uint64 kSegmentStartTime = 0; - const uint32 kSegmentIndex = 0; - const uint32 kBandwidth = 0; + const uint64_t kSegmentStartTime = 0; + const uint32_t kSegmentIndex = 0; + const uint32_t kBandwidth = 0; EXPECT_EQ("1", GetSegmentName("$Number$", kSegmentStartTime, kSegmentIndex, @@ -143,9 +143,9 @@ TEST(MuxerUtilTest, GetSegmentNameWithIndexZero) { } TEST(MuxerUtilTest, GetSegmentNameLargeTime) { - const uint64 kSegmentStartTime = 1601599839840ULL; - const uint32 kSegmentIndex = 8888888; - const uint32 kBandwidth = 444444; + const uint64_t kSegmentStartTime = 1601599839840ULL; + const uint32_t kSegmentIndex = 8888888; + const uint32_t kBandwidth = 444444; EXPECT_EQ("1601599839840", GetSegmentName("$Time$", kSegmentStartTime, diff --git a/media/base/network_util.cc b/media/base/network_util.cc index 11ebe02d84..a09b775e36 100644 --- a/media/base/network_util.cc +++ b/media/base/network_util.cc @@ -7,24 +7,24 @@ namespace edash_packager { namespace media { -uint32 -ntohlFromBuffer(const unsigned char * buf) { - return (static_cast(buf[0])<<24) | (static_cast(buf[1])<<16) - | (static_cast(buf[2])<<8) | (static_cast(buf[3])); - +uint32_t ntohlFromBuffer(const unsigned char* buf) { + return (static_cast(buf[0]) << 24) | + (static_cast(buf[1]) << 16) | + (static_cast(buf[2]) << 8) | (static_cast(buf[3])); } -uint16 -ntohsFromBuffer( const unsigned char * buf) { - return (static_cast(buf[0])<<8) | (static_cast(buf[1])); +uint16_t ntohsFromBuffer(const unsigned char* buf) { + return (static_cast(buf[0]) << 8) | (static_cast(buf[1])); } -uint64 -ntohllFromBuffer( const unsigned char * buf ) { - return (static_cast(buf[0])<<56)| (static_cast(buf[1])<<48) - | (static_cast(buf[2])<<40)| (static_cast(buf[3])<<32) - | (static_cast(buf[4])<<24)| (static_cast(buf[5])<<16) - | (static_cast(buf[6])<<8) | (static_cast(buf[7])); +uint64_t ntohllFromBuffer(const unsigned char* buf) { + return (static_cast(buf[0]) << 56) | + (static_cast(buf[1]) << 48) | + (static_cast(buf[2]) << 40) | + (static_cast(buf[3]) << 32) | + (static_cast(buf[4]) << 24) | + (static_cast(buf[5]) << 16) | + (static_cast(buf[6]) << 8) | (static_cast(buf[7])); } } // namespace media diff --git a/media/base/network_util.h b/media/base/network_util.h index 2633d988f2..d3bea6e5ea 100644 --- a/media/base/network_util.h +++ b/media/base/network_util.h @@ -11,9 +11,9 @@ namespace edash_packager { namespace media { -uint32 ntohlFromBuffer(const unsigned char * buf); -uint16 ntohsFromBuffer(const unsigned char * buf); -uint64 ntohllFromBuffer(const unsigned char * buf); +uint32_t ntohlFromBuffer(const unsigned char* buf); +uint16_t ntohsFromBuffer(const unsigned char* buf); +uint64_t ntohllFromBuffer(const unsigned char* buf); } // namespace media } // namespace edash_packager diff --git a/media/base/offset_byte_queue.cc b/media/base/offset_byte_queue.cc index 2f6e7a810c..cf2d93cbe0 100644 --- a/media/base/offset_byte_queue.cc +++ b/media/base/offset_byte_queue.cc @@ -20,13 +20,13 @@ void OffsetByteQueue::Reset() { head_ = 0; } -void OffsetByteQueue::Push(const uint8* buf, int size) { +void OffsetByteQueue::Push(const uint8_t* buf, int size) { queue_.Push(buf, size); Sync(); DVLOG(4) << "Buffer pushed. head=" << head() << " tail=" << tail(); } -void OffsetByteQueue::Peek(const uint8** buf, int* size) { +void OffsetByteQueue::Peek(const uint8_t** buf, int* size) { *buf = size_ > 0 ? buf_ : NULL; *size = size_; } @@ -37,7 +37,7 @@ void OffsetByteQueue::Pop(int count) { Sync(); } -void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) { +void OffsetByteQueue::PeekAt(int64_t offset, const uint8_t** buf, int* size) { DCHECK(offset >= head()); if (offset < head() || offset >= tail()) { *buf = NULL; @@ -48,7 +48,7 @@ void OffsetByteQueue::PeekAt(int64 offset, const uint8** buf, int* size) { *size = tail() - offset; } -bool OffsetByteQueue::Trim(int64 max_offset) { +bool OffsetByteQueue::Trim(int64_t max_offset) { if (max_offset < head_) return true; if (max_offset > tail()) { Pop(size_); diff --git a/media/base/offset_byte_queue.h b/media/base/offset_byte_queue.h index 5060bfaf00..b4140e0d14 100644 --- a/media/base/offset_byte_queue.h +++ b/media/base/offset_byte_queue.h @@ -23,8 +23,8 @@ class OffsetByteQueue { /// @name These work like their underlying ByteQueue counterparts. /// @{ void Reset(); - void Push(const uint8* buf, int size); - void Peek(const uint8** buf, int* size); + void Push(const uint8_t* buf, int size); + void Peek(const uint8_t** buf, int* size); void Pop(int count); /// @} @@ -34,7 +34,7 @@ class OffsetByteQueue { /// It is an error if the offset is before the current head. It's not an error /// if the current offset is beyond tail(), but you will of course get back /// a null @a buf and a @a size of zero. - void PeekAt(int64 offset, const uint8** buf, int* size); + void PeekAt(int64_t offset, const uint8_t** buf, int* size); /// Mark the bytes up to (but not including) @a max_offset as ready for /// deletion. This is relatively inexpensive, but will not necessarily reduce @@ -45,22 +45,22 @@ class OffsetByteQueue { /// head. /// @return false if @a max_offset > tail() (although all bytes currently /// buffered are still cleared). - bool Trim(int64 max_offset); + bool Trim(int64_t max_offset); /// @return The head position, in terms of the file's absolute offset. - int64 head() { return head_; } + int64_t head() { return head_; } /// @return The tail position (exclusive), in terms of the file's absolute /// offset. - int64 tail() { return head_ + size_; } + int64_t tail() { return head_ + size_; } private: // Synchronize |buf_| and |size_| with |queue_|. void Sync(); ByteQueue queue_; - const uint8* buf_; + const uint8_t* buf_; int size_; - int64 head_; + int64_t head_; DISALLOW_COPY_AND_ASSIGN(OffsetByteQueue); }; diff --git a/media/base/offset_byte_queue_unittest.cc b/media/base/offset_byte_queue_unittest.cc index 7070c68297..7f1a302852 100644 --- a/media/base/offset_byte_queue_unittest.cc +++ b/media/base/offset_byte_queue_unittest.cc @@ -15,7 +15,7 @@ namespace media { class OffsetByteQueueTest : public testing::Test { public: virtual void SetUp() OVERRIDE { - uint8 buf[256]; + uint8_t buf[256]; for (int i = 0; i < 256; i++) { buf[i] = i; } @@ -36,7 +36,7 @@ TEST_F(OffsetByteQueueTest, SetUp) { EXPECT_EQ(384, queue_->head()); EXPECT_EQ(512, queue_->tail()); - const uint8* buf; + const uint8_t* buf; int size; queue_->Peek(&buf, &size); @@ -46,7 +46,7 @@ TEST_F(OffsetByteQueueTest, SetUp) { } TEST_F(OffsetByteQueueTest, PeekAt) { - const uint8* buf; + const uint8_t* buf; int size; queue_->PeekAt(400, &buf, &size); @@ -68,7 +68,7 @@ TEST_F(OffsetByteQueueTest, Trim) { EXPECT_EQ(400, queue_->head()); EXPECT_EQ(512, queue_->tail()); - const uint8* buf; + const uint8_t* buf; int size; queue_->PeekAt(400, &buf, &size); EXPECT_EQ(queue_->tail() - 400, size); diff --git a/media/base/producer_consumer_queue.h b/media/base/producer_consumer_queue.h index 72cfb17473..4102d6cc0f 100644 --- a/media/base/producer_consumer_queue.h +++ b/media/base/producer_consumer_queue.h @@ -19,7 +19,7 @@ namespace edash_packager { namespace media { static const size_t kUnlimitedCapacity = 0u; -static const int64 kInfiniteTimeout = -1; +static const int64_t kInfiniteTimeout = -1; /// A thread safe producer consumer queue implementation. It allows the standard /// push and pop operations. It also maintains a monotonically-increasing @@ -48,7 +48,7 @@ class ProducerConsumerQueue { /// return immediately. A negative value means waiting indefinitely. /// @return OK if the element was pushed successfully, STOPPED if Stop has /// has been called, TIME_OUT if times out. - Status Push(const T& element, int64 timeout_ms); + Status Push(const T& element, int64_t timeout_ms); /// Pop an element from the front of the queue. If the queue is empty, block /// for an element to be available to be consumed or time out or stopped. @@ -57,7 +57,7 @@ class ProducerConsumerQueue { /// return immediately. A negative value means waiting indefinitely. /// @return STOPPED if Stop has been called and the queue is completely empty, /// TIME_OUT if times out, OK otherwise. - Status Pop(T* element, int64 timeout_ms); + Status Pop(T* element, int64_t timeout_ms); /// Peek at the element at the specified position from the queue. If the /// element is not available yet, block until it to be available or time out @@ -71,7 +71,7 @@ class ProducerConsumerQueue { /// @return STOPPED if Stop has been called and @a pos is out of range, /// INVALID_ARGUMENT if the pos < Head(), TIME_OUT if times out, /// OK otherwise. - Status Peek(size_t pos, T* element, int64 timeout_ms); + Status Peek(size_t pos, T* element, int64_t timeout_ms); /// Terminate Pop and Peek requests once the queue drains entirely. /// Also terminate all waiting and future Push requests immediately. @@ -158,7 +158,7 @@ template ProducerConsumerQueue::~ProducerConsumerQueue() {} template -Status ProducerConsumerQueue::Push(const T& element, int64 timeout_ms) { +Status ProducerConsumerQueue::Push(const T& element, int64_t timeout_ms) { base::AutoLock l(lock_); bool woken = false; @@ -207,7 +207,7 @@ Status ProducerConsumerQueue::Push(const T& element, int64 timeout_ms) { } template -Status ProducerConsumerQueue::Pop(T* element, int64 timeout_ms) { +Status ProducerConsumerQueue::Pop(T* element, int64_t timeout_ms) { base::AutoLock l(lock_); bool woken = false; @@ -251,7 +251,7 @@ Status ProducerConsumerQueue::Pop(T* element, int64 timeout_ms) { template Status ProducerConsumerQueue::Peek(size_t pos, T* element, - int64 timeout_ms) { + int64_t timeout_ms) { base::AutoLock l(lock_); if (pos < head_pos_) { return Status( diff --git a/media/base/producer_consumer_queue_unittest.cc b/media/base/producer_consumer_queue_unittest.cc index 0646c2137c..2b89a27d4a 100644 --- a/media/base/producer_consumer_queue_unittest.cc +++ b/media/base/producer_consumer_queue_unittest.cc @@ -14,12 +14,12 @@ namespace { const size_t kCapacity = 10u; -const int64 kTimeout = 100; // 0.1s. +const int64_t kTimeout = 100; // 0.1s. // Check that the |delta| is approximately |time_in_milliseconds|. -bool CheckTimeApproxEqual(int64 time_in_milliseconds, +bool CheckTimeApproxEqual(int64_t time_in_milliseconds, const base::TimeDelta& delta) { - const int64 kOverhead = 10; // 0.01s. + const int64_t kOverhead = 10; // 0.01s. return delta.InMilliseconds() >= time_in_milliseconds && delta.InMilliseconds() <= time_in_milliseconds + kOverhead; } diff --git a/media/base/request_signer.cc b/media/base/request_signer.cc index 318e6195a7..757ed79fec 100644 --- a/media/base/request_signer.cc +++ b/media/base/request_signer.cc @@ -28,12 +28,12 @@ AesRequestSigner::~AesRequestSigner() {} AesRequestSigner* AesRequestSigner::CreateSigner(const std::string& signer_name, const std::string& aes_key_hex, const std::string& iv_hex) { - std::vector aes_key; + std::vector aes_key; if (!base::HexStringToBytes(aes_key_hex, &aes_key)) { LOG(ERROR) << "Failed to convert hex string to bytes: " << aes_key_hex; return NULL; } - std::vector iv; + std::vector iv; if (!base::HexStringToBytes(iv_hex, &iv)) { LOG(ERROR) << "Failed to convert hex string to bytes: " << iv_hex; return NULL; diff --git a/media/base/rsa_key.cc b/media/base/rsa_key.cc index c824b05d5d..bb2fb13ccf 100644 --- a/media/base/rsa_key.cc +++ b/media/base/rsa_key.cc @@ -113,8 +113,8 @@ bool RsaPrivateKey::Decrypt(const std::string& encrypted_message, decrypted_message->resize(rsa_size); int decrypted_size = RSA_private_decrypt( rsa_size, - reinterpret_cast(encrypted_message.data()), - reinterpret_cast(string_as_array(decrypted_message)), + reinterpret_cast(encrypted_message.data()), + reinterpret_cast(string_as_array(decrypted_message)), rsa_key_, RSA_PKCS1_OAEP_PADDING); @@ -139,13 +139,13 @@ bool RsaPrivateKey::GenerateSignature(const std::string& message, // Add PSS padding. size_t rsa_size = RSA_size(rsa_key_); - std::vector padded_digest(rsa_size); + std::vector padded_digest(rsa_size); if (!RSA_padding_add_PKCS1_PSS( - rsa_key_, - &padded_digest[0], - reinterpret_cast(string_as_array(&message_digest)), - EVP_sha1(), - kPssSaltLength)) { + rsa_key_, + &padded_digest[0], + reinterpret_cast(string_as_array(&message_digest)), + EVP_sha1(), + kPssSaltLength)) { LOG(ERROR) << "RSA padding failure: " << ERR_error_string(ERR_get_error(), NULL); return false; @@ -153,12 +153,12 @@ bool RsaPrivateKey::GenerateSignature(const std::string& message, // Encrypt PSS padded digest. signature->resize(rsa_size); - int signature_size = - RSA_private_encrypt(padded_digest.size(), - &padded_digest[0], - reinterpret_cast(string_as_array(signature)), - rsa_key_, - RSA_NO_PADDING); + int signature_size = RSA_private_encrypt( + padded_digest.size(), + &padded_digest[0], + reinterpret_cast(string_as_array(signature)), + rsa_key_, + RSA_NO_PADDING); if (signature_size != static_cast(rsa_size)) { LOG(ERROR) << "RSA private encrypt failure: " << ERR_error_string( @@ -193,8 +193,8 @@ bool RsaPublicKey::Encrypt(const std::string& clear_message, encrypted_message->resize(rsa_size); int encrypted_size = RSA_public_encrypt( clear_message.size(), - reinterpret_cast(clear_message.data()), - reinterpret_cast(string_as_array(encrypted_message)), + reinterpret_cast(clear_message.data()), + reinterpret_cast(string_as_array(encrypted_message)), rsa_key_, RSA_PKCS1_OAEP_PADDING); @@ -221,10 +221,10 @@ bool RsaPublicKey::VerifySignature(const std::string& message, } // Decrypt the signature. - std::vector padded_digest(signature.size()); + std::vector padded_digest(signature.size()); int decrypted_size = RSA_public_decrypt(signature.size(), - reinterpret_cast(signature.data()), + reinterpret_cast(signature.data()), &padded_digest[0], rsa_key_, RSA_NO_PADDING); @@ -240,7 +240,7 @@ bool RsaPublicKey::VerifySignature(const std::string& message, // Verify PSS padding. return RSA_verify_PKCS1_PSS( rsa_key_, - reinterpret_cast(message_digest.data()), + reinterpret_cast(message_digest.data()), EVP_sha1(), &padded_digest[0], kPssSaltLength) != 0; diff --git a/media/base/rsa_test_data.cc b/media/base/rsa_test_data.cc index 80ab63128d..318675de9a 100644 --- a/media/base/rsa_test_data.cc +++ b/media/base/rsa_test_data.cc @@ -7,7 +7,7 @@ #include "media/base/rsa_test_data.h" namespace { -const uint8 kTestRsaPrivateKey_3072[] = { +const uint8_t kTestRsaPrivateKey_3072[] = { 0x30, 0x82, 0x06, 0xe3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x81, 0x00, 0xa5, 0x62, 0x07, 0xdf, 0xc8, 0x84, 0x74, 0xe1, 0x2a, 0xb7, 0xbb, 0xc0, 0x78, 0x76, 0xbe, 0x13, 0x3b, 0xe6, 0x2c, 0x09, 0x9d, 0x35, 0x3f, 0xf3, @@ -157,7 +157,7 @@ const uint8 kTestRsaPrivateKey_3072[] = { 0x0f, 0xed, 0x55, 0xb5, 0x49, 0xd6, 0x94, 0x59, 0xee, 0xcc, 0x1b, 0x5a, 0x00, 0x3d, 0xcd}; -const uint8 kTestRsaPublicKey_3072[] = { +const uint8_t kTestRsaPublicKey_3072[] = { 0x30, 0x82, 0x01, 0x8a, 0x02, 0x82, 0x01, 0x81, 0x00, 0xa5, 0x62, 0x07, 0xdf, 0xc8, 0x84, 0x74, 0xe1, 0x2a, 0xb7, 0xbb, 0xc0, 0x78, 0x76, 0xbe, 0x13, 0x3b, 0xe6, 0x2c, 0x09, 0x9d, 0x35, 0x3f, 0xf3, 0x0f, 0xe9, 0x61, @@ -193,7 +193,7 @@ const uint8 kTestRsaPublicKey_3072[] = { 0x2e, 0x23, 0x23, 0x60, 0x0b, 0x83, 0x9c, 0xc2, 0x87, 0x02, 0x03, 0x01, 0x00, 0x01}; -const uint8 kTestRsaPrivateKey_2048[] = { +const uint8_t kTestRsaPrivateKey_2048[] = { 0x30, 0x82, 0x04, 0xa2, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xa7, 0x00, 0x36, 0x60, 0x65, 0xdc, 0xbd, 0x54, 0x5a, 0x2a, 0x40, 0xb4, 0xe1, 0x15, 0x94, 0x58, 0x11, 0x4f, 0x94, 0x58, 0xdd, 0xde, 0xa7, 0x1f, @@ -295,7 +295,7 @@ const uint8 kTestRsaPrivateKey_2048[] = { 0xf7, 0xc1, 0x22, 0x36, 0xd9, 0x18, 0x56, 0xfe, 0x39, 0x28, 0x33, 0xe0, 0xdb, 0x03}; -const uint8 kTestRsaPublicKey_2048[] = { +const uint8_t kTestRsaPublicKey_2048[] = { 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xa7, 0x00, 0x36, 0x60, 0x65, 0xdc, 0xbd, 0x54, 0x5a, 0x2a, 0x40, 0xb4, 0xe1, 0x15, 0x94, 0x58, 0x11, 0x4f, 0x94, 0x58, 0xdd, 0xde, 0xa7, 0x1f, 0x3c, 0x2c, 0xe0, @@ -324,7 +324,7 @@ const char kTestMessage[] = "A fool thinks himself to be wise, but a" " wise man knows himself to be a fool."; -const uint8 kTestEncryptedMessage_3072[] = { +const uint8_t kTestEncryptedMessage_3072[] = { 0x4e, 0x85, 0x01, 0x65, 0x1c, 0xb2, 0xe6, 0x39, 0xb9, 0x6e, 0x93, 0x6a, 0x18, 0xa4, 0xa6, 0xb2, 0x86, 0x3d, 0x8e, 0x23, 0x34, 0x68, 0xa9, 0x74, 0x78, 0x0e, 0x6f, 0x94, 0xb3, 0x4f, 0x14, 0xc0, 0x88, 0x0a, 0xec, 0x64, @@ -359,7 +359,7 @@ const uint8 kTestEncryptedMessage_3072[] = { 0x34, 0xd5, 0x1a, 0x62, 0x9c, 0xb2, 0x9d, 0x8b, 0xe9, 0x49, 0x48, 0x1d}; // Self-generated test vector. Used to verify algorithm stability. -const uint8 kTestEncryptedMessage_2048[] = { +const uint8_t kTestEncryptedMessage_2048[] = { 0x73, 0x37, 0xa5, 0xe3, 0x73, 0xbb, 0xa7, 0xbf, 0xb1, 0xfc, 0x98, 0x6c, 0xd2, 0x20, 0xe2, 0x79, 0xea, 0x90, 0x41, 0xcf, 0x2b, 0xe0, 0x22, 0x0f, 0xe3, 0x6e, 0x2e, 0x61, 0x7d, 0xe5, 0xc7, 0x5a, 0x46, 0x87, 0xed, 0x35, @@ -383,7 +383,7 @@ const uint8 kTestEncryptedMessage_2048[] = { 0xee, 0x0e, 0x96, 0xcf, 0xcf, 0xee, 0xfa, 0xf9, 0xcc, 0x73, 0xd5, 0x7c, 0xf3, 0xbe, 0x9a, 0xb3}; -const uint8 kTestSignature_3072[] = { +const uint8_t kTestSignature_3072[] = { 0x80, 0xfd, 0x25, 0x0d, 0x3a, 0xac, 0x37, 0x58, 0x66, 0x62, 0x18, 0xb0, 0x48, 0x0b, 0x24, 0x27, 0x63, 0x54, 0x49, 0x44, 0x9b, 0x80, 0xc3, 0xec, 0xb2, 0xec, 0xad, 0xde, 0x1a, 0x19, 0x04, 0xed, 0xe3, 0xbb, 0x51, 0xc4, @@ -417,7 +417,7 @@ const uint8 kTestSignature_3072[] = { 0xdd, 0xa1, 0xd9, 0xe7, 0x03, 0x30, 0x44, 0x3b, 0xbf, 0x51, 0xee, 0x74, 0xf3, 0xd6, 0xfe, 0xf4, 0x36, 0x28, 0xf8, 0x35, 0x1a, 0xcd, 0x88, 0xec}; -const uint8 kTestSignature_2048[] = { +const uint8_t kTestSignature_2048[] = { 0x6b, 0x8e, 0x01, 0x11, 0xc3, 0x8e, 0x1a, 0xf7, 0xd1, 0x91, 0x72, 0xe7, 0xf2, 0x3e, 0x6f, 0xfd, 0x34, 0xfe, 0x11, 0x8f, 0x03, 0xc0, 0x01, 0xa5, 0x87, 0xbf, 0xab, 0x92, 0x46, 0x4a, 0x33, 0xf6, 0xb1, 0x37, 0xdb, 0x5a, diff --git a/media/base/stream_info.cc b/media/base/stream_info.cc index 877d00c25f..64493d1b67 100644 --- a/media/base/stream_info.cc +++ b/media/base/stream_info.cc @@ -16,11 +16,11 @@ namespace media { StreamInfo::StreamInfo(StreamType stream_type, int track_id, - uint32 time_scale, - uint64 duration, + uint32_t time_scale, + uint64_t duration, const std::string& codec_string, const std::string& language, - const uint8* extra_data, + const uint8_t* extra_data, size_t extra_data_size, bool is_encrypted) : stream_type_(stream_type), @@ -30,7 +30,6 @@ StreamInfo::StreamInfo(StreamType stream_type, codec_string_(codec_string), language_(language), is_encrypted_(is_encrypted) { - if (extra_data_size > 0) { extra_data_.assign(extra_data, extra_data + extra_data_size); } diff --git a/media/base/stream_info.h b/media/base/stream_info.h index 775b5b16c8..9e1d45748d 100644 --- a/media/base/stream_info.h +++ b/media/base/stream_info.h @@ -26,11 +26,11 @@ class StreamInfo : public base::RefCountedThreadSafe { public: StreamInfo(StreamType stream_type, int track_id, - uint32 time_scale, - uint64 duration, + uint32_t time_scale, + uint64_t duration, const std::string& codec_string, const std::string& language, - const uint8* extra_data, + const uint8_t* extra_data, size_t extra_data_size, bool is_encrypted); @@ -42,19 +42,19 @@ class StreamInfo : public base::RefCountedThreadSafe { virtual std::string ToString() const; StreamType stream_type() const { return stream_type_; } - uint32 track_id() const { return track_id_; } - uint32 time_scale() const { return time_scale_; } - uint64 duration() const { return duration_; } + uint32_t track_id() const { return track_id_; } + uint32_t time_scale() const { return time_scale_; } + uint64_t duration() const { return duration_; } const std::string& codec_string() const { return codec_string_; } const std::string& language() const { return language_; } bool is_encrypted() const { return is_encrypted_; } - const std::vector& extra_data() const { return extra_data_; } + const std::vector& extra_data() const { return extra_data_; } void set_duration(int duration) { duration_ = duration; } - void set_extra_data(const std::vector& data) { extra_data_ = data; } + void set_extra_data(const std::vector& data) { extra_data_ = data; } void set_codec_string(const std::string& codec_string) { codec_string_ = codec_string; @@ -67,11 +67,11 @@ class StreamInfo : public base::RefCountedThreadSafe { private: // Whether the stream is Audio or Video. StreamType stream_type_; - uint32 track_id_; + uint32_t track_id_; // The actual time is calculated as time / time_scale_ in seconds. - uint32 time_scale_; + uint32_t time_scale_; // Duration base on time_scale. - uint64 duration_; + uint64_t duration_; std::string codec_string_; std::string language_; // Whether the stream is potentially encrypted. @@ -80,7 +80,7 @@ class StreamInfo : public base::RefCountedThreadSafe { bool is_encrypted_; // Optional byte data required for some audio/video decoders such as Vorbis // codebooks. - std::vector extra_data_; + std::vector extra_data_; // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler // generated copy constructor and assignment operator. Since the extra data is diff --git a/media/base/timestamp.h b/media/base/timestamp.h index 94241c640d..b8aa6a4a3f 100644 --- a/media/base/timestamp.h +++ b/media/base/timestamp.h @@ -13,8 +13,8 @@ namespace edash_packager { namespace media { -const int64 kNoTimestamp = kint64min; -const int64 kInfiniteDuration = kint64max; +const int64_t kNoTimestamp = kint64min; +const int64_t kInfiniteDuration = kint64max; } // namespace media } // namespace edash_packager diff --git a/media/base/video_stream_info.cc b/media/base/video_stream_info.cc index 2456f05d82..94661fa992 100644 --- a/media/base/video_stream_info.cc +++ b/media/base/video_stream_info.cc @@ -39,15 +39,15 @@ std::string VideoCodecToString(VideoCodec video_codec) { } // namespace VideoStreamInfo::VideoStreamInfo(int track_id, - uint32 time_scale, - uint64 duration, + uint32_t time_scale, + uint64_t duration, VideoCodec codec, const std::string& codec_string, const std::string& language, - uint16 width, - uint16 height, - uint8 nalu_length_size, - const uint8* extra_data, + uint16_t width, + uint16_t height, + uint8_t nalu_length_size, + const uint8_t* extra_data, size_t extra_data_size, bool is_encrypted) : StreamInfo(kStreamVideo, @@ -62,7 +62,8 @@ VideoStreamInfo::VideoStreamInfo(int track_id, codec_(codec), width_(width), height_(height), - nalu_length_size_(nalu_length_size) {} + nalu_length_size_(nalu_length_size) { +} VideoStreamInfo::~VideoStreamInfo() {} @@ -84,16 +85,16 @@ std::string VideoStreamInfo::ToString() const { } std::string VideoStreamInfo::GetCodecString(VideoCodec codec, - uint8 profile, - uint8 compatible_profiles, - uint8 level) { + uint8_t profile, + uint8_t compatible_profiles, + uint8_t level) { switch (codec) { case kCodecVP8: return "vp8"; case kCodecVP9: return "vp9"; case kCodecH264: { - const uint8 bytes[] = {profile, compatible_profiles, level}; + const uint8_t bytes[] = {profile, compatible_profiles, level}; return "avc1." + StringToLowerASCII(base::HexEncode(bytes, arraysize(bytes))); } diff --git a/media/base/video_stream_info.h b/media/base/video_stream_info.h index 83ff92dc09..e461b0fb67 100644 --- a/media/base/video_stream_info.h +++ b/media/base/video_stream_info.h @@ -29,15 +29,15 @@ class VideoStreamInfo : public StreamInfo { public: /// Construct an initialized video stream info object. VideoStreamInfo(int track_id, - uint32 time_scale, - uint64 duration, + uint32_t time_scale, + uint64_t duration, VideoCodec codec, const std::string& codec_string, const std::string& language, - uint16 width, - uint16 height, - uint8 nalu_length_size, - const uint8* extra_data, + uint16_t width, + uint16_t height, + uint8_t nalu_length_size, + const uint8_t* extra_data, size_t extra_data_size, bool is_encrypted); @@ -48,28 +48,28 @@ class VideoStreamInfo : public StreamInfo { /// @} VideoCodec codec() const { return codec_; } - uint16 width() const { return width_; } - uint16 height() const { return height_; } - uint8 nalu_length_size() const { return nalu_length_size_; } + uint16_t width() const { return width_; } + uint16_t height() const { return height_; } + uint8_t nalu_length_size() const { return nalu_length_size_; } /// @param profile,compatible_profiles,level are only used by H.264 codec. /// @return The codec string. static std::string GetCodecString(VideoCodec codec, - uint8 profile, - uint8 compatible_profiles, - uint8 level); + uint8_t profile, + uint8_t compatible_profiles, + uint8_t level); private: virtual ~VideoStreamInfo(); VideoCodec codec_; - uint16 width_; - uint16 height_; + uint16_t width_; + uint16_t height_; // Specifies the normalized size of the NAL unit length field. Can be 1, 2 or // 4 bytes, or 0 if the size if unknown or the stream is not a AVC stream // (H.264). - uint8 nalu_length_size_; + uint8_t nalu_length_size_; // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler // generated copy constructor and assignment operator. Since the extra data is diff --git a/media/base/widevine_key_source.cc b/media/base/widevine_key_source.cc index 28e1454f65..d17817215b 100644 --- a/media/base/widevine_key_source.cc +++ b/media/base/widevine_key_source.cc @@ -46,7 +46,7 @@ const int kGetKeyTimeoutInSeconds = 5 * 60; // 5 minutes. const int kHttpTimeoutInSeconds = 60; // 1 minute. bool Base64StringToBytes(const std::string& base64_string, - std::vector* bytes) { + std::vector* bytes) { DCHECK(bytes); std::string str; if (!base::Base64Decode(base64_string, &str)) @@ -55,7 +55,7 @@ bool Base64StringToBytes(const std::string& base64_string, return true; } -void BytesToBase64String(const std::vector& bytes, +void BytesToBase64String(const std::vector& bytes, std::string* base64_string) { DCHECK(base64_string); base::Base64Encode(base::StringPiece(reinterpret_cast @@ -64,7 +64,7 @@ void BytesToBase64String(const std::vector& bytes, } bool GetKeyFromTrack(const base::DictionaryValue& track_dict, - std::vector* key) { + std::vector* key) { DCHECK(key); std::string key_base64_string; RCHECK(track_dict.GetString("key", &key_base64_string)); @@ -74,7 +74,7 @@ bool GetKeyFromTrack(const base::DictionaryValue& track_dict, } bool GetKeyIdFromTrack(const base::DictionaryValue& track_dict, - std::vector* key_id) { + std::vector* key_id) { DCHECK(key_id); std::string key_id_base64_string; RCHECK(track_dict.GetString("key_id", &key_id_base64_string)); @@ -84,7 +84,7 @@ bool GetKeyIdFromTrack(const base::DictionaryValue& track_dict, } bool GetPsshDataFromTrack(const base::DictionaryValue& track_dict, - std::vector* pssh_data) { + std::vector* pssh_data) { DCHECK(pssh_data); const base::ListValue* pssh_list; @@ -164,7 +164,7 @@ WidevineKeySource::~WidevineKeySource() { } } -Status WidevineKeySource::FetchKeys(const std::vector& content_id, +Status WidevineKeySource::FetchKeys(const std::vector& content_id, const std::string& policy) { base::AutoLock scoped_lock(lock_); request_dict_.Clear(); @@ -175,8 +175,7 @@ Status WidevineKeySource::FetchKeys(const std::vector& content_id, return FetchKeysCommon(false); } -Status WidevineKeySource::FetchKeys( - const std::vector& pssh_data) { +Status WidevineKeySource::FetchKeys(const std::vector& pssh_data) { base::AutoLock scoped_lock(lock_); request_dict_.Clear(); std::string pssh_data_base64_string; @@ -185,7 +184,7 @@ Status WidevineKeySource::FetchKeys( return FetchKeysCommon(false); } -Status WidevineKeySource::FetchKeys(uint32 asset_id) { +Status WidevineKeySource::FetchKeys(uint32_t asset_id) { base::AutoLock scoped_lock(lock_); request_dict_.Clear(); request_dict_.SetInteger("asset_id", asset_id); @@ -214,7 +213,7 @@ Status WidevineKeySource::GetKey(TrackType track_type, return Status::OK; } -Status WidevineKeySource::GetKey(const std::vector& key_id, +Status WidevineKeySource::GetKey(const std::vector& key_id, EncryptionKey* key) { DCHECK(key); for (std::map::iterator iter = @@ -230,10 +229,9 @@ Status WidevineKeySource::GetKey(const std::vector& key_id, "Cannot find key with specified key ID"); } -Status WidevineKeySource::GetCryptoPeriodKey( - uint32 crypto_period_index, - TrackType track_type, - EncryptionKey* key) { +Status WidevineKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index, + TrackType track_type, + EncryptionKey* key) { DCHECK(key_production_thread_.HasBeenStarted()); // TODO(kqyang): This is not elegant. Consider refactoring later. { @@ -257,10 +255,9 @@ void WidevineKeySource::set_http_fetcher( http_fetcher_ = http_fetcher.Pass(); } -Status WidevineKeySource::GetKeyInternal( - uint32 crypto_period_index, - TrackType track_type, - EncryptionKey* key) { +Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index, + TrackType track_type, + EncryptionKey* key) { DCHECK(key_pool_); DCHECK(key); DCHECK_LE(track_type, NUM_VALID_TRACK_TYPES); @@ -307,7 +304,7 @@ void WidevineKeySource::FetchKeysTask() { } Status WidevineKeySource::FetchKeysInternal(bool enable_key_rotation, - uint32 first_crypto_period_index, + uint32_t first_crypto_period_index, bool widevine_classic) { std::string request; FillRequest(enable_key_rotation, @@ -321,7 +318,7 @@ Status WidevineKeySource::FetchKeysInternal(bool enable_key_rotation, VLOG(1) << "Message: " << message; std::string raw_response; - int64 sleep_duration = kFirstRetryDelayMilliseconds; + int64_t sleep_duration = kFirstRetryDelayMilliseconds; // Perform client side retries if seeing server transient error to workaround // server limitation. @@ -364,7 +361,7 @@ Status WidevineKeySource::FetchKeysInternal(bool enable_key_rotation, } void WidevineKeySource::FillRequest(bool enable_key_rotation, - uint32 first_crypto_period_index, + uint32_t first_crypto_period_index, std::string* request) { DCHECK(request); DCHECK(!request_dict_.empty()); @@ -516,7 +513,7 @@ bool WidevineKeySource::ExtractEncryptionKey( if (!GetKeyIdFromTrack(*track_dict, &encryption_key->key_id)) return false; - std::vector pssh_data; + std::vector pssh_data; if (!GetPsshDataFromTrack(*track_dict, &pssh_data)) return false; encryption_key->pssh = PsshBoxFromPsshData(pssh_data); diff --git a/media/base/widevine_key_source.h b/media/base/widevine_key_source.h index 0699c7585a..acf6228d81 100644 --- a/media/base/widevine_key_source.h +++ b/media/base/widevine_key_source.h @@ -34,15 +34,15 @@ class WidevineKeySource : public KeySource { /// @name KeySource implementation overrides. /// @{ - virtual Status FetchKeys(const std::vector& content_id, + virtual Status FetchKeys(const std::vector& content_id, const std::string& policy) OVERRIDE; - virtual Status FetchKeys(const std::vector& pssh_data) OVERRIDE; - Status FetchKeys(uint32 asset_id); + virtual Status FetchKeys(const std::vector& pssh_data) OVERRIDE; + Status FetchKeys(uint32_t asset_id); virtual Status GetKey(TrackType track_type, EncryptionKey* key) OVERRIDE; - virtual Status GetKey(const std::vector& key_id, + virtual Status GetKey(const std::vector& key_id, EncryptionKey* key) OVERRIDE; - virtual Status GetCryptoPeriodKey(uint32 crypto_period_index, + virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey* key) OVERRIDE; /// @} @@ -58,7 +58,7 @@ class WidevineKeySource : public KeySource { EncryptionKeyQueue; // Internal routine for getting keys. - Status GetKeyInternal(uint32 crypto_period_index, + Status GetKeyInternal(uint32_t crypto_period_index, TrackType track_type, EncryptionKey* key); @@ -70,13 +70,13 @@ class WidevineKeySource : public KeySource { // Fetch keys from server. Status FetchKeysInternal(bool enable_key_rotation, - uint32 first_crypto_period_index, + uint32_t first_crypto_period_index, bool widevine_classic); // Fill |request| with necessary fields for Widevine encryption request. // |request| should not be NULL. void FillRequest(bool enable_key_rotation, - uint32 first_crypto_period_index, + uint32_t first_crypto_period_index, std::string* request); // Sign and properly format |request|. // |signed_request| should not be NULL. Return OK on success. @@ -103,11 +103,11 @@ class WidevineKeySource : public KeySource { scoped_ptr signer_; base::DictionaryValue request_dict_; - const uint32 crypto_period_count_; + const uint32_t crypto_period_count_; base::Lock lock_; bool key_production_started_; base::WaitableEvent start_key_production_; - uint32 first_crypto_period_index_; + uint32_t first_crypto_period_index_; ClosureThread key_production_thread_; scoped_ptr key_pool_; EncryptionKeyMap encryption_key_map_; // For non key rotation request. diff --git a/media/base/widevine_key_source_unittest.cc b/media/base/widevine_key_source_unittest.cc index 8d59e41b3d..a410ab0a8d 100644 --- a/media/base/widevine_key_source_unittest.cc +++ b/media/base/widevine_key_source_unittest.cc @@ -44,7 +44,7 @@ const char kClassicTrackFormat[] = "{\"type\":\"%s\",\"key\":\"%s\"}"; const char kLicenseResponseFormat[] = "{\"status\":\"%s\",\"tracks\":[%s]}"; const char kHttpResponseFormat[] = "{\"response\":\"%s\"}"; const char kRequestPsshData[] = "PSSH data"; -const uint32 kClassicAssetId = 1234; +const uint32_t kClassicAssetId = 1234; std::string Base64Encode(const std::string& input) { std::string output; @@ -52,7 +52,7 @@ std::string Base64Encode(const std::string& input) { return output; } -std::string ToString(const std::vector v) { +std::string ToString(const std::vector v) { return std::string(v.begin(), v.end()); } @@ -150,9 +150,9 @@ class WidevineKeySourceTest : public ::testing::Test { mock_http_fetcher_(new MockHttpFetcher()) {} virtual void SetUp() OVERRIDE { - content_id_.assign(reinterpret_cast(kContentId), - reinterpret_cast(kContentId) + - strlen(kContentId)); + content_id_.assign( + reinterpret_cast(kContentId), + reinterpret_cast(kContentId) + strlen(kContentId)); } protected: @@ -183,7 +183,7 @@ class WidevineKeySourceTest : public ::testing::Test { scoped_ptr mock_request_signer_; scoped_ptr mock_http_fetcher_; scoped_ptr widevine_key_source_; - std::vector content_id_; + std::vector content_id_; private: DISALLOW_COPY_AND_ASSIGN(WidevineKeySourceTest); @@ -274,9 +274,9 @@ TEST_F(WidevineKeySourceTest, LicenseStatusCencWithPsshDataOK) { .WillOnce(DoAll(SetArgPointee<2>(mock_response), Return(Status::OK))); CreateWidevineKeySource(); - std::vector pssh_data( - reinterpret_cast(kRequestPsshData), - reinterpret_cast(kRequestPsshData) + strlen(kContentId)); + std::vector pssh_data( + reinterpret_cast(kRequestPsshData), + reinterpret_cast(kRequestPsshData) + strlen(kContentId)); ASSERT_OK(widevine_key_source_->FetchKeys(pssh_data)); VerifyKeys(false); } @@ -366,16 +366,17 @@ const char kCryptoPeriodTrackFormat[] = "\"%s\",\"pssh\":[{\"drm_type\":\"WIDEVINE\",\"data\":\"\"}], " "\"crypto_period_index\":%u}"; -std::string GetMockKey(const std::string& track_type, uint32 index) { +std::string GetMockKey(const std::string& track_type, uint32_t index) { return "MockKey" + track_type + "@" + base::UintToString(index); } std::string GenerateMockKeyRotationLicenseResponse( - uint32 initial_crypto_period_index, uint32 crypto_period_count) { + uint32_t initial_crypto_period_index, + uint32_t crypto_period_count) { const std::string kTrackTypes[] = {"SD", "HD", "AUDIO"}; std::string tracks; - for (uint32 index = initial_crypto_period_index; - index < initial_crypto_period_index + crypto_period_count; + for (uint32_t index = initial_crypto_period_index; + index < initial_crypto_period_index + crypto_period_count; ++index) { for (size_t i = 0; i < 3; ++i) { if (!tracks.empty()) @@ -393,13 +394,13 @@ std::string GenerateMockKeyRotationLicenseResponse( } // namespace TEST_F(WidevineKeySourceTest, KeyRotationTest) { - const uint32 kFirstCryptoPeriodIndex = 8; - const uint32 kCryptoPeriodCount = 10; + const uint32_t kFirstCryptoPeriodIndex = 8; + const uint32_t kCryptoPeriodCount = 10; // Array of indexes to be checked. - const uint32 kCryptoPeriodIndexes[] = {kFirstCryptoPeriodIndex, 17, 37, - 38, 36, 39}; + const uint32_t kCryptoPeriodIndexes[] = { + kFirstCryptoPeriodIndex, 17, 37, 38, 36, 39}; // Derived from kCryptoPeriodIndexes: ceiling((39 - 8 ) / 10). - const uint32 kCryptoIterations = 4; + const uint32_t kCryptoIterations = 4; // Generate expectations in sequence. InSequence dummy; @@ -412,8 +413,8 @@ TEST_F(WidevineKeySourceTest, KeyRotationTest) { EXPECT_CALL(*mock_http_fetcher_, Post(_, _, _)) .WillOnce(DoAll(SetArgPointee<2>(mock_response), Return(Status::OK))); - for (uint32 i = 0; i < kCryptoIterations; ++i) { - uint32 first_crypto_period_index = + for (uint32_t i = 0; i < kCryptoIterations; ++i) { + uint32_t first_crypto_period_index = kFirstCryptoPeriodIndex - 1 + i * kCryptoPeriodCount; std::string expected_message = base::StringPrintf(kCryptoPeriodRequestMessageFormat, diff --git a/media/event/mpd_notify_muxer_listener.cc b/media/event/mpd_notify_muxer_listener.cc index 6f807a2ff4..4dc8cd8743 100644 --- a/media/event/mpd_notify_muxer_listener.cc +++ b/media/event/mpd_notify_muxer_listener.cc @@ -36,7 +36,7 @@ void MpdNotifyMuxerListener::SetContentProtectionSchemeIdUri( void MpdNotifyMuxerListener::OnMediaStart( const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 time_scale, + uint32_t time_scale, ContainerType container_type, bool is_encrypted) { scoped_ptr media_info(new MediaInfo()); @@ -66,13 +66,13 @@ void MpdNotifyMuxerListener::OnMediaStart( } void MpdNotifyMuxerListener::OnMediaEnd(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size) { + uint64_t file_size) { if (mpd_notifier_->dash_profile() == kLiveProfile) return; DCHECK(media_info_); @@ -89,14 +89,14 @@ void MpdNotifyMuxerListener::OnMediaEnd(bool has_init_range, return; } - uint32 id; // Result unused. + uint32_t id; // Result unused. // TODO(kqyang): Check return result. mpd_notifier_->NotifyNewContainer(*media_info_, &id); } -void MpdNotifyMuxerListener::OnNewSegment(uint64 start_time, - uint64 duration, - uint64 segment_file_size) { +void MpdNotifyMuxerListener::OnNewSegment(uint64_t start_time, + uint64_t duration, + uint64_t segment_file_size) { if (mpd_notifier_->dash_profile() != kLiveProfile) return; // TODO(kqyang): Check return result. mpd_notifier_->NotifyNewSegment( diff --git a/media/event/mpd_notify_muxer_listener.h b/media/event/mpd_notify_muxer_listener.h index 74732c44c5..3a4ea0d4fc 100644 --- a/media/event/mpd_notify_muxer_listener.h +++ b/media/event/mpd_notify_muxer_listener.h @@ -39,27 +39,27 @@ class MpdNotifyMuxerListener : public MuxerListener { /// @{ virtual void OnMediaStart(const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 time_scale, + uint32_t time_scale, ContainerType container_type, bool is_encrypted) OVERRIDE; virtual void OnMediaEnd(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size) OVERRIDE; + uint64_t file_size) OVERRIDE; - virtual void OnNewSegment(uint64 start_time, - uint64 duration, - uint64 segment_file_size) OVERRIDE; + virtual void OnNewSegment(uint64_t start_time, + uint64_t duration, + uint64_t segment_file_size) OVERRIDE; /// @} private: MpdNotifier* const mpd_notifier_; - uint32 notification_id_; + uint32_t notification_id_; scoped_ptr media_info_; std::string scheme_id_uri_; diff --git a/media/event/muxer_listener.h b/media/event/muxer_listener.h index 92f2eee9df..f7da5a6f5c 100644 --- a/media/event/muxer_listener.h +++ b/media/event/muxer_listener.h @@ -39,7 +39,7 @@ class MuxerListener { // specified in |stream_infos|. virtual void OnMediaStart(const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 time_scale, + uint32_t time_scale, ContainerType container_type, bool is_encrypted) = 0; @@ -54,22 +54,23 @@ class MuxerListener { // Media length of |duration_seconds|. // |file_size| of the media in bytes. virtual void OnMediaEnd(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size) = 0; + uint64_t file_size) = 0; // Called when a segment has been muxed and the file has been written. // Note: For video on demand (VOD), this would be for subsegments. // |start_time| and |duration| are relative to time scale specified // OnMediaStart(). // |segment_file_size| in bytes. - virtual void OnNewSegment(uint64 start_time, - uint64 duration, - uint64 segment_file_size) = 0; + virtual void OnNewSegment(uint64_t start_time, + uint64_t duration, + uint64_t segment_file_size) = 0; + protected: MuxerListener() {}; }; diff --git a/media/event/muxer_listener_internal.cc b/media/event/muxer_listener_internal.cc index 0943afad3f..b2475b847a 100644 --- a/media/event/muxer_listener_internal.cc +++ b/media/event/muxer_listener_internal.cc @@ -23,27 +23,27 @@ namespace { // This will return a positive value, given that |file_size| and // |duration_seconds| are positive. -uint32 EstimateRequiredBandwidth(uint64 file_size, float duration_seconds) { - const uint64 file_size_bits = file_size * 8; +uint32_t EstimateRequiredBandwidth(uint64_t file_size, float duration_seconds) { + const uint64_t file_size_bits = file_size * 8; const float bits_per_second = file_size_bits / duration_seconds; // Note that casting |bits_per_second| to an integer might make it 0. Take the // ceiling and make sure that it returns a positive value. - return static_cast(ceil(bits_per_second)); + return static_cast(ceil(bits_per_second)); } -void SetRange(uint64 begin, uint64 end, Range* range) { +void SetRange(uint64_t begin, uint64_t end, Range* range) { DCHECK(range); range->set_begin(begin); range->set_end(end); } void SetMediaInfoRanges(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, MediaInfo* media_info) { if (has_init_range) { SetRange( @@ -87,7 +87,7 @@ void AddVideoInfo(const VideoStreamInfo* video_stream_info, video_info->set_height(video_stream_info->height()); video_info->set_time_scale(video_stream_info->time_scale()); - const std::vector& extra_data = video_stream_info->extra_data(); + const std::vector& extra_data = video_stream_info->extra_data(); if (!extra_data.empty()) { video_info->set_decoder_config(&extra_data[0], extra_data.size()); } @@ -109,7 +109,7 @@ void AddAudioInfo(const AudioStreamInfo* audio_stream_info, audio_info->set_language(language); } - const std::vector& extra_data = audio_stream_info->extra_data(); + const std::vector& extra_data = audio_stream_info->extra_data(); if (!extra_data.empty()) { audio_info->set_decoder_config(&extra_data[0], extra_data.size()); } @@ -152,7 +152,7 @@ void SetMediaInfoMuxerOptions(const MuxerOptions& muxer_options, bool GenerateMediaInfo(const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 reference_time_scale, + uint32_t reference_time_scale, MuxerListener::ContainerType container_type, MediaInfo* media_info) { DCHECK(media_info); @@ -168,13 +168,13 @@ bool GenerateMediaInfo(const MuxerOptions& muxer_options, } bool SetVodInformation(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size, + uint64_t file_size, MediaInfo* media_info) { DCHECK(media_info); if (file_size == 0) { diff --git a/media/event/muxer_listener_internal.h b/media/event/muxer_listener_internal.h index ebed26f862..0f24fe1514 100644 --- a/media/event/muxer_listener_internal.h +++ b/media/event/muxer_listener_internal.h @@ -29,20 +29,20 @@ namespace internal { /// @return true on success, false otherwise. bool GenerateMediaInfo(const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 reference_time_scale_, + uint32_t reference_time_scale_, MuxerListener::ContainerType container_type, MediaInfo* media_info); /// @param[in,out] media_info points to the MediaInfo object to be filled. /// @return true on success, false otherwise. bool SetVodInformation(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size, + uint64_t file_size, MediaInfo* media_info); /// @param container_type specifies container type. A default ContentProtection diff --git a/media/event/vod_media_info_dump_muxer_listener.cc b/media/event/vod_media_info_dump_muxer_listener.cc index 0f92eb84b2..79007868da 100644 --- a/media/event/vod_media_info_dump_muxer_listener.cc +++ b/media/event/vod_media_info_dump_muxer_listener.cc @@ -33,7 +33,7 @@ void VodMediaInfoDumpMuxerListener::SetContentProtectionSchemeIdUri( void VodMediaInfoDumpMuxerListener::OnMediaStart( const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 time_scale, + uint32_t time_scale, ContainerType container_type, bool is_encrypted) { DCHECK(muxer_options.single_segment); @@ -57,13 +57,13 @@ void VodMediaInfoDumpMuxerListener::OnMediaStart( } void VodMediaInfoDumpMuxerListener::OnMediaEnd(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size) { + uint64_t file_size) { DCHECK(media_info_); if (!internal::SetVodInformation(has_init_range, init_range_start, @@ -80,9 +80,9 @@ void VodMediaInfoDumpMuxerListener::OnMediaEnd(bool has_init_range, SerializeMediaInfoToFile(); } -void VodMediaInfoDumpMuxerListener::OnNewSegment(uint64 start_time, - uint64 duration, - uint64 segment_file_size) { +void VodMediaInfoDumpMuxerListener::OnNewSegment(uint64_t start_time, + uint64_t duration, + uint64_t segment_file_size) { NOTIMPLEMENTED(); } diff --git a/media/event/vod_media_info_dump_muxer_listener.h b/media/event/vod_media_info_dump_muxer_listener.h index d29ae5345f..2ce7a83a5e 100644 --- a/media/event/vod_media_info_dump_muxer_listener.h +++ b/media/event/vod_media_info_dump_muxer_listener.h @@ -39,22 +39,22 @@ class VodMediaInfoDumpMuxerListener : public MuxerListener { /// @{ virtual void OnMediaStart(const MuxerOptions& muxer_options, const std::vector& stream_infos, - uint32 time_scale, + uint32_t time_scale, ContainerType container_type, bool is_encrypted) OVERRIDE; virtual void OnMediaEnd(bool has_init_range, - uint64 init_range_start, - uint64 init_range_end, + uint64_t init_range_start, + uint64_t init_range_end, bool has_index_range, - uint64 index_range_start, - uint64 index_range_end, + uint64_t index_range_start, + uint64_t index_range_end, float duration_seconds, - uint64 file_size) OVERRIDE; + uint64_t file_size) OVERRIDE; - virtual void OnNewSegment(uint64 start_time, - uint64 duration, - uint64 segment_file_size) OVERRIDE; + virtual void OnNewSegment(uint64_t start_time, + uint64_t duration, + uint64_t segment_file_size) OVERRIDE; /// @} private: diff --git a/media/event/vod_media_info_dump_muxer_listener_unittest.cc b/media/event/vod_media_info_dump_muxer_listener_unittest.cc index 883e937fcd..1c84039acd 100644 --- a/media/event/vod_media_info_dump_muxer_listener_unittest.cc +++ b/media/event/vod_media_info_dump_muxer_listener_unittest.cc @@ -29,28 +29,28 @@ namespace event { namespace { struct VideoStreamInfoParameters { int track_id; - uint32 time_scale; - uint64 duration; + uint32_t time_scale; + uint64_t duration; VideoCodec codec; std::string codec_string; std::string language; - uint16 width; - uint16 height; - uint8 nalu_length_size; - std::vector extra_data; + uint16_t width; + uint16_t height; + uint8_t nalu_length_size; + std::vector extra_data; bool is_encrypted; }; // Note that this does not have vector of StreamInfo pointer. struct OnMediaEndParameters { bool has_init_range; - uint64 init_range_start; - uint64 init_range_end; + uint64_t init_range_start; + uint64_t init_range_end; bool has_index_range; - uint64 index_range_start; - uint64 index_range_end; + uint64_t index_range_start; + uint64_t index_range_end; float duration_seconds; - uint64 file_size; + uint64_t file_size; }; scoped_refptr CreateVideoStreamInfo( @@ -72,17 +72,17 @@ scoped_refptr CreateVideoStreamInfo( VideoStreamInfoParameters GetDefaultVideoStreamInfoParams() { const int kTrackId = 0; - const uint32 kTimeScale = 10; - const uint64 kVideoStreamDuration = 200; + const uint32_t kTimeScale = 10; + const uint64_t kVideoStreamDuration = 200; const VideoCodec kH264Codec = kCodecH264; - const uint8 kH264Profile = 1; - const uint8 kH264CompatibleProfile = 1; - const uint8 kH264Level = 1; + const uint8_t kH264Profile = 1; + const uint8_t kH264CompatibleProfile = 1; + const uint8_t kH264Level = 1; const char* kLanuageUndefined = "und"; - const uint16 kWidth = 720; - const uint16 kHeight = 480; - const uint8 kNaluLengthSize = 1; - const std::vector kExtraData; + const uint16_t kWidth = 720; + const uint16_t kHeight = 480; + const uint8_t kNaluLengthSize = 1; + const std::vector kExtraData; const bool kEncryptedFlag = false; VideoStreamInfoParameters param = { @@ -98,13 +98,13 @@ OnMediaEndParameters GetDefaultOnMediaEndParams() { // Values for {init, index} range {start, end} are arbitrary, but makes sure // that it is monotonically increasing and contiguous. const bool kHasInitRange = true; - const uint64 kInitRangeStart = 0; - const uint64 kInitRangeEnd = kInitRangeStart + 120; - const uint64 kHasIndexRange = true; - const uint64 kIndexRangeStart = kInitRangeEnd + 1; - const uint64 kIndexRangeEnd = kIndexRangeStart + 100; + const uint64_t kInitRangeStart = 0; + const uint64_t kInitRangeEnd = kInitRangeStart + 120; + const uint64_t kHasIndexRange = true; + const uint64_t kIndexRangeStart = kInitRangeEnd + 1; + const uint64_t kIndexRangeEnd = kIndexRangeStart + 100; const float kMediaDuration = 10.5f; - const uint64 kFileSize = 10000; + const uint64_t kFileSize = 10000; OnMediaEndParameters param = { kHasInitRange, kInitRangeStart, kInitRangeEnd, kHasIndexRange, kIndexRangeStart, kIndexRangeEnd, kMediaDuration, kFileSize}; @@ -171,7 +171,7 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test { bool enable_encryption) { MuxerOptions muxer_options; SetDefaultMuxerOptionsValues(&muxer_options); - const uint32 kReferenceTimeScale = 1000; + const uint32_t kReferenceTimeScale = 1000; listener_->OnMediaStart(muxer_options, stream_infos, kReferenceTimeScale, diff --git a/media/file/file.cc b/media/file/file.cc index a2958c5216..39b3f88688 100644 --- a/media/file/file.cc +++ b/media/file/file.cc @@ -66,11 +66,11 @@ File* File::Open(const char* file_name, const char* mode) { return file; } -int64 File::GetFileSize(const char* file_name) { +int64_t File::GetFileSize(const char* file_name) { File* file = File::Open(file_name, "r"); if (!file) return -1; - int64 res = file->Size(); + int64_t res = file->Size(); file->Close(); return res; } @@ -85,7 +85,7 @@ bool File::ReadFileToString(const char* file_name, std::string* contents) { const size_t kBufferSize = 0x40000; // 256KB. scoped_ptr buf(new char[kBufferSize]); - int64 len; + int64_t len; while ((len = file->Read(buf.get(), kBufferSize)) > 0) contents->append(buf.get(), len); diff --git a/media/file/file.h b/media/file/file.h index c4db9b3767..3f81931e1d 100644 --- a/media/file/file.h +++ b/media/file/file.h @@ -40,17 +40,17 @@ class File { /// @param length indicates number of bytes to be read. /// @return Number of bytes read, or a value < 0 on error. /// Zero on end-of-file, or if 'length' is zero. - virtual int64 Read(void* buffer, uint64 length) = 0; + virtual int64_t Read(void* buffer, uint64_t length) = 0; /// Write block of data. /// @param buffer points to a block of memory with at least @a length bytes. /// @param length indicates number of bytes to write. /// @return Number of bytes written, or a value < 0 on error. - virtual int64 Write(const void* buffer, uint64 length) = 0; + virtual int64_t Write(const void* buffer, uint64_t length) = 0; /// @return Size of the file in bytes. A return value less than zero /// indicates a problem getting the size. - virtual int64 Size() = 0; + virtual int64_t Size() = 0; /// Flush the file so that recently written data will survive an /// application crash (but not necessarily an OS crash). For @@ -71,7 +71,7 @@ class File { /// @return The size of a file in bytes on success, a value < 0 otherwise. /// The file will be opened and closed in the process. - static int64 GetFileSize(const char* file_name); + static int64_t GetFileSize(const char* file_name); /// Read the file into string. /// @param file_name is the file to be read. It should be a valid file. diff --git a/media/file/local_file.cc b/media/file/local_file.cc index 6a1eddaeb1..950192a5ac 100644 --- a/media/file/local_file.cc +++ b/media/file/local_file.cc @@ -25,19 +25,19 @@ bool LocalFile::Close() { return result; } -int64 LocalFile::Read(void* buffer, uint64 length) { +int64_t LocalFile::Read(void* buffer, uint64_t length) { DCHECK(buffer != NULL); DCHECK(internal_file_ != NULL); return fread(buffer, sizeof(char), length, internal_file_); } -int64 LocalFile::Write(const void* buffer, uint64 length) { +int64_t LocalFile::Write(const void* buffer, uint64_t length) { DCHECK(buffer != NULL); DCHECK(internal_file_ != NULL); return fwrite(buffer, sizeof(char), length, internal_file_); } -int64 LocalFile::Size() { +int64_t LocalFile::Size() { DCHECK(internal_file_ != NULL); // Flush any buffered data, so we get the true file size. @@ -46,7 +46,7 @@ int64 LocalFile::Size() { return -1; } - int64 file_size; + int64_t file_size; if (!base::GetFileSize(base::FilePath(file_name()), &file_size)) { LOG(ERROR) << "Cannot get file size."; return -1; diff --git a/media/file/local_file.h b/media/file/local_file.h index 6a05a2be55..b34a2bbd84 100644 --- a/media/file/local_file.h +++ b/media/file/local_file.h @@ -27,9 +27,9 @@ class LocalFile : public File { /// @name File implementation overrides. /// @{ virtual bool Close() OVERRIDE; - virtual int64 Read(void* buffer, uint64 length) OVERRIDE; - virtual int64 Write(const void* buffer, uint64 length) OVERRIDE; - virtual int64 Size() OVERRIDE; + virtual int64_t Read(void* buffer, uint64_t length) OVERRIDE; + virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE; + virtual int64_t Size() OVERRIDE; virtual bool Flush() OVERRIDE; virtual bool Eof() OVERRIDE; /// @} diff --git a/media/file/udp_file.cc b/media/file/udp_file.cc index 0828a45d0c..949ca2baa8 100644 --- a/media/file/udp_file.cc +++ b/media/file/udp_file.cc @@ -30,7 +30,7 @@ namespace { const int kInvalidSocket(-1); -bool StringToIpv4Address(const std::string& addr_in, uint32* addr_out) { +bool StringToIpv4Address(const std::string& addr_in, uint32_t* addr_out) { DCHECK(addr_out); *addr_out = 0; @@ -53,8 +53,8 @@ bool StringToIpv4Address(const std::string& addr_in, uint32* addr_out) { } bool StringToIpv4AddressAndPort(const std::string& addr_and_port, - uint32* addr, - uint16* port) { + uint32_t* addr, + uint16_t* port) { DCHECK(addr); DCHECK(port); @@ -73,7 +73,7 @@ bool StringToIpv4AddressAndPort(const std::string& addr_and_port, return true; } -bool IsIpv4MulticastAddress(uint32 addr) { +bool IsIpv4MulticastAddress(uint32_t addr) { return (addr & 0xf0000000) == 0xe0000000; } @@ -94,7 +94,7 @@ bool UdpFile::Close() { return true; } -int64 UdpFile::Read(void* buffer, uint64 length) { +int64_t UdpFile::Read(void* buffer, uint64_t length) { DCHECK(buffer); DCHECK_GE(length, 65535u) << "Buffer may be too small to read entire datagram."; @@ -102,7 +102,7 @@ int64 UdpFile::Read(void* buffer, uint64 length) { if (socket_ == kInvalidSocket) return -1; - int64 result; + int64_t result; do { result = recvfrom(socket_, buffer, length, 0, NULL, 0); } while ((result == -1) && (errno == EINTR)); @@ -110,12 +110,12 @@ int64 UdpFile::Read(void* buffer, uint64 length) { return result; } -int64 UdpFile::Write(const void* buffer, uint64 length) { +int64_t UdpFile::Write(const void* buffer, uint64_t length) { NOTIMPLEMENTED(); return -1; } -int64 UdpFile::Size() { +int64_t UdpFile::Size() { if (socket_ == kInvalidSocket) return -1; @@ -159,8 +159,8 @@ bool UdpFile::Open() { DCHECK_EQ(kInvalidSocket, socket_); // TODO(tinskip): Support IPv6 addresses. - uint32 dest_addr; - uint16 dest_port; + uint32_t dest_addr; + uint16_t dest_port; if (!StringToIpv4AddressAndPort(file_name(), &dest_addr, &dest_port)) { @@ -187,7 +187,7 @@ bool UdpFile::Open() { } if (IsIpv4MulticastAddress(dest_addr)) { - uint32 if_addr; + uint32_t if_addr; if (!StringToIpv4Address(FLAGS_udp_interface_address, &if_addr)) { LOG(ERROR) << "Malformed IPv4 address for interface."; return false; diff --git a/media/file/udp_file.h b/media/file/udp_file.h index c24de90c1c..5dc828e1e9 100644 --- a/media/file/udp_file.h +++ b/media/file/udp_file.h @@ -26,9 +26,9 @@ class UdpFile : public File { /// @name File implementation overrides. /// @{ virtual bool Close() OVERRIDE; - virtual int64 Read(void* buffer, uint64 length) OVERRIDE; - virtual int64 Write(const void* buffer, uint64 length) OVERRIDE; - virtual int64 Size() OVERRIDE; + virtual int64_t Read(void* buffer, uint64_t length) OVERRIDE; + virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE; + virtual int64_t Size() OVERRIDE; virtual bool Flush() OVERRIDE; virtual bool Eof() OVERRIDE; /// @} diff --git a/media/filters/h264_bit_reader.cc b/media/filters/h264_bit_reader.cc index 1ecbc2c80f..93e8e6821f 100644 --- a/media/filters/h264_bit_reader.cc +++ b/media/filters/h264_bit_reader.cc @@ -18,7 +18,7 @@ H264BitReader::H264BitReader() H264BitReader::~H264BitReader() {} -bool H264BitReader::Initialize(const uint8* data, off_t size) { +bool H264BitReader::Initialize(const uint8_t* data, off_t size) { DCHECK(data); if (size < 1) diff --git a/media/filters/h264_bit_reader.h b/media/filters/h264_bit_reader.h index 71e744e04e..f0931d7402 100644 --- a/media/filters/h264_bit_reader.h +++ b/media/filters/h264_bit_reader.h @@ -26,7 +26,7 @@ class H264BitReader { // Initialize the reader to start reading at |data|, |size| being size // of |data| in bytes. // Return false on insufficient size of stream.. - bool Initialize(const uint8* data, off_t size); + bool Initialize(const uint8_t* data, off_t size); // Read |num_bits| next bits from stream and return in |*out|, first bit // from the stream starting at |num_bits| position in |*out|. @@ -50,7 +50,7 @@ class H264BitReader { bool UpdateCurrByte(); // Pointer to the next unread (not in curr_byte_) byte in the stream. - const uint8* data_; + const uint8_t* data_; // Bytes left in the stream (without the curr_byte_). off_t bytes_left_; diff --git a/media/filters/h264_byte_to_unit_stream_converter.cc b/media/filters/h264_byte_to_unit_stream_converter.cc index 08fce61b81..adb68192cb 100644 --- a/media/filters/h264_byte_to_unit_stream_converter.cc +++ b/media/filters/h264_byte_to_unit_stream_converter.cc @@ -24,16 +24,16 @@ H264ByteToUnitStreamConverter::H264ByteToUnitStreamConverter() {} H264ByteToUnitStreamConverter::~H264ByteToUnitStreamConverter() {} bool H264ByteToUnitStreamConverter::ConvertByteStreamToNalUnitStream( - const uint8* input_frame, + const uint8_t* input_frame, size_t input_frame_size, - std::vector* output_frame) { + std::vector* output_frame) { DCHECK(input_frame); DCHECK(output_frame); BufferWriter output_buffer(input_frame_size + kStreamConversionOverhead); - const uint8* input_ptr(input_frame); - const uint8* input_end(input_ptr + input_frame_size); + const uint8_t* input_ptr(input_frame); + const uint8_t* input_end(input_ptr + input_frame_size); off_t next_start_code_offset; off_t next_start_code_size; bool first_nalu(true); @@ -64,17 +64,16 @@ bool H264ByteToUnitStreamConverter::ConvertByteStreamToNalUnitStream( return true; } -void H264ByteToUnitStreamConverter::ProcessNalu( - const uint8* nalu_ptr, - size_t nalu_size, - BufferWriter* output_buffer) { +void H264ByteToUnitStreamConverter::ProcessNalu(const uint8_t* nalu_ptr, + size_t nalu_size, + BufferWriter* output_buffer) { DCHECK(nalu_ptr); DCHECK(output_buffer); if (!nalu_size) return; // Edge case. - uint8 nalu_type = *nalu_ptr & 0x0f; + uint8_t nalu_type = *nalu_ptr & 0x0f; switch (nalu_type) { case H264NALU::kSPS: // Grab SPS NALU. @@ -93,12 +92,12 @@ void H264ByteToUnitStreamConverter::ProcessNalu( } // Append 4-byte length and NAL unit data to the buffer. - output_buffer->AppendInt(static_cast(nalu_size)); + output_buffer->AppendInt(static_cast(nalu_size)); output_buffer->AppendArray(nalu_ptr, nalu_size); } bool H264ByteToUnitStreamConverter::GetAVCDecoderConfigurationRecord( - std::vector* decoder_config) { + std::vector* decoder_config) { DCHECK(decoder_config); if ((last_sps_.size() < 4) || last_pps_.empty()) { @@ -109,20 +108,20 @@ bool H264ByteToUnitStreamConverter::GetAVCDecoderConfigurationRecord( // Construct an AVCDecoderConfigurationRecord containing a single SPS and a // single PPS NALU. Please refer to ISO/IEC 14496-15 for format specifics. BufferWriter buffer(last_sps_.size() + last_pps_.size() + 11); - uint8 version(1); + uint8_t version(1); buffer.AppendInt(version); buffer.AppendInt(last_sps_[1]); buffer.AppendInt(last_sps_[2]); buffer.AppendInt(last_sps_[3]); - uint8 reserved_and_length_size_minus_one(0xff); + uint8_t reserved_and_length_size_minus_one(0xff); buffer.AppendInt(reserved_and_length_size_minus_one); - uint8 reserved_and_num_sps(0xe1); + uint8_t reserved_and_num_sps(0xe1); buffer.AppendInt(reserved_and_num_sps); - buffer.AppendInt(static_cast(last_sps_.size())); + buffer.AppendInt(static_cast(last_sps_.size())); buffer.AppendVector(last_sps_); - uint8 num_pps(1); + uint8_t num_pps(1); buffer.AppendInt(num_pps); - buffer.AppendInt(static_cast(last_pps_.size())); + buffer.AppendInt(static_cast(last_pps_.size())); buffer.AppendVector(last_pps_); buffer.SwapBuffer(decoder_config); diff --git a/media/filters/h264_byte_to_unit_stream_converter.h b/media/filters/h264_byte_to_unit_stream_converter.h index 6e06fdf721..b84734272c 100644 --- a/media/filters/h264_byte_to_unit_stream_converter.h +++ b/media/filters/h264_byte_to_unit_stream_converter.h @@ -33,24 +33,24 @@ class H264ByteToUnitStreamConverter { /// @param output_frame is a pointer to a vector which will receive the /// converted frame. /// @return true if successful, false otherwise. - bool ConvertByteStreamToNalUnitStream(const uint8* input_frame, + bool ConvertByteStreamToNalUnitStream(const uint8_t* input_frame, size_t input_frame_size, - std::vector* output_frame); + std::vector* output_frame); /// Synthesizes an AVCDecoderConfigurationRecord from the SPS and PPS NAL /// units extracted from the AVC byte stream. /// @param decoder_config is a pointer to a vector, which on successful /// return will contain the computed AVCDecoderConfigurationRecord. /// @return true if successful, or false otherwise. - bool GetAVCDecoderConfigurationRecord(std::vector* decoder_config); + bool GetAVCDecoderConfigurationRecord(std::vector* decoder_config); private: - void ProcessNalu(const uint8* nalu_ptr, + void ProcessNalu(const uint8_t* nalu_ptr, size_t nalu_size, BufferWriter* output_buffer); - std::vector last_sps_; - std::vector last_pps_; + std::vector last_sps_; + std::vector last_pps_; }; } // namespace media diff --git a/media/filters/h264_byte_to_unit_stream_converter_unittest.cc b/media/filters/h264_byte_to_unit_stream_converter_unittest.cc index 7be4ef9703..e982078182 100644 --- a/media/filters/h264_byte_to_unit_stream_converter_unittest.cc +++ b/media/filters/h264_byte_to_unit_stream_converter_unittest.cc @@ -21,41 +21,41 @@ namespace edash_packager { namespace media { TEST(H264ByteToUnitStreamConverter, ConversionSuccess) { - std::vector input_frame = + std::vector input_frame = ReadTestDataFile("avc-byte-stream-frame.h264"); ASSERT_FALSE(input_frame.empty()); - std::vector expected_output_frame = + std::vector expected_output_frame = ReadTestDataFile("avc-unit-stream-frame.h264"); ASSERT_FALSE(expected_output_frame.empty()); H264ByteToUnitStreamConverter converter; - std::vector output_frame; + std::vector output_frame; ASSERT_TRUE(converter.ConvertByteStreamToNalUnitStream(input_frame.data(), input_frame.size(), &output_frame)); EXPECT_EQ(expected_output_frame, output_frame); - std::vector expected_decoder_config; + std::vector expected_decoder_config; ASSERT_TRUE(base::HexStringToBytes(kExpectedConfigRecord, &expected_decoder_config)); - std::vector decoder_config; + std::vector decoder_config; ASSERT_TRUE(converter.GetAVCDecoderConfigurationRecord(&decoder_config)); EXPECT_EQ(expected_decoder_config, decoder_config); } TEST(H264ByteToUnitStreamConverter, ConversionFailure) { - std::vector input_frame(100, 0); + std::vector input_frame(100, 0); H264ByteToUnitStreamConverter converter; - std::vector output_frame; + std::vector output_frame; EXPECT_FALSE(converter.ConvertByteStreamToNalUnitStream(input_frame.data(), 0, &output_frame)); EXPECT_FALSE(converter.ConvertByteStreamToNalUnitStream(input_frame.data(), input_frame.size(), &output_frame)); - std::vector decoder_config; + std::vector decoder_config; EXPECT_FALSE(converter.GetAVCDecoderConfigurationRecord(&decoder_config)); } diff --git a/media/filters/h264_parser.cc b/media/filters/h264_parser.cc index edd1b15779..c2b8cefffb 100644 --- a/media/filters/h264_parser.cc +++ b/media/filters/h264_parser.cc @@ -136,7 +136,7 @@ void H264Parser::Reset() { bytes_left_ = 0; } -void H264Parser::SetStream(const uint8* stream, off_t stream_size) { +void H264Parser::SetStream(const uint8_t* stream, off_t stream_size) { DCHECK(stream); DCHECK_GT(stream_size, 0); @@ -152,13 +152,15 @@ const H264SPS* H264Parser::GetSPS(int sps_id) { return active_SPSes_[sps_id]; } -static inline bool IsStartCode(const uint8* data) { +static inline bool IsStartCode(const uint8_t* data) { return data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x01; } // static -bool H264Parser::FindStartCode(const uint8* data, off_t data_size, - off_t* offset, off_t* start_code_size) { +bool H264Parser::FindStartCode(const uint8_t* data, + off_t data_size, + off_t* offset, + off_t* start_code_size) { DCHECK_GE(data_size, 0); off_t bytes_left = data_size; @@ -206,7 +208,7 @@ bool H264Parser::LocateNALU(off_t* nalu_size, off_t* start_code_size) { stream_ += nalu_start_off; bytes_left_ -= nalu_start_off; - const uint8* nalu_data = stream_ + annexb_start_code_size; + const uint8_t* nalu_data = stream_ + annexb_start_code_size; off_t max_nalu_data_size = bytes_left_ - annexb_start_code_size; if (max_nalu_data_size <= 0) { DVLOG(3) << "End of stream"; diff --git a/media/filters/h264_parser.h b/media/filters/h264_parser.h index 84cd7935c0..e074c9cad5 100644 --- a/media/filters/h264_parser.h +++ b/media/filters/h264_parser.h @@ -37,7 +37,7 @@ struct H264NALU { // After (without) start code; we don't own the underlying memory // and a shallow copy should be made when copying this struct. - const uint8* data; + const uint8_t* data; off_t size; // From after start code to start code of next NALU (or EOS). int nal_ref_idc; @@ -180,7 +180,7 @@ struct H264SliceHeader { bool idr_pic_flag; // from NAL header int nal_ref_idc; // from NAL header - const uint8* nalu_data; // from NAL header + const uint8_t* nalu_data; // from NAL header off_t nalu_size; // from NAL header off_t header_bit_size; // calculated @@ -277,8 +277,10 @@ class H264Parser { // - |*offset| is between 0 and |data_size| included. // It is strictly less than |data_size| if |data_size| > 0. // - |*start_code_size| is either 0, 3 or 4. - static bool FindStartCode(const uint8* data, off_t data_size, - off_t* offset, off_t* start_code_size); + static bool FindStartCode(const uint8_t* data, + off_t data_size, + off_t* offset, + off_t* start_code_size); H264Parser(); ~H264Parser(); @@ -286,7 +288,7 @@ class H264Parser { void Reset(); // Set current stream pointer to |stream| of |stream_size| in bytes, // |stream| owned by caller. - void SetStream(const uint8* stream, off_t stream_size); + void SetStream(const uint8_t* stream, off_t stream_size); // Read the stream to find the next NALU, identify it and return // that information in |*nalu|. This advances the stream to the beginning @@ -376,7 +378,7 @@ class H264Parser { Result ParseDecRefPicMarking(H264SliceHeader* shdr); // Pointer to the current NALU in the stream. - const uint8* stream_; + const uint8_t* stream_; // Bytes left in the stream after the current NALU. off_t bytes_left_; diff --git a/media/formats/mp2t/adts_header.cc b/media/formats/mp2t/adts_header.cc index 4e86868d57..419442e78d 100644 --- a/media/formats/mp2t/adts_header.cc +++ b/media/formats/mp2t/adts_header.cc @@ -20,7 +20,7 @@ AdtsHeader::AdtsHeader() sampling_frequency_index_(0), channel_configuration_(0) {} -size_t AdtsHeader::GetAdtsFrameSize(const uint8* data, size_t num_bytes) { +size_t AdtsHeader::GetAdtsFrameSize(const uint8_t* data, size_t num_bytes) { if (num_bytes < 6) return 0; return ((static_cast(data[5]) >> 5) | @@ -28,23 +28,22 @@ size_t AdtsHeader::GetAdtsFrameSize(const uint8* data, size_t num_bytes) { ((static_cast(data[3]) & 0x3) << 11)); } -size_t AdtsHeader::GetAdtsHeaderSize(const uint8* data, size_t num_bytes) { +size_t AdtsHeader::GetAdtsHeaderSize(const uint8_t* data, size_t num_bytes) { if (num_bytes < 2) return 0; if (data[1] & 0x01) return kAdtsHeaderMinSize; - return kAdtsHeaderMinSize + sizeof(uint16); // Header + CRC. + return kAdtsHeaderMinSize + sizeof(uint16_t); // Header + CRC. } -bool AdtsHeader::Parse( - const uint8* adts_frame, size_t adts_frame_size) { +bool AdtsHeader::Parse(const uint8_t* adts_frame, size_t adts_frame_size) { CHECK(adts_frame); valid_config_ = false; BitReader frame(adts_frame, adts_frame_size); // Verify frame starts with sync bits (0xfff). - uint32 sync; + uint32_t sync; RCHECK(frame.ReadBits(12, &sync)); RCHECK(sync == 0xfff); // Skip MPEG version and layer. @@ -66,12 +65,12 @@ bool AdtsHeader::Parse( // Skip originality, home and copyright info. RCHECK(frame.SkipBits(4)); // Verify that the frame size matches input parameters. - uint16 frame_size; + uint16_t frame_size; RCHECK(frame.ReadBits(13, &frame_size)); RCHECK(frame_size == adts_frame_size); // Skip buffer fullness indicator. RCHECK(frame.SkipBits(11)); - uint8 num_blocks_minus_1; + uint8_t num_blocks_minus_1; RCHECK(frame.ReadBits(2, &num_blocks_minus_1)); if (num_blocks_minus_1) { NOTIMPLEMENTED() << "ADTS frames with more than one data block " @@ -83,8 +82,7 @@ bool AdtsHeader::Parse( return true; } -bool AdtsHeader::GetAudioSpecificConfig( - std::vector* buffer) const { +bool AdtsHeader::GetAudioSpecificConfig(std::vector* buffer) const { DCHECK(buffer); if (!valid_config_) return false; @@ -96,16 +94,16 @@ bool AdtsHeader::GetAudioSpecificConfig( return true; } -uint8 AdtsHeader::GetObjectType() const { +uint8_t AdtsHeader::GetObjectType() const { return profile_ + 1; } -uint32 AdtsHeader::GetSamplingFrequency() const { +uint32_t AdtsHeader::GetSamplingFrequency() const { DCHECK_LT(sampling_frequency_index_, kAdtsFrequencyTableSize); return kAdtsFrequencyTable[sampling_frequency_index_]; } -uint8 AdtsHeader::GetNumChannels() const { +uint8_t AdtsHeader::GetNumChannels() const { DCHECK_GT(channel_configuration_, 0); DCHECK_LT(channel_configuration_, kAdtsNumChannelsTableSize); return kAdtsNumChannelsTable[channel_configuration_]; diff --git a/media/formats/mp2t/adts_header.h b/media/formats/mp2t/adts_header.h index fb0ad88c3a..26acbc33e7 100644 --- a/media/formats/mp2t/adts_header.h +++ b/media/formats/mp2t/adts_header.h @@ -27,42 +27,42 @@ class AdtsHeader { /// @param num_bytes is the number of data bytes at @a data. /// @return Size of the ADTS frame (header + payload) if successful, or /// zero otherwise. - static size_t GetAdtsFrameSize(const uint8* data, size_t num_bytes); + static size_t GetAdtsFrameSize(const uint8_t* data, size_t num_bytes); /// Get the size of the ADTS header from a partial or complete frame. /// @param data is a pointer to the beginning of the ADTS frame. /// @param num_bytes is the number of data bytes at @a data. /// @return Size of the ADTS header if successful, or zero otherwise. - static size_t GetAdtsHeaderSize(const uint8* data, size_t num_bytes); + static size_t GetAdtsHeaderSize(const uint8_t* data, size_t num_bytes); /// Parse an ADTS header, extracting the fields within. /// @param adts_frame is an input parameter pointing to the ADTS header /// of an ADTS-framed audio sample. /// @param adts_frame_size is the size, in bytes of the input ADTS frame. /// @return true if successful, false otherwise. - bool Parse(const uint8* adts_frame, size_t adts_frame_size); + bool Parse(const uint8_t* adts_frame, size_t adts_frame_size); /// Synthesize an AudioSpecificConfig record from the fields within the ADTS /// header. /// @param [out] buffer is a pointer to a vector to contain the /// AudioSpecificConfig. /// @return true if successful, false otherwise. - bool GetAudioSpecificConfig(std::vector* buffer) const; + bool GetAudioSpecificConfig(std::vector* buffer) const; /// @return The audio profile for this ADTS frame. - uint8 GetObjectType() const; + uint8_t GetObjectType() const; /// @return The sampling frequency for this ADTS frame. - uint32 GetSamplingFrequency() const; + uint32_t GetSamplingFrequency() const; /// @return Number of channels for this AAC config. - uint8 GetNumChannels() const; + uint8_t GetNumChannels() const; private: bool valid_config_; - uint8 profile_; - uint8 sampling_frequency_index_; - uint8 channel_configuration_; + uint8_t profile_; + uint8_t sampling_frequency_index_; + uint8_t channel_configuration_; DISALLOW_COPY_AND_ASSIGN(AdtsHeader); }; diff --git a/media/formats/mp2t/adts_header_unittest.cc b/media/formats/mp2t/adts_header_unittest.cc index 3742f0c43e..4cb12ba8bd 100644 --- a/media/formats/mp2t/adts_header_unittest.cc +++ b/media/formats/mp2t/adts_header_unittest.cc @@ -30,7 +30,7 @@ const char kValidAdtsFrame[] = "f2112c2202973b00de71bb49f906ed1bc63768dda378c8f9c6ed1bb48f68" "dda378c9f68dda3768dda3768de323da3768de31bb4e"; -const uint8 kExpectedAudioSpecificConfig[] = { 0x12, 0x10 }; +const uint8_t kExpectedAudioSpecificConfig[] = {0x12, 0x10}; } // anonymous namespace @@ -45,27 +45,26 @@ class AdtsHeaderTest : public testing::Test { } protected: - std::vector adts_frame_; + std::vector adts_frame_; }; TEST_F(AdtsHeaderTest, ParseSuccess) { - const uint8 kExpectedObjectType(2); - const uint32 kExpectedSamplingFrequency(44100); - const uint8 kExpectedNumChannels(2); + const uint8_t kExpectedObjectType(2); + const uint32_t kExpectedSamplingFrequency(44100); + const uint8_t kExpectedNumChannels(2); AdtsHeader adts_header; EXPECT_TRUE(adts_header.Parse(adts_frame_.data(), adts_frame_.size())); EXPECT_EQ(kExpectedObjectType, adts_header.GetObjectType()); EXPECT_EQ(kExpectedSamplingFrequency, adts_header.GetSamplingFrequency()); EXPECT_EQ(kExpectedNumChannels, adts_header.GetNumChannels()); - std::vector audio_specific_config; + std::vector audio_specific_config; ASSERT_TRUE(adts_header.GetAudioSpecificConfig(&audio_specific_config)); EXPECT_EQ(arraysize(kExpectedAudioSpecificConfig), audio_specific_config.size()); - EXPECT_EQ( - std::vector( - kExpectedAudioSpecificConfig, - kExpectedAudioSpecificConfig + arraysize(kExpectedAudioSpecificConfig)), - audio_specific_config); + EXPECT_EQ(std::vector(kExpectedAudioSpecificConfig, + kExpectedAudioSpecificConfig + + arraysize(kExpectedAudioSpecificConfig)), + audio_specific_config); } TEST_F(AdtsHeaderTest, ParseFailFrameSize) { diff --git a/media/formats/mp2t/es_parser.h b/media/formats/mp2t/es_parser.h index 599ba94a8b..e6897b8acb 100644 --- a/media/formats/mp2t/es_parser.h +++ b/media/formats/mp2t/es_parser.h @@ -20,15 +20,18 @@ namespace mp2t { class EsParser { public: typedef base::Callback&)> NewStreamInfoCB; - typedef base::Callback&)> EmitSampleCB; + typedef base::Callback&)> + EmitSampleCB; - EsParser(uint32 pid) - : pid_(pid) {} + EsParser(uint32_t pid) : pid_(pid) {} virtual ~EsParser() {} // ES parsing. // Should use kNoTimestamp when a timestamp is not valid. - virtual bool Parse(const uint8* buf, int size, int64 pts, int64 dts) = 0; + virtual bool Parse(const uint8_t* buf, + int size, + int64_t pts, + int64_t dts) = 0; // Flush any pending buffer. virtual void Flush() = 0; @@ -36,10 +39,10 @@ class EsParser { // Reset the state of the ES parser. virtual void Reset() = 0; - uint32 pid() { return pid_; } + uint32_t pid() { return pid_; } private: - uint32 pid_; + uint32_t pid_; }; } // namespace mp2t diff --git a/media/formats/mp2t/es_parser_adts.cc b/media/formats/mp2t/es_parser_adts.cc index 81061cb7c1..2ea2720b99 100644 --- a/media/formats/mp2t/es_parser_adts.cc +++ b/media/formats/mp2t/es_parser_adts.cc @@ -22,7 +22,7 @@ namespace media { // Return true if buf corresponds to an ADTS syncword. // |buf| size must be at least 2. -static bool isAdtsSyncWord(const uint8* buf) { +static bool isAdtsSyncWord(const uint8_t* buf) { return (buf[0] == 0xff) && ((buf[1] & 0xf6) == 0xf0); } @@ -33,9 +33,11 @@ static bool isAdtsSyncWord(const uint8* buf) { // In every case, the returned value in |new_pos| is such that new_pos >= pos // |frame_sz| returns the size of the ADTS frame (if found). // Return whether a syncword was found. -static bool LookForSyncWord(const uint8* raw_es, int raw_es_size, +static bool LookForSyncWord(const uint8_t* raw_es, + int raw_es_size, int pos, - int* new_pos, int* frame_sz) { + int* new_pos, + int* frame_sz) { DCHECK_GE(pos, 0); DCHECK_LE(pos, raw_es_size); @@ -52,7 +54,7 @@ static bool LookForSyncWord(const uint8* raw_es, int raw_es_size, } for (int offset = pos; offset < max_offset; offset++) { - const uint8* cur_buf = &raw_es[offset]; + const uint8_t* cur_buf = &raw_es[offset]; if (!isAdtsSyncWord(cur_buf)) // The first 12 bits must be 1. @@ -85,11 +87,10 @@ static bool LookForSyncWord(const uint8* raw_es, int raw_es_size, namespace mp2t { -EsParserAdts::EsParserAdts( - uint32 pid, - const NewStreamInfoCB& new_stream_info_cb, - const EmitSampleCB& emit_sample_cb, - bool sbr_in_mimetype) +EsParserAdts::EsParserAdts(uint32_t pid, + const NewStreamInfoCB& new_stream_info_cb, + const EmitSampleCB& emit_sample_cb, + bool sbr_in_mimetype) : EsParser(pid), new_stream_info_cb_(new_stream_info_cb), emit_sample_cb_(emit_sample_cb), @@ -99,9 +100,12 @@ EsParserAdts::EsParserAdts( EsParserAdts::~EsParserAdts() { } -bool EsParserAdts::Parse(const uint8* buf, int size, int64 pts, int64 dts) { +bool EsParserAdts::Parse(const uint8_t* buf, + int size, + int64_t pts, + int64_t dts) { int raw_es_size; - const uint8* raw_es; + const uint8_t* raw_es; // The incoming PTS applies to the access unit that comes just after // the beginning of |buf|. @@ -119,7 +123,7 @@ bool EsParserAdts::Parse(const uint8* buf, int size, int64 pts, int64 dts) { int frame_size; while (LookForSyncWord(raw_es, raw_es_size, es_position, &es_position, &frame_size)) { - const uint8* frame_ptr = raw_es + es_position; + const uint8_t* frame_ptr = raw_es + es_position; DVLOG(LOG_LEVEL_ES) << "ADTS syncword @ pos=" << es_position << " frame_size=" << frame_size; @@ -146,8 +150,8 @@ bool EsParserAdts::Parse(const uint8* buf, int size, int64 pts, int64 dts) { pts_list_.pop_front(); } - int64 current_pts = audio_timestamp_helper_->GetTimestamp(); - int64 frame_duration = + int64_t current_pts = audio_timestamp_helper_->GetTimestamp(); + int64_t frame_duration = audio_timestamp_helper_->GetFrameDuration(kSamplesPerAACFrame); // Emit an audio frame. @@ -185,17 +189,16 @@ void EsParserAdts::Reset() { last_audio_decoder_config_ = scoped_refptr(); } -bool EsParserAdts::UpdateAudioConfiguration(const uint8* adts_frame, +bool EsParserAdts::UpdateAudioConfiguration(const uint8_t* adts_frame, size_t adts_frame_size) { - - const uint8 kAacSampleSizeBits(16); + const uint8_t kAacSampleSizeBits(16); AdtsHeader adts_header; if (!adts_header.Parse(adts_frame, adts_frame_size)) { LOG(ERROR) << "Error parsing ADTS frame header."; return false; } - std::vector audio_specific_config; + std::vector audio_specific_config; if (!adts_header.GetAudioSpecificConfig(&audio_specific_config)) return false; @@ -239,7 +242,7 @@ bool EsParserAdts::UpdateAudioConfiguration(const uint8* adts_frame, DVLOG(1) << "Object type: " << adts_header.GetObjectType(); // Reset the timestamp helper to use a new sampling frequency. if (audio_timestamp_helper_) { - int64 base_timestamp = audio_timestamp_helper_->GetTimestamp(); + int64_t base_timestamp = audio_timestamp_helper_->GetTimestamp(); audio_timestamp_helper_.reset( new AudioTimestampHelper(kMpeg2Timescale, samples_per_second)); audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); diff --git a/media/formats/mp2t/es_parser_adts.h b/media/formats/mp2t/es_parser_adts.h index 190e637bdf..d1ddd012e3 100644 --- a/media/formats/mp2t/es_parser_adts.h +++ b/media/formats/mp2t/es_parser_adts.h @@ -24,28 +24,29 @@ namespace mp2t { class EsParserAdts : public EsParser { public: - EsParserAdts(uint32 pid, + EsParserAdts(uint32_t pid, const NewStreamInfoCB& new_stream_info_cb, const EmitSampleCB& emit_sample_cb, bool sbr_in_mimetype); virtual ~EsParserAdts(); // EsParser implementation. - virtual bool Parse(const uint8* buf, int size, - int64 pts, - int64 dts) OVERRIDE; + virtual bool Parse(const uint8_t* buf, + int size, + int64_t pts, + int64_t dts) OVERRIDE; virtual void Flush() OVERRIDE; virtual void Reset() OVERRIDE; private: // Used to link a PTS with a byte position in the ES stream. - typedef std::pair EsPts; + typedef std::pair EsPts; typedef std::list EsPtsList; // Signal any audio configuration change (if any). // Return false if the current audio config is not // a supported ADTS audio config. - bool UpdateAudioConfiguration(const uint8* adts_frame, size_t frame_size); + bool UpdateAudioConfiguration(const uint8_t* adts_frame, size_t frame_size); // Discard some bytes from the ES stream. void DiscardEs(int nbytes); diff --git a/media/formats/mp2t/es_parser_h264.cc b/media/formats/mp2t/es_parser_h264.cc index 30d32ade80..5447c09b8d 100644 --- a/media/formats/mp2t/es_parser_h264.cc +++ b/media/formats/mp2t/es_parser_h264.cc @@ -27,10 +27,9 @@ const int kMinAUDSize = 4; } // anonymous namespace -EsParserH264::EsParserH264( - uint32 pid, - const NewStreamInfoCB& new_stream_info_cb, - const EmitSampleCB& emit_sample_cb) +EsParserH264::EsParserH264(uint32_t pid, + const NewStreamInfoCB& new_stream_info_cb, + const EmitSampleCB& emit_sample_cb) : EsParser(pid), new_stream_info_cb_(new_stream_info_cb), emit_sample_cb_(emit_sample_cb), @@ -47,7 +46,10 @@ EsParserH264::EsParserH264( EsParserH264::~EsParserH264() { } -bool EsParserH264::Parse(const uint8* buf, int size, int64 pts, int64 dts) { +bool EsParserH264::Parse(const uint8_t* buf, + int size, + int64_t pts, + int64_t dts) { // Note: Parse is invoked each time a PES packet has been reassembled. // Unfortunately, a PES packet does not necessarily map // to an h264 access unit, although the HLS recommendation is to use one PES @@ -65,7 +67,7 @@ bool EsParserH264::Parse(const uint8* buf, int size, int64 pts, int64 dts) { // Link the end of the byte queue with the incoming timing descriptor. timing_desc_list_.push_back( - std::pair(es_queue_->tail(), timing_desc)); + std::pair(es_queue_->tail(), timing_desc)); } // Add the incoming bytes to the ES queue. @@ -79,7 +81,7 @@ void EsParserH264::Flush() { if (FindAUD(¤t_access_unit_pos_)) { // Simulate an additional AUD to force emitting the last access unit // which is assumed to be complete at this point. - uint8 aud[] = { 0x00, 0x00, 0x01, 0x09 }; + uint8_t aud[] = {0x00, 0x00, 0x01, 0x09}; es_queue_->Push(aud, sizeof(aud)); ParseInternal(); } @@ -107,9 +109,9 @@ void EsParserH264::Reset() { waiting_for_key_frame_ = true; } -bool EsParserH264::FindAUD(int64* stream_pos) { +bool EsParserH264::FindAUD(int64_t* stream_pos) { while (true) { - const uint8* es; + const uint8_t* es; int size; es_queue_->PeekAt(*stream_pos, &es, &size); @@ -170,10 +172,10 @@ bool EsParserH264::ParseInternal() { bool is_key_frame = false; int pps_id_for_access_unit = -1; - const uint8* es; + const uint8_t* es; int size; es_queue_->PeekAt(current_access_unit_pos_, &es, &size); - int access_unit_size = base::checked_cast( + int access_unit_size = base::checked_cast( next_access_unit_pos_ - current_access_unit_pos_); DCHECK_LE(access_unit_size, size); h264_parser_->SetStream(es, access_unit_size); @@ -254,8 +256,10 @@ bool EsParserH264::ParseInternal() { return true; } -bool EsParserH264::EmitFrame(int64 access_unit_pos, int access_unit_size, - bool is_key_frame, int pps_id) { +bool EsParserH264::EmitFrame(int64_t access_unit_pos, + int access_unit_size, + bool is_key_frame, + int pps_id) { // Get the access unit timing info. TimingDesc current_timing_desc = {kNoTimestamp, kNoTimestamp}; while (!timing_desc_list_.empty() && @@ -270,12 +274,12 @@ bool EsParserH264::EmitFrame(int64 access_unit_pos, int access_unit_size, DVLOG(LOG_LEVEL_ES) << "Emit frame: stream_pos=" << current_access_unit_pos_ << " size=" << access_unit_size; int es_size; - const uint8* es; + const uint8_t* es; es_queue_->PeekAt(current_access_unit_pos_, &es, &es_size); CHECK_GE(es_size, access_unit_size); // Convert frame to unit stream format. - std::vector converted_frame; + std::vector converted_frame; if (!stream_converter_->ConvertByteStreamToNalUnitStream( es, access_unit_size, &converted_frame)) { DLOG(ERROR) << "Failure to convert video frame to unit stream format."; @@ -320,7 +324,7 @@ bool EsParserH264::EmitFrame(int64 access_unit_pos, int access_unit_size, } bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps) { - std::vector decoder_config_record; + std::vector decoder_config_record; if (!stream_converter_->GetAVCDecoderConfigurationRecord( &decoder_config_record)) { DLOG(ERROR) << "Failure to construct an AVCDecoderConfigurationRecord"; @@ -342,8 +346,8 @@ bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps) { // TODO: a MAP unit can be either 16 or 32 pixels. // although it's 16 pixels for progressive non MBAFF frames. - uint16 width = (sps->pic_width_in_mbs_minus1 + 1) * 16; - uint16 height = (sps->pic_height_in_map_units_minus1 + 1) * 16; + uint16_t width = (sps->pic_width_in_mbs_minus1 + 1) * 16; + uint16_t height = (sps->pic_height_in_map_units_minus1 + 1) * 16; last_video_decoder_config_ = scoped_refptr( new VideoStreamInfo( diff --git a/media/formats/mp2t/es_parser_h264.h b/media/formats/mp2t/es_parser_h264.h index 25fbc53357..9b8b55fae2 100644 --- a/media/formats/mp2t/es_parser_h264.h +++ b/media/formats/mp2t/es_parser_h264.h @@ -31,20 +31,23 @@ namespace mp2t { // class EsParserH264 : public EsParser { public: - EsParserH264(uint32 pid, + EsParserH264(uint32_t pid, const NewStreamInfoCB& new_stream_info_cb, const EmitSampleCB& emit_sample_cb); virtual ~EsParserH264(); // EsParser implementation overrides. - virtual bool Parse(const uint8* buf, int size, int64 pts, int64 dts) OVERRIDE; + virtual bool Parse(const uint8_t* buf, + int size, + int64_t pts, + int64_t dts) OVERRIDE; virtual void Flush() OVERRIDE; virtual void Reset() OVERRIDE; private: struct TimingDesc { - int64 dts; - int64 pts; + int64_t dts; + int64_t pts; }; // Find the AUD located at or after |*stream_pos|. @@ -52,7 +55,7 @@ class EsParserH264 : public EsParser { // If found, |*stream_pos| corresponds to the position of the AUD start code // in the stream. Otherwise, |*stream_pos| corresponds to the last position // of the start code parser. - bool FindAUD(int64* stream_pos); + bool FindAUD(int64_t* stream_pos); // Resumes the H264 ES parsing. // Return true if successful. @@ -60,8 +63,10 @@ class EsParserH264 : public EsParser { // Emit a frame whose position in the ES queue starts at |access_unit_pos|. // Returns true if successful, false if no PTS is available for the frame. - bool EmitFrame(int64 access_unit_pos, int access_unit_size, - bool is_key_frame, int pps_id); + bool EmitFrame(int64_t access_unit_pos, + int access_unit_size, + bool is_key_frame, + int pps_id); // Update the video decoder config based on an H264 SPS. // Return true if successful. @@ -73,14 +78,14 @@ class EsParserH264 : public EsParser { // Bytes of the ES stream that have not been emitted yet. scoped_ptr es_queue_; - std::list > timing_desc_list_; + std::list > timing_desc_list_; // H264 parser state. // - |current_access_unit_pos_| is pointing to an annexB syncword // representing the first NALU of an H264 access unit. scoped_ptr h264_parser_; - int64 current_access_unit_pos_; - int64 next_access_unit_pos_; + int64_t current_access_unit_pos_; + int64_t next_access_unit_pos_; // Filter to convert H.264 Annex B byte stream to unit stream. scoped_ptr stream_converter_; @@ -91,7 +96,7 @@ class EsParserH264 : public EsParser { // Frame for which we do not yet have a duration. scoped_refptr pending_sample_; - uint64 pending_sample_duration_; + uint64_t pending_sample_duration_; // Indicates whether waiting for first key frame. bool waiting_for_key_frame_; diff --git a/media/formats/mp2t/es_parser_h264_unittest.cc b/media/formats/mp2t/es_parser_h264_unittest.cc index 777351f409..3747dcd569 100644 --- a/media/formats/mp2t/es_parser_h264_unittest.cc +++ b/media/formats/mp2t/es_parser_h264_unittest.cc @@ -49,7 +49,7 @@ void ComputePacketSize(std::vector& packets, size_t stream_size) { // This function assumes there is only one slice per access unit. // This is a very simplified access unit segmenter that is good // enough for unit tests. -std::vector GetAccessUnits(const uint8* stream, size_t stream_size) { +std::vector GetAccessUnits(const uint8_t* stream, size_t stream_size) { std::vector access_units; bool start_access_unit = true; @@ -92,12 +92,12 @@ std::vector GetAccessUnits(const uint8* stream, size_t stream_size) { // Append an AUD NALU at the beginning of each access unit // needed for streams which do not already have AUD NALUs. -void AppendAUD( - const uint8* stream, size_t stream_size, - const std::vector& access_units, - std::vector& stream_with_aud, - std::vector& access_units_with_aud) { - uint8 aud[] = { 0x00, 0x00, 0x01, 0x09 }; +void AppendAUD(const uint8_t* stream, + size_t stream_size, + const std::vector& access_units, + std::vector& stream_with_aud, + std::vector& access_units_with_aud) { + uint8_t aud[] = {0x00, 0x00, 0x01, 0x09}; stream_with_aud.resize(stream_size + access_units.size() * sizeof(aud)); access_units_with_aud.resize(access_units.size()); @@ -126,7 +126,7 @@ class EsParserH264Test : public testing::Test { void LoadStream(const char* filename); void ProcessPesPackets(const std::vector& pes_packets); - void EmitSample(uint32 pid, scoped_refptr& sample) { + void EmitSample(uint32_t pid, scoped_refptr& sample) { sample_count_++; if (sample_count_ == 1) first_frame_is_key_frame_ = sample->is_key_frame(); @@ -139,7 +139,7 @@ class EsParserH264Test : public testing::Test { bool first_frame_is_key_frame() { return first_frame_is_key_frame_; } // Stream with AUD NALUs. - std::vector stream_; + std::vector stream_; // Access units of the stream with AUD NALUs. std::vector access_units_; @@ -168,7 +168,7 @@ void EsParserH264Test::LoadStream(const char* filename) { void EsParserH264Test::ProcessPesPackets( const std::vector& pes_packets) { // Duration of one 25fps video frame in 90KHz clock units. - const uint32 kMpegTicksPerFrame = 3600; + const uint32_t kMpegTicksPerFrame = 3600; EsParserH264 es_parser( 0, @@ -189,8 +189,8 @@ void EsParserH264Test::ProcessPesPackets( // Check whether the PES packet includes the start of an access unit. // The timings are relevant only in this case. - int64 pts = kNoTimestamp; - int64 dts = kNoTimestamp; + int64_t pts = kNoTimestamp; + int64_t dts = kNoTimestamp; if (cur_pes_offset <= access_units_[au_idx].offset && cur_pes_offset + cur_pes_size > access_units_[au_idx].offset) { pts = au_idx * kMpegTicksPerFrame; diff --git a/media/formats/mp2t/mp2t_common.h b/media/formats/mp2t/mp2t_common.h index af00e677ee..1dfde0391d 100644 --- a/media/formats/mp2t/mp2t_common.h +++ b/media/formats/mp2t/mp2t_common.h @@ -22,7 +22,7 @@ namespace edash_packager { namespace media { -const uint32 kMpeg2Timescale = 90000; +const uint32_t kMpeg2Timescale = 90000; } // namespace media } // namespace edash_packager diff --git a/media/formats/mp2t/mp2t_media_parser.cc b/media/formats/mp2t/mp2t_media_parser.cc index bdc1627081..98c1e7dfe2 100644 --- a/media/formats/mp2t/mp2t_media_parser.cc +++ b/media/formats/mp2t/mp2t_media_parser.cc @@ -184,14 +184,14 @@ void Mp2tMediaParser::Flush() { ts_byte_queue_.Reset(); } -bool Mp2tMediaParser::Parse(const uint8* buf, int size) { +bool Mp2tMediaParser::Parse(const uint8_t* buf, int size) { DVLOG(1) << "Mp2tMediaParser::Parse size=" << size; // Add the data to the parser state. ts_byte_queue_.Push(buf, size); while (true) { - const uint8* ts_buffer; + const uint8_t* ts_buffer; int ts_buffer_size; ts_byte_queue_.Peek(&ts_buffer, &ts_buffer_size); if (ts_buffer_size < TsPacket::kPacketSize) @@ -354,7 +354,7 @@ bool Mp2tMediaParser::FinishInitializationIfNeeded() { return true; std::vector > all_stream_info; - uint32 num_es(0); + uint32_t num_es(0); for (PidMap::const_iterator iter = pids_.begin(); iter != pids_.end(); ++iter) { if (((iter->second->pid_type() == PidState::kPidAudioPes) || @@ -374,7 +374,7 @@ bool Mp2tMediaParser::FinishInitializationIfNeeded() { return true; } -void Mp2tMediaParser::OnEmitSample(uint32 pes_pid, +void Mp2tMediaParser::OnEmitSample(uint32_t pes_pid, scoped_refptr& new_sample) { DCHECK(new_sample); DVLOG(LOG_LEVEL_ES) diff --git a/media/formats/mp2t/mp2t_media_parser.h b/media/formats/mp2t/mp2t_media_parser.h index 6f5d18d4af..507959d941 100644 --- a/media/formats/mp2t/mp2t_media_parser.h +++ b/media/formats/mp2t/mp2t_media_parser.h @@ -39,7 +39,7 @@ class Mp2tMediaParser : public MediaParser { virtual void Flush() OVERRIDE; - virtual bool Parse(const uint8* buf, int size) OVERRIDE; + virtual bool Parse(const uint8_t* buf, int size) OVERRIDE; private: typedef std::map PidMap; @@ -60,7 +60,7 @@ class Mp2tMediaParser : public MediaParser { // Callback invoked by the ES media parser // to emit a new audio/video access unit. - void OnEmitSample(uint32 pes_pid, scoped_refptr& new_sample); + void OnEmitSample(uint32_t pes_pid, scoped_refptr& new_sample); // Invoke the initialization callback if needed. bool FinishInitializationIfNeeded(); diff --git a/media/formats/mp2t/mp2t_media_parser_unittest.cc b/media/formats/mp2t/mp2t_media_parser_unittest.cc index d796a63ccb..2e64241dc8 100644 --- a/media/formats/mp2t/mp2t_media_parser_unittest.cc +++ b/media/formats/mp2t/mp2t_media_parser_unittest.cc @@ -40,16 +40,18 @@ class Mp2tMediaParserTest : public testing::Test { StreamMap stream_map_; int audio_frame_count_; int video_frame_count_; - int64 video_min_dts_; - int64 video_max_dts_; + int64_t video_min_dts_; + int64_t video_max_dts_; - bool AppendData(const uint8* data, size_t length) { + bool AppendData(const uint8_t* data, size_t length) { return parser_->Parse(data, length); } - bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) { - const uint8* start = data; - const uint8* end = data + length; + bool AppendDataInPieces(const uint8_t* data, + size_t length, + size_t piece_size) { + const uint8_t* start = data; + const uint8_t* end = data + length; while (start < end) { size_t append_size = std::min(piece_size, static_cast(end - start)); @@ -69,7 +71,8 @@ class Mp2tMediaParserTest : public testing::Test { } } - bool OnNewSample(uint32 track_id, const scoped_refptr& sample) { + bool OnNewSample(uint32_t track_id, + const scoped_refptr& sample) { std::string stream_type; StreamMap::const_iterator stream = stream_map_.find(track_id); if (stream != stream_map_.end()) { @@ -110,7 +113,7 @@ class Mp2tMediaParserTest : public testing::Test { bool ParseMpeg2TsFile(const std::string& filename, int append_bytes) { InitializeParser(); - std::vector buffer = ReadTestDataFile(filename); + std::vector buffer = ReadTestDataFile(filename); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), append_bytes)); @@ -144,7 +147,7 @@ TEST_F(Mp2tMediaParserTest, TimestampWrapAround) { EXPECT_EQ(video_frame_count_, 82); EXPECT_GE(video_min_dts_, (95443 - 1) * kMpeg2Timescale); EXPECT_LE(video_max_dts_, - static_cast((95443 + 4)) * kMpeg2Timescale); + static_cast((95443 + 4)) * kMpeg2Timescale); } } // namespace mp2t diff --git a/media/formats/mp2t/ts_packet.cc b/media/formats/mp2t/ts_packet.cc index 64164f6d36..cf9daff985 100644 --- a/media/formats/mp2t/ts_packet.cc +++ b/media/formats/mp2t/ts_packet.cc @@ -12,10 +12,10 @@ namespace edash_packager { namespace media { namespace mp2t { -static const uint8 kTsHeaderSyncword = 0x47; +static const uint8_t kTsHeaderSyncword = 0x47; // static -int TsPacket::Sync(const uint8* buf, int size) { +int TsPacket::Sync(const uint8_t* buf, int size) { int k = 0; for (; k < size; k++) { // Verify that we have 4 syncwords in a row when possible, @@ -42,7 +42,7 @@ int TsPacket::Sync(const uint8* buf, int size) { } // static -TsPacket* TsPacket::Parse(const uint8* buf, int size) { +TsPacket* TsPacket::Parse(const uint8_t* buf, int size) { if (size < kPacketSize) { DVLOG(1) << "Buffer does not hold one full TS packet:" << " buffer_size=" << size; @@ -72,7 +72,7 @@ TsPacket::TsPacket() { TsPacket::~TsPacket() { } -bool TsPacket::ParseHeader(const uint8* buf) { +bool TsPacket::ParseHeader(const uint8_t* buf) { BitReader bit_reader(buf, kPacketSize); payload_ = buf; payload_size_ = kPacketSize; @@ -160,7 +160,7 @@ bool TsPacket::ParseAdaptationField(BitReader* bit_reader, random_access_indicator_ = (random_access_indicator != 0); if (pcr_flag) { - int64 program_clock_reference_base; + int64_t program_clock_reference_base; int reserved; int program_clock_reference_extension; RCHECK(bit_reader->ReadBits(33, &program_clock_reference_base)); @@ -169,7 +169,7 @@ bool TsPacket::ParseAdaptationField(BitReader* bit_reader, } if (opcr_flag) { - int64 original_program_clock_reference_base; + int64_t original_program_clock_reference_base; int reserved; int original_program_clock_reference_extension; RCHECK(bit_reader->ReadBits(33, &original_program_clock_reference_base)); diff --git a/media/formats/mp2t/ts_packet.h b/media/formats/mp2t/ts_packet.h index 46a1838cce..eb205e0af8 100644 --- a/media/formats/mp2t/ts_packet.h +++ b/media/formats/mp2t/ts_packet.h @@ -20,12 +20,12 @@ class TsPacket { // Return the number of bytes to discard // to be synchronized on a TS syncword. - static int Sync(const uint8* buf, int size); + static int Sync(const uint8_t* buf, int size); // Parse a TS packet. // Return a TsPacket only when parsing was successful. // Return NULL otherwise. - static TsPacket* Parse(const uint8* buf, int size); + static TsPacket* Parse(const uint8_t* buf, int size); ~TsPacket(); @@ -39,7 +39,7 @@ class TsPacket { bool random_access_indicator() const { return random_access_indicator_; } // Return the offset and the size of the payload. - const uint8* payload() const { return payload_; } + const uint8_t* payload() const { return payload_; } int payload_size() const { return payload_size_; } private: @@ -47,12 +47,12 @@ class TsPacket { // Parse an Mpeg2 TS header. // The buffer size should be at least |kPacketSize| - bool ParseHeader(const uint8* buf); + bool ParseHeader(const uint8_t* buf); bool ParseAdaptationField(BitReader* bit_reader, int adaptation_field_length); // Size of the payload. - const uint8* payload_; + const uint8_t* payload_; int payload_size_; // TS header. diff --git a/media/formats/mp2t/ts_section.h b/media/formats/mp2t/ts_section.h index ad443ecca4..160f6e70f4 100644 --- a/media/formats/mp2t/ts_section.h +++ b/media/formats/mp2t/ts_section.h @@ -25,7 +25,8 @@ class TsSection { // Parse the data bytes of the TS packet. // Return true if parsing is successful. virtual bool Parse(bool payload_unit_start_indicator, - const uint8* buf, int size) = 0; + const uint8_t* buf, + int size) = 0; // Process bytes that have not been processed yet (pending buffers in the // pipe). Flush might thus results in frame emission, as an example. diff --git a/media/formats/mp2t/ts_section_pes.cc b/media/formats/mp2t/ts_section_pes.cc index fe9059709b..ca8b2ee642 100644 --- a/media/formats/mp2t/ts_section_pes.cc +++ b/media/formats/mp2t/ts_section_pes.cc @@ -19,7 +19,7 @@ static const int kPesStartCode = 0x000001; // |time| + k * (2 ^ 33) // where k is estimated so that the unrolled timestamp // is as close as possible to |previous_unrolled_time|. -static int64 UnrollTimestamp(int64 previous_unrolled_time, int64 time) { +static int64_t UnrollTimestamp(int64_t previous_unrolled_time, int64_t time) { // Mpeg2 TS timestamps have an accuracy of 33 bits. const int nbits = 33; @@ -28,17 +28,16 @@ static int64 UnrollTimestamp(int64 previous_unrolled_time, int64 time) { DCHECK_EQ((time >> nbits), 0); // Consider 3 possibilities to estimate the missing high bits of |time|. - int64 previous_unrolled_time_high = - (previous_unrolled_time >> nbits); - int64 time0 = ((previous_unrolled_time_high - 1) << nbits) | time; - int64 time1 = ((previous_unrolled_time_high + 0) << nbits) | time; - int64 time2 = ((previous_unrolled_time_high + 1) << nbits) | time; + int64_t previous_unrolled_time_high = (previous_unrolled_time >> nbits); + int64_t time0 = ((previous_unrolled_time_high - 1) << nbits) | time; + int64_t time1 = ((previous_unrolled_time_high + 0) << nbits) | time; + int64_t time2 = ((previous_unrolled_time_high + 1) << nbits) | time; // Select the min absolute difference with the current time // so as to ensure time continuity. - int64 diff0 = time0 - previous_unrolled_time; - int64 diff1 = time1 - previous_unrolled_time; - int64 diff2 = time2 - previous_unrolled_time; + int64_t diff0 = time0 - previous_unrolled_time; + int64_t diff1 = time1 - previous_unrolled_time; + int64_t diff2 = time2 - previous_unrolled_time; if (diff0 < 0) diff0 = -diff0; if (diff1 < 0) @@ -46,8 +45,8 @@ static int64 UnrollTimestamp(int64 previous_unrolled_time, int64 time) { if (diff2 < 0) diff2 = -diff2; - int64 unrolled_time; - int64 min_diff; + int64_t unrolled_time; + int64_t min_diff; if (diff1 < diff0) { unrolled_time = time1; min_diff = diff1; @@ -61,7 +60,7 @@ static int64 UnrollTimestamp(int64 previous_unrolled_time, int64 time) { return unrolled_time; } -static bool IsTimestampSectionValid(int64 timestamp_section) { +static bool IsTimestampSectionValid(int64_t timestamp_section) { // |pts_section| has 40 bits: // - starting with either '0010' or '0011' or '0001' // - and ending with a marker bit. @@ -73,7 +72,7 @@ static bool IsTimestampSectionValid(int64 timestamp_section) { ((timestamp_section & 0x100000000LL) != 0); } -static int64 ConvertTimestampSectionToTimestamp(int64 timestamp_section) { +static int64_t ConvertTimestampSectionToTimestamp(int64_t timestamp_section) { return (((timestamp_section >> 33) & 0x7) << 30) | (((timestamp_section >> 17) & 0x7fff) << 15) | (((timestamp_section >> 1) & 0x7fff) << 0); @@ -97,7 +96,8 @@ TsSectionPes::~TsSectionPes() { } bool TsSectionPes::Parse(bool payload_unit_start_indicator, - const uint8* buf, int size) { + const uint8_t* buf, + int size) { // Ignore partial PES. if (wait_for_pusi_ && !payload_unit_start_indicator) return true; @@ -108,7 +108,7 @@ bool TsSectionPes::Parse(bool payload_unit_start_indicator, // with an undefined size. // In this case, a unit is emitted when the next unit is coming. int raw_pes_size; - const uint8* raw_pes; + const uint8_t* raw_pes; pes_byte_queue_.Peek(&raw_pes, &raw_pes_size); if (raw_pes_size > 0) parse_result = Emit(true); @@ -150,7 +150,7 @@ void TsSectionPes::Reset() { bool TsSectionPes::Emit(bool emit_for_unknown_size) { int raw_pes_size; - const uint8* raw_pes; + const uint8_t* raw_pes; pes_byte_queue_.Peek(&raw_pes, &raw_pes_size); // A PES should be at least 6 bytes. @@ -181,7 +181,7 @@ bool TsSectionPes::Emit(bool emit_for_unknown_size) { return parse_result; } -bool TsSectionPes::ParseInternal(const uint8* raw_pes, int raw_pes_size) { +bool TsSectionPes::ParseInternal(const uint8_t* raw_pes, int raw_pes_size) { BitReader bit_reader(raw_pes, raw_pes_size); // Read up to the pes_packet_length (6 bytes). @@ -247,8 +247,8 @@ bool TsSectionPes::ParseInternal(const uint8* raw_pes, int raw_pes_size) { // Read the timing information section. bool is_pts_valid = false; bool is_dts_valid = false; - int64 pts_section = 0; - int64 dts_section = 0; + int64_t pts_section = 0; + int64_t dts_section = 0; if (pts_dts_flags == 0x2) { RCHECK(bit_reader.ReadBits(40, &pts_section)); RCHECK((((pts_section >> 36) & 0xf) == 0x2) && @@ -267,10 +267,10 @@ bool TsSectionPes::ParseInternal(const uint8* raw_pes, int raw_pes_size) { } // Convert and unroll the timestamps. - int64 media_pts(kNoTimestamp); - int64 media_dts(kNoTimestamp); + int64_t media_pts(kNoTimestamp); + int64_t media_dts(kNoTimestamp); if (is_pts_valid) { - int64 pts = ConvertTimestampSectionToTimestamp(pts_section); + int64_t pts = ConvertTimestampSectionToTimestamp(pts_section); if (previous_pts_valid_) pts = UnrollTimestamp(previous_pts_, pts); previous_pts_ = pts; @@ -278,7 +278,7 @@ bool TsSectionPes::ParseInternal(const uint8* raw_pes, int raw_pes_size) { media_pts = pts; } if (is_dts_valid) { - int64 dts = ConvertTimestampSectionToTimestamp(dts_section); + int64_t dts = ConvertTimestampSectionToTimestamp(dts_section); if (previous_dts_valid_) dts = UnrollTimestamp(previous_dts_, dts); previous_dts_ = dts; diff --git a/media/formats/mp2t/ts_section_pes.h b/media/formats/mp2t/ts_section_pes.h index a49eb35eb1..76051d3860 100644 --- a/media/formats/mp2t/ts_section_pes.h +++ b/media/formats/mp2t/ts_section_pes.h @@ -24,7 +24,8 @@ class TsSectionPes : public TsSection { // TsSection implementation. virtual bool Parse(bool payload_unit_start_indicator, - const uint8* buf, int size) OVERRIDE; + const uint8_t* buf, + int size) OVERRIDE; virtual void Flush() OVERRIDE; virtual void Reset() OVERRIDE; @@ -36,7 +37,7 @@ class TsSectionPes : public TsSection { bool Emit(bool emit_for_unknown_size); // Parse a PES packet, return true if successful. - bool ParseInternal(const uint8* raw_pes, int raw_pes_size); + bool ParseInternal(const uint8_t* raw_pes, int raw_pes_size); void ResetPesState(); @@ -51,9 +52,9 @@ class TsSectionPes : public TsSection { // Used to unroll PTS and DTS. bool previous_pts_valid_; - int64 previous_pts_; + int64_t previous_pts_; bool previous_dts_valid_; - int64 previous_dts_; + int64_t previous_dts_; DISALLOW_COPY_AND_ASSIGN(TsSectionPes); }; diff --git a/media/formats/mp2t/ts_section_psi.cc b/media/formats/mp2t/ts_section_psi.cc index 48b7c6d930..eaba1457a3 100644 --- a/media/formats/mp2t/ts_section_psi.cc +++ b/media/formats/mp2t/ts_section_psi.cc @@ -9,13 +9,13 @@ #include "media/base/bit_reader.h" #include "media/formats/mp2t/mp2t_common.h" -static bool IsCrcValid(const uint8* buf, int size) { - uint32 crc = 0xffffffffu; - const uint32 kCrcPoly = 0x4c11db7; +static bool IsCrcValid(const uint8_t* buf, int size) { + uint32_t crc = 0xffffffffu; + const uint32_t kCrcPoly = 0x4c11db7; for (int k = 0; k < size; k++) { int nbits = 8; - uint32 data_msb_aligned = buf[k]; + uint32_t data_msb_aligned = buf[k]; data_msb_aligned <<= (32 - nbits); while (nbits > 0) { @@ -47,7 +47,8 @@ TsSectionPsi::~TsSectionPsi() { } bool TsSectionPsi::Parse(bool payload_unit_start_indicator, - const uint8* buf, int size) { + const uint8_t* buf, + int size) { // Ignore partial PSI. if (wait_for_pusi_ && !payload_unit_start_indicator) return true; @@ -78,7 +79,7 @@ bool TsSectionPsi::Parse(bool payload_unit_start_indicator, // Add the data to the parser state. psi_byte_queue_.Push(buf, size); int raw_psi_size; - const uint8* raw_psi; + const uint8_t* raw_psi; psi_byte_queue_.Peek(&raw_psi, &raw_psi_size); // Check whether we have enough data to start parsing. diff --git a/media/formats/mp2t/ts_section_psi.h b/media/formats/mp2t/ts_section_psi.h index 5c47262ece..44c68fc6d2 100644 --- a/media/formats/mp2t/ts_section_psi.h +++ b/media/formats/mp2t/ts_section_psi.h @@ -23,7 +23,8 @@ class TsSectionPsi : public TsSection { // TsSection implementation. virtual bool Parse(bool payload_unit_start_indicator, - const uint8* buf, int size) OVERRIDE; + const uint8_t* buf, + int size) OVERRIDE; virtual void Flush() OVERRIDE; virtual void Reset() OVERRIDE; diff --git a/media/formats/mp4/aac_audio_specific_config.cc b/media/formats/mp4/aac_audio_specific_config.cc index 7162e63f96..9ec56d1b6d 100644 --- a/media/formats/mp4/aac_audio_specific_config.cc +++ b/media/formats/mp4/aac_audio_specific_config.cc @@ -13,13 +13,12 @@ namespace { // Sampling Frequency Index table, from ISO 14496-3 Table 1.16 -static const uint32 kSampleRates[] = { - 96000, 88200, 64000, 48000, 44100, 32000, 24000, - 22050, 16000, 12000, 11025, 8000, 7350 -}; +static const uint32_t kSampleRates[] = {96000, 88200, 64000, 48000, 44100, + 32000, 24000, 22050, 16000, 12000, + 11025, 8000, 7350}; // Channel Configuration table, from ISO 14496-3 Table 1.17 -const uint8 kChannelConfigs[] = {0, 1, 2, 3, 4, 5, 6, 8}; +const uint8_t kChannelConfigs[] = {0, 1, 2, 3, 4, 5, 6, 8}; } // namespace @@ -39,13 +38,13 @@ AACAudioSpecificConfig::AACAudioSpecificConfig() AACAudioSpecificConfig::~AACAudioSpecificConfig() {} -bool AACAudioSpecificConfig::Parse(const std::vector& data) { +bool AACAudioSpecificConfig::Parse(const std::vector& data) { if (data.empty()) return false; BitReader reader(&data[0], data.size()); - uint8 extension_type = 0; - uint8 extension_frequency_index = 0xff; + uint8_t extension_type = 0; + uint8_t extension_frequency_index = 0xff; ps_present_ = false; frequency_ = 0; @@ -82,9 +81,9 @@ bool AACAudioSpecificConfig::Parse(const std::vector& data) { // Read extension configuration again // Note: The check for 16 available bits comes from the AAC spec. if (extension_type != 5 && reader.bits_available() >= 16) { - uint16 sync_extension_type; - uint8 sbr_present_flag; - uint8 ps_present_flag; + uint16_t sync_extension_type; + uint8_t sbr_present_flag; + uint8_t ps_present_flag; if (reader.ReadBits(11, &sync_extension_type) && sync_extension_type == 0x2b7) { @@ -128,8 +127,8 @@ bool AACAudioSpecificConfig::Parse(const std::vector& data) { channel_config_ <= 7; } -uint32 AACAudioSpecificConfig::GetOutputSamplesPerSecond(bool sbr_in_mimetype) - const { +uint32_t AACAudioSpecificConfig::GetOutputSamplesPerSecond( + bool sbr_in_mimetype) const { if (extension_frequency_ > 0) return extension_frequency_; @@ -143,7 +142,7 @@ uint32 AACAudioSpecificConfig::GetOutputSamplesPerSecond(bool sbr_in_mimetype) return std::min(2 * frequency_, 48000u); } -uint8 AACAudioSpecificConfig::GetNumChannels(bool sbr_in_mimetype) const { +uint8_t AACAudioSpecificConfig::GetNumChannels(bool sbr_in_mimetype) const { // Check for implicit signalling of HE-AAC and indicate stereo output // if the mono channel configuration is signalled. // See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing. @@ -157,7 +156,7 @@ uint8 AACAudioSpecificConfig::GetNumChannels(bool sbr_in_mimetype) const { return num_channels_; } -bool AACAudioSpecificConfig::ConvertToADTS(std::vector* buffer) const { +bool AACAudioSpecificConfig::ConvertToADTS(std::vector* buffer) const { size_t size = buffer->size() + kADTSHeaderSize; DCHECK(audio_object_type_ >= 1 && audio_object_type_ <= 4 && @@ -167,7 +166,7 @@ bool AACAudioSpecificConfig::ConvertToADTS(std::vector* buffer) const { if (size >= (1 << 13)) return false; - std::vector& adts = *buffer; + std::vector& adts = *buffer; adts.insert(buffer->begin(), kADTSHeaderSize, 0); adts[0] = 0xff; @@ -229,9 +228,9 @@ bool AACAudioSpecificConfig::SkipErrorSpecificConfig() const { // The following code is written according to ISO 14496 part 3 Table 4.1 - // GASpecificConfig. bool AACAudioSpecificConfig::SkipGASpecificConfig(BitReader* bit_reader) const { - uint8 extension_flag = 0; - uint8 depends_on_core_coder; - uint16 dummy; + uint8_t extension_flag = 0; + uint8_t depends_on_core_coder; + uint16_t dummy; RCHECK(bit_reader->ReadBits(1, &dummy)); // frameLengthFlag RCHECK(bit_reader->ReadBits(1, &depends_on_core_coder)); diff --git a/media/formats/mp4/aac_audio_specific_config.h b/media/formats/mp4/aac_audio_specific_config.h index a28721b9e6..1b4c0638a7 100644 --- a/media/formats/mp4/aac_audio_specific_config.h +++ b/media/formats/mp4/aac_audio_specific_config.h @@ -31,39 +31,33 @@ class AACAudioSpecificConfig { /// ElementaryStreamDescriptor to get audio stream configurations. /// @param data contains decoder specific information from an @b esds box. /// @return true if successful, false otherwise. - bool Parse(const std::vector& data); + bool Parse(const std::vector& data); /// @param sbr_in_mimetype indicates whether SBR mode is specified in the /// mimetype, i.e. codecs parameter contains mp4a.40.5. /// @return Output sample rate for the AAC stream. - uint32 GetOutputSamplesPerSecond(bool sbr_in_mimetype) const; + uint32_t GetOutputSamplesPerSecond(bool sbr_in_mimetype) const; /// @param sbr_in_mimetype indicates whether SBR mode is specified in the /// mimetype, i.e. codecs parameter contains mp4a.40.5. /// @return Number of channels for the AAC stream. - uint8 GetNumChannels(bool sbr_in_mimetype) const; + uint8_t GetNumChannels(bool sbr_in_mimetype) const; /// Convert a raw AAC frame into an AAC frame with an ADTS header. /// @param[in,out] buffer contains the raw AAC frame on input, and the /// converted frame on output if successful; it is untouched /// on failure. /// @return true on success, false otherwise. - bool ConvertToADTS(std::vector* buffer) const; + bool ConvertToADTS(std::vector* buffer) const; /// @return The audio object type for this AAC config. - uint8 audio_object_type() const { - return audio_object_type_; - } + uint8_t audio_object_type() const { return audio_object_type_; } /// @return The sampling frequency for this AAC config. - uint32 frequency() const { - return frequency_; - } + uint32_t frequency() const { return frequency_; } /// @return Number of channels for this AAC config. - uint8 num_channels() const { - return num_channels_; - } + uint8_t num_channels() const { return num_channels_; } /// Size in bytes of the ADTS header added by ConvertEsdsToADTS(). static const size_t kADTSHeaderSize = 7; @@ -75,18 +69,18 @@ class AACAudioSpecificConfig { // The following variables store the AAC specific configuration information // that are used to generate the ADTS header. - uint8 audio_object_type_; - uint8 frequency_index_; - uint8 channel_config_; + uint8_t audio_object_type_; + uint8_t frequency_index_; + uint8_t channel_config_; // Is Parametric Stereo on? bool ps_present_; // The following variables store audio configuration information. // They are based on the AAC specific configuration but can be overridden // by extensions in elementary stream descriptor. - uint32 frequency_; - uint32 extension_frequency_; - uint8 num_channels_; + uint32_t frequency_; + uint32_t extension_frequency_; + uint8_t num_channels_; }; } // namespace mp4 diff --git a/media/formats/mp4/aac_audio_specific_config_unittest.cc b/media/formats/mp4/aac_audio_specific_config_unittest.cc index c04102c1fd..5512c9896b 100644 --- a/media/formats/mp4/aac_audio_specific_config_unittest.cc +++ b/media/formats/mp4/aac_audio_specific_config_unittest.cc @@ -12,8 +12,8 @@ namespace mp4 { TEST(AACAudioSpecificConfigTest, BasicProfileTest) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x12, 0x10}; - std::vector data; + uint8_t buffer[] = {0x12, 0x10}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -24,8 +24,8 @@ TEST(AACAudioSpecificConfigTest, BasicProfileTest) { TEST(AACAudioSpecificConfigTest, ExtensionTest) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80}; - std::vector data; + uint8_t buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -41,8 +41,8 @@ TEST(AACAudioSpecificConfigTest, ExtensionTest) { // See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing. TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig0) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x13, 0x08}; - std::vector data; + uint8_t buffer[] = {0x13, 0x08}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -60,8 +60,8 @@ TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig0) { // Tests implicit SBR with a stereo channel config. TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig1) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x13, 0x10}; - std::vector data; + uint8_t buffer[] = {0x13, 0x10}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -78,8 +78,8 @@ TEST(AACAudioSpecificConfigTest, ImplicitSBR_ChannelConfig1) { TEST(AACAudioSpecificConfigTest, SixChannelTest) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x11, 0xb0}; - std::vector data; + uint8_t buffer[] = {0x11, 0xb0}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -90,7 +90,7 @@ TEST(AACAudioSpecificConfigTest, SixChannelTest) { TEST(AACAudioSpecificConfigTest, DataTooShortTest) { AACAudioSpecificConfig aac_audio_specific_config; - std::vector data; + std::vector data; EXPECT_FALSE(aac_audio_specific_config.Parse(data)); @@ -100,8 +100,8 @@ TEST(AACAudioSpecificConfigTest, DataTooShortTest) { TEST(AACAudioSpecificConfigTest, IncorrectProfileTest) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x0, 0x08}; - std::vector data; + uint8_t buffer[] = {0x0, 0x08}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -116,8 +116,8 @@ TEST(AACAudioSpecificConfigTest, IncorrectProfileTest) { TEST(AACAudioSpecificConfigTest, IncorrectFrequencyTest) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x0f, 0x88}; - std::vector data; + uint8_t buffer[] = {0x0f, 0x88}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -130,8 +130,8 @@ TEST(AACAudioSpecificConfigTest, IncorrectFrequencyTest) { TEST(AACAudioSpecificConfigTest, IncorrectChannelTest) { AACAudioSpecificConfig aac_audio_specific_config; - uint8 buffer[] = {0x0e, 0x00}; - std::vector data; + uint8_t buffer[] = {0x0e, 0x00}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); diff --git a/media/formats/mp4/box.cc b/media/formats/mp4/box.cc index 315a1b3758..88186c2046 100644 --- a/media/formats/mp4/box.cc +++ b/media/formats/mp4/box.cc @@ -24,7 +24,7 @@ bool Box::Parse(BoxReader* reader) { void Box::Write(BufferWriter* writer) { DCHECK(writer != NULL); - uint32 size = ComputeSize(); + uint32_t size = ComputeSize(); DCHECK_EQ(size, this->atom_size); size_t buffer_size_before_write = writer->Size(); @@ -50,7 +50,7 @@ FullBox::~FullBox() {} bool FullBox::ReadWrite(BoxBuffer* buffer) { RCHECK(Box::ReadWrite(buffer)); - uint32 vflags; + uint32_t vflags; if (buffer->Reading()) { RCHECK(buffer->ReadWriteUInt32(&vflags)); this->version = vflags >> 24; diff --git a/media/formats/mp4/box.h b/media/formats/mp4/box.h index 0770f049b8..175611448a 100644 --- a/media/formats/mp4/box.h +++ b/media/formats/mp4/box.h @@ -38,7 +38,7 @@ struct Box { void Write(BufferWriter* writer); /// Compute the size of this box. /// The calculated size will be saved in |atom_size| for later consumption. - virtual uint32 ComputeSize() = 0; + virtual uint32_t ComputeSize() = 0; virtual FourCC BoxType() const = 0; protected: @@ -48,7 +48,7 @@ struct Box { /// We don't support 64-bit atom sizes. 32-bit should be large enough for our /// current needs. - uint32 atom_size; + uint32_t atom_size; }; /// Defines FullBox, the other base ISO BMFF box objects as defined in @@ -59,8 +59,8 @@ struct FullBox : Box { FullBox(); virtual ~FullBox(); - uint8 version; - uint32 flags; + uint8_t version; + uint32_t flags; protected: virtual bool ReadWrite(BoxBuffer* buffer) OVERRIDE; diff --git a/media/formats/mp4/box_buffer.h b/media/formats/mp4/box_buffer.h index 0b781fac94..358ecbb077 100644 --- a/media/formats/mp4/box_buffer.h +++ b/media/formats/mp4/box_buffer.h @@ -57,43 +57,43 @@ class BoxBuffer { /// @name Read/write integers of various sizes and signedness. /// @{ - bool ReadWriteUInt8(uint8* v) { + bool ReadWriteUInt8(uint8_t* v) { if (reader_) return reader_->Read1(v); writer_->AppendInt(*v); return true; } - bool ReadWriteUInt16(uint16* v) { + bool ReadWriteUInt16(uint16_t* v) { if (reader_) return reader_->Read2(v); writer_->AppendInt(*v); return true; } - bool ReadWriteUInt32(uint32* v) { + bool ReadWriteUInt32(uint32_t* v) { if (reader_) return reader_->Read4(v); writer_->AppendInt(*v); return true; } - bool ReadWriteUInt64(uint64* v) { + bool ReadWriteUInt64(uint64_t* v) { if (reader_) return reader_->Read8(v); writer_->AppendInt(*v); return true; } - bool ReadWriteInt16(int16* v) { + bool ReadWriteInt16(int16_t* v) { if (reader_) return reader_->Read2s(v); writer_->AppendInt(*v); return true; } - bool ReadWriteInt32(int32* v) { + bool ReadWriteInt32(int32_t* v) { if (reader_) return reader_->Read4s(v); writer_->AppendInt(*v); return true; } - bool ReadWriteInt64(int64* v) { + bool ReadWriteInt64(int64_t* v) { if (reader_) return reader_->Read8s(v); writer_->AppendInt(*v); @@ -104,19 +104,19 @@ class BoxBuffer { /// Read/write the least significant |num_bytes| of |v| from/to the buffer. /// @param num_bytes should not be larger than sizeof(v), i.e. 8. /// @return true on success, false otherwise. - bool ReadWriteUInt64NBytes(uint64* v, size_t num_bytes) { + bool ReadWriteUInt64NBytes(uint64_t* v, size_t num_bytes) { if (reader_) return reader_->ReadNBytesInto8(v, num_bytes); writer_->AppendNBytes(*v, num_bytes); return true; } - bool ReadWriteInt64NBytes(int64* v, size_t num_bytes) { + bool ReadWriteInt64NBytes(int64_t* v, size_t num_bytes) { if (reader_) return reader_->ReadNBytesInto8s(v, num_bytes); writer_->AppendNBytes(*v, num_bytes); return true; } - bool ReadWriteVector(std::vector* vector, size_t count) { + bool ReadWriteVector(std::vector* vector, size_t count) { if (reader_) return reader_->ReadToVector(vector, count); DCHECK_EQ(vector->size(), count); @@ -126,7 +126,7 @@ class BoxBuffer { bool ReadWriteFourCC(FourCC* fourcc) { if (reader_) return reader_->ReadFourCC(fourcc); - writer_->AppendInt(static_cast(*fourcc)); + writer_->AppendInt(static_cast(*fourcc)); return true; } @@ -167,7 +167,7 @@ class BoxBuffer { bool IgnoreBytes(size_t num_bytes) { if (reader_) return reader_->SkipBytes(num_bytes); - std::vector vector(num_bytes, 0); + std::vector vector(num_bytes, 0); writer_->AppendVector(vector); return true; } diff --git a/media/formats/mp4/box_definitions.cc b/media/formats/mp4/box_definitions.cc index f858a7b7d6..87266a5bd5 100644 --- a/media/formats/mp4/box_definitions.cc +++ b/media/formats/mp4/box_definitions.cc @@ -10,35 +10,39 @@ #include "media/formats/mp4/rcheck.h" namespace { -const uint32 kFourCCSize = 4; +const uint32_t kFourCCSize = 4; // Additional 32-bit size. We don't support 64-bit size. -const uint32 kBoxSize = kFourCCSize + sizeof(uint32); +const uint32_t kBoxSize = kFourCCSize + sizeof(uint32_t); // Additional 1-byte version and 3-byte flags. -const uint32 kFullBoxSize = kBoxSize + 4; +const uint32_t kFullBoxSize = kBoxSize + 4; -// 9 uint32 in big endian formatted array. -const uint8 kUnityMatrix[] = {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0}; +// 9 uint32_t in big endian formatted array. +const uint8_t kUnityMatrix[] = {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0, 0}; // Default entries for HandlerReference box. const char kVideoHandlerName[] = "VideoHandler"; const char kAudioHandlerName[] = "SoundHandler"; // Default values for VideoSampleEntry box. -const uint32 kVideoResolution = 0x00480000; // 72 dpi. -const uint16 kVideoFrameCount = 1; -const uint16 kVideoDepth = 0x0018; +const uint32_t kVideoResolution = 0x00480000; // 72 dpi. +const uint16_t kVideoFrameCount = 1; +const uint16_t kVideoDepth = 0x0018; -bool IsFitIn32Bits(uint64 a) { return a <= kuint32max; } -bool IsFitIn32Bits(int64 a) { return a <= kint32max && a >= kint32min; } -bool IsFitIn32Bits(uint64 a, uint64 b) { +bool IsFitIn32Bits(uint64_t a) { + return a <= kuint32max; +} +bool IsFitIn32Bits(int64_t a) { + return a <= kint32max && a >= kint32min; +} +bool IsFitIn32Bits(uint64_t a, uint64_t b) { return IsFitIn32Bits(a) && IsFitIn32Bits(b); } -bool IsFitIn32Bits(uint64 a, int64 b) { +bool IsFitIn32Bits(uint64_t a, int64_t b) { return IsFitIn32Bits(a) && IsFitIn32Bits(b); } -bool IsFitIn32Bits(uint64 a, uint64 b, uint64 c) { +bool IsFitIn32Bits(uint64_t a, uint64_t b, uint64_t c) { return IsFitIn32Bits(a) && IsFitIn32Bits(b) && IsFitIn32Bits(c); } @@ -68,7 +72,7 @@ bool FileType::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 FileType::ComputeSize() { +uint32_t FileType::ComputeSize() { atom_size = kBoxSize + kFourCCSize + sizeof(minor_version) + kFourCCSize * compatible_brands.size(); return atom_size; @@ -82,7 +86,7 @@ bool SegmentType::ReadWrite(BoxBuffer* buffer) { return FileType::ReadWrite(buffer); } -uint32 SegmentType::ComputeSize() { +uint32_t SegmentType::ComputeSize() { return FileType::ComputeSize(); } @@ -97,7 +101,7 @@ bool ProtectionSystemSpecificHeader::ReadWrite(BoxBuffer* buffer) { return true; } - uint32 size = data.size(); + uint32_t size = data.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteVector(&system_id, 16) && buffer->ReadWriteUInt32(&size) && @@ -114,11 +118,13 @@ bool ProtectionSystemSpecificHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 ProtectionSystemSpecificHeader::ComputeSize() { - if (!raw_box.empty()) +uint32_t ProtectionSystemSpecificHeader::ComputeSize() { + if (!raw_box.empty()) { atom_size = raw_box.size(); - else - atom_size = kFullBoxSize + system_id.size() + sizeof(uint32) + data.size(); + } else { + atom_size = + kFullBoxSize + system_id.size() + sizeof(uint32_t) + data.size(); + } return atom_size; } @@ -131,22 +137,22 @@ bool SampleAuxiliaryInformationOffset::ReadWrite(BoxBuffer* buffer) { if (flags & 1) RCHECK(buffer->IgnoreBytes(8)); // aux_info_type and parameter. - uint32 count = offsets.size(); + uint32_t count = offsets.size(); RCHECK(buffer->ReadWriteUInt32(&count)); offsets.resize(count); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); - for (uint32 i = 0; i < count; ++i) + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); + for (uint32_t i = 0; i < count; ++i) RCHECK(buffer->ReadWriteUInt64NBytes(&offsets[i], num_bytes)); return true; } -uint32 SampleAuxiliaryInformationOffset::ComputeSize() { +uint32_t SampleAuxiliaryInformationOffset::ComputeSize() { // This box is optional. Skip it if it is empty. atom_size = 0; if (offsets.size() != 0) { - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); - atom_size = kFullBoxSize + sizeof(uint32) + num_bytes * offsets.size(); + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); + atom_size = kFullBoxSize + sizeof(uint32_t) + num_bytes * offsets.size(); } return atom_size; } @@ -168,7 +174,7 @@ bool SampleAuxiliaryInformationSize::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SampleAuxiliaryInformationSize::ComputeSize() { +uint32_t SampleAuxiliaryInformationSize::ComputeSize() { // This box is optional. Skip it if it is empty. atom_size = 0; if (sample_count != 0) { @@ -187,7 +193,7 @@ bool OriginalFormat::ReadWrite(BoxBuffer* buffer) { return Box::ReadWrite(buffer) && buffer->ReadWriteFourCC(&format); } -uint32 OriginalFormat::ComputeSize() { +uint32_t OriginalFormat::ComputeSize() { atom_size = kBoxSize + kFourCCSize; return atom_size; } @@ -203,7 +209,7 @@ bool SchemeType::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SchemeType::ComputeSize() { +uint32_t SchemeType::ComputeSize() { atom_size = kFullBoxSize + kFourCCSize + sizeof(version); return atom_size; } @@ -214,7 +220,7 @@ TrackEncryption::~TrackEncryption() {} FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; } bool TrackEncryption::ReadWrite(BoxBuffer* buffer) { - uint8 flag = is_encrypted ? 1 : 0; + uint8_t flag = is_encrypted ? 1 : 0; RCHECK(FullBox::ReadWrite(buffer) && buffer->IgnoreBytes(2) && // reserved. buffer->ReadWriteUInt8(&flag) && @@ -231,8 +237,8 @@ bool TrackEncryption::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 TrackEncryption::ComputeSize() { - atom_size = kFullBoxSize + sizeof(uint32) + default_kid.size(); +uint32_t TrackEncryption::ComputeSize() { + atom_size = kFullBoxSize + sizeof(uint32_t) + default_kid.size(); return atom_size; } @@ -246,7 +252,7 @@ bool SchemeInfo::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SchemeInfo::ComputeSize() { +uint32_t SchemeInfo::ComputeSize() { atom_size = kBoxSize + track_encryption.ComputeSize(); return atom_size; } @@ -269,7 +275,7 @@ bool ProtectionSchemeInfo::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 ProtectionSchemeInfo::ComputeSize() { +uint32_t ProtectionSchemeInfo::ComputeSize() { // Skip sinf box if it is not initialized. atom_size = 0; if (format.format != FOURCC_NULL) { @@ -293,14 +299,14 @@ FourCC MovieHeader::BoxType() const { return FOURCC_MVHD; } bool MovieHeader::ReadWrite(BoxBuffer* buffer) { RCHECK(FullBox::ReadWrite(buffer)); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); RCHECK(buffer->ReadWriteUInt64NBytes(&creation_time, num_bytes) && buffer->ReadWriteUInt64NBytes(&modification_time, num_bytes) && buffer->ReadWriteUInt32(×cale) && buffer->ReadWriteUInt64NBytes(&duration, num_bytes)); - std::vector matrix(kUnityMatrix, - kUnityMatrix + arraysize(kUnityMatrix)); + std::vector matrix(kUnityMatrix, + kUnityMatrix + arraysize(kUnityMatrix)); RCHECK(buffer->ReadWriteInt32(&rate) && buffer->ReadWriteInt16(&volume) && buffer->IgnoreBytes(10) && // reserved @@ -310,9 +316,9 @@ bool MovieHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 MovieHeader::ComputeSize() { +uint32_t MovieHeader::ComputeSize() { version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1; - atom_size = kFullBoxSize + sizeof(uint32) * (1 + version) * 3 + + atom_size = kFullBoxSize + sizeof(uint32_t) * (1 + version) * 3 + sizeof(timescale) + sizeof(rate) + sizeof(volume) + sizeof(next_track_id) + sizeof(kUnityMatrix) + 10 + 24; // 10 bytes reserved, 24 bytes predefined. @@ -337,7 +343,7 @@ FourCC TrackHeader::BoxType() const { return FOURCC_TKHD; } bool TrackHeader::ReadWrite(BoxBuffer* buffer) { RCHECK(FullBox::ReadWrite(buffer)); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); RCHECK(buffer->ReadWriteUInt64NBytes(&creation_time, num_bytes) && buffer->ReadWriteUInt64NBytes(&modification_time, num_bytes) && buffer->ReadWriteUInt32(&track_id) && @@ -352,8 +358,8 @@ bool TrackHeader::ReadWrite(BoxBuffer* buffer) { width <<= 16; height <<= 16; } - std::vector matrix(kUnityMatrix, - kUnityMatrix + arraysize(kUnityMatrix)); + std::vector matrix(kUnityMatrix, + kUnityMatrix + arraysize(kUnityMatrix)); RCHECK(buffer->IgnoreBytes(8) && // reserved buffer->ReadWriteInt16(&layer) && buffer->ReadWriteInt16(&alternate_group) && @@ -368,10 +374,10 @@ bool TrackHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 TrackHeader::ComputeSize() { +uint32_t TrackHeader::ComputeSize() { version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1; atom_size = kFullBoxSize + sizeof(track_id) + - sizeof(uint32) * (1 + version) * 3 + sizeof(layer) + + sizeof(uint32_t) * (1 + version) * 3 + sizeof(layer) + sizeof(alternate_group) + sizeof(volume) + sizeof(width) + sizeof(height) + sizeof(kUnityMatrix) + 14; // 14 bytes reserved. return atom_size; @@ -382,7 +388,7 @@ SampleDescription::~SampleDescription() {} FourCC SampleDescription::BoxType() const { return FOURCC_STSD; } bool SampleDescription::ReadWrite(BoxBuffer* buffer) { - uint32 count = 0; + uint32_t count = 0; if (type == kVideo) count = video_entries.size(); else @@ -407,10 +413,10 @@ bool SampleDescription::ReadWrite(BoxBuffer* buffer) { } else { DCHECK_LT(0u, count); if (type == kVideo) { - for (uint32 i = 0; i < count; ++i) + for (uint32_t i = 0; i < count; ++i) RCHECK(video_entries[i].ReadWrite(buffer)); } else if (type == kAudio) { - for (uint32 i = 0; i < count; ++i) + for (uint32_t i = 0; i < count; ++i) RCHECK(audio_entries[i].ReadWrite(buffer)); } else { NOTIMPLEMENTED(); @@ -419,13 +425,13 @@ bool SampleDescription::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SampleDescription::ComputeSize() { - atom_size = kFullBoxSize + sizeof(uint32); +uint32_t SampleDescription::ComputeSize() { + atom_size = kFullBoxSize + sizeof(uint32_t); if (type == kVideo) { - for (uint32 i = 0; i < video_entries.size(); ++i) + for (uint32_t i = 0; i < video_entries.size(); ++i) atom_size += video_entries[i].ComputeSize(); } else if (type == kAudio) { - for (uint32 i = 0; i < audio_entries.size(); ++i) + for (uint32_t i = 0; i < audio_entries.size(); ++i) atom_size += audio_entries[i].ComputeSize(); } return atom_size; @@ -436,20 +442,20 @@ DecodingTimeToSample::~DecodingTimeToSample() {} FourCC DecodingTimeToSample::BoxType() const { return FOURCC_STTS; } bool DecodingTimeToSample::ReadWrite(BoxBuffer* buffer) { - uint32 count = decoding_time.size(); + uint32_t count = decoding_time.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&count)); decoding_time.resize(count); - for (uint32 i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { RCHECK(buffer->ReadWriteUInt32(&decoding_time[i].sample_count) && buffer->ReadWriteUInt32(&decoding_time[i].sample_delta)); } return true; } -uint32 DecodingTimeToSample::ComputeSize() { - atom_size = kFullBoxSize + sizeof(uint32) + +uint32_t DecodingTimeToSample::ComputeSize() { + atom_size = kFullBoxSize + sizeof(uint32_t) + sizeof(DecodingTime) * decoding_time.size(); return atom_size; } @@ -459,25 +465,25 @@ CompositionTimeToSample::~CompositionTimeToSample() {} FourCC CompositionTimeToSample::BoxType() const { return FOURCC_CTTS; } bool CompositionTimeToSample::ReadWrite(BoxBuffer* buffer) { - uint32 count = composition_offset.size(); + uint32_t count = composition_offset.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&count)); composition_offset.resize(count); - for (uint32 i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { RCHECK(buffer->ReadWriteUInt32(&composition_offset[i].sample_count) && buffer->ReadWriteInt32(&composition_offset[i].sample_offset)); } return true; } -uint32 CompositionTimeToSample::ComputeSize() { +uint32_t CompositionTimeToSample::ComputeSize() { // Version 1 to support signed offset. version = 1; // This box is optional. Skip it if it is empty. atom_size = 0; if (!composition_offset.empty()) { - atom_size = kFullBoxSize + sizeof(uint32) + + atom_size = kFullBoxSize + sizeof(uint32_t) + sizeof(CompositionOffset) * composition_offset.size(); } return atom_size; @@ -488,12 +494,12 @@ SampleToChunk::~SampleToChunk() {} FourCC SampleToChunk::BoxType() const { return FOURCC_STSC; } bool SampleToChunk::ReadWrite(BoxBuffer* buffer) { - uint32 count = chunk_info.size(); + uint32_t count = chunk_info.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&count)); chunk_info.resize(count); - for (uint32 i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { RCHECK(buffer->ReadWriteUInt32(&chunk_info[i].first_chunk) && buffer->ReadWriteUInt32(&chunk_info[i].samples_per_chunk) && buffer->ReadWriteUInt32(&chunk_info[i].sample_description_index)); @@ -504,9 +510,9 @@ bool SampleToChunk::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SampleToChunk::ComputeSize() { +uint32_t SampleToChunk::ComputeSize() { atom_size = - kFullBoxSize + sizeof(uint32) + sizeof(ChunkInfo) * chunk_info.size(); + kFullBoxSize + sizeof(uint32_t) + sizeof(ChunkInfo) * chunk_info.size(); return atom_size; } @@ -524,15 +530,15 @@ bool SampleSize::ReadWrite(BoxBuffer* buffer) { sizes.resize(sample_count); else DCHECK(sample_count == sizes.size()); - for (uint32 i = 0; i < sample_count; ++i) + for (uint32_t i = 0; i < sample_count; ++i) RCHECK(buffer->ReadWriteUInt32(&sizes[i])); } return true; } -uint32 SampleSize::ComputeSize() { +uint32_t SampleSize::ComputeSize() { atom_size = kFullBoxSize + sizeof(sample_size) + sizeof(sample_count) + - (sample_size == 0 ? sizeof(uint32) * sizes.size() : 0); + (sample_size == 0 ? sizeof(uint32_t) * sizes.size() : 0); return atom_size; } @@ -541,7 +547,7 @@ CompactSampleSize::~CompactSampleSize() {} FourCC CompactSampleSize::BoxType() const { return FOURCC_STZ2; } bool CompactSampleSize::ReadWrite(BoxBuffer* buffer) { - uint32 sample_count = sizes.size(); + uint32_t sample_count = sizes.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->IgnoreBytes(3) && buffer->ReadWriteUInt8(&field_size) && @@ -551,30 +557,30 @@ bool CompactSampleSize::ReadWrite(BoxBuffer* buffer) { sizes.resize(sample_count + (field_size == 4 ? 1 : 0), 0); switch (field_size) { case 4: - for (uint32 i = 0; i < sample_count; i += 2) { + for (uint32_t i = 0; i < sample_count; i += 2) { if (buffer->Reading()) { - uint8 size = 0; + uint8_t size = 0; RCHECK(buffer->ReadWriteUInt8(&size)); sizes[i] = size >> 4; sizes[i + 1] = size & 0x0F; } else { DCHECK_LT(sizes[i], 16u); DCHECK_LT(sizes[i + 1], 16u); - uint8 size = (sizes[i] << 4) | sizes[i + 1]; + uint8_t size = (sizes[i] << 4) | sizes[i + 1]; RCHECK(buffer->ReadWriteUInt8(&size)); } } break; case 8: - for (uint32 i = 0; i < sample_count; ++i) { - uint8 size = sizes[i]; + for (uint32_t i = 0; i < sample_count; ++i) { + uint8_t size = sizes[i]; RCHECK(buffer->ReadWriteUInt8(&size)); sizes[i] = size; } break; case 16: - for (uint32 i = 0; i < sample_count; ++i) { - uint16 size = sizes[i]; + for (uint32_t i = 0; i < sample_count; ++i) { + uint16_t size = sizes[i]; RCHECK(buffer->ReadWriteUInt16(&size)); sizes[i] = size; } @@ -586,8 +592,8 @@ bool CompactSampleSize::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 CompactSampleSize::ComputeSize() { - atom_size = kFullBoxSize + sizeof(uint32) + sizeof(uint32) + +uint32_t CompactSampleSize::ComputeSize() { + atom_size = kFullBoxSize + sizeof(uint32_t) + sizeof(uint32_t) + (field_size * sizes.size() + 7) / 8; return atom_size; } @@ -597,18 +603,19 @@ ChunkOffset::~ChunkOffset() {} FourCC ChunkOffset::BoxType() const { return FOURCC_STCO; } bool ChunkOffset::ReadWrite(BoxBuffer* buffer) { - uint32 count = offsets.size(); + uint32_t count = offsets.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&count)); offsets.resize(count); - for (uint32 i = 0; i < count; ++i) - RCHECK(buffer->ReadWriteUInt64NBytes(&offsets[i], sizeof(uint32))); + for (uint32_t i = 0; i < count; ++i) + RCHECK(buffer->ReadWriteUInt64NBytes(&offsets[i], sizeof(uint32_t))); return true; } -uint32 ChunkOffset::ComputeSize() { - atom_size = kFullBoxSize + sizeof(uint32) + sizeof(uint32) * offsets.size(); +uint32_t ChunkOffset::ComputeSize() { + atom_size = + kFullBoxSize + sizeof(uint32_t) + sizeof(uint32_t) * offsets.size(); return atom_size; } @@ -617,7 +624,7 @@ ChunkLargeOffset::~ChunkLargeOffset() {} FourCC ChunkLargeOffset::BoxType() const { return FOURCC_CO64; } bool ChunkLargeOffset::ReadWrite(BoxBuffer* buffer) { - uint32 count = offsets.size(); + uint32_t count = offsets.size(); if (!buffer->Reading()) { // Switch to ChunkOffset box if it is able to fit in 32 bits offset. @@ -635,17 +642,17 @@ bool ChunkLargeOffset::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteUInt32(&count)); offsets.resize(count); - for (uint32 i = 0; i < count; ++i) + for (uint32_t i = 0; i < count; ++i) RCHECK(buffer->ReadWriteUInt64(&offsets[i])); return true; } -uint32 ChunkLargeOffset::ComputeSize() { - uint32 count = offsets.size(); +uint32_t ChunkLargeOffset::ComputeSize() { + uint32_t count = offsets.size(); int use_large_offset = (count > 0 && !IsFitIn32Bits(offsets[count - 1])) ? 1 : 0; atom_size = kFullBoxSize + sizeof(count) + - sizeof(uint32) * (1 + use_large_offset) * offsets.size(); + sizeof(uint32_t) * (1 + use_large_offset) * offsets.size(); return atom_size; } @@ -654,22 +661,22 @@ SyncSample::~SyncSample() {} FourCC SyncSample::BoxType() const { return FOURCC_STSS; } bool SyncSample::ReadWrite(BoxBuffer* buffer) { - uint32 count = sample_number.size(); + uint32_t count = sample_number.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&count)); sample_number.resize(count); - for (uint32 i = 0; i < count; ++i) + for (uint32_t i = 0; i < count; ++i) RCHECK(buffer->ReadWriteUInt32(&sample_number[i])); return true; } -uint32 SyncSample::ComputeSize() { +uint32_t SyncSample::ComputeSize() { // Sync sample box is optional. Skip it if it is empty. atom_size = 0; if (!sample_number.empty()) { - atom_size = - kFullBoxSize + sizeof(uint32) + sizeof(uint32) * sample_number.size(); + atom_size = kFullBoxSize + sizeof(uint32_t) + + sizeof(uint32_t) * sample_number.size(); } return atom_size; } @@ -717,7 +724,7 @@ bool SampleTable::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SampleTable::ComputeSize() { +uint32_t SampleTable::ComputeSize() { atom_size = kBoxSize + description.ComputeSize() + decoding_time_to_sample.ComputeSize() + composition_time_to_sample.ComputeSize() + @@ -731,12 +738,12 @@ EditList::~EditList() {} FourCC EditList::BoxType() const { return FOURCC_ELST; } bool EditList::ReadWrite(BoxBuffer* buffer) { - uint32 count = edits.size(); + uint32_t count = edits.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&count)); edits.resize(count); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); - for (uint32 i = 0; i < count; ++i) { + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); + for (uint32_t i = 0; i < count; ++i) { RCHECK( buffer->ReadWriteUInt64NBytes(&edits[i].segment_duration, num_bytes) && buffer->ReadWriteInt64NBytes(&edits[i].media_time, num_bytes) && @@ -746,22 +753,22 @@ bool EditList::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 EditList::ComputeSize() { +uint32_t EditList::ComputeSize() { // EditList box is optional. Skip it if it is empty. atom_size = 0; if (edits.empty()) return 0; version = 0; - for (uint32 i = 0; i < edits.size(); ++i) { + for (uint32_t i = 0; i < edits.size(); ++i) { if (!IsFitIn32Bits(edits[i].segment_duration, edits[i].media_time)) { version = 1; break; } } - atom_size = - kFullBoxSize + sizeof(uint32) + - (sizeof(uint32) * (1 + version) * 2 + sizeof(int16) * 2) * edits.size(); + atom_size = kFullBoxSize + sizeof(uint32_t) + + (sizeof(uint32_t) * (1 + version) * 2 + sizeof(int16_t) * 2) * + edits.size(); return atom_size; } @@ -775,7 +782,7 @@ bool Edit::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteChild(&list); } -uint32 Edit::ComputeSize() { +uint32_t Edit::ComputeSize() { // Edit box is optional. Skip it if it is empty. atom_size = 0; if (!list.edits.empty()) @@ -789,7 +796,7 @@ FourCC HandlerReference::BoxType() const { return FOURCC_HDLR; } bool HandlerReference::ReadWrite(BoxBuffer* buffer) { FourCC hdlr_type = FOURCC_NULL; - std::vector handler_name; + std::vector handler_name; if (!buffer->Reading()) { if (type == kVideo) { hdlr_type = FOURCC_VIDE; @@ -823,7 +830,7 @@ bool HandlerReference::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 HandlerReference::ComputeSize() { +uint32_t HandlerReference::ComputeSize() { atom_size = kFullBoxSize + kFourCCSize + 16 + // 16 bytes Reserved (type == kVideo ? sizeof(kVideoHandlerName) : sizeof(kAudioHandlerName)); @@ -858,28 +865,28 @@ bool AVCDecoderConfigurationRecord::ParseData(BufferReader* reader) { reader->Read1(&profile_compatibility) && reader->Read1(&avc_level)); - uint8 length_size_minus_one; + uint8_t length_size_minus_one; RCHECK(reader->Read1(&length_size_minus_one) && (length_size_minus_one & 0xfc) == 0xfc); length_size = (length_size_minus_one & 0x3) + 1; - uint8 num_sps; + uint8_t num_sps; RCHECK(reader->Read1(&num_sps) && (num_sps & 0xe0) == 0xe0); num_sps &= 0x1f; sps_list.resize(num_sps); for (int i = 0; i < num_sps; i++) { - uint16 sps_length; + uint16_t sps_length; RCHECK(reader->Read2(&sps_length) && reader->ReadToVector(&sps_list[i], sps_length)); } - uint8 num_pps; + uint8_t num_pps; RCHECK(reader->Read1(&num_pps)); pps_list.resize(num_pps); for (int i = 0; i < num_pps; i++) { - uint16 pps_length; + uint16_t pps_length; RCHECK(reader->Read2(&pps_length) && reader->ReadToVector(&pps_list[i], pps_length)); } @@ -887,7 +894,7 @@ bool AVCDecoderConfigurationRecord::ParseData(BufferReader* reader) { return true; } -uint32 AVCDecoderConfigurationRecord::ComputeSize() { +uint32_t AVCDecoderConfigurationRecord::ComputeSize() { atom_size = 0; if (!data.empty()) atom_size = kBoxSize + data.size(); @@ -905,7 +912,7 @@ bool PixelAspectRatioBox::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 PixelAspectRatioBox::ComputeSize() { +uint32_t PixelAspectRatioBox::ComputeSize() { // This box is optional. Skip it if it is not initialized. atom_size = 0; if (h_spacing != 0 || v_spacing != 0) { @@ -935,10 +942,10 @@ bool VideoSampleEntry::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteFourCC(&format)); } - uint32 video_resolution = kVideoResolution; - uint16 video_frame_count = kVideoFrameCount; - uint16 video_depth = kVideoDepth; - int16 predefined = -1; + uint32_t video_resolution = kVideoResolution; + uint16_t video_frame_count = kVideoFrameCount; + uint16_t video_depth = kVideoDepth; + int16_t predefined = -1; RCHECK(buffer->IgnoreBytes(6) && // reserved. buffer->ReadWriteUInt16(&data_reference_index) && buffer->IgnoreBytes(16) && // predefined 0. @@ -975,7 +982,7 @@ bool VideoSampleEntry::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 VideoSampleEntry::ComputeSize() { +uint32_t VideoSampleEntry::ComputeSize() { atom_size = kBoxSize + sizeof(data_reference_index) + sizeof(width) + sizeof(height) + sizeof(kVideoResolution) * 2 + sizeof(kVideoFrameCount) + sizeof(kVideoDepth) + @@ -992,7 +999,7 @@ FourCC ElementaryStreamDescriptor::BoxType() const { return FOURCC_ESDS; } bool ElementaryStreamDescriptor::ReadWrite(BoxBuffer* buffer) { RCHECK(FullBox::ReadWrite(buffer)); if (buffer->Reading()) { - std::vector data; + std::vector data; RCHECK(buffer->ReadWriteVector(&data, buffer->Size() - buffer->Pos())); RCHECK(es_descriptor.Parse(data)); if (es_descriptor.IsAAC()) { @@ -1006,7 +1013,7 @@ bool ElementaryStreamDescriptor::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 ElementaryStreamDescriptor::ComputeSize() { +uint32_t ElementaryStreamDescriptor::ComputeSize() { // This box is optional. Skip it if not initialized. atom_size = 0; if (es_descriptor.object_type() != kForbidden) @@ -1069,7 +1076,7 @@ bool AudioSampleEntry::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 AudioSampleEntry::ComputeSize() { +uint32_t AudioSampleEntry::ComputeSize() { atom_size = kBoxSize + sizeof(data_reference_index) + sizeof(channelcount) + sizeof(samplesize) + sizeof(samplerate) + sinf.ComputeSize() + esds.ComputeSize() + 6 + 8 + // 6 + 8 bytes reserved. @@ -1087,7 +1094,7 @@ FourCC MediaHeader::BoxType() const { return FOURCC_MDHD; } bool MediaHeader::ReadWrite(BoxBuffer* buffer) { RCHECK(FullBox::ReadWrite(buffer)); - uint8 num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); + uint8_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); RCHECK(buffer->ReadWriteUInt64NBytes(&creation_time, num_bytes) && buffer->ReadWriteUInt64NBytes(&modification_time, num_bytes) && buffer->ReadWriteUInt32(×cale) && @@ -1096,7 +1103,7 @@ bool MediaHeader::ReadWrite(BoxBuffer* buffer) { if (buffer->Reading()) { // Read language codes into temp first then use BitReader to read the // values. ISO-639-2/T language code: unsigned int(5)[3] language (2 bytes). - std::vector temp; + std::vector temp; RCHECK(buffer->ReadWriteVector(&temp, 2)); BitReader bit_reader(&temp[0], 2); @@ -1113,7 +1120,7 @@ bool MediaHeader::ReadWrite(BoxBuffer* buffer) { strcpy(language, kUndefinedLanguage); // Lang format: bit(1) pad, unsigned int(5)[3] language. - uint16 lang = 0; + uint16_t lang = 0; for (int i = 0; i < 3; ++i) lang |= (language[i] - 0x60) << ((2 - i) * 5); RCHECK(buffer->ReadWriteUInt16(&lang)); @@ -1123,17 +1130,17 @@ bool MediaHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 MediaHeader::ComputeSize() { +uint32_t MediaHeader::ComputeSize() { version = IsFitIn32Bits(creation_time, modification_time, duration) ? 0 : 1; atom_size = kFullBoxSize + sizeof(timescale) + - sizeof(uint32) * (1 + version) * 3 + 2 + // 2 bytes language. - 2; // 2 bytes predefined. + sizeof(uint32_t) * (1 + version) * 3 + 2 + // 2 bytes language. + 2; // 2 bytes predefined. return atom_size; } VideoMediaHeader::VideoMediaHeader() : graphicsmode(0), opcolor_red(0), opcolor_green(0), opcolor_blue(0) { - const uint32 kVideoMediaHeaderFlags = 1; + const uint32_t kVideoMediaHeaderFlags = 1; flags = kVideoMediaHeaderFlags; } VideoMediaHeader::~VideoMediaHeader() {} @@ -1147,7 +1154,7 @@ bool VideoMediaHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 VideoMediaHeader::ComputeSize() { +uint32_t VideoMediaHeader::ComputeSize() { atom_size = kFullBoxSize + sizeof(graphicsmode) + sizeof(opcolor_red) + sizeof(opcolor_green) + sizeof(opcolor_blue); return atom_size; @@ -1163,13 +1170,13 @@ bool SoundMediaHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SoundMediaHeader::ComputeSize() { - atom_size = kFullBoxSize + sizeof(balance) + sizeof(uint16); +uint32_t SoundMediaHeader::ComputeSize() { + atom_size = kFullBoxSize + sizeof(balance) + sizeof(uint16_t); return atom_size; } DataEntryUrl::DataEntryUrl() { - const uint32 kDataEntryUrlFlags = 1; + const uint32_t kDataEntryUrlFlags = 1; flags = kDataEntryUrlFlags; } DataEntryUrl::~DataEntryUrl() {} @@ -1184,7 +1191,7 @@ bool DataEntryUrl::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 DataEntryUrl::ComputeSize() { +uint32_t DataEntryUrl::ComputeSize() { atom_size = kBoxSize + sizeof(flags) + location.size(); return atom_size; } @@ -1196,20 +1203,20 @@ DataReference::DataReference() { DataReference::~DataReference() {} FourCC DataReference::BoxType() const { return FOURCC_DREF; } bool DataReference::ReadWrite(BoxBuffer* buffer) { - uint32 entry_count = data_entry.size(); + uint32_t entry_count = data_entry.size(); RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt32(&entry_count)); data_entry.resize(entry_count); RCHECK(buffer->PrepareChildren()); - for (uint32 i = 0; i < entry_count; ++i) + for (uint32_t i = 0; i < entry_count; ++i) RCHECK(buffer->ReadWriteChild(&data_entry[i])); return true; } -uint32 DataReference::ComputeSize() { - uint32 count = data_entry.size(); +uint32_t DataReference::ComputeSize() { + uint32_t count = data_entry.size(); atom_size = kFullBoxSize + sizeof(count); - for (uint32 i = 0; i < count; ++i) + for (uint32_t i = 0; i < count; ++i) atom_size += data_entry[i].ComputeSize(); return atom_size; } @@ -1224,7 +1231,7 @@ bool DataInformation::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteChild(&dref); } -uint32 DataInformation::ComputeSize() { +uint32_t DataInformation::ComputeSize() { atom_size = kBoxSize + dref.ComputeSize(); return atom_size; } @@ -1248,7 +1255,7 @@ bool MediaInformation::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 MediaInformation::ComputeSize() { +uint32_t MediaInformation::ComputeSize() { atom_size = kBoxSize + dinf.ComputeSize() + sample_table.ComputeSize(); if (sample_table.description.type == kVideo) atom_size += vmhd.ComputeSize(); @@ -1281,7 +1288,7 @@ bool Media::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 Media::ComputeSize() { +uint32_t Media::ComputeSize() { atom_size = kBoxSize + header.ComputeSize() + handler.ComputeSize() + information.ComputeSize(); return atom_size; @@ -1300,7 +1307,7 @@ bool Track::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 Track::ComputeSize() { +uint32_t Track::ComputeSize() { atom_size = kBoxSize + header.ComputeSize() + media.ComputeSize() + edit.ComputeSize(); return atom_size; @@ -1312,17 +1319,17 @@ FourCC MovieExtendsHeader::BoxType() const { return FOURCC_MEHD; } bool MovieExtendsHeader::ReadWrite(BoxBuffer* buffer) { RCHECK(FullBox::ReadWrite(buffer)); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); RCHECK(buffer->ReadWriteUInt64NBytes(&fragment_duration, num_bytes)); return true; } -uint32 MovieExtendsHeader::ComputeSize() { +uint32_t MovieExtendsHeader::ComputeSize() { atom_size = 0; // This box is optional. Skip it if it is not used. if (fragment_duration != 0) { version = IsFitIn32Bits(fragment_duration) ? 0 : 1; - atom_size = kFullBoxSize + sizeof(uint32) * (1 + version); + atom_size = kFullBoxSize + sizeof(uint32_t) * (1 + version); } return atom_size; } @@ -1346,7 +1353,7 @@ bool TrackExtends::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 TrackExtends::ComputeSize() { +uint32_t TrackExtends::ComputeSize() { atom_size = kFullBoxSize + sizeof(track_id) + sizeof(default_sample_description_index) + sizeof(default_sample_duration) + sizeof(default_sample_size) + @@ -1366,18 +1373,18 @@ bool MovieExtends::ReadWrite(BoxBuffer* buffer) { DCHECK(buffer->reader()); RCHECK(buffer->reader()->ReadChildren(&tracks)); } else { - for (uint32 i = 0; i < tracks.size(); ++i) + for (uint32_t i = 0; i < tracks.size(); ++i) RCHECK(tracks[i].ReadWrite(buffer)); } return true; } -uint32 MovieExtends::ComputeSize() { +uint32_t MovieExtends::ComputeSize() { // This box is optional. Skip it if it does not contain any track. atom_size = 0; if (tracks.size() != 0) { atom_size = kBoxSize + header.ComputeSize(); - for (uint32 i = 0; i < tracks.size(); ++i) + for (uint32_t i = 0; i < tracks.size(); ++i) atom_size += tracks[i].ComputeSize(); } return atom_size; @@ -1398,19 +1405,19 @@ bool Movie::ReadWrite(BoxBuffer* buffer) { RCHECK(reader->ReadChildren(&tracks) && reader->TryReadChildren(&pssh)); } else { - for (uint32 i = 0; i < tracks.size(); ++i) + for (uint32_t i = 0; i < tracks.size(); ++i) RCHECK(tracks[i].ReadWrite(buffer)); - for (uint32 i = 0; i < pssh.size(); ++i) + for (uint32_t i = 0; i < pssh.size(); ++i) RCHECK(pssh[i].ReadWrite(buffer)); } return true; } -uint32 Movie::ComputeSize() { +uint32_t Movie::ComputeSize() { atom_size = kBoxSize + header.ComputeSize() + extends.ComputeSize(); - for (uint32 i = 0; i < tracks.size(); ++i) + for (uint32_t i = 0; i < tracks.size(); ++i) atom_size += tracks[i].ComputeSize(); - for (uint32 i = 0; i < pssh.size(); ++i) + for (uint32_t i = 0; i < pssh.size(); ++i) atom_size += pssh[i].ComputeSize(); return atom_size; } @@ -1421,14 +1428,14 @@ FourCC TrackFragmentDecodeTime::BoxType() const { return FOURCC_TFDT; } bool TrackFragmentDecodeTime::ReadWrite(BoxBuffer* buffer) { RCHECK(FullBox::ReadWrite(buffer)); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); RCHECK(buffer->ReadWriteUInt64NBytes(&decode_time, num_bytes)); return true; } -uint32 TrackFragmentDecodeTime::ComputeSize() { +uint32_t TrackFragmentDecodeTime::ComputeSize() { version = IsFitIn32Bits(decode_time) ? 0 : 1; - atom_size = kFullBoxSize + sizeof(uint32) * (1 + version); + atom_size = kFullBoxSize + sizeof(uint32_t) * (1 + version); return atom_size; } @@ -1441,7 +1448,7 @@ bool MovieFragmentHeader::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteUInt32(&sequence_number); } -uint32 MovieFragmentHeader::ComputeSize() { +uint32_t MovieFragmentHeader::ComputeSize() { atom_size = kFullBoxSize + sizeof(sequence_number); return atom_size; } @@ -1495,7 +1502,7 @@ bool TrackFragmentHeader::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 TrackFragmentHeader::ComputeSize() { +uint32_t TrackFragmentHeader::ComputeSize() { atom_size = kFullBoxSize + sizeof(track_id); if (flags & kSampleDescriptionIndexPresentMask) atom_size += sizeof(sample_description_index); @@ -1536,7 +1543,7 @@ bool TrackFragmentRun::ReadWrite(BoxBuffer* buffer) { NOTIMPLEMENTED(); } - uint32 first_sample_flags; + uint32_t first_sample_flags; if (buffer->Reading()) { if (first_sample_flags_present) @@ -1567,7 +1574,7 @@ bool TrackFragmentRun::ReadWrite(BoxBuffer* buffer) { DCHECK(sample_composition_time_offsets.size() == sample_count); } - for (uint32 i = 0; i < sample_count; ++i) { + for (uint32_t i = 0; i < sample_count; ++i) { if (sample_duration_present) RCHECK(buffer->ReadWriteUInt32(&sample_durations[i])); if (sample_size_present) @@ -1590,18 +1597,18 @@ bool TrackFragmentRun::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 TrackFragmentRun::ComputeSize() { +uint32_t TrackFragmentRun::ComputeSize() { version = 1; // Version 1 to support signed offset. atom_size = kFullBoxSize + sizeof(sample_count); if (flags & kDataOffsetPresentMask) atom_size += sizeof(data_offset); if (flags & kFirstSampleFlagsPresentMask) - atom_size += sizeof(uint32); - uint32 fields = (flags & kSampleDurationPresentMask ? 1 : 0) + - (flags & kSampleSizePresentMask ? 1 : 0) + - (flags & kSampleFlagsPresentMask ? 1 : 0) + - (flags & kSampleCompTimeOffsetsPresentMask ? 1 : 0); - atom_size += fields * sizeof(uint32) * sample_count; + atom_size += sizeof(uint32_t); + uint32_t fields = (flags & kSampleDurationPresentMask ? 1 : 0) + + (flags & kSampleSizePresentMask ? 1 : 0) + + (flags & kSampleFlagsPresentMask ? 1 : 0) + + (flags & kSampleCompTimeOffsetsPresentMask ? 1 : 0); + atom_size += fields * sizeof(uint32_t) * sample_count; return atom_size; } @@ -1621,23 +1628,23 @@ bool SampleToGroup::ReadWrite(BoxBuffer* buffer) { return true; } - uint32 count = entries.size(); + uint32_t count = entries.size(); RCHECK(buffer->ReadWriteUInt32(&count)); entries.resize(count); - for (uint32 i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { RCHECK(buffer->ReadWriteUInt32(&entries[i].sample_count) && buffer->ReadWriteUInt32(&entries[i].group_description_index)); } return true; } -uint32 SampleToGroup::ComputeSize() { +uint32_t SampleToGroup::ComputeSize() { // This box is optional. Skip it if it is not used. atom_size = 0; if (!entries.empty()) { atom_size = kFullBoxSize + sizeof(grouping_type) + (version == 1 ? sizeof(grouping_type_parameter) : 0) + - sizeof(uint32) + entries.size() * sizeof(entries[0]); + sizeof(uint32_t) + entries.size() * sizeof(entries[0]); } return atom_size; } @@ -1662,8 +1669,8 @@ bool SampleGroupDescription::ReadWrite(BoxBuffer* buffer) { } const size_t kKeyIdSize = 16; - const size_t kEntrySize = sizeof(uint32) + kKeyIdSize; - uint32 default_length = 0; + const size_t kEntrySize = sizeof(uint32_t) + kKeyIdSize; + uint32_t default_length = 0; if (version == 1) { if (buffer->Reading()) { RCHECK(buffer->ReadWriteUInt32(&default_length)); @@ -1674,13 +1681,13 @@ bool SampleGroupDescription::ReadWrite(BoxBuffer* buffer) { } } - uint32 count = entries.size(); + uint32_t count = entries.size(); RCHECK(buffer->ReadWriteUInt32(&count)); entries.resize(count); - for (uint32 i = 0; i < count; ++i) { + for (uint32_t i = 0; i < count; ++i) { if (version == 1) { if (buffer->Reading() && default_length == 0) { - uint32 description_length = 0; + uint32_t description_length = 0; RCHECK(buffer->ReadWriteUInt32(&description_length)); RCHECK(description_length >= kEntrySize); } @@ -1689,7 +1696,7 @@ bool SampleGroupDescription::ReadWrite(BoxBuffer* buffer) { if (!buffer->Reading()) RCHECK(entries[i].key_id.size() == kKeyIdSize); - uint8 flag = entries[i].is_encrypted ? 1 : 0; + uint8_t flag = entries[i].is_encrypted ? 1 : 0; RCHECK(buffer->IgnoreBytes(2) && // reserved. buffer->ReadWriteUInt8(&flag) && buffer->ReadWriteUInt8(&entries[i].iv_size) && @@ -1707,17 +1714,17 @@ bool SampleGroupDescription::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SampleGroupDescription::ComputeSize() { +uint32_t SampleGroupDescription::ComputeSize() { // Version 0 is obsoleted, so always generate version 1 box. version = 1; // This box is optional. Skip it if it is not used. atom_size = 0; if (!entries.empty()) { const size_t kKeyIdSize = 16; - const size_t kEntrySize = sizeof(uint32) + kKeyIdSize; + const size_t kEntrySize = sizeof(uint32_t) + kKeyIdSize; atom_size = kFullBoxSize + sizeof(grouping_type) + - (version == 1 ? sizeof(uint32) : 0) + - sizeof(uint32) + entries.size() * kEntrySize; + (version == 1 ? sizeof(uint32_t) : 0) + sizeof(uint32_t) + + entries.size() * kEntrySize; } return atom_size; } @@ -1749,7 +1756,7 @@ bool TrackFragment::ReadWrite(BoxBuffer* buffer) { RCHECK(buffer->reader()->ReadChild(&sample_group_description)); } } else { - for (uint32 i = 0; i < runs.size(); ++i) + for (uint32_t i = 0; i < runs.size(); ++i) RCHECK(runs[i].ReadWrite(buffer)); RCHECK(buffer->TryReadWriteChild(&sample_to_group) && buffer->TryReadWriteChild(&sample_group_description)); @@ -1758,12 +1765,12 @@ bool TrackFragment::ReadWrite(BoxBuffer* buffer) { buffer->TryReadWriteChild(&auxiliary_offset); } -uint32 TrackFragment::ComputeSize() { +uint32_t TrackFragment::ComputeSize() { atom_size = kBoxSize + header.ComputeSize() + decode_time.ComputeSize() + sample_to_group.ComputeSize() + sample_group_description.ComputeSize() + auxiliary_size.ComputeSize() + auxiliary_offset.ComputeSize(); - for (uint32 i = 0; i < runs.size(); ++i) + for (uint32_t i = 0; i < runs.size(); ++i) atom_size += runs[i].ComputeSize(); return atom_size; } @@ -1782,19 +1789,19 @@ bool MovieFragment::ReadWrite(BoxBuffer* buffer) { RCHECK(reader->ReadChildren(&tracks) && reader->TryReadChildren(&pssh)); } else { - for (uint32 i = 0; i < tracks.size(); ++i) + for (uint32_t i = 0; i < tracks.size(); ++i) RCHECK(tracks[i].ReadWrite(buffer)); - for (uint32 i = 0; i < pssh.size(); ++i) + for (uint32_t i = 0; i < pssh.size(); ++i) RCHECK(pssh[i].ReadWrite(buffer)); } return true; } -uint32 MovieFragment::ComputeSize() { +uint32_t MovieFragment::ComputeSize() { atom_size = kBoxSize + header.ComputeSize(); - for (uint32 i = 0; i < tracks.size(); ++i) + for (uint32_t i = 0; i < tracks.size(); ++i) atom_size += tracks[i].ComputeSize(); - for (uint32 i = 0; i < pssh.size(); ++i) + for (uint32_t i = 0; i < pssh.size(); ++i) atom_size += pssh[i].ComputeSize(); return atom_size; } @@ -1812,19 +1819,19 @@ bool SegmentIndex::ReadWrite(BoxBuffer* buffer) { buffer->ReadWriteUInt32(&reference_id) && buffer->ReadWriteUInt32(×cale)); - size_t num_bytes = (version == 1) ? sizeof(uint64) : sizeof(uint32); + size_t num_bytes = (version == 1) ? sizeof(uint64_t) : sizeof(uint32_t); RCHECK( buffer->ReadWriteUInt64NBytes(&earliest_presentation_time, num_bytes) && buffer->ReadWriteUInt64NBytes(&first_offset, num_bytes)); - uint16 reference_count = references.size(); + uint16_t reference_count = references.size(); RCHECK(buffer->IgnoreBytes(2) && // reserved. buffer->ReadWriteUInt16(&reference_count)); references.resize(reference_count); - uint32 reference_type_size; - uint32 sap; - for (uint32 i = 0; i < reference_count; ++i) { + uint32_t reference_type_size; + uint32_t sap; + for (uint32_t i = 0; i < reference_count; ++i) { if (!buffer->Reading()) { reference_type_size = references[i].referenced_size; if (references[i].reference_type) @@ -1848,11 +1855,11 @@ bool SegmentIndex::ReadWrite(BoxBuffer* buffer) { return true; } -uint32 SegmentIndex::ComputeSize() { +uint32_t SegmentIndex::ComputeSize() { version = IsFitIn32Bits(earliest_presentation_time, first_offset) ? 0 : 1; atom_size = kFullBoxSize + sizeof(reference_id) + sizeof(timescale) + - sizeof(uint32) * (1 + version) * 2 + 2 * sizeof(uint16) + - 3 * sizeof(uint32) * references.size(); + sizeof(uint32_t) * (1 + version) * 2 + 2 * sizeof(uint16_t) + + 3 * sizeof(uint32_t) * references.size(); return atom_size; } @@ -1862,10 +1869,10 @@ FourCC MediaData::BoxType() const { return FOURCC_MDAT; } void MediaData::Write(BufferWriter* buffer) { buffer->AppendInt(ComputeSize()); - buffer->AppendInt(static_cast(BoxType())); + buffer->AppendInt(static_cast(BoxType())); } -uint32 MediaData::ComputeSize() { +uint32_t MediaData::ComputeSize() { return kBoxSize + data_size; } diff --git a/media/formats/mp4/box_definitions.h b/media/formats/mp4/box_definitions.h index a2c9d22b15..e4cddeb64a 100644 --- a/media/formats/mp4/box_definitions.h +++ b/media/formats/mp4/box_definitions.h @@ -34,13 +34,13 @@ class BoxBuffer; virtual ~T(); \ virtual bool ReadWrite(BoxBuffer* buffer) OVERRIDE; \ virtual FourCC BoxType() const OVERRIDE; \ - virtual uint32 ComputeSize() OVERRIDE; + virtual uint32_t ComputeSize() OVERRIDE; struct FileType : Box { DECLARE_BOX_METHODS(FileType); FourCC major_brand; - uint32 minor_version; + uint32_t minor_version; std::vector compatible_brands; }; @@ -51,23 +51,23 @@ struct SegmentType : FileType { struct ProtectionSystemSpecificHeader : FullBox { DECLARE_BOX_METHODS(ProtectionSystemSpecificHeader); - std::vector system_id; - std::vector data; - std::vector raw_box; + std::vector system_id; + std::vector data; + std::vector raw_box; }; struct SampleAuxiliaryInformationOffset : FullBox { DECLARE_BOX_METHODS(SampleAuxiliaryInformationOffset); - std::vector offsets; + std::vector offsets; }; struct SampleAuxiliaryInformationSize : FullBox { DECLARE_BOX_METHODS(SampleAuxiliaryInformationSize); - uint8 default_sample_info_size; - uint32 sample_count; - std::vector sample_info_sizes; + uint8_t default_sample_info_size; + uint32_t sample_count; + std::vector sample_info_sizes; }; struct OriginalFormat : Box { @@ -80,7 +80,7 @@ struct SchemeType : FullBox { DECLARE_BOX_METHODS(SchemeType); FourCC type; - uint32 version; + uint32_t version; }; struct TrackEncryption : FullBox { @@ -88,8 +88,8 @@ struct TrackEncryption : FullBox { // Note: this definition is specific to the CENC protection type. bool is_encrypted; - uint8 default_iv_size; - std::vector default_kid; + uint8_t default_iv_size; + std::vector default_kid; }; struct SchemeInfo : Box { @@ -109,13 +109,13 @@ struct ProtectionSchemeInfo : Box { struct MovieHeader : FullBox { DECLARE_BOX_METHODS(MovieHeader); - uint64 creation_time; - uint64 modification_time; - uint32 timescale; - uint64 duration; - int32 rate; - int16 volume; - uint32 next_track_id; + uint64_t creation_time; + uint64_t modification_time; + uint32_t timescale; + uint64_t duration; + int32_t rate; + int16_t volume; + uint32_t next_track_id; }; struct TrackHeader : FullBox { @@ -127,22 +127,22 @@ struct TrackHeader : FullBox { DECLARE_BOX_METHODS(TrackHeader); - uint64 creation_time; - uint64 modification_time; - uint32 track_id; - uint64 duration; - int16 layer; - int16 alternate_group; - int16 volume; - uint32 width; - uint32 height; + uint64_t creation_time; + uint64_t modification_time; + uint32_t track_id; + uint64_t duration; + int16_t layer; + int16_t alternate_group; + int16_t volume; + uint32_t width; + uint32_t height; }; struct EditListEntry { - uint64 segment_duration; - int64 media_time; - int16 media_rate_integer; - int16 media_rate_fraction; + uint64_t segment_duration; + int64_t media_time; + int16_t media_rate_integer; + int16_t media_rate_fraction; }; struct EditList : FullBox { @@ -171,16 +171,16 @@ struct AVCDecoderConfigurationRecord : Box { // 5.2.4.1, including possible extension bytes described in paragraph 3. // Known fields defined in the spec are also parsed and included in this // structure. - std::vector data; + std::vector data; - uint8 version; - uint8 profile_indication; - uint8 profile_compatibility; - uint8 avc_level; - uint8 length_size; + uint8_t version; + uint8_t profile_indication; + uint8_t profile_compatibility; + uint8_t avc_level; + uint8_t length_size; - typedef std::vector SPS; - typedef std::vector PPS; + typedef std::vector SPS; + typedef std::vector PPS; std::vector sps_list; std::vector pps_list; @@ -189,17 +189,17 @@ struct AVCDecoderConfigurationRecord : Box { struct PixelAspectRatioBox : Box { DECLARE_BOX_METHODS(PixelAspectRatioBox); - uint32 h_spacing; - uint32 v_spacing; + uint32_t h_spacing; + uint32_t v_spacing; }; struct VideoSampleEntry : Box { DECLARE_BOX_METHODS(VideoSampleEntry); FourCC format; - uint16 data_reference_index; - uint16 width; - uint16 height; + uint16_t data_reference_index; + uint16_t width; + uint16_t height; PixelAspectRatioBox pixel_aspect; ProtectionSchemeInfo sinf; @@ -219,10 +219,10 @@ struct AudioSampleEntry : Box { DECLARE_BOX_METHODS(AudioSampleEntry); FourCC format; - uint16 data_reference_index; - uint16 channelcount; - uint16 samplesize; - uint32 samplerate; + uint16_t data_reference_index; + uint16_t channelcount; + uint16_t samplesize; + uint32_t samplerate; ProtectionSchemeInfo sinf; ElementaryStreamDescriptor esds; @@ -237,8 +237,8 @@ struct SampleDescription : FullBox { }; struct DecodingTime { - uint32 sample_count; - uint32 sample_delta; + uint32_t sample_count; + uint32_t sample_delta; }; // stts. @@ -249,12 +249,12 @@ struct DecodingTimeToSample : FullBox { }; struct CompositionOffset { - uint32 sample_count; - // If version == 0, sample_offset is uint32; - // If version == 1, sample_offset is int32. + uint32_t sample_count; + // If version == 0, sample_offset is uint32_t; + // If version == 1, sample_offset is int32_t. // Always use signed version, which should work unless the offset // exceeds 31 bits, which shouldn't happen. - int32 sample_offset; + int32_t sample_offset; }; // ctts. Optional. @@ -265,9 +265,9 @@ struct CompositionTimeToSample : FullBox { }; struct ChunkInfo { - uint32 first_chunk; - uint32 samples_per_chunk; - uint32 sample_description_index; + uint32_t first_chunk; + uint32_t samples_per_chunk; + uint32_t sample_description_index; }; // stsc. @@ -281,24 +281,24 @@ struct SampleToChunk : FullBox { struct SampleSize : FullBox { DECLARE_BOX_METHODS(SampleSize); - uint32 sample_size; - uint32 sample_count; - std::vector sizes; + uint32_t sample_size; + uint32_t sample_count; + std::vector sizes; }; // stz2. struct CompactSampleSize : FullBox { DECLARE_BOX_METHODS(CompactSampleSize); - uint8 field_size; - std::vector sizes; + uint8_t field_size; + std::vector sizes; }; // co64. struct ChunkLargeOffset : FullBox { DECLARE_BOX_METHODS(ChunkLargeOffset); - std::vector offsets; + std::vector offsets; }; // stco. @@ -310,7 +310,7 @@ struct ChunkOffset : ChunkLargeOffset { struct SyncSample : FullBox { DECLARE_BOX_METHODS(SyncSample); - std::vector sample_number; + std::vector sample_number; }; struct SampleTable : Box { @@ -331,10 +331,10 @@ struct SampleTable : Box { struct MediaHeader : FullBox { DECLARE_BOX_METHODS(MediaHeader); - uint64 creation_time; - uint64 modification_time; - uint32 timescale; - uint64 duration; + uint64_t creation_time; + uint64_t modification_time; + uint32_t timescale; + uint64_t duration; // 3-char language code + 1 null terminating char. char language[4]; }; @@ -342,22 +342,22 @@ struct MediaHeader : FullBox { struct VideoMediaHeader : FullBox { DECLARE_BOX_METHODS(VideoMediaHeader); - uint16 graphicsmode; - uint16 opcolor_red; - uint16 opcolor_green; - uint16 opcolor_blue; + uint16_t graphicsmode; + uint16_t opcolor_red; + uint16_t opcolor_green; + uint16_t opcolor_blue; }; struct SoundMediaHeader : FullBox { DECLARE_BOX_METHODS(SoundMediaHeader); - uint16 balance; + uint16_t balance; }; struct DataEntryUrl : FullBox { DECLARE_BOX_METHODS(DataEntryUrl); - std::vector location; + std::vector location; }; struct DataReference : FullBox { @@ -402,17 +402,17 @@ struct Track : Box { struct MovieExtendsHeader : FullBox { DECLARE_BOX_METHODS(MovieExtendsHeader); - uint64 fragment_duration; + uint64_t fragment_duration; }; struct TrackExtends : FullBox { DECLARE_BOX_METHODS(TrackExtends); - uint32 track_id; - uint32 default_sample_description_index; - uint32 default_sample_duration; - uint32 default_sample_size; - uint32 default_sample_flags; + uint32_t track_id; + uint32_t default_sample_description_index; + uint32_t default_sample_duration; + uint32_t default_sample_size; + uint32_t default_sample_flags; }; struct MovieExtends : Box { @@ -434,13 +434,13 @@ struct Movie : Box { struct TrackFragmentDecodeTime : FullBox { DECLARE_BOX_METHODS(TrackFragmentDecodeTime); - uint64 decode_time; + uint64_t decode_time; }; struct MovieFragmentHeader : FullBox { DECLARE_BOX_METHODS(MovieFragmentHeader); - uint32 sequence_number; + uint32_t sequence_number; }; struct TrackFragmentHeader : FullBox { @@ -466,11 +466,11 @@ struct TrackFragmentHeader : FullBox { DECLARE_BOX_METHODS(TrackFragmentHeader); - uint32 track_id; - uint32 sample_description_index; - uint32 default_sample_duration; - uint32 default_sample_size; - uint32 default_sample_flags; + uint32_t track_id; + uint32_t sample_description_index; + uint32_t default_sample_duration; + uint32_t default_sample_size; + uint32_t default_sample_flags; }; struct TrackFragmentRun : FullBox { @@ -485,12 +485,12 @@ struct TrackFragmentRun : FullBox { DECLARE_BOX_METHODS(TrackFragmentRun); - uint32 sample_count; - uint32 data_offset; - std::vector sample_flags; - std::vector sample_sizes; - std::vector sample_durations; - std::vector sample_composition_time_offsets; + uint32_t sample_count; + uint32_t data_offset; + std::vector sample_flags; + std::vector sample_sizes; + std::vector sample_durations; + std::vector sample_composition_time_offsets; }; struct SampleToGroupEntry { @@ -499,15 +499,15 @@ struct SampleToGroupEntry { kTrackFragmentGroupDescriptionIndexBase = 0x10000, }; - uint32 sample_count; - uint32 group_description_index; + uint32_t sample_count; + uint32_t group_description_index; }; struct SampleToGroup : FullBox { DECLARE_BOX_METHODS(SampleToGroup); - uint32 grouping_type; - uint32 grouping_type_parameter; // Version 1 only. + uint32_t grouping_type; + uint32_t grouping_type_parameter; // Version 1 only. std::vector entries; }; @@ -516,14 +516,14 @@ struct CencSampleEncryptionInfoEntry { ~CencSampleEncryptionInfoEntry(); bool is_encrypted; - uint8 iv_size; - std::vector key_id; + uint8_t iv_size; + std::vector key_id; }; struct SampleGroupDescription : FullBox { DECLARE_BOX_METHODS(SampleGroupDescription); - uint32 grouping_type; + uint32_t grouping_type; std::vector entries; }; @@ -559,23 +559,23 @@ struct SegmentReference { }; bool reference_type; - uint32 referenced_size; - uint32 subsegment_duration; + uint32_t referenced_size; + uint32_t subsegment_duration; bool starts_with_sap; SAPType sap_type; - uint32 sap_delta_time; + uint32_t sap_delta_time; // We add this field to keep track of earliest_presentation_time in this // subsegment. It is not part of SegmentReference. - uint64 earliest_presentation_time; + uint64_t earliest_presentation_time; }; struct SegmentIndex : FullBox { DECLARE_BOX_METHODS(SegmentIndex); - uint32 reference_id; - uint32 timescale; - uint64 earliest_presentation_time; - uint64 first_offset; + uint32_t reference_id; + uint32_t timescale; + uint64_t earliest_presentation_time; + uint64_t first_offset; std::vector references; }; @@ -585,10 +585,10 @@ struct MediaData { MediaData(); ~MediaData(); void Write(BufferWriter* buffer_writer); - uint32 ComputeSize(); + uint32_t ComputeSize(); FourCC BoxType() const; - uint32 data_size; + uint32_t data_size; }; #undef DECLARE_BOX diff --git a/media/formats/mp4/box_definitions_unittest.cc b/media/formats/mp4/box_definitions_unittest.cc index 87487217b8..249ae8cc06 100644 --- a/media/formats/mp4/box_definitions_unittest.cc +++ b/media/formats/mp4/box_definitions_unittest.cc @@ -16,16 +16,16 @@ namespace edash_packager { namespace media { namespace mp4 { namespace { -const uint8 kData16Bytes[] = {8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8}; -const uint8 kData4[] = {1, 5, 4, 3, 15}; -const uint8 kData8[] = {1, 8, 42, 98, 156}; -const uint16 kData16[] = {1, 15, 45, 768, 60000}; -const uint32 kData32[] = {1, 24, 99, 1234, 9000000}; -const uint64 kData64[] = {1, 9000000, 12345678901234ULL, 56780909090900ULL}; +const uint8_t kData16Bytes[] = {8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8}; +const uint8_t kData4[] = {1, 5, 4, 3, 15}; +const uint8_t kData8[] = {1, 8, 42, 98, 156}; +const uint16_t kData16[] = {1, 15, 45, 768, 60000}; +const uint32_t kData32[] = {1, 24, 99, 1234, 9000000}; +const uint64_t kData64[] = {1, 9000000, 12345678901234ULL, 56780909090900ULL}; const TrackType kSampleDescriptionTrackType = kVideo; // 4-byte FourCC + 4-bytes size. -const uint32 kBoxSize = 8; +const uint32_t kBoxSize = 8; } // namespace template @@ -37,9 +37,9 @@ class BoxDefinitionsTestGeneral : public testing::Test { // Create a fake skip box contains the buffer and Write it. BufferWriter buffer; buffer.Swap(buffer_.get()); - uint32 skip_box_size = buffer.Size() + kBoxSize; + uint32_t skip_box_size = buffer.Size() + kBoxSize; buffer_->AppendInt(skip_box_size); - buffer_->AppendInt(static_cast(FOURCC_SKIP)); + buffer_->AppendInt(static_cast(FOURCC_SKIP)); buffer_->AppendBuffer(buffer); bool err = false; return BoxReader::ReadTopLevelBox(buffer_->Buffer(), buffer_->Size(), &err); @@ -106,11 +106,11 @@ class BoxDefinitionsTestGeneral : public testing::Test { bool IsOptional(const Box* box) { return false; } // Non-full box does not have version field. - uint8 GetAndClearVersion(Box* box) { return 0; } + uint8_t GetAndClearVersion(Box* box) { return 0; } // Get full box version and then reset it to 0. - uint8 GetAndClearVersion(FullBox* full_box) { - uint8 version = full_box->version; + uint8_t GetAndClearVersion(FullBox* full_box) { + uint8_t version = full_box->version; full_box->version = 0; return version; } @@ -273,7 +273,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { void Modify(PixelAspectRatioBox* pasp) { pasp->v_spacing *= 8; } void Fill(AVCDecoderConfigurationRecord* avcc) { - const uint8 kAvccData[] = { + const uint8_t kAvccData[] = { 0x01, 0x64, 0x00, 0x1f, 0xff, 0xe1, 0x00, 0x18, 0x67, 0x64, 0x00, 0x1f, 0xac, 0xd9, 0x40, 0x50, 0x05, 0xbb, 0x01, 0x10, 0x00, 0x00, 0x3e, 0x90, 0x00, 0x0e, 0xa6, 0x00, 0xf1, 0x83, 0x19, 0x60, 0x01, @@ -284,7 +284,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { } void Modify(AVCDecoderConfigurationRecord* avcc) { - const uint8 kAvccData[] = { + const uint8_t kAvccData[] = { 0x01, 0x64, 0x00, 0x1e, 0xff, 0xe1, 0x00, 0x19, 0x67, 0x64, 0x00, 0x1e, 0xac, 0xd9, 0x40, 0xa0, 0x2f, 0xf9, 0x70, 0x11, 0x00, 0x00, 0x03, 0x03, 0xe9, 0x00, 0x00, 0xea, 0x60, 0x0f, 0x16, 0x2d, 0x96, @@ -310,10 +310,10 @@ class BoxDefinitionsTestGeneral : public testing::Test { } void Fill(ElementaryStreamDescriptor* esds) { - const uint8 kDecoderSpecificInfo[] = {18, 16}; + const uint8_t kDecoderSpecificInfo[] = {18, 16}; esds->es_descriptor.set_esid(1); esds->es_descriptor.set_object_type(kISO_14496_3); - std::vector decoder_specific_info( + std::vector decoder_specific_info( kDecoderSpecificInfo, kDecoderSpecificInfo + sizeof(kDecoderSpecificInfo)); esds->es_descriptor.set_decoder_specific_info(decoder_specific_info); @@ -447,7 +447,7 @@ class BoxDefinitionsTestGeneral : public testing::Test { void Fill(MediaHeader* mdhd) { mdhd->creation_time = 124231432; - mdhd->modification_time = static_cast(kuint32max) + 1; + mdhd->modification_time = static_cast(kuint32max) + 1; mdhd->timescale = 50000; mdhd->duration = 250000; strcpy(mdhd->language, "abc"); @@ -812,7 +812,7 @@ TYPED_TEST_P(BoxDefinitionsTestGeneral, WriteModifyWrite) { this->Fill(&box); // Save the expected version set earlier in function |Fill|, then clear // the version, expecting box.Write set version as expected. - uint8 version = this->GetAndClearVersion(&box); + uint8_t version = this->GetAndClearVersion(&box); box.Write(this->buffer_.get()); EXPECT_EQ(version, this->GetAndClearVersion(&box)); diff --git a/media/formats/mp4/box_reader.cc b/media/formats/mp4/box_reader.cc index d350834dae..1e4a31817d 100644 --- a/media/formats/mp4/box_reader.cc +++ b/media/formats/mp4/box_reader.cc @@ -15,7 +15,7 @@ namespace edash_packager { namespace media { namespace mp4 { -BoxReader::BoxReader(const uint8* buf, size_t size) +BoxReader::BoxReader(const uint8_t* buf, size_t size) : BufferReader(buf, size), type_(FOURCC_NULL), scanned_(false) { DCHECK(buf); DCHECK_LT(0u, size); @@ -32,7 +32,7 @@ BoxReader::~BoxReader() { } // static -BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf, +BoxReader* BoxReader::ReadTopLevelBox(const uint8_t* buf, const size_t buf_size, bool* err) { scoped_ptr reader(new BoxReader(buf, buf_size)); @@ -55,10 +55,10 @@ BoxReader* BoxReader::ReadTopLevelBox(const uint8* buf, } // static -bool BoxReader::StartTopLevelBox(const uint8* buf, +bool BoxReader::StartTopLevelBox(const uint8_t* buf, const size_t buf_size, FourCC* type, - uint64* box_size, + uint64_t* box_size, bool* err) { BoxReader reader(buf, buf_size); if (!reader.ReadHeader(err)) @@ -142,10 +142,10 @@ bool BoxReader::TryReadChild(Box* child) { } bool BoxReader::ReadHeader(bool* err) { - uint64 size = 0; + uint64_t size = 0; *err = false; - if (!ReadNBytesInto8(&size, sizeof(uint32)) || !ReadFourCC(&type_)) + if (!ReadNBytesInto8(&size, sizeof(uint32_t)) || !ReadFourCC(&type_)) return false; if (size == 0) { @@ -170,7 +170,7 @@ bool BoxReader::ReadHeader(bool* err) { } // 'mdat' box could have a 64-bit size; other boxes should be very small. - if (size > static_cast(kint32max) && type_ != FOURCC_MDAT) { + if (size > static_cast(kint32max) && type_ != FOURCC_MDAT) { LOG(ERROR) << base::StringPrintf("Box '%s' size (%" PRIu64 ") is too large.", FourCCToString(type_).c_str(), diff --git a/media/formats/mp4/box_reader.h b/media/formats/mp4/box_reader.h index 456c0826df..43673eb8b2 100644 --- a/media/formats/mp4/box_reader.h +++ b/media/formats/mp4/box_reader.h @@ -35,7 +35,7 @@ class BoxReader : public BufferReader { /// function may return NULL if an intact, complete box is not /// available in the buffer. For MDAT box only, a BoxReader object is /// returned as long as the box header is available. - static BoxReader* ReadTopLevelBox(const uint8* buf, + static BoxReader* ReadTopLevelBox(const uint8_t* buf, const size_t buf_size, bool* err); @@ -48,10 +48,10 @@ class BoxReader : public BufferReader { /// reading the box. /// @return true if there is enough data to read the header and the header is /// sane, which does not imply that the entire box is in the buffer. - static bool StartTopLevelBox(const uint8* buf, + static bool StartTopLevelBox(const uint8_t* buf, const size_t buf_size, FourCC* type, - uint64* box_size, + uint64_t* box_size, bool* err) WARN_UNUSED_RESULT; /// @return true if @a type is recognized to be the fourcc of a top-level box, @@ -95,7 +95,7 @@ class BoxReader : public BufferReader { bool ReadAllChildren(std::vector* children) WARN_UNUSED_RESULT; bool ReadFourCC(FourCC* fourcc) { - uint32 val; + uint32_t val; if (!Read4(&val)) return false; *fourcc = static_cast(val); @@ -105,7 +105,7 @@ class BoxReader : public BufferReader { FourCC type() const { return type_; } private: - BoxReader(const uint8* buf, size_t size); + BoxReader(const uint8_t* buf, size_t size); // Must be called immediately after init. If the return is false, this // indicates that the box header and its contents were not available in the diff --git a/media/formats/mp4/box_reader_unittest.cc b/media/formats/mp4/box_reader_unittest.cc index 53b9dac61d..58db942c7c 100644 --- a/media/formats/mp4/box_reader_unittest.cc +++ b/media/formats/mp4/box_reader_unittest.cc @@ -15,7 +15,7 @@ namespace edash_packager { namespace media { namespace mp4 { -static const uint8 kSkipBox[] = { +static const uint8_t kSkipBox[] = { // Top-level test box containing three children. 0x00, 0x00, 0x00, 0x40, 's', 'k', 'i', 'p', 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xf9, 0x0a, 0x0b, 0x0c, 0xfd, 0x0e, 0x0f, 0x10, @@ -34,7 +34,7 @@ struct FreeBox : Box { return true; } virtual FourCC BoxType() const OVERRIDE { return FOURCC_FREE; } - virtual uint32 ComputeSize() OVERRIDE { + virtual uint32_t ComputeSize() OVERRIDE { NOTIMPLEMENTED(); return 0; } @@ -45,22 +45,20 @@ struct PsshBox : Box { return buffer->ReadWriteUInt32(&val); } virtual FourCC BoxType() const OVERRIDE { return FOURCC_PSSH; } - virtual uint32 ComputeSize() OVERRIDE { + virtual uint32_t ComputeSize() OVERRIDE { NOTIMPLEMENTED(); return 0; } - uint32 val; + uint32_t val; }; struct SkipBox : FullBox { virtual bool ReadWrite(BoxBuffer* buffer) OVERRIDE { - RCHECK(FullBox::ReadWrite(buffer) && - buffer->ReadWriteUInt8(&a) && - buffer->ReadWriteUInt8(&b) && - buffer->ReadWriteUInt16(&c) && + RCHECK(FullBox::ReadWrite(buffer) && buffer->ReadWriteUInt8(&a) && + buffer->ReadWriteUInt8(&b) && buffer->ReadWriteUInt16(&c) && buffer->ReadWriteInt32(&d) && - buffer->ReadWriteInt64NBytes(&e, sizeof(uint32))); + buffer->ReadWriteInt64NBytes(&e, sizeof(uint32_t))); RCHECK(buffer->PrepareChildren()); if (buffer->Reading()) { DCHECK(buffer->reader()); @@ -71,15 +69,15 @@ struct SkipBox : FullBox { return buffer->TryReadWriteChild(&empty); } virtual FourCC BoxType() const OVERRIDE { return FOURCC_SKIP; } - virtual uint32 ComputeSize() OVERRIDE { + virtual uint32_t ComputeSize() OVERRIDE { NOTIMPLEMENTED(); return 0; } - uint8 a, b; - uint16 c; - int32 d; - int64 e; + uint8_t a, b; + uint16_t c; + int32_t d; + int64_t e; std::vector kids; FreeBox empty; @@ -87,13 +85,13 @@ struct SkipBox : FullBox { class BoxReaderTest : public testing::Test { protected: - std::vector GetBuf() { - return std::vector(kSkipBox, kSkipBox + sizeof(kSkipBox)); + std::vector GetBuf() { + return std::vector(kSkipBox, kSkipBox + sizeof(kSkipBox)); } }; TEST_F(BoxReaderTest, ExpectedOperationTest) { - std::vector buf = GetBuf(); + std::vector buf = GetBuf(); bool err; scoped_ptr reader( BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err)); @@ -107,19 +105,19 @@ TEST_F(BoxReaderTest, ExpectedOperationTest) { EXPECT_EQ(0x05, box.a); EXPECT_EQ(0x06, box.b); EXPECT_EQ(0x0708, box.c); - EXPECT_EQ(static_cast(0xf90a0b0c), box.d); - EXPECT_EQ(static_cast(0xfd0e0f10), box.e); + EXPECT_EQ(static_cast(0xf90a0b0c), box.d); + EXPECT_EQ(static_cast(0xfd0e0f10), box.e); EXPECT_EQ(2u, box.kids.size()); EXPECT_EQ(0xdeadbeef, box.kids[0].val); EXPECT_EQ(0xfacecafe, box.kids[1].val); // Accounting for the extra byte outside of the box above. - EXPECT_EQ(buf.size(), static_cast(reader->size() + 1)); + EXPECT_EQ(buf.size(), static_cast(reader->size() + 1)); } TEST_F(BoxReaderTest, OuterTooShortTest) { - std::vector buf = GetBuf(); + std::vector buf = GetBuf(); bool err; // Create a soft failure by truncating the outer box. @@ -131,7 +129,7 @@ TEST_F(BoxReaderTest, OuterTooShortTest) { } TEST_F(BoxReaderTest, InnerTooLongTest) { - std::vector buf = GetBuf(); + std::vector buf = GetBuf(); bool err; // Make an inner box too big for its outer box. @@ -144,7 +142,7 @@ TEST_F(BoxReaderTest, InnerTooLongTest) { } TEST_F(BoxReaderTest, WrongFourCCTest) { - std::vector buf = GetBuf(); + std::vector buf = GetBuf(); bool err; // Set an unrecognized top-level FourCC. @@ -156,7 +154,7 @@ TEST_F(BoxReaderTest, WrongFourCCTest) { } TEST_F(BoxReaderTest, ScanChildrenTest) { - std::vector buf = GetBuf(); + std::vector buf = GetBuf(); bool err; scoped_ptr reader( BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &err)); @@ -178,7 +176,7 @@ TEST_F(BoxReaderTest, ScanChildrenTest) { } TEST_F(BoxReaderTest, ReadAllChildrenTest) { - std::vector buf = GetBuf(); + std::vector buf = GetBuf(); // Modify buffer to exclude its last 'free' box. buf[3] = 0x38; bool err; @@ -192,11 +190,17 @@ TEST_F(BoxReaderTest, ReadAllChildrenTest) { } TEST_F(BoxReaderTest, SkippingBloc) { - static const uint8 kData[] = {0x00, 0x00, 0x00, 0x09, // Box size. - 'b', 'l', 'o', 'c', // FourCC. - 0x00}; // Reserved byte. + static const uint8_t kData[] = {0x00, + 0x00, + 0x00, + 0x09, // Box size. + 'b', + 'l', + 'o', + 'c', // FourCC. + 0x00}; // Reserved byte. - std::vector buf(kData, kData + sizeof(kData)); + std::vector buf(kData, kData + sizeof(kData)); bool err; scoped_ptr reader( diff --git a/media/formats/mp4/cenc.cc b/media/formats/mp4/cenc.cc index 54fec8e5ee..bac477955c 100644 --- a/media/formats/mp4/cenc.cc +++ b/media/formats/mp4/cenc.cc @@ -16,7 +16,7 @@ namespace { bool IsIvSizeValid(size_t iv_size) { return iv_size == 8 || iv_size == 16; } // 16-bit |clear_bytes| and 32-bit |cipher_bytes|. -const size_t kSubsampleEntrySize = sizeof(uint16) + sizeof(uint32); +const size_t kSubsampleEntrySize = sizeof(uint16_t) + sizeof(uint32_t); } // namespace namespace edash_packager { @@ -24,10 +24,11 @@ namespace media { namespace mp4 { FrameCENCInfo::FrameCENCInfo() {} -FrameCENCInfo::FrameCENCInfo(const std::vector& iv) : iv_(iv) {} +FrameCENCInfo::FrameCENCInfo(const std::vector& iv) : iv_(iv) { +} FrameCENCInfo::~FrameCENCInfo() {} -bool FrameCENCInfo::Parse(uint8 iv_size, BufferReader* reader) { +bool FrameCENCInfo::Parse(uint8_t iv_size, BufferReader* reader) { DCHECK(reader); // Mandated by CENC spec. RCHECK(IsIvSizeValid(iv_size)); @@ -38,14 +39,14 @@ bool FrameCENCInfo::Parse(uint8 iv_size, BufferReader* reader) { if (!reader->HasBytes(1)) return true; - uint16 subsample_count; + uint16_t subsample_count; RCHECK(reader->Read2(&subsample_count) && reader->HasBytes(subsample_count * kSubsampleEntrySize)); subsamples_.resize(subsample_count); - for (uint16 i = 0; i < subsample_count; ++i) { - uint16 clear_bytes; - uint32 cipher_bytes; + for (uint16_t i = 0; i < subsample_count; ++i) { + uint16_t clear_bytes; + uint32_t cipher_bytes; RCHECK(reader->Read2(&clear_bytes) && reader->Read4(&cipher_bytes)); subsamples_[i].clear_bytes = clear_bytes; @@ -59,19 +60,19 @@ void FrameCENCInfo::Write(BufferWriter* writer) const { DCHECK(IsIvSizeValid(iv_.size())); writer->AppendVector(iv_); - uint16 subsample_count = subsamples_.size(); + uint16_t subsample_count = subsamples_.size(); if (subsample_count == 0) return; writer->AppendInt(subsample_count); - for (uint16 i = 0; i < subsample_count; ++i) { + for (uint16_t i = 0; i < subsample_count; ++i) { writer->AppendInt(subsamples_[i].clear_bytes); writer->AppendInt(subsamples_[i].cipher_bytes); } } size_t FrameCENCInfo::ComputeSize() const { - uint16 subsample_count = subsamples_.size(); + uint16_t subsample_count = subsamples_.size(); if (subsample_count == 0) return iv_.size(); diff --git a/media/formats/mp4/cenc.h b/media/formats/mp4/cenc.h index 24f2e1ee9e..c769f68438 100644 --- a/media/formats/mp4/cenc.h +++ b/media/formats/mp4/cenc.h @@ -21,10 +21,10 @@ namespace mp4 { class FrameCENCInfo { public: FrameCENCInfo(); - explicit FrameCENCInfo(const std::vector& iv); + explicit FrameCENCInfo(const std::vector& iv); ~FrameCENCInfo(); - bool Parse(uint8 iv_size, BufferReader* reader); + bool Parse(uint8_t iv_size, BufferReader* reader); void Write(BufferWriter* writer) const; size_t ComputeSize() const; size_t GetTotalSizeOfSubsamples() const; @@ -33,11 +33,11 @@ class FrameCENCInfo { subsamples_.push_back(subsample); } - const std::vector& iv() const { return iv_; } + const std::vector& iv() const { return iv_; } const std::vector& subsamples() const { return subsamples_; } private: - std::vector iv_; + std::vector iv_; std::vector subsamples_; // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler diff --git a/media/formats/mp4/chunk_info_iterator.cc b/media/formats/mp4/chunk_info_iterator.cc index a48f2e3e01..9d90148fc3 100644 --- a/media/formats/mp4/chunk_info_iterator.cc +++ b/media/formats/mp4/chunk_info_iterator.cc @@ -47,17 +47,17 @@ bool ChunkInfoIterator::IsValid() const { chunk_sample_index_ < iterator_->samples_per_chunk; } -uint32 ChunkInfoIterator::NumSamples(uint32 start_chunk, - uint32 end_chunk) const { +uint32_t ChunkInfoIterator::NumSamples(uint32_t start_chunk, + uint32_t end_chunk) const { DCHECK_LE(start_chunk, end_chunk); - uint32 last_chunk = 0; - uint32 num_samples = 0; + uint32_t last_chunk = 0; + uint32_t num_samples = 0; for (std::vector::const_iterator it = chunk_info_table_.begin(); it != chunk_info_table_.end(); ++it) { last_chunk = (it + 1 == chunk_info_table_.end()) - ? std::numeric_limits::max() + ? std::numeric_limits::max() : (it + 1)->first_chunk - 1; if (last_chunk >= start_chunk) { num_samples += (std::min(end_chunk, last_chunk) - diff --git a/media/formats/mp4/chunk_info_iterator.h b/media/formats/mp4/chunk_info_iterator.h index eee2d5af74..9fc3b0f445 100644 --- a/media/formats/mp4/chunk_info_iterator.h +++ b/media/formats/mp4/chunk_info_iterator.h @@ -36,29 +36,29 @@ class ChunkInfoIterator { bool IsValid() const; /// @return Current chunk. - uint32 current_chunk() const { return current_chunk_; } + uint32_t current_chunk() const { return current_chunk_; } /// @return Samples per chunk for current chunk. - uint32 samples_per_chunk() const { return iterator_->samples_per_chunk; } + uint32_t samples_per_chunk() const { return iterator_->samples_per_chunk; } /// @return Sample description index for current chunk. - uint32 sample_description_index() const { + uint32_t sample_description_index() const { return iterator_->sample_description_index; } /// @return Number of samples from start_chunk to end_chunk, both 1-based, /// inclusive. - uint32 NumSamples(uint32 start_chunk, uint32 end_chunk) const; + uint32_t NumSamples(uint32_t start_chunk, uint32_t end_chunk) const; /// @return The last first_chunk in chunk_info_table. - uint32 LastFirstChunk() const { + uint32_t LastFirstChunk() const { return chunk_info_table_.empty() ? 0 : chunk_info_table_.back().first_chunk; } private: - uint32 chunk_sample_index_; - uint32 current_chunk_; + uint32_t chunk_sample_index_; + uint32_t current_chunk_; const std::vector& chunk_info_table_; std::vector::const_iterator iterator_; diff --git a/media/formats/mp4/chunk_info_iterator_unittest.cc b/media/formats/mp4/chunk_info_iterator_unittest.cc index 695e463645..dfb071a966 100644 --- a/media/formats/mp4/chunk_info_iterator_unittest.cc +++ b/media/formats/mp4/chunk_info_iterator_unittest.cc @@ -12,8 +12,8 @@ namespace { struct ChunkProperty { - uint32 samples_per_chunk; - uint32 sample_description_index; + uint32_t samples_per_chunk; + uint32_t sample_description_index; }; } // namespace @@ -21,7 +21,7 @@ namespace edash_packager { namespace media { namespace mp4 { -const uint32 kNumChunks = 100; +const uint32_t kNumChunks = 100; const ChunkInfo kChunkInfos[] = { {1, 8, 1}, {9, 5, 1}, {25, 7, 2}, {48, 63, 2}, {80, 2, 1}}; @@ -29,12 +29,12 @@ class ChunkInfoIteratorTest : public testing::Test { public: ChunkInfoIteratorTest() { // Build chunk info table from kChunkInfos. - uint32 length = sizeof(kChunkInfos) / sizeof(ChunkInfo); + uint32_t length = sizeof(kChunkInfos) / sizeof(ChunkInfo); CHECK(kChunkInfos[0].first_chunk == 1); CHECK(kChunkInfos[length - 1].first_chunk <= kNumChunks); - uint32 chunk_index = kChunkInfos[0].first_chunk; - for (uint32 i = 0; i < length; ++i) { - uint32 next_first_chunk = + uint32_t chunk_index = kChunkInfos[0].first_chunk; + for (uint32_t i = 0; i < length; ++i) { + uint32_t next_first_chunk = (i == length - 1) ? kNumChunks + 1 : kChunkInfos[i + 1].first_chunk; for (; chunk_index < next_first_chunk; ++chunk_index) { ChunkProperty chunk = {kChunkInfos[i].samples_per_chunk, @@ -70,8 +70,8 @@ TEST_F(ChunkInfoIteratorTest, LastFirstChunk) { } TEST_F(ChunkInfoIteratorTest, NumSamples) { - for (uint32 i = 0; i < kNumChunks; ++i) { - for (uint32 num_samples = 0, j = i; j < kNumChunks; ++j) { + for (uint32_t i = 0; i < kNumChunks; ++i) { + for (uint32_t num_samples = 0, j = i; j < kNumChunks; ++j) { num_samples += chunk_info_table_[j].samples_per_chunk; ASSERT_EQ(num_samples, chunk_info_iterator_->NumSamples(i + 1, j + 1)); } @@ -79,7 +79,7 @@ TEST_F(ChunkInfoIteratorTest, NumSamples) { } TEST_F(ChunkInfoIteratorTest, AdvanceChunk) { - for (uint32 chunk = 0; chunk < kNumChunks; ++chunk) { + for (uint32_t chunk = 0; chunk < kNumChunks; ++chunk) { ASSERT_TRUE(chunk_info_iterator_->IsValid()); EXPECT_EQ(chunk + 1, chunk_info_iterator_->current_chunk()); EXPECT_EQ(chunk_info_table_[chunk].samples_per_chunk, @@ -93,9 +93,9 @@ TEST_F(ChunkInfoIteratorTest, AdvanceChunk) { } TEST_F(ChunkInfoIteratorTest, AdvanceSample) { - for (uint32 chunk = 0; chunk < kNumChunks; ++chunk) { - uint32 samples_per_chunk = chunk_info_table_[chunk].samples_per_chunk; - for (uint32 sample = 0; sample < samples_per_chunk; ++sample) { + for (uint32_t chunk = 0; chunk < kNumChunks; ++chunk) { + uint32_t samples_per_chunk = chunk_info_table_[chunk].samples_per_chunk; + for (uint32_t sample = 0; sample < samples_per_chunk; ++sample) { ASSERT_TRUE(chunk_info_iterator_->IsValid()); EXPECT_EQ(chunk + 1, chunk_info_iterator_->current_chunk()); EXPECT_EQ(chunk_info_table_[chunk].samples_per_chunk, diff --git a/media/formats/mp4/composition_offset_iterator.cc b/media/formats/mp4/composition_offset_iterator.cc index 448052278c..dbe12c7236 100644 --- a/media/formats/mp4/composition_offset_iterator.cc +++ b/media/formats/mp4/composition_offset_iterator.cc @@ -35,8 +35,8 @@ bool CompositionOffsetIterator::IsValid() const { sample_index_ < iterator_->sample_count; } -int32 CompositionOffsetIterator::SampleOffset(uint32 sample) const { - uint32 current_sample = 0; +int32_t CompositionOffsetIterator::SampleOffset(uint32_t sample) const { + uint32_t current_sample = 0; std::vector::const_iterator it = composition_offset_table_.begin(); for (; it != composition_offset_table_.end(); ++it) { @@ -48,8 +48,8 @@ int32 CompositionOffsetIterator::SampleOffset(uint32 sample) const { return 0; } -uint32 CompositionOffsetIterator::NumSamples() const { - uint32 num_samples = 0; +uint32_t CompositionOffsetIterator::NumSamples() const { + uint32_t num_samples = 0; std::vector::const_iterator it = composition_offset_table_.begin(); for (; it != composition_offset_table_.end(); ++it) { diff --git a/media/formats/mp4/composition_offset_iterator.h b/media/formats/mp4/composition_offset_iterator.h index 252eac2d9f..e9e0b35380 100644 --- a/media/formats/mp4/composition_offset_iterator.h +++ b/media/formats/mp4/composition_offset_iterator.h @@ -34,16 +34,16 @@ class CompositionOffsetIterator { bool IsValid() const; /// @return Sample offset for current sample. - int32 sample_offset() const { return iterator_->sample_offset; } + int32_t sample_offset() const { return iterator_->sample_offset; } /// @return Sample offset @a sample, 1-based. - int32 SampleOffset(uint32 sample) const; + int32_t SampleOffset(uint32_t sample) const; /// @return Total number of samples. - uint32 NumSamples() const; + uint32_t NumSamples() const; private: - uint32 sample_index_; + uint32_t sample_index_; const std::vector& composition_offset_table_; std::vector::const_iterator iterator_; diff --git a/media/formats/mp4/composition_offset_iterator_unittest.cc b/media/formats/mp4/composition_offset_iterator_unittest.cc index ea74e2db88..127584e077 100644 --- a/media/formats/mp4/composition_offset_iterator_unittest.cc +++ b/media/formats/mp4/composition_offset_iterator_unittest.cc @@ -20,9 +20,9 @@ class CompositionOffsetIteratorTest : public testing::Test { public: CompositionOffsetIteratorTest() { // Build composition offset table from kCompositionOffsets. - uint32 length = sizeof(kCompositionOffsets) / sizeof(CompositionOffset); - for (uint32 i = 0; i < length; ++i) { - for (uint32 j = 0; j < kCompositionOffsets[i].sample_count; ++j) { + uint32_t length = sizeof(kCompositionOffsets) / sizeof(CompositionOffset); + for (uint32_t i = 0; i < length; ++i) { + for (uint32_t j = 0; j < kCompositionOffsets[i].sample_count; ++j) { composition_offset_table_.push_back( kCompositionOffsets[i].sample_offset); } @@ -35,7 +35,7 @@ class CompositionOffsetIteratorTest : public testing::Test { } protected: - std::vector composition_offset_table_; + std::vector composition_offset_table_; CompositionTimeToSample composition_time_to_sample_; scoped_ptr composition_offset_iterator_; @@ -58,7 +58,8 @@ TEST_F(CompositionOffsetIteratorTest, NumSamples) { TEST_F(CompositionOffsetIteratorTest, AdvanceSample) { ASSERT_EQ(composition_offset_table_[0], composition_offset_iterator_->sample_offset()); - for (uint32 sample = 1; sample < composition_offset_table_.size(); ++sample) { + for (uint32_t sample = 1; sample < composition_offset_table_.size(); + ++sample) { ASSERT_TRUE(composition_offset_iterator_->AdvanceSample()); ASSERT_EQ(composition_offset_table_[sample], composition_offset_iterator_->sample_offset()); @@ -69,7 +70,8 @@ TEST_F(CompositionOffsetIteratorTest, AdvanceSample) { } TEST_F(CompositionOffsetIteratorTest, SampleOffset) { - for (uint32 sample = 0; sample < composition_offset_table_.size(); ++sample) { + for (uint32_t sample = 0; sample < composition_offset_table_.size(); + ++sample) { ASSERT_EQ(composition_offset_table_[sample], composition_offset_iterator_->SampleOffset(sample+1)); } diff --git a/media/formats/mp4/decoding_time_iterator.cc b/media/formats/mp4/decoding_time_iterator.cc index 50a43362e2..e31d4731dc 100644 --- a/media/formats/mp4/decoding_time_iterator.cc +++ b/media/formats/mp4/decoding_time_iterator.cc @@ -37,12 +37,12 @@ bool DecodingTimeIterator::IsValid() const { sample_index_ < iterator_->sample_count; } -uint64 DecodingTimeIterator::Duration(uint32 start_sample, - uint32 end_sample) const { +uint64_t DecodingTimeIterator::Duration(uint32_t start_sample, + uint32_t end_sample) const { DCHECK_LE(start_sample, end_sample); - uint32 current_sample = 0; - uint32 prev_sample = 0; - uint64 duration = 0; + uint32_t current_sample = 0; + uint32_t prev_sample = 0; + uint64_t duration = 0; std::vector::const_iterator it = decoding_time_table_.begin(); for (; it != decoding_time_table_.end(); ++it) { current_sample += it->sample_count; @@ -58,8 +58,8 @@ uint64 DecodingTimeIterator::Duration(uint32 start_sample, return duration; } -uint32 DecodingTimeIterator::NumSamples() const { - uint32 num_samples = 0; +uint32_t DecodingTimeIterator::NumSamples() const { + uint32_t num_samples = 0; std::vector::const_iterator it = decoding_time_table_.begin(); for (; it != decoding_time_table_.end(); ++it) { num_samples += it->sample_count; diff --git a/media/formats/mp4/decoding_time_iterator.h b/media/formats/mp4/decoding_time_iterator.h index ed1619352b..70f14098ed 100644 --- a/media/formats/mp4/decoding_time_iterator.h +++ b/media/formats/mp4/decoding_time_iterator.h @@ -34,16 +34,16 @@ class DecodingTimeIterator { bool IsValid() const; /// @return Sample delta for current sample. - uint32 sample_delta() const { return iterator_->sample_delta; } + uint32_t sample_delta() const { return iterator_->sample_delta; } /// @return Duration from start_sample to end_sample, both 1-based, inclusive. - uint64 Duration(uint32 start_sample, uint32 end_sample) const; + uint64_t Duration(uint32_t start_sample, uint32_t end_sample) const; /// @return Total number of samples in the table. - uint32 NumSamples() const; + uint32_t NumSamples() const; private: - uint32 sample_index_; + uint32_t sample_index_; const std::vector& decoding_time_table_; std::vector::const_iterator iterator_; diff --git a/media/formats/mp4/decoding_time_iterator_unittest.cc b/media/formats/mp4/decoding_time_iterator_unittest.cc index 4184684bc5..d611e7a8c3 100644 --- a/media/formats/mp4/decoding_time_iterator_unittest.cc +++ b/media/formats/mp4/decoding_time_iterator_unittest.cc @@ -20,10 +20,10 @@ class DecodingTimeIteratorTest : public testing::Test { public: DecodingTimeIteratorTest() { // Build decoding time table from kDecodingTimes. - uint32 decoding_time = 0; - uint32 length = sizeof(kDecodingTimes) / sizeof(DecodingTime); - for (uint32 i = 0; i < length; ++i) { - for (uint32 j = 0; j < kDecodingTimes[i].sample_count; ++j) { + uint32_t decoding_time = 0; + uint32_t length = sizeof(kDecodingTimes) / sizeof(DecodingTime); + for (uint32_t i = 0; i < length; ++i) { + for (uint32_t j = 0; j < kDecodingTimes[i].sample_count; ++j) { decoding_time += kDecodingTimes[i].sample_delta; decoding_time_table_.push_back(decoding_time); } @@ -36,7 +36,7 @@ class DecodingTimeIteratorTest : public testing::Test { } protected: - std::vector decoding_time_table_; + std::vector decoding_time_table_; DecodingTimeToSample decoding_time_to_sample_; scoped_ptr decoding_time_iterator_; @@ -57,7 +57,7 @@ TEST_F(DecodingTimeIteratorTest, NumSamples) { TEST_F(DecodingTimeIteratorTest, AdvanceSample) { ASSERT_EQ(decoding_time_table_[0], decoding_time_iterator_->sample_delta()); - for (uint32 sample = 1; sample < decoding_time_table_.size(); ++sample) { + for (uint32_t sample = 1; sample < decoding_time_table_.size(); ++sample) { ASSERT_TRUE(decoding_time_iterator_->AdvanceSample()); ASSERT_EQ(decoding_time_table_[sample] - decoding_time_table_[sample - 1], decoding_time_iterator_->sample_delta()); @@ -68,8 +68,8 @@ TEST_F(DecodingTimeIteratorTest, AdvanceSample) { } TEST_F(DecodingTimeIteratorTest, Duration) { - for (uint32 i = 0; i < decoding_time_table_.size(); ++i) { - for (uint32 j = i; j < decoding_time_table_.size(); ++j) { + for (uint32_t i = 0; i < decoding_time_table_.size(); ++i) { + for (uint32_t j = i; j < decoding_time_table_.size(); ++j) { ASSERT_EQ( decoding_time_table_[j] - (i == 0 ? 0 : decoding_time_table_[i - 1]), decoding_time_iterator_->Duration(i + 1, j + 1)); diff --git a/media/formats/mp4/encrypting_fragmenter.cc b/media/formats/mp4/encrypting_fragmenter.cc index e88aa54371..d8f280b342 100644 --- a/media/formats/mp4/encrypting_fragmenter.cc +++ b/media/formats/mp4/encrypting_fragmenter.cc @@ -25,8 +25,8 @@ namespace mp4 { EncryptingFragmenter::EncryptingFragmenter( TrackFragment* traf, scoped_ptr encryption_key, - int64 clear_time, - uint8 nalu_length_size) + int64_t clear_time, + uint8_t nalu_length_size) : Fragmenter(traf), encryption_key_(encryption_key.Pass()), nalu_length_size_(nalu_length_size), @@ -51,7 +51,7 @@ Status EncryptingFragmenter::AddSample(scoped_refptr sample) { return Fragmenter::AddSample(sample); } -Status EncryptingFragmenter::InitializeFragment(int64 first_sample_dts) { +Status EncryptingFragmenter::InitializeFragment(int64_t first_sample_dts) { Status status = Fragmenter::InitializeFragment(first_sample_dts); if (!status.ok()) return status; @@ -64,7 +64,7 @@ Status EncryptingFragmenter::InitializeFragment(int64 first_sample_dts) { // This fragment should be in clear text. // At most two sample description entries, an encrypted entry and a clear // entry, are generated. The 1-based clear entry index is always 2. - const uint32 kClearSampleDescriptionIndex = 2; + const uint32_t kClearSampleDescriptionIndex = 2; traf()->header.flags |= TrackFragmentHeader::kSampleDescriptionIndexPresentMask; @@ -124,7 +124,7 @@ Status EncryptingFragmenter::CreateEncryptor() { return Status::OK; } -void EncryptingFragmenter::EncryptBytes(uint8* data, uint32 size) { +void EncryptingFragmenter::EncryptBytes(uint8_t* data, uint32_t size) { DCHECK(encryptor_); CHECK(encryptor_->Encrypt(data, size, data)); } @@ -133,13 +133,13 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr sample) { DCHECK(encryptor_); FrameCENCInfo cenc_info(encryptor_->iv()); - uint8* data = sample->writable_data(); + uint8_t* data = sample->writable_data(); if (!IsSubsampleEncryptionRequired()) { EncryptBytes(data, sample->data_size()); } else { BufferReader reader(data, sample->data_size()); while (reader.HasBytes(1)) { - uint64 nalu_length; + uint64_t nalu_length; if (!reader.ReadNBytesInto8(&nalu_length, nalu_length_size_)) return Status(error::MUXER_FAILURE, "Fail to read nalu_length."); diff --git a/media/formats/mp4/encrypting_fragmenter.h b/media/formats/mp4/encrypting_fragmenter.h index fbe6f9efe6..24335cd20d 100644 --- a/media/formats/mp4/encrypting_fragmenter.h +++ b/media/formats/mp4/encrypting_fragmenter.h @@ -28,15 +28,15 @@ class EncryptingFragmenter : public Fragmenter { /// for subsample encryption. EncryptingFragmenter(TrackFragment* traf, scoped_ptr encryption_key, - int64 clear_time, - uint8 nalu_length_size); + int64_t clear_time, + uint8_t nalu_length_size); virtual ~EncryptingFragmenter(); /// @name Fragmenter implementation overrides. /// @{ virtual Status AddSample(scoped_refptr sample) OVERRIDE; - virtual Status InitializeFragment(int64 first_sample_dts) OVERRIDE; + virtual Status InitializeFragment(int64_t first_sample_dts) OVERRIDE; virtual void FinalizeFragment() OVERRIDE; /// @} @@ -60,7 +60,7 @@ class EncryptingFragmenter : public Fragmenter { } private: - void EncryptBytes(uint8* data, uint32 size); + void EncryptBytes(uint8_t* data, uint32_t size); Status EncryptSample(scoped_refptr sample); // Should we enable subsample encryption? @@ -71,8 +71,8 @@ class EncryptingFragmenter : public Fragmenter { // If this stream contains AVC, subsample encryption specifies that the size // and type of NAL units remain unencrypted. This field specifies the size of // the size field. Can be 1, 2 or 4 bytes. - const uint8 nalu_length_size_; - int64 clear_time_; + const uint8_t nalu_length_size_; + int64_t clear_time_; DISALLOW_COPY_AND_ASSIGN(EncryptingFragmenter); }; diff --git a/media/formats/mp4/es_descriptor.cc b/media/formats/mp4/es_descriptor.cc index b04a3f1bf8..99eab5c908 100644 --- a/media/formats/mp4/es_descriptor.cc +++ b/media/formats/mp4/es_descriptor.cc @@ -36,9 +36,9 @@ enum SLPredefinedTags { // The elementary stream size is specific by up to 4 bytes. // The MSB of a byte indicates if there are more bytes for the size. -bool ReadESSize(BitReader* reader, uint32* size) { - uint8 msb; - uint8 byte; +bool ReadESSize(BitReader* reader, uint32_t* size) { + uint8_t msb; + uint8_t byte; *size = 0; @@ -67,14 +67,14 @@ ESDescriptor::ESDescriptor() : esid_(0), object_type_(kForbidden) {} ESDescriptor::~ESDescriptor() {} -bool ESDescriptor::Parse(const std::vector& data) { +bool ESDescriptor::Parse(const std::vector& data) { BitReader reader(&data[0], data.size()); - uint8 tag; - uint32 size; - uint8 stream_dependency_flag; - uint8 url_flag; - uint8 ocr_stream_flag; - uint16 dummy; + uint8_t tag; + uint32_t size; + uint8_t stream_dependency_flag; + uint8_t url_flag; + uint8_t ocr_stream_flag; + uint16_t dummy; RCHECK(reader.ReadBits(8, &tag)); RCHECK(tag == kESDescrTag); @@ -98,9 +98,9 @@ bool ESDescriptor::Parse(const std::vector& data) { } bool ESDescriptor::ParseDecoderConfigDescriptor(BitReader* reader) { - uint8 tag; - uint32 size; - uint64 dummy; + uint8_t tag; + uint32_t size; + uint64_t dummy; RCHECK(reader->ReadBits(8, &tag)); RCHECK(tag == kDecoderConfigDescrTag); @@ -116,15 +116,15 @@ bool ESDescriptor::ParseDecoderConfigDescriptor(BitReader* reader) { bool ESDescriptor::ParseDecoderSpecificInfo(BitReader* reader) { DCHECK(reader); - uint8 tag; - uint32 size; + uint8_t tag; + uint32_t size; RCHECK(reader->ReadBits(8, &tag)); RCHECK(tag == kDecoderSpecificInfoTag); RCHECK(ReadESSize(reader, &size)); decoder_specific_info_.resize(size); - for (uint32 i = 0; i < size; ++i) + for (uint32_t i = 0; i < size; ++i) RCHECK(reader->ReadBits(8, &decoder_specific_info_[i])); return true; @@ -134,55 +134,55 @@ void ESDescriptor::Write(BufferWriter* writer) const { DCHECK(writer); CHECK_LT(decoder_specific_info_.size(), kMaxDecoderSpecificInfoSize); - const std::vector kEmptyDecodingBufferSize(3, 0); - const uint32 kUnknownBitrate = 0; - const uint8 kNoEsFlags = 0; + const std::vector kEmptyDecodingBufferSize(3, 0); + const uint32_t kUnknownBitrate = 0; + const uint8_t kNoEsFlags = 0; - const uint8 decoder_specific_info_size = decoder_specific_info_.size(); + const uint8_t decoder_specific_info_size = decoder_specific_info_.size(); // 6 bit stream type. The last bit is reserved with 1. - const uint8 stream_type = (kAudioStreamType << 2) | 1; - const uint8 decoder_config_size = decoder_specific_info_size + kHeaderSize + - sizeof(uint8) + // object_type_. - sizeof(stream_type) + - kEmptyDecodingBufferSize.size() + - sizeof(kUnknownBitrate) * 2; + const uint8_t stream_type = (kAudioStreamType << 2) | 1; + const uint8_t decoder_config_size = decoder_specific_info_size + kHeaderSize + + sizeof(uint8_t) + // object_type_. + sizeof(stream_type) + + kEmptyDecodingBufferSize.size() + + sizeof(kUnknownBitrate) * 2; - const uint8 sl_config_size = sizeof(uint8); // predefined. - const uint8 es_size = decoder_config_size + kHeaderSize + sl_config_size + - kHeaderSize + sizeof(esid_) + sizeof(kNoEsFlags); + const uint8_t sl_config_size = sizeof(uint8_t); // predefined. + const uint8_t es_size = decoder_config_size + kHeaderSize + sl_config_size + + kHeaderSize + sizeof(esid_) + sizeof(kNoEsFlags); - writer->AppendInt(static_cast(kESDescrTag)); + writer->AppendInt(static_cast(kESDescrTag)); writer->AppendInt(es_size); writer->AppendInt(esid_); writer->AppendInt(kNoEsFlags); - writer->AppendInt(static_cast(kDecoderConfigDescrTag)); + writer->AppendInt(static_cast(kDecoderConfigDescrTag)); writer->AppendInt(decoder_config_size); - writer->AppendInt(static_cast(object_type_)); + writer->AppendInt(static_cast(object_type_)); writer->AppendInt(stream_type); writer->AppendVector(kEmptyDecodingBufferSize); writer->AppendInt(kUnknownBitrate); // max_bitrate. writer->AppendInt(kUnknownBitrate); // avg_bitrate. - writer->AppendInt(static_cast(kDecoderSpecificInfoTag)); + writer->AppendInt(static_cast(kDecoderSpecificInfoTag)); writer->AppendInt(decoder_specific_info_size); writer->AppendVector(decoder_specific_info_); - writer->AppendInt(static_cast(kSLConfigTag)); + writer->AppendInt(static_cast(kSLConfigTag)); writer->AppendInt(sl_config_size); - writer->AppendInt(static_cast(kSLPredefinedMP4)); + writer->AppendInt(static_cast(kSLPredefinedMP4)); } size_t ESDescriptor::ComputeSize() const { // A bit magical. Refer to ESDescriptor::Write for details. - const uint8 decoder_specific_info_size = decoder_specific_info_.size(); - const uint8 decoder_config_size = decoder_specific_info_size + kHeaderSize + - sizeof(uint8) * 5 + sizeof(uint32) * 2; - const uint8 sl_config_size = sizeof(uint8); - const uint8 es_size = decoder_config_size + kHeaderSize + - sl_config_size + kHeaderSize + - sizeof(esid_) + sizeof(uint8); + const uint8_t decoder_specific_info_size = decoder_specific_info_.size(); + const uint8_t decoder_config_size = decoder_specific_info_size + kHeaderSize + + sizeof(uint8_t) * 5 + + sizeof(uint32_t) * 2; + const uint8_t sl_config_size = sizeof(uint8_t); + const uint8_t es_size = decoder_config_size + kHeaderSize + sl_config_size + + kHeaderSize + sizeof(esid_) + sizeof(uint8_t); return es_size + kHeaderSize; } diff --git a/media/formats/mp4/es_descriptor.h b/media/formats/mp4/es_descriptor.h index b44a261c64..effc7461f7 100644 --- a/media/formats/mp4/es_descriptor.h +++ b/media/formats/mp4/es_descriptor.h @@ -34,21 +34,21 @@ class ESDescriptor { ESDescriptor(); ~ESDescriptor(); - bool Parse(const std::vector& data); + bool Parse(const std::vector& data); void Write(BufferWriter* writer) const; size_t ComputeSize() const; - uint16 esid() const { return esid_; } - void set_esid(uint16 esid) { esid_ = esid; } + uint16_t esid() const { return esid_; } + void set_esid(uint16_t esid) { esid_ = esid; } ObjectType object_type() const { return object_type_; } void set_object_type(ObjectType object_type) { object_type_ = object_type; } - const std::vector& decoder_specific_info() const { + const std::vector& decoder_specific_info() const { return decoder_specific_info_; } void set_decoder_specific_info( - const std::vector& decoder_specific_info) { + const std::vector& decoder_specific_info) { decoder_specific_info_ = decoder_specific_info; } @@ -68,9 +68,9 @@ class ESDescriptor { bool ParseDecoderConfigDescriptor(BitReader* reader); bool ParseDecoderSpecificInfo(BitReader* reader); - uint16 esid_; // Elementary Stream ID. + uint16_t esid_; // Elementary Stream ID. ObjectType object_type_; - std::vector decoder_specific_info_; + std::vector decoder_specific_info_; }; } // namespace mp4 diff --git a/media/formats/mp4/es_descriptor_unittest.cc b/media/formats/mp4/es_descriptor_unittest.cc index 00f769dde4..5d31d58d54 100644 --- a/media/formats/mp4/es_descriptor_unittest.cc +++ b/media/formats/mp4/es_descriptor_unittest.cc @@ -13,13 +13,10 @@ namespace mp4 { TEST(ESDescriptorTest, SingleByteLengthTest) { ESDescriptor es_desc; - uint8 buffer[] = { - 0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x40, - 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x12, 0x10, - 0x06, 0x01, 0x02 - }; - std::vector data; + uint8_t buffer[] = {0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x40, 0x15, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x05, 0x02, 0x12, 0x10, 0x06, 0x01, 0x02}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -33,13 +30,10 @@ TEST(ESDescriptorTest, SingleByteLengthTest) { TEST(ESDescriptorTest, NonAACTest) { ESDescriptor es_desc; - uint8 buffer[] = { - 0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x66, - 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x02, 0x12, 0x10, - 0x06, 0x01, 0x02 - }; - std::vector data; + uint8_t buffer[] = {0x03, 0x19, 0x00, 0x01, 0x00, 0x04, 0x11, 0x66, 0x15, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x05, 0x02, 0x12, 0x10, 0x06, 0x01, 0x02}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -52,14 +46,11 @@ TEST(ESDescriptorTest, NonAACTest) { TEST(ESDescriptorTest, MultiByteLengthTest) { ESDescriptor es_desc; - uint8 buffer[] = { - 0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80, - 0x80, 0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x80, 0x80, 0x80, 0x02, 0x12, 0x10, 0x06, 0x01, - 0x02 - }; - std::vector data; + uint8_t buffer[] = {0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80, 0x80, + 0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x80, 0x80, 0x80, + 0x02, 0x12, 0x10, 0x06, 0x01, 0x02}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); @@ -72,14 +63,11 @@ TEST(ESDescriptorTest, MultiByteLengthTest) { TEST(ESDescriptorTest, FiveByteLengthTest) { ESDescriptor es_desc; - uint8 buffer[] = { - 0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80, - 0x80, 0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, - 0x80, 0x80, 0x80, 0x80, 0x02, 0x12, 0x10, 0x06, - 0x01, 0x02 - }; - std::vector data; + uint8_t buffer[] = {0x03, 0x80, 0x19, 0x00, 0x01, 0x00, 0x04, 0x80, 0x80, + 0x11, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x80, 0x80, 0x80, + 0x80, 0x02, 0x12, 0x10, 0x06, 0x01, 0x02}; + std::vector data; data.assign(buffer, buffer + sizeof(buffer)); diff --git a/media/formats/mp4/fragmenter.cc b/media/formats/mp4/fragmenter.cc index 51680d4efe..fccd1c69d1 100644 --- a/media/formats/mp4/fragmenter.cc +++ b/media/formats/mp4/fragmenter.cc @@ -15,7 +15,7 @@ namespace media { namespace mp4 { namespace { -const int64 kInvalidTime = kint64max; +const int64_t kInvalidTime = kint64max; } // namespace Fragmenter::Fragmenter(TrackFragment* traf) @@ -50,7 +50,7 @@ Status Fragmenter::AddSample(scoped_refptr sample) { data_->AppendArray(sample->data(), sample->data_size()); fragment_duration_ += sample->duration(); - int64 pts = sample->pts(); + int64_t pts = sample->pts(); // Set |earliest_presentation_time_| to |pts| if |pts| is smaller or if it is // not yet initialized (kInvalidTime > pts is always true). @@ -68,7 +68,7 @@ Status Fragmenter::AddSample(scoped_refptr sample) { return Status::OK; } -Status Fragmenter::InitializeFragment(int64 first_sample_dts) { +Status Fragmenter::InitializeFragment(int64_t first_sample_dts) { fragment_initialized_ = true; fragment_finalized_ = false; traf_->decode_time.decode_time = first_sample_dts; @@ -128,7 +128,7 @@ void Fragmenter::GenerateSegmentReference(SegmentReference* reference) { bool Fragmenter::StartsWithSAP() { DCHECK(!traf_->runs.empty()); - uint32 start_sample_flag; + uint32_t start_sample_flag; if (traf_->runs[0].flags & TrackFragmentRun::kSampleFlagsPresentMask) { DCHECK(!traf_->runs[0].sample_flags.empty()); start_sample_flag = traf_->runs[0].sample_flags[0]; diff --git a/media/formats/mp4/fragmenter.h b/media/formats/mp4/fragmenter.h index 371b13fab7..8987521148 100644 --- a/media/formats/mp4/fragmenter.h +++ b/media/formats/mp4/fragmenter.h @@ -42,7 +42,7 @@ class Fragmenter { /// @param first_sample_dts specifies the decoding timestamp for the first /// sample for this fragment. /// @return OK on success, an error status otherwise. - virtual Status InitializeFragment(int64 first_sample_dts); + virtual Status InitializeFragment(int64_t first_sample_dts); /// Finalize and optimize the fragment. virtual void FinalizeFragment(); @@ -50,9 +50,9 @@ class Fragmenter { /// Fill @a reference with current fragment information. void GenerateSegmentReference(SegmentReference* reference); - uint64 fragment_duration() const { return fragment_duration_; } - uint64 first_sap_time() const { return first_sap_time_; } - uint64 earliest_presentation_time() const { + uint64_t fragment_duration() const { return fragment_duration_; } + uint64_t first_sap_time() const { return first_sap_time_; } + uint64_t earliest_presentation_time() const { return earliest_presentation_time_; } bool fragment_initialized() const { return fragment_initialized_; } @@ -76,10 +76,10 @@ class Fragmenter { TrackFragment* traf_; bool fragment_initialized_; bool fragment_finalized_; - uint64 fragment_duration_; - int64 presentation_start_time_; - int64 earliest_presentation_time_; - int64 first_sap_time_; + uint64_t fragment_duration_; + int64_t presentation_start_time_; + int64_t earliest_presentation_time_; + int64_t first_sap_time_; scoped_ptr data_; scoped_ptr aux_data_; diff --git a/media/formats/mp4/key_rotation_fragmenter.cc b/media/formats/mp4/key_rotation_fragmenter.cc index c2a1f20626..80e61380e2 100644 --- a/media/formats/mp4/key_rotation_fragmenter.cc +++ b/media/formats/mp4/key_rotation_fragmenter.cc @@ -13,14 +13,13 @@ namespace edash_packager { namespace media { namespace mp4 { -KeyRotationFragmenter::KeyRotationFragmenter( - MovieFragment* moof, - TrackFragment* traf, - KeySource* encryption_key_source, - KeySource::TrackType track_type, - int64 crypto_period_duration, - int64 clear_time, - uint8 nalu_length_size) +KeyRotationFragmenter::KeyRotationFragmenter(MovieFragment* moof, + TrackFragment* traf, + KeySource* encryption_key_source, + KeySource::TrackType track_type, + int64_t crypto_period_duration, + int64_t clear_time, + uint8_t nalu_length_size) : EncryptingFragmenter(traf, scoped_ptr(new EncryptionKey()), clear_time, diff --git a/media/formats/mp4/key_rotation_fragmenter.h b/media/formats/mp4/key_rotation_fragmenter.h index 1b46526271..3fe4cf5df0 100644 --- a/media/formats/mp4/key_rotation_fragmenter.h +++ b/media/formats/mp4/key_rotation_fragmenter.h @@ -36,9 +36,9 @@ class KeyRotationFragmenter : public EncryptingFragmenter { TrackFragment* traf, KeySource* encryption_key_source, KeySource::TrackType track_type, - int64 crypto_period_duration, - int64 clear_time, - uint8 nalu_length_size); + int64_t crypto_period_duration, + int64_t clear_time, + uint8_t nalu_length_size); virtual ~KeyRotationFragmenter(); protected: @@ -53,7 +53,7 @@ class KeyRotationFragmenter : public EncryptingFragmenter { KeySource* encryption_key_source_; KeySource::TrackType track_type_; - const int64 crypto_period_duration_; + const int64_t crypto_period_duration_; size_t prev_crypto_period_index_; DISALLOW_COPY_AND_ASSIGN(KeyRotationFragmenter); diff --git a/media/formats/mp4/mp4_media_parser.cc b/media/formats/mp4/mp4_media_parser.cc index b61fba6fa0..bd4709f624 100644 --- a/media/formats/mp4/mp4_media_parser.cc +++ b/media/formats/mp4/mp4_media_parser.cc @@ -23,7 +23,9 @@ namespace { -uint64 Rescale(uint64 time_in_old_scale, uint32 old_scale, uint32 new_scale) { +uint64_t Rescale(uint64_t time_in_old_scale, + uint32_t old_scale, + uint32_t new_scale) { return (static_cast(time_in_old_scale) / old_scale) * new_scale; } @@ -70,7 +72,7 @@ void MP4MediaParser::Flush() { ChangeState(kParsingBoxes); } -bool MP4MediaParser::Parse(const uint8* buf, int size) { +bool MP4MediaParser::Parse(const uint8_t* buf, int size) { DCHECK_NE(state_, kWaitingForInit); if (state_ == kError) @@ -87,7 +89,7 @@ bool MP4MediaParser::Parse(const uint8* buf, int size) { DCHECK_EQ(kEmittingSamples, state_); result = EnqueueSample(&err); if (result) { - int64 max_clear = runs_->GetMaxClearOffset() + moof_head_; + int64_t max_clear = runs_->GetMaxClearOffset() + moof_head_; err = !ReadAndDiscardMDATsUntil(max_clear); } } @@ -105,7 +107,7 @@ bool MP4MediaParser::Parse(const uint8* buf, int size) { } bool MP4MediaParser::ParseBox(bool* err) { - const uint8* buf; + const uint8_t* buf; int size; queue_.Peek(&buf, &size); if (!size) @@ -156,10 +158,10 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) { for (std::vector::const_iterator track = moov_->tracks.begin(); track != moov_->tracks.end(); ++track) { - const uint32 timescale = track->media.header.timescale; + const uint32_t timescale = track->media.header.timescale; // Calculate duration (based on timescale). - uint64 duration = 0; + uint64_t duration = 0; if (track->media.header.duration > 0) { duration = track->media.header.duration; } else if (moov_->extends.header.fragment_duration > 0) { @@ -222,10 +224,10 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) { } AudioCodec codec = kUnknownAudioCodec; - uint8 num_channels = 0; - uint32 sampling_frequency = 0; - uint8 audio_object_type = 0; - std::vector extra_data; + uint8_t num_channels = 0; + uint32_t sampling_frequency = 0; + uint8_t audio_object_type = 0; + std::vector extra_data; // Check if it is MPEG4 AAC defined in ISO 14496 Part 3 or // supported MPEG2 AAC variants. if (entry.esds.es_descriptor.IsAAC()) { @@ -335,7 +337,7 @@ bool MP4MediaParser::FetchKeysIfNecessary( // TODO(tinskip): Pass in raw 'pssh' boxes to FetchKeys. This will allow // supporting multiple keysystems. Move this to KeySource. - std::vector widevine_system_id; + std::vector widevine_system_id; base::HexStringToBytes(kWidevineKeySystemId, &widevine_system_id); for (std::vector::const_iterator iter = headers.begin(); iter != headers.end(); ++iter) { @@ -371,7 +373,7 @@ bool MP4MediaParser::EnqueueSample(bool* err) { DCHECK(!(*err)); - const uint8* buf; + const uint8_t* buf; int buf_size; queue_.Peek(&buf, &buf_size); if (!buf_size) @@ -432,7 +434,7 @@ bool MP4MediaParser::EnqueueSample(bool* err) { } bool MP4MediaParser::DecryptSampleBuffer(const DecryptConfig* decrypt_config, - uint8* buffer, + uint8_t* buffer, size_t buffer_size) { DCHECK(decrypt_config); DCHECK(buffer); @@ -481,8 +483,8 @@ bool MP4MediaParser::DecryptSampleBuffer(const DecryptConfig* decrypt_config, // Subsample decryption. const std::vector& subsamples = decrypt_config->subsamples(); - uint8* current_ptr = buffer; - const uint8* buffer_end = buffer + buffer_size; + uint8_t* current_ptr = buffer; + const uint8_t* buffer_end = buffer + buffer_size; current_ptr += decrypt_config->data_offset(); if (current_ptr > buffer_end) { LOG(ERROR) << "Subsample data_offset too large."; @@ -505,15 +507,15 @@ bool MP4MediaParser::DecryptSampleBuffer(const DecryptConfig* decrypt_config, return true; } -bool MP4MediaParser::ReadAndDiscardMDATsUntil(const int64 offset) { +bool MP4MediaParser::ReadAndDiscardMDATsUntil(const int64_t offset) { bool err = false; while (mdat_tail_ < offset) { - const uint8* buf; + const uint8_t* buf; int size; queue_.PeekAt(mdat_tail_, &buf, &size); FourCC type; - uint64 box_sz; + uint64_t box_sz; if (!BoxReader::StartTopLevelBox(buf, size, &type, &box_sz, &err)) break; diff --git a/media/formats/mp4/mp4_media_parser.h b/media/formats/mp4/mp4_media_parser.h index e8236a6b24..615a7d4239 100644 --- a/media/formats/mp4/mp4_media_parser.h +++ b/media/formats/mp4/mp4_media_parser.h @@ -43,7 +43,7 @@ class MP4MediaParser : public MediaParser { const NewSampleCB& new_sample_cb, KeySource* decryption_key_source) OVERRIDE; virtual void Flush() OVERRIDE; - virtual bool Parse(const uint8* buf, int size) OVERRIDE; + virtual bool Parse(const uint8_t* buf, int size) OVERRIDE; /// @} private: @@ -62,7 +62,7 @@ class MP4MediaParser : public MediaParser { const std::vector& headers); bool DecryptSampleBuffer(const DecryptConfig* decrypt_config, - uint8* buffer, + uint8_t* buffer, size_t buffer_size); // To retain proper framing, each 'mdat' atom must be read; to limit memory @@ -71,7 +71,7 @@ class MP4MediaParser : public MediaParser { // to |offset|, updating the |mdat_tail_| value so that framing can be // retained after all 'mdat' information has been read. // Returns 'true' on success, 'false' if there was an error. - bool ReadAndDiscardMDATsUntil(const int64 offset); + bool ReadAndDiscardMDATsUntil(const int64_t offset); void ChangeState(State new_state); @@ -93,15 +93,15 @@ class MP4MediaParser : public MediaParser { // |moof_head_| is the offset of the start of the most recently parsed moof // block. All byte offsets in sample information are relative to this offset, // as mandated by the Media Source spec. - int64 moof_head_; + int64_t moof_head_; // |mdat_tail_| is the stream offset of the end of the current 'mdat' box. // Valid iff it is greater than the head of the queue. - int64 mdat_tail_; + int64_t mdat_tail_; scoped_ptr moov_; scoped_ptr runs_; - typedef std::map, AesCtrEncryptor*> DecryptorMap; + typedef std::map, AesCtrEncryptor*> DecryptorMap; DecryptorMap decryptor_map_; DISALLOW_COPY_AND_ASSIGN(MP4MediaParser); diff --git a/media/formats/mp4/mp4_media_parser_unittest.cc b/media/formats/mp4/mp4_media_parser_unittest.cc index d2b6a0a328..9aff6fb930 100644 --- a/media/formats/mp4/mp4_media_parser_unittest.cc +++ b/media/formats/mp4/mp4_media_parser_unittest.cc @@ -26,13 +26,15 @@ class MP4MediaParserTest : public testing::Test { scoped_ptr parser_; bool configs_received_; - bool AppendData(const uint8* data, size_t length) { + bool AppendData(const uint8_t* data, size_t length) { return parser_->Parse(data, length); } - bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) { - const uint8* start = data; - const uint8* end = data + length; + bool AppendDataInPieces(const uint8_t* data, + size_t length, + size_t piece_size) { + const uint8_t* start = data; + const uint8_t* end = data + length; while (start < end) { size_t append_size = std::min(piece_size, static_cast(end - start)); @@ -48,7 +50,7 @@ class MP4MediaParserTest : public testing::Test { configs_received_ = true; } - bool NewSampleF(uint32 track_id, const scoped_refptr& sample) { + bool NewSampleF(uint32_t track_id, const scoped_refptr& sample) { DVLOG(2) << "Track Id: " << track_id << " " << sample->ToString(); return true; @@ -64,7 +66,7 @@ class MP4MediaParserTest : public testing::Test { bool ParseMP4File(const std::string& filename, int append_bytes) { InitializeParser(); - std::vector buffer = ReadTestDataFile(filename); + std::vector buffer = ReadTestDataFile(filename); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), append_bytes)); @@ -93,7 +95,7 @@ TEST_F(MP4MediaParserTest, Flush) { // Flush while reading sample data, then start a new stream. InitializeParser(); - std::vector buffer = ReadTestDataFile("bear-1280x720-av_frag.mp4"); + std::vector buffer = ReadTestDataFile("bear-1280x720-av_frag.mp4"); EXPECT_TRUE(AppendDataInPieces(buffer.data(), 65536, 512)); parser_->Flush(); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); @@ -102,7 +104,7 @@ TEST_F(MP4MediaParserTest, Flush) { TEST_F(MP4MediaParserTest, Reinitialization) { InitializeParser(); - std::vector buffer = ReadTestDataFile("bear-1280x720-av_frag.mp4"); + std::vector buffer = ReadTestDataFile("bear-1280x720-av_frag.mp4"); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); } @@ -115,7 +117,7 @@ TEST_F(MP4MediaParserTest, MPEG2_AAC_LC) { TEST_F(MP4MediaParserTest, NoMoovAfterFlush) { InitializeParser(); - std::vector buffer = ReadTestDataFile("bear-1280x720-av_frag.mp4"); + std::vector buffer = ReadTestDataFile("bear-1280x720-av_frag.mp4"); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); parser_->Flush(); diff --git a/media/formats/mp4/mp4_muxer.cc b/media/formats/mp4/mp4_muxer.cc index 218b02b771..3428443e37 100644 --- a/media/formats/mp4/mp4_muxer.cc +++ b/media/formats/mp4/mp4_muxer.cc @@ -27,12 +27,12 @@ namespace { // |start| and |end| are for byte-range-spec specified in RFC2616. void SetStartAndEndFromOffsetAndSize(size_t offset, size_t size, - uint32* start, - uint32* end) { + uint32_t* start, + uint32_t* end) { DCHECK(start && end); - *start = static_cast(offset); + *start = static_cast(offset); // Note that ranges are inclusive. So we need - 1. - *end = *start + static_cast(size) - 1; + *end = *start + static_cast(size) - 1; } } // namespace @@ -64,7 +64,7 @@ Status MP4Muxer::Initialize() { moov->extends.tracks.resize(streams().size()); // Initialize tracks. - for (uint32 i = 0; i < streams().size(); ++i) { + for (uint32_t i = 0; i < streams().size(); ++i) { Track& trak = moov->tracks[i]; trak.header.track_id = i + 1; @@ -132,7 +132,7 @@ Status MP4Muxer::DoAddSample(const MediaStream* stream, } void MP4Muxer::InitializeTrak(const StreamInfo* info, Track* trak) { - int64 now = IsoTimeNow(); + int64_t now = IsoTimeNow(); trak->header.creation_time = now; trak->header.modification_time = now; trak->header.duration = 0; @@ -150,7 +150,7 @@ void MP4Muxer::InitializeTrak(const StreamInfo* info, Track* trak) { void MP4Muxer::GenerateVideoTrak(const VideoStreamInfo* video_info, Track* trak, - uint32 track_id) { + uint32_t track_id) { InitializeTrak(video_info, trak); trak->header.width = video_info->width(); @@ -171,7 +171,7 @@ void MP4Muxer::GenerateVideoTrak(const VideoStreamInfo* video_info, void MP4Muxer::GenerateAudioTrak(const AudioStreamInfo* audio_info, Track* trak, - uint32 track_id) { + uint32_t track_id) { InitializeTrak(audio_info, trak); trak->header.volume = 0x100; @@ -207,7 +207,7 @@ void MP4Muxer::GetStreamInfo(std::vector* stream_infos) { } } -bool MP4Muxer::GetInitRangeStartAndEnd(uint32* start, uint32* end) { +bool MP4Muxer::GetInitRangeStartAndEnd(uint32_t* start, uint32_t* end) { DCHECK(start && end); size_t range_offset = 0; size_t range_size = 0; @@ -220,7 +220,7 @@ bool MP4Muxer::GetInitRangeStartAndEnd(uint32* start, uint32* end) { return true; } -bool MP4Muxer::GetIndexRangeStartAndEnd(uint32* start, uint32* end) { +bool MP4Muxer::GetIndexRangeStartAndEnd(uint32_t* start, uint32_t* end) { DCHECK(start && end); size_t range_offset = 0; size_t range_size = 0; @@ -239,7 +239,7 @@ void MP4Muxer::FireOnMediaStartEvent() { std::vector stream_info_vec; GetStreamInfo(&stream_info_vec); - const uint32 timescale = segmenter_->GetReferenceTimeScale(); + const uint32_t timescale = segmenter_->GetReferenceTimeScale(); muxer_listener()->OnMediaStart(options(), stream_info_vec, timescale, @@ -251,19 +251,20 @@ void MP4Muxer::FireOnMediaEndEvent() { if (!muxer_listener()) return; - uint32 init_range_start = 0; - uint32 init_range_end = 0; + uint32_t init_range_start = 0; + uint32_t init_range_end = 0; const bool has_init_range = GetInitRangeStartAndEnd(&init_range_start, &init_range_end); - uint32 index_range_start = 0; - uint32 index_range_end = 0; + uint32_t index_range_start = 0; + uint32_t index_range_end = 0; const bool has_index_range = GetIndexRangeStartAndEnd(&index_range_start, &index_range_end); const float duration_seconds = static_cast(segmenter_->GetDuration()); - const int64 file_size = File::GetFileSize(options().output_file_name.c_str()); + const int64_t file_size = + File::GetFileSize(options().output_file_name.c_str()); if (file_size <= 0) { LOG(ERROR) << "Invalid file size: " << file_size; return; @@ -279,9 +280,9 @@ void MP4Muxer::FireOnMediaEndEvent() { file_size); } -uint64 MP4Muxer::IsoTimeNow() { +uint64_t MP4Muxer::IsoTimeNow() { // Time in seconds from Jan. 1, 1904 to epoch time, i.e. Jan. 1, 1970. - const uint64 kIsomTimeOffset = 2082844800l; + const uint64_t kIsomTimeOffset = 2082844800l; return kIsomTimeOffset + (clock() ? clock()->Now() : base::Time::Now()).ToDoubleT(); } diff --git a/media/formats/mp4/mp4_muxer.h b/media/formats/mp4/mp4_muxer.h index 050eaf5bfb..e72e92f353 100644 --- a/media/formats/mp4/mp4_muxer.h +++ b/media/formats/mp4/mp4_muxer.h @@ -46,28 +46,28 @@ class MP4Muxer : public Muxer { void InitializeTrak(const StreamInfo* info, Track* trak); void GenerateAudioTrak(const AudioStreamInfo* audio_info, Track* trak, - uint32 track_id); + uint32_t track_id); void GenerateVideoTrak(const VideoStreamInfo* video_info, Track* trak, - uint32 track_id); + uint32_t track_id); // Helper functions for events. void GetStreamInfo(std::vector* stream_infos); // Gets |start| and |end| initialization range. Returns true if there is an // init range and sets start-end byte-range-spec specified in RFC2616. - bool GetInitRangeStartAndEnd(uint32* start, uint32* end); + bool GetInitRangeStartAndEnd(uint32_t* start, uint32_t* end); // Gets |start| and |end| index range. Returns true if there is an index range // and sets start-end byte-range-spec specified in RFC2616. - bool GetIndexRangeStartAndEnd(uint32* start, uint32* end); + bool GetIndexRangeStartAndEnd(uint32_t* start, uint32_t* end); // Fire events if there are no errors and Muxer::muxer_listener() is not NULL. void FireOnMediaStartEvent(); void FireOnMediaEndEvent(); // Get time in seconds since midnight, Jan. 1, 1904, in UTC Time. - uint64 IsoTimeNow(); + uint64_t IsoTimeNow(); scoped_ptr segmenter_; diff --git a/media/formats/mp4/multi_segment_segmenter.cc b/media/formats/mp4/multi_segment_segmenter.cc index 064cc1c980..424c348fe2 100644 --- a/media/formats/mp4/multi_segment_segmenter.cc +++ b/media/formats/mp4/multi_segment_segmenter.cc @@ -82,18 +82,18 @@ Status MultiSegmentSegmenter::DoFinalizeSegment() { // sidx() contains pre-generated segment references with one reference per // fragment. Calculate |num_fragments_per_subsegment| and combine // pre-generated references into final subsegment references. - uint32 num_fragments = sidx()->references.size(); - uint32 num_fragments_per_subsegment = + uint32_t num_fragments = sidx()->references.size(); + uint32_t num_fragments_per_subsegment = (num_fragments - 1) / options().num_subsegments_per_sidx + 1; if (num_fragments_per_subsegment <= 1) return WriteSegment(); - uint32 frag_index = 0; - uint32 subseg_index = 0; + uint32_t frag_index = 0; + uint32_t subseg_index = 0; std::vector& refs = sidx()->references; - uint64 first_sap_time = + uint64_t first_sap_time = refs[0].sap_delta_time + refs[0].earliest_presentation_time; - for (uint32 i = 1; i < num_fragments; ++i) { + for (uint32_t i = 1; i < num_fragments; ++i) { refs[subseg_index].referenced_size += refs[i].referenced_size; refs[subseg_index].subsegment_duration += refs[i].subsegment_duration; refs[subseg_index].earliest_presentation_time = @@ -175,7 +175,7 @@ Status MultiSegmentSegmenter::WriteSegment() { LOG(WARNING) << "Failed to close the file properly: " << file_name; if (status.ok() && muxer_listener()) { - uint64 segment_duration = 0; + uint64_t segment_duration = 0; // ISO/IEC 23009-1:2012: the value shall be identical to sum of the the // values of all Subsegment_duration fields in the first ‘sidx’ box. for (size_t i = 0; i < sidx()->references.size(); ++i) diff --git a/media/formats/mp4/multi_segment_segmenter.h b/media/formats/mp4/multi_segment_segmenter.h index 293a47a665..8734527cd5 100644 --- a/media/formats/mp4/multi_segment_segmenter.h +++ b/media/formats/mp4/multi_segment_segmenter.h @@ -51,7 +51,7 @@ class MultiSegmentSegmenter : public Segmenter { Status WriteSegment(); scoped_ptr styp_; - uint32 num_segments_; + uint32_t num_segments_; DISALLOW_COPY_AND_ASSIGN(MultiSegmentSegmenter); }; diff --git a/media/formats/mp4/segmenter.cc b/media/formats/mp4/segmenter.cc index 956b13fb8f..7f1f975cce 100644 --- a/media/formats/mp4/segmenter.cc +++ b/media/formats/mp4/segmenter.cc @@ -31,7 +31,9 @@ const size_t kCencKeyIdSize = 16u; // The version of cenc implemented here. CENC 4. const int kCencSchemeVersion = 0x00010000; -uint64 Rescale(uint64 time_in_old_scale, uint32 old_scale, uint32 new_scale) { +uint64_t Rescale(uint64_t time_in_old_scale, + uint32_t old_scale, + uint32_t new_scale) { return static_cast(time_in_old_scale) / old_scale * new_scale; } @@ -87,7 +89,7 @@ void GenerateEncryptedSampleEntryForKeyRotation( encryption_key, clear_lead_in_seconds, description); } -uint8 GetNaluLengthSize(const StreamInfo& stream_info) { +uint8_t GetNaluLengthSize(const StreamInfo& stream_info) { if (stream_info.stream_type() != kStreamVideo) return 0; const VideoStreamInfo& video_stream_info = @@ -95,15 +97,15 @@ uint8 GetNaluLengthSize(const StreamInfo& stream_info) { return video_stream_info.nalu_length_size(); } -KeySource::TrackType GetTrackTypeForEncryption( - const StreamInfo& stream_info, uint32 max_sd_pixels) { +KeySource::TrackType GetTrackTypeForEncryption(const StreamInfo& stream_info, + uint32_t max_sd_pixels) { if (stream_info.stream_type() == kStreamAudio) return KeySource::TRACK_TYPE_AUDIO; DCHECK_EQ(kStreamVideo, stream_info.stream_type()); const VideoStreamInfo& video_stream_info = static_cast(stream_info); - uint32 pixels = video_stream_info.width() * video_stream_info.height(); + uint32_t pixels = video_stream_info.width() * video_stream_info.height(); return (pixels > max_sd_pixels) ? KeySource::TRACK_TYPE_HD : KeySource::TRACK_TYPE_SD; } @@ -128,7 +130,7 @@ Segmenter::~Segmenter() { STLDeleteElements(&fragmenters_); } Status Segmenter::Initialize(const std::vector& streams, event::MuxerListener* muxer_listener, KeySource* encryption_key_source, - uint32 max_sd_pixels, + uint32_t max_sd_pixels, double clear_lead_in_seconds, double crypto_period_duration_in_seconds) { DCHECK_LT(0u, streams.size()); @@ -138,7 +140,7 @@ Status Segmenter::Initialize(const std::vector& streams, moof_->tracks.resize(streams.size()); segment_durations_.resize(streams.size()); fragmenters_.resize(streams.size()); - for (uint32 i = 0; i < streams.size(); ++i) { + for (uint32_t i = 0; i < streams.size(); ++i) { stream_map_[streams[i]] = i; moof_->tracks[i].header.track_id = i + 1; if (streams[i]->info()->stream_type() == kStreamVideo) { @@ -151,7 +153,7 @@ Status Segmenter::Initialize(const std::vector& streams, continue; } - uint8 nalu_length_size = GetNaluLengthSize(*streams[i]->info()); + uint8_t nalu_length_size = GetNaluLengthSize(*streams[i]->info()); KeySource::TrackType track_type = GetTrackTypeForEncryption(*streams[i]->info(), max_sd_pixels); SampleDescription& description = @@ -237,7 +239,7 @@ Status Segmenter::AddSample(const MediaStream* stream, // Find the fragmenter for this stream. DCHECK(stream); DCHECK(stream_map_.find(stream) != stream_map_.end()); - uint32 stream_id = stream_map_[stream]; + uint32_t stream_id = stream_map_[stream]; Fragmenter* fragmenter = fragmenters_[stream_id]; // Set default sample duration if it has not been set yet. @@ -287,7 +289,7 @@ Status Segmenter::AddSample(const MediaStream* stream, return Status::OK; } -uint32 Segmenter::GetReferenceTimeScale() const { +uint32_t Segmenter::GetReferenceTimeScale() const { return moov_->header.timescale; } @@ -303,7 +305,7 @@ double Segmenter::GetDuration() const { void Segmenter::InitializeSegment() { sidx_->references.clear(); end_of_segment_ = false; - std::vector::iterator it = segment_durations_.begin(); + std::vector::iterator it = segment_durations_.begin(); for (; it != segment_durations_.end(); ++it) *it = 0; } @@ -313,7 +315,7 @@ Status Segmenter::FinalizeSegment() { return DoFinalizeSegment(); } -uint32 Segmenter::GetReferenceStreamId() { +uint32_t Segmenter::GetReferenceStreamId() { DCHECK(sidx_); return sidx_->reference_id - 1; } @@ -332,7 +334,7 @@ Status Segmenter::FinalizeFragment(Fragmenter* fragmenter) { MediaData mdat; // Fill in data offsets. Data offset base is moof size + mdat box size. // (mdat is still empty, mdat size is the same as mdat box size). - uint64 base = moof_->ComputeSize() + mdat.ComputeSize(); + uint64_t base = moof_->ComputeSize() + mdat.ComputeSize(); for (uint i = 0; i < moof_->tracks.size(); ++i) { TrackFragment& traf = moof_->tracks[i]; Fragmenter* fragmenter = fragmenters_[i]; diff --git a/media/formats/mp4/segmenter.h b/media/formats/mp4/segmenter.h index dbeb5bfae0..78be6b5c8d 100644 --- a/media/formats/mp4/segmenter.h +++ b/media/formats/mp4/segmenter.h @@ -66,7 +66,7 @@ class Segmenter { Status Initialize(const std::vector& streams, event::MuxerListener* muxer_listener, KeySource* encryption_key_source, - uint32 max_sd_pixels, + uint32_t max_sd_pixels, double clear_lead_in_seconds, double crypto_period_duration_in_seconds); @@ -90,7 +90,7 @@ class Segmenter { /// and @a size; or false if index byte range does not apply. virtual bool GetIndexRange(size_t* offset, size_t* size) = 0; - uint32 GetReferenceTimeScale() const; + uint32_t GetReferenceTimeScale() const; /// @return The total length, in seconds, of segmented media files. double GetDuration() const; @@ -110,7 +110,7 @@ class Segmenter { void InitializeSegment(); Status FinalizeSegment(); - uint32 GetReferenceStreamId(); + uint32_t GetReferenceStreamId(); Status FinalizeFragment(Fragmenter* fragment); @@ -121,8 +121,8 @@ class Segmenter { scoped_ptr fragment_buffer_; scoped_ptr sidx_; std::vector fragmenters_; - std::vector segment_durations_; - std::map stream_map_; + std::vector segment_durations_; + std::map stream_map_; bool segment_initialized_; bool end_of_segment_; event::MuxerListener* muxer_listener_; diff --git a/media/formats/mp4/single_segment_segmenter.cc b/media/formats/mp4/single_segment_segmenter.cc index a013a10f5b..d15d3a9044 100644 --- a/media/formats/mp4/single_segment_segmenter.cc +++ b/media/formats/mp4/single_segment_segmenter.cc @@ -92,14 +92,14 @@ Status SingleSegmentSegmenter::DoFinalize() { } const int kBufSize = 0x40000; // 256KB. - scoped_ptr buf(new uint8[kBufSize]); + scoped_ptr buf(new uint8_t[kBufSize]); while (!temp_file->Eof()) { - int64 size = temp_file->Read(buf.get(), kBufSize); + int64_t size = temp_file->Read(buf.get(), kBufSize); if (size <= 0) { return Status(error::FILE_FAILURE, "Failed to read file " + temp_file_name_); } - int64 size_written = file->Write(buf.get(), size); + int64_t size_written = file->Write(buf.get(), size); if (size_written != size) { return Status(error::FILE_FAILURE, "Failed to write file " + options().output_file_name); @@ -116,9 +116,9 @@ Status SingleSegmentSegmenter::DoFinalizeSegment() { // reference, which contains all the fragments in sidx(). std::vector& refs = sidx()->references; SegmentReference& vod_ref = refs[0]; - uint64 first_sap_time = + uint64_t first_sap_time = refs[0].sap_delta_time + refs[0].earliest_presentation_time; - for (uint32 i = 1; i < sidx()->references.size(); ++i) { + for (uint32_t i = 1; i < sidx()->references.size(); ++i) { vod_ref.referenced_size += refs[i].referenced_size; // NOTE: We calculate subsegment duration based on the total duration of // this subsegment instead of subtracting earliest_presentation_time as diff --git a/media/formats/mp4/sync_sample_iterator.cc b/media/formats/mp4/sync_sample_iterator.cc index f60dbdbf3d..17f92c3ce1 100644 --- a/media/formats/mp4/sync_sample_iterator.cc +++ b/media/formats/mp4/sync_sample_iterator.cc @@ -33,7 +33,7 @@ bool SyncSampleIterator::IsSyncSample() const { return iterator_ != sync_sample_vector_.end() && sample_number_ == *iterator_; } -bool SyncSampleIterator::IsSyncSample(uint32 sample) const { +bool SyncSampleIterator::IsSyncSample(uint32_t sample) const { // If the sync sample box is not present, every sample is a sync sample. if (is_empty_) return true; diff --git a/media/formats/mp4/sync_sample_iterator.h b/media/formats/mp4/sync_sample_iterator.h index e072bc8ca0..7a14f94973 100644 --- a/media/formats/mp4/sync_sample_iterator.h +++ b/media/formats/mp4/sync_sample_iterator.h @@ -31,12 +31,12 @@ class SyncSampleIterator { bool IsSyncSample() const; /// @return true if @a sample (1-based) is a sync sample, false otherwise. - bool IsSyncSample(uint32 sample) const; + bool IsSyncSample(uint32_t sample) const; private: - uint32 sample_number_; - const std::vector& sync_sample_vector_; - std::vector::const_iterator iterator_; + uint32_t sample_number_; + const std::vector& sync_sample_vector_; + std::vector::const_iterator iterator_; bool is_empty_; DISALLOW_COPY_AND_ASSIGN(SyncSampleIterator); diff --git a/media/formats/mp4/sync_sample_iterator_unittest.cc b/media/formats/mp4/sync_sample_iterator_unittest.cc index 8865f8b41e..e78127ce38 100644 --- a/media/formats/mp4/sync_sample_iterator_unittest.cc +++ b/media/formats/mp4/sync_sample_iterator_unittest.cc @@ -9,12 +9,12 @@ #include "media/formats/mp4/sync_sample_iterator.h" namespace { -const uint32 kNumSamples = 100; -const uint32 kSyncSamples[] = {3, 10, 30, 35, 89, 97}; +const uint32_t kNumSamples = 100; +const uint32_t kSyncSamples[] = {3, 10, 30, 35, 89, 97}; // Check if sample is an element in kSyncSamples. -bool InSyncSamples(uint32 sample) { - for (uint32 i = 0; i < sizeof(kSyncSamples) / sizeof(uint32); ++i) { +bool InSyncSamples(uint32_t sample) { + for (uint32_t i = 0; i < sizeof(kSyncSamples) / sizeof(uint32_t); ++i) { if (sample == kSyncSamples[i]) return true; } @@ -36,10 +36,10 @@ TEST(SyncSampleIteratorTest, EmptySyncSample) { TEST(SyncSampleIteratorTest, SyncSample) { SyncSample sync_sample; sync_sample.sample_number.assign( - kSyncSamples, kSyncSamples + sizeof(kSyncSamples) / sizeof(uint32)); + kSyncSamples, kSyncSamples + sizeof(kSyncSamples) / sizeof(uint32_t)); SyncSampleIterator iterator(sync_sample); - uint32 i = 1; + uint32_t i = 1; // Check if it is sync sample using SyncSampleIterator::AdvanceSample() and // SyncSampleIterator::IsSyncSample(). @@ -48,7 +48,8 @@ TEST(SyncSampleIteratorTest, SyncSample) { ASSERT_TRUE(iterator.AdvanceSample()); } - // Check if it is sync sample using SyncSampleIterator::IsSyncSample(uint32). + // Check if it is sync sample using + // SyncSampleIterator::IsSyncSample(uint32_t). // No need to advance sample for this case. for (; i <= kNumSamples / 2; ++i) { ASSERT_EQ(InSyncSamples(i), iterator.IsSyncSample(i)); diff --git a/media/formats/mp4/track_run_iterator.cc b/media/formats/mp4/track_run_iterator.cc index b2c14abe95..985f55015b 100644 --- a/media/formats/mp4/track_run_iterator.cc +++ b/media/formats/mp4/track_run_iterator.cc @@ -25,19 +25,19 @@ struct SampleInfo { }; struct TrackRunInfo { - uint32 track_id; + uint32_t track_id; std::vector samples; - int64 timescale; - int64 start_dts; - int64 sample_start_offset; + int64_t timescale; + int64_t start_dts; + int64_t sample_start_offset; TrackType track_type; const AudioSampleEntry* audio_description; const VideoSampleEntry* video_description; - int64 aux_info_start_offset; // Only valid if aux_info_total_size > 0. + int64_t aux_info_start_offset; // Only valid if aux_info_total_size > 0. int aux_info_default_size; - std::vector aux_info_sizes; // Populated if default_size == 0. + std::vector aux_info_sizes; // Populated if default_size == 0. int aux_info_total_size; TrackRunInfo(); @@ -67,7 +67,7 @@ TrackRunIterator::~TrackRunIterator() {} static void PopulateSampleInfo(const TrackExtends& trex, const TrackFragmentHeader& tfhd, const TrackFragmentRun& trun, - const uint32 i, + const uint32_t i, SampleInfo* sample_info) { if (i < trun.sample_sizes.size()) { sample_info->size = trun.sample_sizes[i]; @@ -91,7 +91,7 @@ static void PopulateSampleInfo(const TrackExtends& trex, sample_info->cts_offset = 0; } - uint32 flags; + uint32_t flags; if (i < trun.sample_flags.size()) { flags = trun.sample_flags[i]; } else if (tfhd.flags & TrackFragmentHeader::kDefaultSampleFlagsPresentMask) { @@ -116,13 +116,13 @@ static void PopulateSampleInfo(const TrackExtends& trex, class CompareMinTrackRunDataOffset { public: bool operator()(const TrackRunInfo& a, const TrackRunInfo& b) { - int64 a_aux = a.aux_info_total_size ? a.aux_info_start_offset : kint64max; - int64 b_aux = b.aux_info_total_size ? b.aux_info_start_offset : kint64max; + int64_t a_aux = a.aux_info_total_size ? a.aux_info_start_offset : kint64max; + int64_t b_aux = b.aux_info_total_size ? b.aux_info_start_offset : kint64max; - int64 a_lesser = std::min(a_aux, a.sample_start_offset); - int64 a_greater = std::max(a_aux, a.sample_start_offset); - int64 b_lesser = std::min(b_aux, b.sample_start_offset); - int64 b_greater = std::max(b_aux, b.sample_start_offset); + int64_t a_lesser = std::min(a_aux, a.sample_start_offset); + int64_t a_greater = std::max(a_aux, a.sample_start_offset); + int64_t b_lesser = std::min(b_aux, b.sample_start_offset); + int64_t b_greater = std::max(b_aux, b.sample_start_offset); if (a_lesser == b_lesser) return a_greater < b_greater; @@ -169,13 +169,13 @@ bool TrackRunIterator::Init() { const SampleSize& sample_size = trak->media.information.sample_table.sample_size; - const std::vector& chunk_offset_vector = + const std::vector& chunk_offset_vector = trak->media.information.sample_table.chunk_large_offset.offsets; - int64 run_start_dts = 0; + int64_t run_start_dts = 0; - uint32 num_samples = sample_size.sample_count; - uint32 num_chunks = chunk_offset_vector.size(); + uint32_t num_samples = sample_size.sample_count; + uint32_t num_chunks = chunk_offset_vector.size(); // Check that total number of samples match. DCHECK_EQ(num_samples, decoding_time.NumSamples()); @@ -191,8 +191,8 @@ bool TrackRunIterator::Init() { RCHECK(chunk_info.IsValid()); } - uint32 sample_index = 0; - for (uint32 chunk_index = 0; chunk_index < num_chunks; ++chunk_index) { + uint32_t sample_index = 0; + for (uint32_t chunk_index = 0; chunk_index < num_chunks; ++chunk_index) { RCHECK(chunk_info.current_chunk() == chunk_index + 1); TrackRunInfo tri; @@ -201,7 +201,7 @@ bool TrackRunIterator::Init() { tri.start_dts = run_start_dts; tri.sample_start_offset = chunk_offset_vector[chunk_index]; - uint32 desc_idx = chunk_info.sample_description_index(); + uint32_t desc_idx = chunk_info.sample_description_index(); RCHECK(desc_idx > 0); // Descriptions are one-indexed in the file. desc_idx -= 1; @@ -222,9 +222,9 @@ bool TrackRunIterator::Init() { RCHECK(!tri.video_description->sinf.info.track_encryption.is_encrypted); } - uint32 samples_per_chunk = chunk_info.samples_per_chunk(); + uint32_t samples_per_chunk = chunk_info.samples_per_chunk(); tri.samples.resize(samples_per_chunk); - for (uint32 k = 0; k < samples_per_chunk; ++k) { + for (uint32_t k = 0; k < samples_per_chunk; ++k) { SampleInfo& sample = tri.samples[k]; sample.size = sample_size.sample_size != 0 ? sample_size.sample_size @@ -294,7 +294,7 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { RCHECK(desc_idx > 0); // Descriptions are one-indexed in the file desc_idx -= 1; - int64 run_start_dts = traf.decode_time.decode_time; + int64_t run_start_dts = traf.decode_time.decode_time; int sample_count_sum = 0; for (size_t j = 0; j < traf.runs.size(); j++) { @@ -330,7 +330,7 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { tri.aux_info_default_size = traf.auxiliary_size.default_sample_info_size; if (tri.aux_info_default_size == 0) { - const std::vector& sizes = + const std::vector& sizes = traf.auxiliary_size.sample_info_sizes; tri.aux_info_sizes.insert( tri.aux_info_sizes.begin(), @@ -400,11 +400,11 @@ bool TrackRunIterator::AuxInfoNeedsToBeCached() { } // This implementation currently only caches CENC auxiliary info. -bool TrackRunIterator::CacheAuxInfo(const uint8* buf, int buf_size) { +bool TrackRunIterator::CacheAuxInfo(const uint8_t* buf, int buf_size) { RCHECK(AuxInfoNeedsToBeCached() && buf_size >= aux_info_size()); cenc_info_.resize(run_itr_->samples.size()); - int64 pos = 0; + int64_t pos = 0; for (size_t i = 0; i < run_itr_->samples.size(); i++) { int info_size = run_itr_->aux_info_default_size; if (!info_size) @@ -430,8 +430,8 @@ bool TrackRunIterator::IsSampleValid() const { // (The stronger condition - that no data is required before the minimum data // offset of this track alone - is not guaranteed, because the BMFF spec does // not have any inter-run ordering restrictions.) -int64 TrackRunIterator::GetMaxClearOffset() { - int64 offset = kint64max; +int64_t TrackRunIterator::GetMaxClearOffset() { + int64_t offset = kint64max; if (IsSampleValid()) { offset = std::min(offset, sample_offset_); @@ -451,7 +451,7 @@ int64 TrackRunIterator::GetMaxClearOffset() { return offset; } -uint32 TrackRunIterator::track_id() const { +uint32_t TrackRunIterator::track_id() const { DCHECK(IsRunValid()); return run_itr_->track_id; } @@ -461,7 +461,7 @@ bool TrackRunIterator::is_encrypted() const { return track_encryption().is_encrypted; } -int64 TrackRunIterator::aux_info_offset() const { +int64_t TrackRunIterator::aux_info_offset() const { return run_itr_->aux_info_start_offset; } @@ -491,7 +491,7 @@ const VideoSampleEntry& TrackRunIterator::video_description() const { return *run_itr_->video_description; } -int64 TrackRunIterator::sample_offset() const { +int64_t TrackRunIterator::sample_offset() const { DCHECK(IsSampleValid()); return sample_offset_; } @@ -501,17 +501,17 @@ int TrackRunIterator::sample_size() const { return sample_itr_->size; } -int64 TrackRunIterator::dts() const { +int64_t TrackRunIterator::dts() const { DCHECK(IsSampleValid()); return sample_dts_; } -int64 TrackRunIterator::cts() const { +int64_t TrackRunIterator::cts() const { DCHECK(IsSampleValid()); return sample_dts_ + sample_itr_->cts_offset; } -int64 TrackRunIterator::duration() const { +int64_t TrackRunIterator::duration() const { DCHECK(IsSampleValid()); return sample_itr_->duration; } diff --git a/media/formats/mp4/track_run_iterator.h b/media/formats/mp4/track_run_iterator.h index 52e36c8a4e..68f8081105 100644 --- a/media/formats/mp4/track_run_iterator.h +++ b/media/formats/mp4/track_run_iterator.h @@ -62,7 +62,7 @@ class TrackRunIterator { /// @param buf must be a buffer starting at the offset given by cenc_offset(). /// @param size must be at least cenc_size(). /// @return true on success, false on error. - bool CacheAuxInfo(const uint8* buf, int size); + bool CacheAuxInfo(const uint8_t* buf, int size); /// @return the maximum buffer location at which no data earlier in the /// stream will be required in order to read the current or any @@ -70,12 +70,12 @@ class TrackRunIterator { /// before reading the current sample safely. Result is in the same /// units as offset() (for Media Source this is in bytes past the /// head of the MOOF box). - int64 GetMaxClearOffset(); + int64_t GetMaxClearOffset(); /// @name Properties of the current run. Only valid if IsRunValid(). /// @{ - uint32 track_id() const; - int64 aux_info_offset() const; + uint32_t track_id() const; + int64_t aux_info_offset() const; int aux_info_size() const; bool is_encrypted() const; bool is_audio() const; @@ -89,11 +89,11 @@ class TrackRunIterator { /// @name Properties of the current sample. Only valid if IsSampleValid(). /// @{ - int64 sample_offset() const; + int64_t sample_offset() const; int sample_size() const; - int64 dts() const; - int64 cts() const; - int64 duration() const; + int64_t dts() const; + int64_t cts() const; + int64_t duration() const; bool is_keyframe() const; /// @} @@ -113,8 +113,8 @@ class TrackRunIterator { std::vector cenc_info_; - int64 sample_dts_; - int64 sample_offset_; + int64_t sample_dts_; + int64_t sample_offset_; DISALLOW_COPY_AND_ASSIGN(TrackRunIterator); }; diff --git a/media/formats/mp4/track_run_iterator_unittest.cc b/media/formats/mp4/track_run_iterator_unittest.cc index f57c0d4a08..2eb20ff2eb 100644 --- a/media/formats/mp4/track_run_iterator_unittest.cc +++ b/media/formats/mp4/track_run_iterator_unittest.cc @@ -18,7 +18,7 @@ static const int kSumAscending1 = 45; static const int kAudioScale = 48000; static const int kVideoScale = 25; -static const uint8 kAuxInfo[] = { +static const uint8_t kAuxInfo[] = { // Sample 1: IV (no subsumples). 0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x31, // Sample 2: IV. @@ -32,8 +32,9 @@ static const uint8 kAuxInfo[] = { static const char kIv1[] = {0x41, 0x54, 0x65, 0x73, 0x74, 0x49, 0x76, 0x31, }; -static const uint8 kKeyId[] = {0x41, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x54, - 0x65, 0x73, 0x74, 0x4b, 0x65, 0x79, 0x49, 0x44}; +static const uint8_t kKeyId[] = {0x41, 0x47, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x54, 0x65, 0x73, 0x74, 0x4b, + 0x65, 0x79, 0x49, 0x44}; namespace edash_packager { namespace media { @@ -142,7 +143,7 @@ class TrackRunIteratorTest : public testing::Test { frag->runs[0].sample_sizes[1] = 10; } - void SetAscending(std::vector* vec) { + void SetAscending(std::vector* vec) { vec->resize(10); for (size_t i = 0; i < vec->size(); i++) (*vec)[i] = i + 1; @@ -195,7 +196,7 @@ TEST_F(TrackRunIteratorTest, BasicOperationTest) { EXPECT_EQ(iter_->track_id(), 2u); EXPECT_EQ(iter_->sample_offset(), 200 + kSumAscending1); EXPECT_EQ(iter_->sample_size(), 10); - int64 base_dts = kSumAscending1 + moof.tracks[1].decode_time.decode_time; + int64_t base_dts = kSumAscending1 + moof.tracks[1].decode_time.decode_time; EXPECT_EQ(iter_->dts(), base_dts); EXPECT_EQ(iter_->duration(), 10); EXPECT_FALSE(iter_->is_keyframe()); @@ -267,7 +268,7 @@ TEST_F(TrackRunIteratorTest, ReorderingTest) { // would simply be [0, 3, -2]. Since CTS offsets should be non-negative for // maximum compatibility, these values are biased up to [2, 5, 0]. MovieFragment moof = CreateFragment(); - std::vector& cts_offsets = + std::vector& cts_offsets = moof.tracks[1].runs[0].sample_composition_time_offsets; cts_offsets.resize(10); cts_offsets[0] = 2; @@ -316,7 +317,7 @@ TEST_F(TrackRunIteratorTest, DecryptConfigTest) { EXPECT_EQ(iter_->track_id(), 2u); EXPECT_TRUE(iter_->is_encrypted()); EXPECT_TRUE(iter_->AuxInfoNeedsToBeCached()); - EXPECT_EQ(static_cast(iter_->aux_info_size()), arraysize(kAuxInfo)); + EXPECT_EQ(static_cast(iter_->aux_info_size()), arraysize(kAuxInfo)); EXPECT_EQ(iter_->aux_info_offset(), 50); EXPECT_EQ(iter_->GetMaxClearOffset(), 50); EXPECT_FALSE(iter_->CacheAuxInfo(NULL, 0)); diff --git a/media/formats/wvm/wvm_media_parser.cc b/media/formats/wvm/wvm_media_parser.cc index 8b28ef0342..161f9d7f39 100644 --- a/media/formats/wvm/wvm_media_parser.cc +++ b/media/formats/wvm/wvm_media_parser.cc @@ -18,36 +18,36 @@ && (x != 0xFF)) namespace { - const uint32 kMpeg2ClockRate = 90000; - const uint32 kPesOptPts = 0x80; - const uint32 kPesOptDts = 0x40; - const uint32 kPesOptAlign = 0x04; - const uint32 kPsmStreamId = 0xBC; - const uint32 kPaddingStreamId = 0xBE; - const uint32 kIndexMagic = 0x49444d69; - const uint32 kIndexStreamId = 0xBF; // private_stream_2 - const uint32 kIndexVersion4HeaderSize = 12; - const uint32 kEcmStreamId = 0xF0; - const uint32 kV2MetadataStreamId = 0xF1; // EMM_stream - const uint32 kScramblingBitsMask = 0x30; - const uint32 kStartCode1 = 0x00; - const uint32 kStartCode2 = 0x00; - const uint32 kStartCode3 = 0x01; - const uint32 kStartCode4Pack = 0xBA; - const uint32 kStartCode4System = 0xBB; - const uint32 kStartCode4ProgramEnd = 0xB9; - const uint32 kPesStreamIdVideoMask = 0xF0; - const uint32 kPesStreamIdVideo = 0xE0; - const uint32 kPesStreamIdAudioMask = 0xE0; - const uint32 kPesStreamIdAudio = 0xC0; - const uint32 kVersion4 = 4; +const uint32_t kMpeg2ClockRate = 90000; +const uint32_t kPesOptPts = 0x80; +const uint32_t kPesOptDts = 0x40; +const uint32_t kPesOptAlign = 0x04; +const uint32_t kPsmStreamId = 0xBC; +const uint32_t kPaddingStreamId = 0xBE; +const uint32_t kIndexMagic = 0x49444d69; +const uint32_t kIndexStreamId = 0xBF; // private_stream_2 +const uint32_t kIndexVersion4HeaderSize = 12; +const uint32_t kEcmStreamId = 0xF0; +const uint32_t kV2MetadataStreamId = 0xF1; // EMM_stream +const uint32_t kScramblingBitsMask = 0x30; +const uint32_t kStartCode1 = 0x00; +const uint32_t kStartCode2 = 0x00; +const uint32_t kStartCode3 = 0x01; +const uint32_t kStartCode4Pack = 0xBA; +const uint32_t kStartCode4System = 0xBB; +const uint32_t kStartCode4ProgramEnd = 0xB9; +const uint32_t kPesStreamIdVideoMask = 0xF0; +const uint32_t kPesStreamIdVideo = 0xE0; +const uint32_t kPesStreamIdAudioMask = 0xE0; +const uint32_t kPesStreamIdAudio = 0xC0; +const uint32_t kVersion4 = 4; const int kAdtsHeaderMinSize = 7; - const uint8 kAacSampleSizeBits = 16; + const uint8_t kAacSampleSizeBits = 16; // Applies to all video streams. - const uint8 kNaluLengthSize = 4; // unit is bytes. + const uint8_t kNaluLengthSize = 4; // unit is bytes. // Placeholder sampling frequency for all audio streams, which // will be overwritten after filter parsing. - const uint32 kDefaultSamplingFrequency = 100; + const uint32_t kDefaultSamplingFrequency = 100; enum Type { Type_void = 0, @@ -105,11 +105,11 @@ void WvmMediaParser::Init(const InitCB& init_cb, new_sample_cb_ = new_sample_cb; } -bool WvmMediaParser::Parse(const uint8* buf, int size) { - uint32 num_bytes, prev_size; +bool WvmMediaParser::Parse(const uint8_t* buf, int size) { + uint32_t num_bytes, prev_size; num_bytes = prev_size = 0; - uint8* read_ptr = (uint8*)(&buf[0]); - uint8* end = read_ptr + size; + uint8_t* read_ptr = (uint8_t*)(&buf[0]); + uint8_t* end = read_ptr + size; while (read_ptr < end) { switch(parse_state_) { @@ -189,7 +189,7 @@ bool WvmMediaParser::Parse(const uint8* buf, int size) { parse_state_ = SystemHeaderSkip; break; case PackHeaderStuffingSkip: - if ((end - read_ptr) >= (int32)skip_bytes_) { + if ((end - read_ptr) >= (int32_t)skip_bytes_) { read_ptr += skip_bytes_; skip_bytes_ = 0; parse_state_ = StartCode1; @@ -199,12 +199,12 @@ bool WvmMediaParser::Parse(const uint8* buf, int size) { } continue; case SystemHeaderSkip: - if ((end - read_ptr) >= (int32)skip_bytes_) { + if ((end - read_ptr) >= (int32_t)skip_bytes_) { read_ptr += skip_bytes_; skip_bytes_ = 0; parse_state_ = StartCode1; } else { - uint32 remaining_size = end - read_ptr; + uint32_t remaining_size = end - read_ptr; skip_bytes_ -= remaining_size; read_ptr = end; } @@ -466,11 +466,11 @@ bool WvmMediaParser::Parse(const uint8* buf, int size) { return true; } -bool WvmMediaParser::EmitLastSample(uint32 stream_id, +bool WvmMediaParser::EmitLastSample(uint32_t stream_id, scoped_refptr& new_sample) { std::string key = base::UintToString(current_program_id_).append(":") .append(base::UintToString(stream_id)); - std::map::iterator it = + std::map::iterator it = program_demux_stream_map_.find(key); if (it != program_demux_stream_map_.end()) { EmitSample(stream_id, (*it).second, new_sample, true); @@ -518,7 +518,7 @@ bool WvmMediaParser::ParseIndexEntry() { if (current_program_id_ > 0) { return true; } - uint32 index_size = 0; + uint32_t index_size = 0; if (index_data_.size() < kIndexVersion4HeaderSize) { return false; } @@ -528,116 +528,116 @@ bool WvmMediaParser::ParseIndexEntry() { } } - const uint8* read_ptr_index = &index_data_[0]; + const uint8_t* read_ptr_index = &index_data_[0]; if (ntohlFromBuffer(read_ptr_index) != kIndexMagic) { index_data_.clear(); return false; } read_ptr_index += 4; - uint32 version = ntohlFromBuffer(read_ptr_index); + uint32_t version = ntohlFromBuffer(read_ptr_index); read_ptr_index += 4; if (version == kVersion4) { index_size = kIndexVersion4HeaderSize + ntohlFromBuffer(read_ptr_index); if (index_data_.size() < index_size) { return false; } - read_ptr_index += sizeof(uint32); + read_ptr_index += sizeof(uint32_t); // Index metadata - uint32 index_metadata_max_size = index_size - kIndexVersion4HeaderSize; - if (index_metadata_max_size < sizeof(uint8)) { + uint32_t index_metadata_max_size = index_size - kIndexVersion4HeaderSize; + if (index_metadata_max_size < sizeof(uint8_t)) { index_data_.clear(); return false; } - uint64 track_duration = 0; - uint32 sampling_frequency = kDefaultSamplingFrequency; - uint32 time_scale = kMpeg2ClockRate; - uint16 video_width = 0; - uint16 video_height = 0; - uint8 nalu_length_size = kNaluLengthSize; - uint8 num_channels = 0; + uint64_t track_duration = 0; + uint32_t sampling_frequency = kDefaultSamplingFrequency; + uint32_t time_scale = kMpeg2ClockRate; + uint16_t video_width = 0; + uint16_t video_height = 0; + uint8_t nalu_length_size = kNaluLengthSize; + uint8_t num_channels = 0; int audio_pes_stream_id = 0; int video_pes_stream_id = 0; bool has_video = false; bool has_audio = false; - std::vector decoder_config_record; + std::vector decoder_config_record; std::string video_codec_string; std::string audio_codec_string; - uint8 num_index_entries = *read_ptr_index; + uint8_t num_index_entries = *read_ptr_index; ++read_ptr_index; --index_metadata_max_size; - for (uint8 idx = 0; idx < num_index_entries; ++idx) { - if (index_metadata_max_size < (2 * sizeof(uint8)) + sizeof(uint32)) { + for (uint8_t idx = 0; idx < num_index_entries; ++idx) { + if (index_metadata_max_size < (2 * sizeof(uint8_t)) + sizeof(uint32_t)) { return false; } - uint8 tag = *read_ptr_index; + uint8_t tag = *read_ptr_index; ++read_ptr_index; - uint8 type = *read_ptr_index; + uint8_t type = *read_ptr_index; ++read_ptr_index; - uint32 length = ntohlFromBuffer(read_ptr_index); - read_ptr_index += sizeof(uint32); - index_metadata_max_size -= (2 * sizeof(uint8)) + sizeof(uint32); + uint32_t length = ntohlFromBuffer(read_ptr_index); + read_ptr_index += sizeof(uint32_t); + index_metadata_max_size -= (2 * sizeof(uint8_t)) + sizeof(uint32_t); if (index_metadata_max_size < length) { return false; } int value = 0; Tag tagtype = Unset; - std::vector binary_data(length); + std::vector binary_data(length); switch (Type(type)) { case Type_uint8: - if (length == sizeof(uint8)) { + if (length == sizeof(uint8_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_int8: - if (length == sizeof(int8)) { + if (length == sizeof(int8_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_uint16: - if (length == sizeof(uint16)) { + if (length == sizeof(uint16_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_int16: - if (length == sizeof(int16)) { + if (length == sizeof(int16_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_uint32: - if (length == sizeof(uint32)) { + if (length == sizeof(uint32_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_int32: - if (length == sizeof(int32)) { + if (length == sizeof(int32_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_uint64: - if (length == sizeof(uint64)) { + if (length == sizeof(uint64_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; } break; case Type_int64: - if (length == sizeof(int64)) { + if (length == sizeof(int64_t)) { tagtype = GetTag(tag, length, read_ptr_index, &value); } else { return false; @@ -663,13 +663,13 @@ bool WvmMediaParser::ParseIndexEntry() { audio_pes_stream_id = value; break; case VideoWidth: - video_width = (uint16)value; + video_width = (uint16_t)value; break; case VideoHeight: - video_height = (uint16)value; + video_height = (uint16_t)value; break; case AudioNumChannels: - num_channels = (uint8)value; + num_channels = (uint8_t)value; break; case VideoType: has_video = true; @@ -715,7 +715,7 @@ bool WvmMediaParser::ParseIndexEntry() { return true; } -bool WvmMediaParser::DemuxNextPes(uint8* read_ptr, bool is_program_end) { +bool WvmMediaParser::DemuxNextPes(uint8_t* read_ptr, bool is_program_end) { // Demux media sample if we are at program end or if we are not at a // continuation PES. if (is_program_end || (pes_flags_2_ & kPesOptPts)) { @@ -729,7 +729,7 @@ bool WvmMediaParser::DemuxNextPes(uint8* read_ptr, bool is_program_end) { return true; } -void WvmMediaParser::StartMediaSampleDemux(uint8* read_ptr) { +void WvmMediaParser::StartMediaSampleDemux(uint8_t* read_ptr) { bool is_key_frame = ((pes_flags_1_ & kPesOptAlign) != 0); media_sample_ = MediaSample::CreateEmptyMediaSample(); media_sample_->set_dts(dts_); @@ -742,17 +742,17 @@ void WvmMediaParser::StartMediaSampleDemux(uint8* read_ptr) { bool WvmMediaParser::Output() { if ((prev_pes_stream_id_ & kPesStreamIdVideoMask) == kPesStreamIdVideo) { // Set data on the video stream from the NalUnitStream. - std::vector nal_unit_stream; + std::vector nal_unit_stream; byte_to_unit_stream_converter_.ConvertByteStreamToNalUnitStream( &sample_data_[0], sample_data_.size(), &nal_unit_stream); media_sample_->set_data(nal_unit_stream.data(), nal_unit_stream.size()); if (!is_initialized_) { // Set extra data for video stream from AVC Decoder Config Record. // Also, set codec string from the AVC Decoder Config Record. - std::vector decoder_config_record; + std::vector decoder_config_record; byte_to_unit_stream_converter_.GetAVCDecoderConfigurationRecord( &decoder_config_record); - for (uint32 i = 0; i < stream_infos_.size(); i++) { + for (uint32_t i = 0; i < stream_infos_.size(); i++) { if (stream_infos_[i]->stream_type() == media::kStreamVideo && stream_infos_[i]->extra_data().empty()) { stream_infos_[i]->set_extra_data(decoder_config_record); @@ -769,8 +769,8 @@ bool WvmMediaParser::Output() { media::mp2t::AdtsHeader::GetAdtsFrameSize(&sample_data_[0], kAdtsHeaderMinSize); media::mp2t::AdtsHeader adts_header; - const uint8* frame_ptr = &sample_data_[0]; - std::vector extra_data; + const uint8_t* frame_ptr = &sample_data_[0]; + std::vector extra_data; if (adts_header.Parse(frame_ptr, frame_size) && (adts_header.GetAudioSpecificConfig(&extra_data))) { size_t header_size = adts_header.GetAdtsHeaderSize(frame_ptr, @@ -778,8 +778,8 @@ bool WvmMediaParser::Output() { media_sample_->set_data(frame_ptr + header_size, frame_size - header_size); if (!is_initialized_) { - uint32 sampling_frequency = adts_header.GetSamplingFrequency(); - for (uint32 i = 0; i < stream_infos_.size(); i++) { + uint32_t sampling_frequency = adts_header.GetSamplingFrequency(); + for (uint32_t i = 0; i < stream_infos_.size(); i++) { AudioStreamInfo* audio_stream_info = reinterpret_cast( stream_infos_[i].get()); @@ -801,7 +801,7 @@ bool WvmMediaParser::Output() { if (!is_initialized_) { bool is_extra_data_in_stream_infos = true; // Check if all collected stream infos have extra_data set. - for (uint32 i = 0; i < stream_infos_.size(); i++) { + for (uint32_t i = 0; i < stream_infos_.size(); i++) { if (stream_infos_[i]->extra_data().empty()) { is_extra_data_in_stream_infos = false; break; @@ -816,7 +816,7 @@ bool WvmMediaParser::Output() { DCHECK_GT(media_sample_->data_size(), 0UL); std::string key = base::UintToString(current_program_id_).append(":") .append(base::UintToString(prev_pes_stream_id_)); - std::map::iterator it = + std::map::iterator it = program_demux_stream_map_.find(key); if (it == program_demux_stream_map_.end()) { // TODO(ramjic): Log error message here and in other error cases through @@ -842,9 +842,10 @@ bool WvmMediaParser::Output() { return true; } -void WvmMediaParser::EmitSample( - uint32 parsed_audio_or_video_stream_id, uint32 stream_id, - scoped_refptr& new_sample, bool isLastSample) { +void WvmMediaParser::EmitSample(uint32_t parsed_audio_or_video_stream_id, + uint32_t stream_id, + scoped_refptr& new_sample, + bool isLastSample) { DCHECK(new_sample); if (isLastSample) { if ((parsed_audio_or_video_stream_id & kPesStreamIdVideoMask) diff --git a/media/formats/wvm/wvm_media_parser.h b/media/formats/wvm/wvm_media_parser.h index 5494cc792f..26a6e2ba0a 100644 --- a/media/formats/wvm/wvm_media_parser.h +++ b/media/formats/wvm/wvm_media_parser.h @@ -27,8 +27,8 @@ struct DemuxStreamIdMediaSample { public: DemuxStreamIdMediaSample(); ~DemuxStreamIdMediaSample(); - uint32 demux_stream_id; - uint32 parsed_audio_or_video_stream_id; + uint32_t demux_stream_id; + uint32_t parsed_audio_or_video_stream_id; scoped_refptr media_sample; }; @@ -39,10 +39,10 @@ struct PrevSampleData { void Reset(); scoped_refptr audio_sample; scoped_refptr video_sample; - uint32 audio_stream_id; - uint32 video_stream_id; - int64 audio_sample_duration; - int64 video_sample_duration; + uint32_t audio_stream_id; + uint32_t video_stream_id; + int64_t audio_sample_duration; + int64_t video_sample_duration; }; class WvmMediaParser : public MediaParser { @@ -57,7 +57,7 @@ class WvmMediaParser : public MediaParser { virtual void Flush() OVERRIDE; - virtual bool Parse(const uint8* buf, int size) OVERRIDE; + virtual bool Parse(const uint8_t* buf, int size) OVERRIDE; private: enum Tag { @@ -157,41 +157,43 @@ class WvmMediaParser : public MediaParser { ProgramEnd }; - bool DecryptCBC(void* data, uint32 length, uint32 bytesRemaining, - uint32& bytesDecrypted) { + bool DecryptCBC(void* data, + uint32_t length, + uint32_t bytesRemaining, + uint32_t& bytesDecrypted) { return(true); } - bool ProcessEcm(void* ecm, uint32 size) { - return(true); - } + bool ProcessEcm(void* ecm, uint32_t size) { return (true); } // Index denotes 'search index' in the WVM content. bool ParseIndexEntry(); - bool DemuxNextPes(uint8* start, bool is_program_end); + bool DemuxNextPes(uint8_t* start, bool is_program_end); - void StartMediaSampleDemux(uint8* start); + void StartMediaSampleDemux(uint8_t* start); - template - Tag GetTag(const uint8& tag, const uint32& length, - const uint8* start_index, T* value) { - if (length == sizeof(uint8)) { - *value = (uint8)(*start_index); - } else if (length == sizeof(int8)) { - *value = (int8)(*start_index); - } else if (length == sizeof(uint16)) { - *value = (uint16)(ntohsFromBuffer(start_index)); - } else if (length == sizeof(int16)) { - *value = (int16)(ntohsFromBuffer(start_index)); - } else if (length == sizeof(uint32)) { - *value = (uint32)(ntohlFromBuffer(start_index)); - } else if (length == sizeof(int32)) { - *value = (int32)(ntohlFromBuffer(start_index)); - } else if (length == sizeof(uint64)) { - *value = (uint64)(ntohllFromBuffer(start_index)); - } else if (length == sizeof(int64)) { - *value = (int64)(ntohllFromBuffer(start_index)); + template + Tag GetTag(const uint8_t& tag, + const uint32_t& length, + const uint8_t* start_index, + T* value) { + if (length == sizeof(uint8_t)) { + *value = (uint8_t)(*start_index); + } else if (length == sizeof(int8_t)) { + *value = (int8_t)(*start_index); + } else if (length == sizeof(uint16_t)) { + *value = (uint16_t)(ntohsFromBuffer(start_index)); + } else if (length == sizeof(int16_t)) { + *value = (int16_t)(ntohsFromBuffer(start_index)); + } else if (length == sizeof(uint32_t)) { + *value = (uint32_t)(ntohlFromBuffer(start_index)); + } else if (length == sizeof(int32_t)) { + *value = (int32_t)(ntohlFromBuffer(start_index)); + } else if (length == sizeof(uint64_t)) { + *value = (uint64_t)(ntohllFromBuffer(start_index)); + } else if (length == sizeof(int64_t)) { + *value = (int64_t)(ntohllFromBuffer(start_index)); } else { *value = 0; } @@ -202,13 +204,15 @@ class WvmMediaParser : public MediaParser { // Callback invoked by the ES media parser // to emit a new audio/video access unit. - void EmitSample( - uint32 parsed_audio_or_video_stream_id, uint32 stream_id, - scoped_refptr& new_sample, bool isLastSample); + void EmitSample(uint32_t parsed_audio_or_video_stream_id, + uint32_t stream_id, + scoped_refptr& new_sample, + bool isLastSample); void EmitPendingSamples(); - bool EmitLastSample(uint32 stream_id, scoped_refptr& new_sample); + bool EmitLastSample(uint32_t stream_id, + scoped_refptr& new_sample); // List of callbacks.t InitCB init_cb_; @@ -223,19 +227,19 @@ class WvmMediaParser : public MediaParser { bool is_first_pack_; bool is_psm_needed_; - uint32 skip_bytes_; + uint32_t skip_bytes_; bool metadata_is_complete_; - uint8 current_program_id_; - uint32 pes_stream_id_; - uint32 prev_pes_stream_id_; - uint16 pes_packet_bytes_; - uint8 pes_flags_1_; - uint8 pes_flags_2_; - uint8 pes_header_data_bytes_; - uint64 timestamp_; - uint64 pts_; - uint64 dts_; - uint8 index_program_id_; + uint8_t current_program_id_; + uint32_t pes_stream_id_; + uint32_t prev_pes_stream_id_; + uint16_t pes_packet_bytes_; + uint8_t pes_flags_1_; + uint8_t pes_flags_2_; + uint8_t pes_header_data_bytes_; + uint64_t timestamp_; + uint64_t pts_; + uint64_t dts_; + uint8_t index_program_id_; SHA256_CTX* sha_context_; scoped_refptr media_sample_; @@ -243,14 +247,14 @@ class WvmMediaParser : public MediaParser { H264ByteToUnitStreamConverter byte_to_unit_stream_converter_; - std::vector > ecm_; - std::vector psm_data_; - std::vector index_data_; - std::map program_demux_stream_map_; + std::vector > ecm_; + std::vector psm_data_; + std::vector index_data_; + std::map program_demux_stream_map_; int stream_id_count_; std::vector > stream_infos_; std::deque media_sample_queue_; - std::vector sample_data_; + std::vector sample_data_; DISALLOW_COPY_AND_ASSIGN(WvmMediaParser); }; diff --git a/media/formats/wvm/wvm_media_parser_unittest.cc b/media/formats/wvm/wvm_media_parser_unittest.cc index caf65bb917..2d3ea28490 100644 --- a/media/formats/wvm/wvm_media_parser_unittest.cc +++ b/media/formats/wvm/wvm_media_parser_unittest.cc @@ -21,7 +21,7 @@ namespace { const char kClearWvmFile[] = "hb2_4stream_clear.wvm"; // Constants associated with kClearWvmFile follows. -const uint32 kExpectedStreams = 4; +const uint32_t kExpectedStreams = 4; const int kExpectedVideoFrameCount = 6665; const int kExpectedAudioFrameCount = 11964; } @@ -47,8 +47,8 @@ class WvmMediaParserTest : public testing::Test { StreamMap stream_map_; int audio_frame_count_; int video_frame_count_; - int64 video_max_dts_; - uint32 current_track_id_; + int64_t video_max_dts_; + uint32_t current_track_id_; void OnInit(const std::vector >& stream_infos) { DVLOG(1) << "OnInit: " << stream_infos.size() << " streams."; @@ -59,7 +59,8 @@ class WvmMediaParserTest : public testing::Test { } } - bool OnNewSample(uint32 track_id, const scoped_refptr& sample) { + bool OnNewSample(uint32_t track_id, + const scoped_refptr& sample) { std::string stream_type; if (track_id != current_track_id_) { // onto next track. @@ -106,7 +107,7 @@ class WvmMediaParserTest : public testing::Test { void Parse(const std::string& filename) { InitializeParser(); - std::vector buffer = ReadTestDataFile(filename); + std::vector buffer = ReadTestDataFile(filename); EXPECT_TRUE(parser_->Parse(buffer.data(), buffer.size())); } }; diff --git a/media/test/test_data_util.cc b/media/test/test_data_util.cc index 653cf5f2e8..b23863f9f6 100644 --- a/media/test/test_data_util.cc +++ b/media/test/test_data_util.cc @@ -22,10 +22,10 @@ base::FilePath GetTestDataFilePath(const std::string& name) { return file_path; } -std::vector ReadTestDataFile(const std::string& name) { +std::vector ReadTestDataFile(const std::string& name) { std::string buffer; CHECK(base::ReadFileToString(GetTestDataFilePath(name), &buffer)); - return std::vector(buffer.begin(), buffer.end()); + return std::vector(buffer.begin(), buffer.end()); } } // namespace media diff --git a/media/test/test_data_util.h b/media/test/test_data_util.h index 20e1dc4f24..c99f945f24 100644 --- a/media/test/test_data_util.h +++ b/media/test/test_data_util.h @@ -17,7 +17,7 @@ namespace media { base::FilePath GetTestDataFilePath(const std::string& name); // Reads a test file from media/test/data directory and returns its content. -std::vector ReadTestDataFile(const std::string& name); +std::vector ReadTestDataFile(const std::string& name); } // namespace media } // namespace edash_packager diff --git a/mpd/base/bandwidth_estimator.cc b/mpd/base/bandwidth_estimator.cc index 67c701f845..14c9b397e3 100644 --- a/mpd/base/bandwidth_estimator.cc +++ b/mpd/base/bandwidth_estimator.cc @@ -19,7 +19,7 @@ BandwidthEstimator::BandwidthEstimator(int num_blocks) num_blocks_added_(0) {} BandwidthEstimator::~BandwidthEstimator() {} -void BandwidthEstimator::AddBlock(uint64 size, double duration) { +void BandwidthEstimator::AddBlock(uint64_t size, double duration) { DCHECK_GT(duration, 0.0); DCHECK_GT(size, 0u); @@ -52,12 +52,12 @@ void BandwidthEstimator::AddBlock(uint64 size, double duration) { return; } -uint64 BandwidthEstimator::Estimate() const { +uint64_t BandwidthEstimator::Estimate() const { if (harmonic_mean_denominator_ == 0.0) return 0; - const uint64 num_blocks = num_blocks_for_estimation_ == kUseAllBlocks - ? num_blocks_added_ - : history_.size(); - return static_cast(ceil(num_blocks / harmonic_mean_denominator_)); + const uint64_t num_blocks = num_blocks_for_estimation_ == kUseAllBlocks + ? num_blocks_added_ + : history_.size(); + return static_cast(ceil(num_blocks / harmonic_mean_denominator_)); } diff --git a/mpd/base/bandwidth_estimator.h b/mpd/base/bandwidth_estimator.h index 254fe32454..3541251ced 100644 --- a/mpd/base/bandwidth_estimator.h +++ b/mpd/base/bandwidth_estimator.h @@ -20,12 +20,12 @@ class BandwidthEstimator { // @param size is the size of the block in bytes. Should be positive. // @param duration is the length in seconds. Should be positive. - void AddBlock(uint64 size, double duration); + void AddBlock(uint64_t size, double duration); // @return The estimate bandwidth, in bits per second, from the harmonic mean // of the number of blocks specified in the constructor. The value is // rounded up to the nearest integer. - uint64 Estimate() const; + uint64_t Estimate() const; static const int kUseAllBlocks; diff --git a/mpd/base/bandwidth_estimator_test.cc b/mpd/base/bandwidth_estimator_test.cc index 3eee8c464c..683107d4b6 100644 --- a/mpd/base/bandwidth_estimator_test.cc +++ b/mpd/base/bandwidth_estimator_test.cc @@ -15,7 +15,7 @@ namespace edash_packager { namespace { const int kNumBlocksForEstimate = 5; const int kFirstOneBlockForEstimate = -1; -const uint64 kBitsInByte = 8; +const uint64_t kBitsInByte = 8; const int kEstimateRoundError = 1; } // namespace @@ -24,21 +24,21 @@ const int kEstimateRoundError = 1; TEST(BandwidthEstimatorTest, FiveBlocksFiveBlocksAdded) { BandwidthEstimator be(kNumBlocksForEstimate); const double kDuration = 1.0; - const uint64 kExpectedResults[] = { - // Harmonic mean of [1 * 8], [1 * 8, 2 * 8], ... - // 8 is the number of bits in a byte and 1, 2, ... is from the loop - // counter below. - // Note that these are rounded up. - 8, - 11, - 14, - 16, - 18 + const uint64_t kExpectedResults[] = { + // Harmonic mean of [1 * 8], [1 * 8, 2 * 8], ... + // 8 is the number of bits in a byte and 1, 2, ... is from the loop + // counter below. + // Note that these are rounded up. + 8, + 11, + 14, + 16, + 18 }; COMPILE_ASSERT(kNumBlocksForEstimate == arraysize(kExpectedResults), incorrect_number_of_expectations); - for (uint64 i = 1; i <= arraysize(kExpectedResults); ++i) { + for (uint64_t i = 1; i <= arraysize(kExpectedResults); ++i) { be.AddBlock(i, kDuration); EXPECT_EQ(kExpectedResults[i - 1], be.Estimate()); } @@ -49,13 +49,13 @@ TEST(BandwidthEstimatorTest, FiveBlocksFiveBlocksAdded) { TEST(BandwidthEstimatorTest, FiveBlocksNormal) { BandwidthEstimator be(kNumBlocksForEstimate); const double kDuration = 10.0; - const uint64 kNumBlocksToAdd = 200; - const uint64 kExptectedEstimate = 800; + const uint64_t kNumBlocksToAdd = 200; + const uint64_t kExptectedEstimate = 800; // Doesn't matter what gets passed to the estimator except for the last 5 // blocks which we add kExptectedEstimate / 8 bytes per second so that the // estimate becomes kExptectedEstimate. - for (uint64 i = 1; i <= kNumBlocksToAdd; ++i) { + for (uint64_t i = 1; i <= kNumBlocksToAdd; ++i) { if (i > kNumBlocksToAdd - kNumBlocksForEstimate) { be.AddBlock(kExptectedEstimate * kDuration / kBitsInByte, kDuration); } else { @@ -69,13 +69,13 @@ TEST(BandwidthEstimatorTest, FiveBlocksNormal) { // Average all the blocks! TEST(BandwidthEstimatorTest, AllBlocks) { BandwidthEstimator be(BandwidthEstimator::kUseAllBlocks); - const uint64 kNumBlocksToAdd = 100; + const uint64_t kNumBlocksToAdd = 100; const double kDuration = 1.0; - for (uint64 i = 1; i <= kNumBlocksToAdd; ++i) + for (uint64_t i = 1; i <= kNumBlocksToAdd; ++i) be.AddBlock(i, kDuration); // The harmonic mean of 8, 16, ... , 800; rounded up. - const uint64 kExptectedEstimate = 155; + const uint64_t kExptectedEstimate = 155; EXPECT_EQ(kExptectedEstimate, be.Estimate()); } @@ -83,7 +83,7 @@ TEST(BandwidthEstimatorTest, AllBlocks) { TEST(BandwidthEstimatorTest, FirstOneBlock) { BandwidthEstimator be(kFirstOneBlockForEstimate); const double kDuration = 11.0; - const uint64 kExptectedEstimate = 123456; + const uint64_t kExptectedEstimate = 123456; be.AddBlock(kExptectedEstimate * kDuration / kBitsInByte, kDuration); // Anything. Should be ignored. diff --git a/mpd/base/mpd_builder.cc b/mpd/base/mpd_builder.cc index 47420d20e8..d191cc23e1 100644 --- a/mpd/base/mpd_builder.cc +++ b/mpd/base/mpd_builder.cc @@ -93,7 +93,7 @@ bool Positive(double d) { } // Return current time in XML DateTime format. -std::string XmlDateTimeNowWithOffset(int32 offset_seconds) { +std::string XmlDateTimeNowWithOffset(int32_t offset_seconds) { base::Time time = base::Time::Now(); time += base::TimeDelta::FromSeconds(offset_seconds); base::Time::Exploded time_exploded; @@ -114,7 +114,7 @@ void SetIfPositive(const char* attr_name, double value, XmlNode* mpd) { } } -uint32 GetTimeScale(const MediaInfo& media_info) { +uint32_t GetTimeScale(const MediaInfo& media_info) { if (media_info.has_reference_time_scale()) { return media_info.reference_time_scale(); } @@ -131,17 +131,17 @@ uint32 GetTimeScale(const MediaInfo& media_info) { return 1; } -uint64 LastSegmentStartTime(const SegmentInfo& segment_info) { +uint64_t LastSegmentStartTime(const SegmentInfo& segment_info) { return segment_info.start_time + segment_info.duration * segment_info.repeat; } // This is equal to |segment_info| end time -uint64 LastSegmentEndTime(const SegmentInfo& segment_info) { +uint64_t LastSegmentEndTime(const SegmentInfo& segment_info) { return segment_info.start_time + segment_info.duration * (segment_info.repeat + 1); } -uint64 LatestSegmentStartTime(const std::list& segments) { +uint64_t LatestSegmentStartTime(const std::list& segments) { DCHECK(!segments.empty()); const SegmentInfo& latest_segment = segments.back(); return LastSegmentStartTime(latest_segment); @@ -149,7 +149,7 @@ uint64 LatestSegmentStartTime(const std::list& segments) { // Given |timeshift_limit|, finds out the number of segments that are no longer // valid and should be removed from |segment_info|. -int SearchTimedOutRepeatIndex(uint64 timeshift_limit, +int SearchTimedOutRepeatIndex(uint64_t timeshift_limit, const SegmentInfo& segment_info) { DCHECK_LE(timeshift_limit, LastSegmentEndTime(segment_info)); if (timeshift_limit < segment_info.start_time) @@ -423,7 +423,7 @@ bool MpdBuilder::GetEarliestTimestamp(double* timestamp_seconds) { return true; } -AdaptationSet::AdaptationSet(uint32 adaptation_set_id, +AdaptationSet::AdaptationSet(uint32_t adaptation_set_id, const MpdOptions& mpd_options, base::AtomicSequenceNumber* counter) : representations_deleter_(&representations_), @@ -500,15 +500,15 @@ bool AdaptationSet::GetEarliestTimestamp(double* timestamp_seconds) { return true; } - Representation::Representation(const MediaInfo& media_info, const MpdOptions& mpd_options, - uint32 id) + uint32_t id) : media_info_(media_info), id_(id), bandwidth_estimator_(BandwidthEstimator::kUseAllBlocks), mpd_options_(mpd_options), - start_number_(1) {} + start_number_(1) { +} Representation::~Representation() {} @@ -553,9 +553,9 @@ void Representation::AddContentProtectionElement( RemoveDuplicateAttributes(&content_protection_elements_.back()); } -void Representation::AddNewSegment(uint64 start_time, - uint64 duration, - uint64 size) { +void Representation::AddNewSegment(uint64_t start_time, + uint64_t duration, + uint64_t size) { if (start_time == 0 && duration == 0) { LOG(WARNING) << "Got segment with start_time and duration == 0. Ignoring."; return; @@ -590,9 +590,9 @@ xml::ScopedXmlPtr::type Representation::GetXml() { return xml::ScopedXmlPtr::type(); } - const uint64 bandwidth = media_info_.has_bandwidth() - ? media_info_.bandwidth() - : bandwidth_estimator_.Estimate(); + const uint64_t bandwidth = media_info_.has_bandwidth() + ? media_info_.bandwidth() + : bandwidth_estimator_.Estimate(); DCHECK(!(HasVODOnlyFields(media_info_) && HasLiveOnlyFields(media_info_))); @@ -670,17 +670,16 @@ bool Representation::HasRequiredMediaInfoFields() { // In Debug builds, some of the irregular cases crash. It is probably a // programming error but in production, it might not be best to stop the // pipeline, especially for live. -bool Representation::IsContiguous(uint64 start_time, - uint64 duration, - uint64 size) const { +bool Representation::IsContiguous(uint64_t start_time, + uint64_t duration, + uint64_t size) const { if (segment_infos_.empty() || segment_infos_.back().duration != duration) return false; // Contiguous segment. const SegmentInfo& previous = segment_infos_.back(); - const uint64 previous_segment_end_time = - previous.start_time + - previous.duration * (previous.repeat + 1); + const uint64_t previous_segment_end_time = + previous.start_time + previous.duration * (previous.repeat + 1); if (previous_segment_end_time == start_time) return true; @@ -689,9 +688,8 @@ bool Representation::IsContiguous(uint64 start_time, return false; // No out of order segments. - const uint64 previous_segment_start_time = - previous.start_time + - previous.duration * previous.repeat; + const uint64_t previous_segment_start_time = + previous.start_time + previous.duration * previous.repeat; if (previous_segment_start_time >= start_time) { LOG(ERROR) << "Segments should not be out of order segment. Adding segment " "with start_time == " << start_time @@ -702,7 +700,7 @@ bool Representation::IsContiguous(uint64 start_time, } // No overlapping segments. - const uint64 kRoundingErrorGrace = 5; + const uint64_t kRoundingErrorGrace = 5; if (start_time < previous_segment_end_time - kRoundingErrorGrace) { LOG(WARNING) << "Segments shold not be overlapping. The new segment starts at " @@ -721,19 +719,19 @@ void Representation::SlideWindow() { if (mpd_options_.time_shift_buffer_depth <= 0.0) return; - const uint32 time_scale = GetTimeScale(media_info_); + const uint32_t time_scale = GetTimeScale(media_info_); DCHECK_GT(time_scale, 0u); - uint64 time_shift_buffer_depth = - static_cast(mpd_options_.time_shift_buffer_depth * time_scale); + uint64_t time_shift_buffer_depth = + static_cast(mpd_options_.time_shift_buffer_depth * time_scale); // The start time of the latest segment is considered the current_play_time, // and this should guarantee that the latest segment will stay in the list. - const uint64 current_play_time = LatestSegmentStartTime(segment_infos_); + const uint64_t current_play_time = LatestSegmentStartTime(segment_infos_); if (current_play_time <= time_shift_buffer_depth) return; - const uint64 timeshift_limit = current_play_time - time_shift_buffer_depth; + const uint64_t timeshift_limit = current_play_time - time_shift_buffer_depth; // First remove all the SegmentInfos that are completely out of range, by // looking at the very last segment's end time. @@ -741,7 +739,7 @@ void Representation::SlideWindow() { std::list::iterator last = first; size_t num_segments_removed = 0; for (; last != segment_infos_.end(); ++last) { - const uint64 last_segment_end_time = LastSegmentEndTime(*last); + const uint64_t last_segment_end_time = LastSegmentEndTime(*last); if (timeshift_limit < last_segment_end_time) break; num_segments_removed += last->repeat + 1; diff --git a/mpd/base/mpd_builder.h b/mpd/base/mpd_builder.h index 8dcb54c84f..4c045317c3 100644 --- a/mpd/base/mpd_builder.h +++ b/mpd/base/mpd_builder.h @@ -171,9 +171,7 @@ class AdaptationSet { xml::ScopedXmlPtr::type GetXml(); // Must be unique in the Period. - uint32 id() const { - return id_; - } + uint32_t id() const { return id_; } private: friend class MpdBuilder; @@ -182,7 +180,7 @@ class AdaptationSet { /// @param adaptation_set_id is an ID number for this AdaptationSet. /// @param representation_counter is a Counter for assigning ID numbers to /// Representation. It can not be NULL. - AdaptationSet(uint32 adaptation_set_id, + AdaptationSet(uint32_t adaptation_set_id, const MpdOptions& mpd_options_, base::AtomicSequenceNumber* representation_counter); @@ -198,7 +196,7 @@ class AdaptationSet { base::AtomicSequenceNumber* const representation_counter_; - const uint32 id_; + const uint32_t id_; const MpdOptions& mpd_options_; DISALLOW_COPY_AND_ASSIGN(AdaptationSet); @@ -228,15 +226,13 @@ class Representation { /// @param duration is the duration of the segment, in units of the stream's /// time scale. /// @param size of the segment in bytes. - void AddNewSegment(uint64 start_time, uint64 duration, uint64 size); + void AddNewSegment(uint64_t start_time, uint64_t duration, uint64_t size); /// @return Copy of . xml::ScopedXmlPtr::type GetXml(); /// @return ID number for . - uint32 id() const { - return id_; - } + uint32_t id() const { return id_; } private: friend class AdaptationSet; @@ -249,7 +245,7 @@ class Representation { /// @param representation_id is the numeric ID for the . Representation(const MediaInfo& media_info, const MpdOptions& mpd_options, - uint32 representation_id); + uint32_t representation_id); bool AddLiveInfo(xml::RepresentationXmlNode* representation); @@ -259,7 +255,9 @@ class Representation { // Return false if the segment should be considered a new segment. True if the // segment is contiguous. - bool IsContiguous(uint64 start_time, uint64 duration, uint64 size) const; + bool IsContiguous(uint64_t start_time, + uint64_t duration, + uint64_t size) const; // Remove elements from |segment_infos_| if // mpd_options_.time_shift_buffer_depth is specified. Increments @@ -281,7 +279,7 @@ class Representation { base::Lock lock_; - const uint32 id_; + const uint32_t id_; std::string mime_type_; std::string codecs_; BandwidthEstimator bandwidth_estimator_; @@ -289,7 +287,7 @@ class Representation { // startNumber attribute for SegmentTemplate. // Starts from 1. - uint32 start_number_; + uint32_t start_number_; DISALLOW_COPY_AND_ASSIGN(Representation); }; diff --git a/mpd/base/mpd_builder_unittest.cc b/mpd/base/mpd_builder_unittest.cc index 27d45f250c..42bb3df3bf 100644 --- a/mpd/base/mpd_builder_unittest.cc +++ b/mpd/base/mpd_builder_unittest.cc @@ -30,7 +30,7 @@ const int kDefaultStartNumber = 1; // Get 'id' attribute from |node|, convert it to std::string and convert it to a // number. -void ExpectXmlElementIdEqual(xmlNodePtr node, uint32 id) { +void ExpectXmlElementIdEqual(xmlNodePtr node, uint32_t id) { const char kId[] = "id"; xml::ScopedXmlPtr::type id_attribute_xml_str( xmlGetProp(node, BAD_CAST kId)); @@ -46,7 +46,7 @@ void ExpectXmlElementIdEqual(xmlNodePtr node, uint32 id) { // Using template to support both AdaptationSet and Representation. template -void CheckIdEqual(uint32 expected_id, T* node) { +void CheckIdEqual(uint32_t expected_id, T* node) { ASSERT_EQ(expected_id, node->id()); // Also check if the XML generated by libxml2 has the correct id attribute. @@ -122,7 +122,7 @@ class DynamicMpdBuilderTest : public MpdBuilderTest { } // TODO(rkuroiwa): Make this a global constant in anonymous namespace. - uint32 DefaultTimeScale() const { return 1000; }; + uint32_t DefaultTimeScale() const { return 1000; }; }; class SegmentTemplateTest : public DynamicMpdBuilderTest { @@ -136,10 +136,10 @@ class SegmentTemplateTest : public DynamicMpdBuilderTest { ASSERT_NO_FATAL_FAILURE(AddRepresentationWithDefaultMediaInfo()); } - void AddSegments(uint64 start_time, - uint64 duration, - uint64 size, - uint64 repeat) { + void AddSegments(uint64_t start_time, + uint64_t duration, + uint64_t size, + uint64_t repeat) { DCHECK(representation_); SegmentInfo s = {start_time, duration, repeat}; @@ -152,7 +152,7 @@ class SegmentTemplateTest : public DynamicMpdBuilderTest { base::StringPrintf(kSElementTemplate, start_time, duration, repeat); } - for (uint64 i = 0; i < repeat + 1; ++i) { + for (uint64_t i = 0; i < repeat + 1; ++i) { representation_->AddNewSegment(start_time, duration, size); start_time += duration; bandwidth_estimator_.AddBlock( @@ -167,7 +167,7 @@ class SegmentTemplateTest : public DynamicMpdBuilderTest { } std::string TemplateOutputInsertValues(const std::string& s_elements_string, - uint64 bandwidth) { + uint64_t bandwidth) { const char kOutputTemplate[] = "\n" "time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 0; + const uint64_t kInitialStartTime = 0; // Trick to make every segment 1 second long. - const uint64 kDuration = DefaultTimeScale(); - const uint64 kSize = 10000; - const uint64 kRepeat = 1234; - const uint64 kLength = kRepeat; + const uint64_t kDuration = DefaultTimeScale(); + const uint64_t kSize = 10000; + const uint64_t kRepeat = 1234; + const uint64_t kLength = kRepeat; CHECK_EQ(kDuration / DefaultTimeScale() * kRepeat, kLength); @@ -561,7 +561,7 @@ TEST_F(TimeShiftBufferDepthTest, Normal) { base::StringPrintf(kSElementTemplate, kDuration * (kRepeat - kExpectedRepeatsLeft), kDuration, - static_cast(kExpectedRepeatsLeft)); + static_cast(kExpectedRepeatsLeft)); const int kExpectedStartNumber = kRepeat - kExpectedRepeatsLeft + 1; ASSERT_NO_FATAL_FAILURE(CheckTimeShiftBufferDepthResult( @@ -577,11 +577,11 @@ TEST_F(TimeShiftBufferDepthTest, TimeShiftBufferDepthShorterThanSegmentLength) { const int kTimeShiftBufferDepth = 10; // 10 sec. mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 0; + const uint64_t kInitialStartTime = 0; // Each duration is a second longer than timeShiftBufferDepth. - const uint64 kDuration = DefaultTimeScale() * (kTimeShiftBufferDepth + 1); - const uint64 kSize = 10000; - const uint64 kRepeat = 1; + const uint64_t kDuration = DefaultTimeScale() * (kTimeShiftBufferDepth + 1); + const uint64_t kSize = 10000; + const uint64_t kRepeat = 1; AddSegments(kInitialStartTime, kDuration, kSize, kRepeat); @@ -598,19 +598,19 @@ TEST_F(TimeShiftBufferDepthTest, Generic) { const int kTimeShiftBufferDepth = 30; mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 123; - const uint64 kDuration = DefaultTimeScale(); - const uint64 kSize = 10000; - const uint64 kRepeat = 1000; + const uint64_t kInitialStartTime = 123; + const uint64_t kDuration = DefaultTimeScale(); + const uint64_t kSize = 10000; + const uint64_t kRepeat = 1000; AddSegments(kInitialStartTime, kDuration, kSize, kRepeat); - const uint64 first_s_element_end_time = + const uint64_t first_s_element_end_time = kInitialStartTime + kDuration * (kRepeat + 1); // Now add 2 kTimeShiftBufferDepth long segments. const int kNumMoreSegments = 2; const int kMoreSegmentsRepeat = kNumMoreSegments - 1; - const uint64 kTimeShiftBufferDepthDuration = + const uint64_t kTimeShiftBufferDepthDuration = DefaultTimeScale() * kTimeShiftBufferDepth; AddSegments(first_s_element_end_time, kTimeShiftBufferDepthDuration, @@ -622,7 +622,7 @@ TEST_F(TimeShiftBufferDepthTest, Generic) { base::StringPrintf(kSElementTemplate, first_s_element_end_time, kTimeShiftBufferDepthDuration, - static_cast(kMoreSegmentsRepeat)); + static_cast(kMoreSegmentsRepeat)); const int kExpectedRemovedSegments = kRepeat + 1; ASSERT_NO_FATAL_FAILURE(CheckTimeShiftBufferDepthResult( @@ -640,24 +640,24 @@ TEST_F(TimeShiftBufferDepthTest, MoreThanOneS) { const int kTimeShiftBufferDepth = 100; mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 0; - const uint64 kSize = 20000; + const uint64_t kInitialStartTime = 0; + const uint64_t kSize = 20000; - const uint64 kOneSecondDuration = DefaultTimeScale(); - const uint64 kOneSecondSegmentRepeat = 99; + const uint64_t kOneSecondDuration = DefaultTimeScale(); + const uint64_t kOneSecondSegmentRepeat = 99; AddSegments( kInitialStartTime, kOneSecondDuration, kSize, kOneSecondSegmentRepeat); - const uint64 first_s_element_end_time = + const uint64_t first_s_element_end_time = kInitialStartTime + kOneSecondDuration * (kOneSecondSegmentRepeat + 1); - const uint64 kTwoSecondDuration = 2 * DefaultTimeScale(); - const uint64 kTwoSecondSegmentRepeat = 20; + const uint64_t kTwoSecondDuration = 2 * DefaultTimeScale(); + const uint64_t kTwoSecondSegmentRepeat = 20; AddSegments(first_s_element_end_time, kTwoSecondDuration, kSize, kTwoSecondSegmentRepeat); - const uint64 kExpectedRemovedSegments = + const uint64_t kExpectedRemovedSegments = (kOneSecondSegmentRepeat + 1 + kTwoSecondSegmentRepeat * 2) - kTimeShiftBufferDepth; @@ -690,19 +690,18 @@ TEST_F(TimeShiftBufferDepthTest, UseLastSegmentInS) { const int kTimeShiftBufferDepth = 9; mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 1; - const uint64 kDuration1 = - static_cast(DefaultTimeScale() * 1.5); - const uint64 kSize = 20000; - const uint64 kRepeat1 = 1; + const uint64_t kInitialStartTime = 1; + const uint64_t kDuration1 = static_cast(DefaultTimeScale() * 1.5); + const uint64_t kSize = 20000; + const uint64_t kRepeat1 = 1; AddSegments(kInitialStartTime, kDuration1, kSize, kRepeat1); - const uint64 first_s_element_end_time = + const uint64_t first_s_element_end_time = kInitialStartTime + kDuration1 * (kRepeat1 + 1); - const uint64 kTwoSecondDuration = 2 * DefaultTimeScale(); - const uint64 kTwoSecondSegmentRepeat = 4; + const uint64_t kTwoSecondDuration = 2 * DefaultTimeScale(); + const uint64_t kTwoSecondSegmentRepeat = 4; AddSegments(first_s_element_end_time, kTwoSecondDuration, @@ -727,21 +726,21 @@ TEST_F(TimeShiftBufferDepthTest, NormalGap) { const int kTimeShiftBufferDepth = 10; mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 0; - const uint64 kDuration = DefaultTimeScale(); - const uint64 kSize = 20000; - const uint64 kRepeat = 6; + const uint64_t kInitialStartTime = 0; + const uint64_t kDuration = DefaultTimeScale(); + const uint64_t kSize = 20000; + const uint64_t kRepeat = 6; // CHECK here so that the when next S element is added with 1 segment, this S // element doesn't go away. - CHECK_LT(kRepeat - 1u, static_cast(kTimeShiftBufferDepth)); + CHECK_LT(kRepeat - 1u, static_cast(kTimeShiftBufferDepth)); CHECK_EQ(kDuration, DefaultTimeScale()); AddSegments(kInitialStartTime, kDuration, kSize, kRepeat); - const uint64 first_s_element_end_time = + const uint64_t first_s_element_end_time = kInitialStartTime + kDuration * (kRepeat + 1); - const uint64 gap_s_element_start_time = first_s_element_end_time + 1; + const uint64_t gap_s_element_start_time = first_s_element_end_time + 1; AddSegments(gap_s_element_start_time, kDuration, kSize, /* no repeat */ 0); std::string expected_s_element = base::StringPrintf( @@ -758,22 +757,22 @@ TEST_F(TimeShiftBufferDepthTest, HugeGap) { const int kTimeShiftBufferDepth = 10; mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 0; - const uint64 kDuration = DefaultTimeScale(); - const uint64 kSize = 20000; - const uint64 kRepeat = 6; + const uint64_t kInitialStartTime = 0; + const uint64_t kDuration = DefaultTimeScale(); + const uint64_t kSize = 20000; + const uint64_t kRepeat = 6; AddSegments(kInitialStartTime, kDuration, kSize, kRepeat); - const uint64 first_s_element_end_time = + const uint64_t first_s_element_end_time = kInitialStartTime + kDuration * (kRepeat + 1); // Big enough gap so first S element should not be there. - const uint64 gap_s_element_start_time = + const uint64_t gap_s_element_start_time = first_s_element_end_time + (kTimeShiftBufferDepth + 1) * DefaultTimeScale(); - const uint64 kSecondSElementRepeat = 9; + const uint64_t kSecondSElementRepeat = 9; COMPILE_ASSERT( - kSecondSElementRepeat < static_cast(kTimeShiftBufferDepth), + kSecondSElementRepeat < static_cast(kTimeShiftBufferDepth), second_s_element_repeat_must_be_less_than_time_shift_buffer_depth); AddSegments(gap_s_element_start_time, kDuration, kSize, kSecondSElementRepeat); @@ -793,11 +792,11 @@ TEST_F(TimeShiftBufferDepthTest, ManySegments) { const int kTimeShiftBufferDepth = 1; mutable_mpd_options()->time_shift_buffer_depth = kTimeShiftBufferDepth; - const uint64 kInitialStartTime = 0; - const uint64 kDuration = DefaultTimeScale(); - const uint64 kSize = 20000; - const uint64 kRepeat = 10000; - const uint64 kTotalNumSegments = kRepeat + 1; + const uint64_t kInitialStartTime = 0; + const uint64_t kDuration = DefaultTimeScale(); + const uint64_t kSize = 20000; + const uint64_t kRepeat = 10000; + const uint64_t kTotalNumSegments = kRepeat + 1; AddSegments(kInitialStartTime, kDuration, kSize, kRepeat); const int kExpectedSegmentsLeft = kTimeShiftBufferDepth + 1; @@ -809,7 +808,7 @@ TEST_F(TimeShiftBufferDepthTest, ManySegments) { base::StringPrintf(kSElementTemplate, kExpectedRemovedSegments * kDuration, kDuration, - static_cast(kExpectedSegmentsRepeat)); + static_cast(kExpectedSegmentsRepeat)); ASSERT_NO_FATAL_FAILURE(CheckTimeShiftBufferDepthResult( expected_s_element, diff --git a/mpd/base/mpd_notifier.h b/mpd/base/mpd_notifier.h index 18492717aa..3d150ff469 100644 --- a/mpd/base/mpd_notifier.h +++ b/mpd/base/mpd_notifier.h @@ -44,7 +44,7 @@ class MpdNotifier { /// populated on success. /// @return true on success, false otherwise. virtual bool NotifyNewContainer(const MediaInfo& media_info, - uint32* container_id) = 0; + uint32_t* container_id) = 0; /// Notifies MpdBuilder that there is a new segment ready. Used only for live /// profile. @@ -56,10 +56,10 @@ class MpdNotifier { /// stream's time scale. /// @param size is the new segment size in bytes. /// @return true on success, false otherwise. - virtual bool NotifyNewSegment(uint32 container_id, - uint64 start_time, - uint64 duration, - uint64 size) = 0; + virtual bool NotifyNewSegment(uint32_t container_id, + uint64_t start_time, + uint64_t duration, + uint64_t size) = 0; /// Adds content protection information to the MPD. /// @param container_id is the nummeric container ID obtained from calling @@ -68,7 +68,7 @@ class MpdNotifier { /// specification. /// @return true on success, false otherwise. virtual bool AddContentProtectionElement( - uint32 container_id, + uint32_t container_id, const ContentProtectionElement& content_protection_element) = 0; /// @return The dash profile for this object. diff --git a/mpd/base/segment_info.h b/mpd/base/segment_info.h index 83adb2eb68..60d73d2f0a 100644 --- a/mpd/base/segment_info.h +++ b/mpd/base/segment_info.h @@ -12,14 +12,14 @@ namespace edash_packager { /// Used for keeping track of all the segments used for generating MPD with /// dynamic profile. struct SegmentInfo { - uint64 start_time; - uint64 duration; + uint64_t start_time; + uint64_t duration; // This is the number of times same duration segments are repeated not // inclusive. In other words if this is the only one segment that starts at // |start_time| and has |duration| but none others have |start_time| * N and // |duration|, then this should be set to 0. The semantics is the same as S@r // in the DASH MPD spec. - uint64 repeat; + uint64_t repeat; }; } // namespace edash_packager diff --git a/mpd/base/simple_mpd_notifier.cc b/mpd/base/simple_mpd_notifier.cc index e712308e04..bfe21e2687 100644 --- a/mpd/base/simple_mpd_notifier.cc +++ b/mpd/base/simple_mpd_notifier.cc @@ -38,7 +38,7 @@ bool SimpleMpdNotifier::Init() { } bool SimpleMpdNotifier::NotifyNewContainer(const MediaInfo& media_info, - uint32* container_id) { + uint32_t* container_id) { DCHECK(container_id); ContentType content_type = GetContentType(media_info); @@ -68,10 +68,10 @@ bool SimpleMpdNotifier::NotifyNewContainer(const MediaInfo& media_info, return true; } -bool SimpleMpdNotifier::NotifyNewSegment(uint32 container_id, - uint64 start_time, - uint64 duration, - uint64 size) { +bool SimpleMpdNotifier::NotifyNewSegment(uint32_t container_id, + uint64_t start_time, + uint64_t duration, + uint64_t size) { base::AutoLock auto_lock(lock_); RepresentationMap::iterator it = representation_map_.find(container_id); @@ -84,7 +84,7 @@ bool SimpleMpdNotifier::NotifyNewSegment(uint32 container_id, } bool SimpleMpdNotifier::AddContentProtectionElement( - uint32 container_id, + uint32_t container_id, const ContentProtectionElement& content_protection_element) { NOTIMPLEMENTED(); return false; @@ -125,7 +125,7 @@ bool SimpleMpdNotifier::WriteMpdToFile() { const char* mpd_char_ptr = mpd.data(); size_t mpd_bytes_left = mpd.size(); while (mpd_bytes_left > 0) { - int64 length = file->Write(mpd_char_ptr, mpd_bytes_left); + int64_t length = file->Write(mpd_char_ptr, mpd_bytes_left); if (length <= 0) { LOG(ERROR) << "Failed to write to file '" << output_path_ << "' (" << length << ")."; diff --git a/mpd/base/simple_mpd_notifier.h b/mpd/base/simple_mpd_notifier.h index 731e11353c..6818e60095 100644 --- a/mpd/base/simple_mpd_notifier.h +++ b/mpd/base/simple_mpd_notifier.h @@ -37,13 +37,13 @@ class SimpleMpdNotifier : public MpdNotifier { /// @{ virtual bool Init() OVERRIDE; virtual bool NotifyNewContainer(const MediaInfo& media_info, - uint32* id) OVERRIDE; - virtual bool NotifyNewSegment(uint32 id, - uint64 start_time, - uint64 duration, - uint64 size) OVERRIDE; + uint32_t* id) OVERRIDE; + virtual bool NotifyNewSegment(uint32_t id, + uint64_t start_time, + uint64_t duration, + uint64_t size) OVERRIDE; virtual bool AddContentProtectionElement( - uint32 id, + uint32_t id, const ContentProtectionElement& content_protection_element) OVERRIDE; /// @} @@ -66,7 +66,7 @@ class SimpleMpdNotifier : public MpdNotifier { typedef std::map AdaptationSetMap; AdaptationSetMap adaptation_set_map_; - typedef std::map RepresentationMap; + typedef std::map RepresentationMap; RepresentationMap representation_map_; DISALLOW_COPY_AND_ASSIGN(SimpleMpdNotifier); diff --git a/mpd/base/simple_vod_mpd_notifier.cc b/mpd/base/simple_vod_mpd_notifier.cc index b8ca972bfb..a1fcbd78ba 100644 --- a/mpd/base/simple_vod_mpd_notifier.cc +++ b/mpd/base/simple_vod_mpd_notifier.cc @@ -27,7 +27,7 @@ bool SimpleVodMpdNotifier::Init() { } bool SimpleVodMpdNotifier::NotifyNewContainer(const MediaInfo& media_info, - uint32* container_id) { + uint32_t* container_id) { DCHECK(container_id); if (media_info.video_info_size() > 0 && media_info.audio_info_size() > 0) { @@ -52,15 +52,15 @@ bool SimpleVodMpdNotifier::NotifyNewContainer(const MediaInfo& media_info, return mpd_builder_->WriteMpd(); } -bool SimpleVodMpdNotifier::NotifyNewSegment(uint32 container_id, - uint64 start_time, - uint64 duration) { +bool SimpleVodMpdNotifier::NotifyNewSegment(uint32_t container_id, + uint64_t start_time, + uint64_t duration) { DLOG(INFO) << "VOD does not support this operation."; return false; } bool SimpleVodMpdNotifier::AddContentProtectionElement( - uint32 container_id, + uint32_t container_id, const ContentProtectionElement& content_protection_element) { if (!ContainsKey(id_to_representation_, container_id)) return false; @@ -74,7 +74,7 @@ bool SimpleVodMpdNotifier::AddContentProtectionElement( bool SimpleVodMpdNotifier::AddNewRepresentation(ContainerType type, const MediaInfo& media_info, - uint32* container_id) { + uint32_t* container_id) { // Use pointer-pointer to set {video,audio}_adaptation_set_. AdaptationSet** adaptation_set_pp = NULL; if (type == kVideo) { @@ -96,7 +96,7 @@ bool SimpleVodMpdNotifier::AddNewRepresentation(ContainerType type, if (!new_representation) return false; - const uint32 representation_id = new_representation->id(); + const uint32_t representation_id = new_representation->id(); id_to_representation_[representation_id] = new_representation; *container_id = representation_id; diff --git a/mpd/base/simple_vod_mpd_notifier.h b/mpd/base/simple_vod_mpd_notifier.h index d0bce59428..71d45faa6e 100644 --- a/mpd/base/simple_vod_mpd_notifier.h +++ b/mpd/base/simple_vod_mpd_notifier.h @@ -35,20 +35,20 @@ class SimpleVodMpdNotifier : public MpdNotifier { // can both audio and video be empty. // On success this writes out MPD and returns true, otherwise returns false. virtual bool NotifyNewContainer(const MediaInfo& media_info, - uint32* id) OVERRIDE; + uint32_t* id) OVERRIDE; // As documented in MpdNotifier. This is Live only feature. This will return // false. - virtual bool NotifyNewSegment(uint32 id, - uint64 start_time, - uint64 duration) OVERRIDE; + virtual bool NotifyNewSegment(uint32_t id, + uint64_t start_time, + uint64_t duration) OVERRIDE; // Adds content protection information to the container added via // NotifyNewContainer(). This will fail if |id| is not a value populated by // calling NotifyNewContainer(). // On success this writes out MPD and returns true, otherwise returns false. virtual bool AddContentProtectionElement( - uint32 id, + uint32_t id, const ContentProtectionElement& content_protection_element) OVERRIDE; private: @@ -61,7 +61,7 @@ class SimpleVodMpdNotifier : public MpdNotifier { // Sets {audio,video}_adaptation_set_ depending on |type|, if it is NULL. bool AddNewRepresentation(ContainerType type, const MediaInfo& media_info, - uint32* id); + uint32_t* id); // None of these are owned by this object. MpdBuilder* const mpd_builder_; @@ -69,7 +69,7 @@ class SimpleVodMpdNotifier : public MpdNotifier { AdaptationSet* video_adaptation_set_; Representation* representation_; - std::map id_to_representation_; + std::map id_to_representation_; DISALLOW_COPY_AND_ASSIGN(SimpleVodMpdNotifier); }; diff --git a/mpd/base/xml/xml_node.cc b/mpd/base/xml/xml_node.cc index 7dfdce9056..8fdefe9130 100644 --- a/mpd/base/xml/xml_node.cc +++ b/mpd/base/xml/xml_node.cc @@ -202,7 +202,7 @@ void XmlNode::SetStringAttribute(const char* attribute_name, xmlSetProp(node_.get(), BAD_CAST attribute_name, BAD_CAST attribute.c_str()); } -void XmlNode::SetIntegerAttribute(const char* attribute_name, uint64 number) { +void XmlNode::SetIntegerAttribute(const char* attribute_name, uint64_t number) { DCHECK(node_); DCHECK(attribute_name); xmlSetProp(node_.get(), @@ -219,7 +219,7 @@ void XmlNode::SetFloatingPointAttribute(const char* attribute_name, BAD_CAST (base::DoubleToString(number).c_str())); } -void XmlNode::SetId(uint32 id) { +void XmlNode::SetId(uint32_t id) { SetIntegerAttribute("id", id); } @@ -322,8 +322,8 @@ RepresentationXmlNode::~RepresentationXmlNode() {} bool RepresentationXmlNode::AddVideoInfo( const RepeatedVideoInfo& repeated_video_info) { - uint32 width = 0; - uint32 height = 0; + uint32_t width = 0; + uint32_t height = 0; // Make sure that all the widths and heights match. for (int i = 0; i < repeated_video_info.size(); ++i) { @@ -413,7 +413,7 @@ bool RepresentationXmlNode::AddVODOnlyInfo(const MediaInfo& media_info) { bool RepresentationXmlNode::AddLiveOnlyInfo( const MediaInfo& media_info, const std::list& segment_infos, - uint32 start_number) { + uint32_t start_number) { XmlNode segment_template("SegmentTemplate"); if (media_info.has_reference_time_scale()) { segment_template.SetIntegerAttribute("timescale", @@ -459,13 +459,13 @@ bool RepresentationXmlNode::AddLiveOnlyInfo( // AudioChannelConfiguration for each number-of-channels. bool RepresentationXmlNode::AddAudioChannelInfo( const RepeatedAudioInfo& repeated_audio_info) { - std::set num_channels; + std::set num_channels; for (int i = 0; i < repeated_audio_info.size(); ++i) { if (repeated_audio_info.Get(i).has_num_channels()) num_channels.insert(repeated_audio_info.Get(i).num_channels()); } - std::set::const_iterator num_channels_it = num_channels.begin(); + std::set::const_iterator num_channels_it = num_channels.begin(); for (; num_channels_it != num_channels.end(); ++num_channels_it) { XmlNode audio_channel_config("AudioChannelConfiguration"); @@ -487,14 +487,14 @@ bool RepresentationXmlNode::AddAudioChannelInfo( void RepresentationXmlNode::AddAudioSamplingRateInfo( const RepeatedAudioInfo& repeated_audio_info) { bool has_sampling_frequency = false; - uint32 min_sampling_frequency = kuint32max; - uint32 max_sampling_frequency = 0; + uint32_t min_sampling_frequency = kuint32max; + uint32_t max_sampling_frequency = 0; for (int i = 0; i < repeated_audio_info.size(); ++i) { const MediaInfo_AudioInfo &audio_info = repeated_audio_info.Get(i); if (audio_info.has_sampling_frequency()) { has_sampling_frequency = true; - const uint32 sampling_frequency = audio_info.sampling_frequency(); + const uint32_t sampling_frequency = audio_info.sampling_frequency(); if (sampling_frequency < min_sampling_frequency) min_sampling_frequency = sampling_frequency; diff --git a/mpd/base/xml/xml_node.h b/mpd/base/xml/xml_node.h index 77573cf91f..06e5540534 100644 --- a/mpd/base/xml/xml_node.h +++ b/mpd/base/xml/xml_node.h @@ -50,7 +50,7 @@ class XmlNode { /// Sets an interger attribute. /// @param attribute_name The name (lhs) of the attribute. /// @param number The value (rhs) of the attribute. - void SetIntegerAttribute(const char* attribute_name, uint64 number); + void SetIntegerAttribute(const char* attribute_name, uint64_t number); /// Set a floating point number attribute. /// @param attribute_name is the name of the attribute to set. @@ -59,7 +59,7 @@ class XmlNode { /// Sets 'id=@a id' attribute. /// @param id is the ID for this element. - void SetId(uint32 id); + void SetId(uint32_t id); /// Set the contents of an XML element using a string. /// Note: This function does not work well with AddChild(). Use either @@ -157,7 +157,7 @@ class RepresentationXmlNode : public RepresentationBaseXmlNode { /// SegmentInfos are sorted by its start time. bool AddLiveOnlyInfo(const MediaInfo& media_info, const std::list& segment_infos, - uint32 start_number); + uint32_t start_number); private: // Add AudioChannelConfiguration elements. This will add multiple diff --git a/mpd/base/xml/xml_node_unittest.cc b/mpd/base/xml/xml_node_unittest.cc index 6222cbe23e..2c0af11933 100644 --- a/mpd/base/xml/xml_node_unittest.cc +++ b/mpd/base/xml/xml_node_unittest.cc @@ -203,7 +203,7 @@ TEST_F(RepresentationTest, AddContentProtectionXml) { // Some template names cannot be used for init segment name. TEST_F(RepresentationTest, InvalidLiveInitSegmentName) { MediaInfo media_info; - const uint32 kDefaultStartNumber = 1; + const uint32_t kDefaultStartNumber = 1; // $Number$ cannot be used for segment name. media_info.set_init_segment_name("$Number$.mp4"); diff --git a/mpd/util/mpd_writer.cc b/mpd/util/mpd_writer.cc index 0500eecbf6..25fedf3190 100644 --- a/mpd/util/mpd_writer.cc +++ b/mpd/util/mpd_writer.cc @@ -187,7 +187,7 @@ bool MpdWriter::WriteMpdToFile(const char* file_name) { const char* mpd_char_ptr = mpd.data(); size_t mpd_bytes_left = mpd.size(); while (mpd_bytes_left > 0) { - int64 length = file->Write(mpd_char_ptr, mpd_bytes_left); + int64_t length = file->Write(mpd_char_ptr, mpd_bytes_left); if (length < 0) { LOG(ERROR) << "Write error " << length; return false;