Replace vector_as_array(...) with vector::data()
vector::data() introduced in C++11 does exactly what vector_as_array does. Change-Id: Iab436b6f1ce7db7678bd240256d9ae80208be07b
This commit is contained in:
parent
583f1f3352
commit
cef1729652
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "packager/media/base/buffer_writer.h"
|
#include "packager/media/base/buffer_writer.h"
|
||||||
|
|
||||||
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/sys_byteorder.h"
|
#include "packager/base/sys_byteorder.h"
|
||||||
#include "packager/media/file/file.h"
|
#include "packager/media/file/file.h"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/base/stl_util.h"
|
#include "packager/base/macros.h"
|
||||||
#include "packager/media/base/status.h"
|
#include "packager/media/base/status.h"
|
||||||
|
|
||||||
namespace edash_packager {
|
namespace edash_packager {
|
||||||
|
@ -56,7 +56,7 @@ class BufferWriter {
|
||||||
void Clear() { buf_.clear(); }
|
void Clear() { buf_.clear(); }
|
||||||
size_t Size() const { return buf_.size(); }
|
size_t Size() const { return buf_.size(); }
|
||||||
/// @return Underlying buffer. Behavior is undefined if the buffer size is 0.
|
/// @return Underlying buffer. Behavior is undefined if the buffer size is 0.
|
||||||
const uint8_t* Buffer() const { return vector_as_array(&buf_); }
|
const uint8_t* Buffer() const { return buf_.data(); }
|
||||||
|
|
||||||
/// Write the buffer to file. The internal buffer will be cleared after
|
/// Write the buffer to file. The internal buffer will be cleared after
|
||||||
/// writing.
|
/// writing.
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "packager/base/files/file_util.h"
|
#include "packager/base/files/file_util.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/container_names.h"
|
#include "packager/media/base/container_names.h"
|
||||||
#include "packager/media/test/test_data_util.h"
|
#include "packager/media/test/test_data_util.h"
|
||||||
|
|
||||||
|
@ -186,9 +185,8 @@ TEST(ContainerNamesTest, WebVtt) {
|
||||||
webvtt_with_utf8_byte_order_mark.end(), kWebVtt,
|
webvtt_with_utf8_byte_order_mark.end(), kWebVtt,
|
||||||
kWebVtt + arraysize(kWebVtt));
|
kWebVtt + arraysize(kWebVtt));
|
||||||
|
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(CONTAINER_WEBVTT,
|
||||||
CONTAINER_WEBVTT,
|
DetermineContainer(webvtt_with_utf8_byte_order_mark.data(),
|
||||||
DetermineContainer(vector_as_array(&webvtt_with_utf8_byte_order_mark),
|
|
||||||
webvtt_with_utf8_byte_order_mark.size()));
|
webvtt_with_utf8_byte_order_mark.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
|
|
||||||
namespace edash_packager {
|
namespace edash_packager {
|
||||||
namespace media {
|
namespace media {
|
||||||
|
|
||||||
|
@ -31,7 +29,7 @@ scoped_refptr<StreamInfo> CreateVideoStreamInfo(
|
||||||
param.pixel_height,
|
param.pixel_height,
|
||||||
0, // trick_play_rate
|
0, // trick_play_rate
|
||||||
param.nalu_length_size,
|
param.nalu_length_size,
|
||||||
vector_as_array(¶m.extra_data),
|
param.extra_data.data(),
|
||||||
param.extra_data.size(),
|
param.extra_data.size(),
|
||||||
param.is_encrypted));
|
param.is_encrypted));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
|
|
||||||
namespace edash_packager {
|
namespace edash_packager {
|
||||||
|
|
||||||
|
@ -28,8 +27,8 @@ IoCache::IoCache(uint64_t cache_size)
|
||||||
// condition r_ptr == w_ptr is unambiguous (buffer empty).
|
// condition r_ptr == w_ptr is unambiguous (buffer empty).
|
||||||
circular_buffer_(cache_size + 1),
|
circular_buffer_(cache_size + 1),
|
||||||
end_ptr_(&circular_buffer_[0] + cache_size + 1),
|
end_ptr_(&circular_buffer_[0] + cache_size + 1),
|
||||||
r_ptr_(vector_as_array(&circular_buffer_)),
|
r_ptr_(circular_buffer_.data()),
|
||||||
w_ptr_(vector_as_array(&circular_buffer_)),
|
w_ptr_(circular_buffer_.data()),
|
||||||
closed_(false) {}
|
closed_(false) {}
|
||||||
|
|
||||||
IoCache::~IoCache() {
|
IoCache::~IoCache() {
|
||||||
|
@ -102,7 +101,7 @@ uint64_t IoCache::Write(const void* buffer, uint64_t size) {
|
||||||
|
|
||||||
void IoCache::Clear() {
|
void IoCache::Clear() {
|
||||||
AutoLock lock(lock_);
|
AutoLock lock(lock_);
|
||||||
r_ptr_ = w_ptr_ = vector_as_array(&circular_buffer_);
|
r_ptr_ = w_ptr_ = circular_buffer_.data();
|
||||||
// Let any writers know that there is room in the cache.
|
// Let any writers know that there is room in the cache.
|
||||||
read_event_.Signal();
|
read_event_.Signal();
|
||||||
}
|
}
|
||||||
|
@ -117,7 +116,7 @@ void IoCache::Close() {
|
||||||
void IoCache::Reopen() {
|
void IoCache::Reopen() {
|
||||||
AutoLock lock(lock_);
|
AutoLock lock(lock_);
|
||||||
CHECK(closed_);
|
CHECK(closed_);
|
||||||
r_ptr_ = w_ptr_ = vector_as_array(&circular_buffer_);
|
r_ptr_ = w_ptr_ = circular_buffer_.data();
|
||||||
closed_ = false;
|
closed_ = false;
|
||||||
read_event_.Reset();
|
read_event_.Reset();
|
||||||
write_event_.Reset();
|
write_event_.Reset();
|
||||||
|
@ -134,9 +133,9 @@ uint64_t IoCache::BytesFree() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t IoCache::BytesCachedInternal() {
|
uint64_t IoCache::BytesCachedInternal() {
|
||||||
return (r_ptr_ <= w_ptr_) ?
|
return (r_ptr_ <= w_ptr_)
|
||||||
w_ptr_ - r_ptr_ :
|
? w_ptr_ - r_ptr_
|
||||||
(end_ptr_ - r_ptr_) + (w_ptr_ - vector_as_array(&circular_buffer_));
|
: (end_ptr_ - r_ptr_) + (w_ptr_ - circular_buffer_.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t IoCache::BytesFreeInternal() {
|
uint64_t IoCache::BytesFreeInternal() {
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "packager/base/bind.h"
|
#include "packager/base/bind.h"
|
||||||
#include "packager/base/bind_helpers.h"
|
#include "packager/base/bind_helpers.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/threading/platform_thread.h"
|
#include "packager/base/threading/platform_thread.h"
|
||||||
#include "packager/media/base/closure_thread.h"
|
#include "packager/media/base/closure_thread.h"
|
||||||
#include "packager/media/file/io_cache.h"
|
#include "packager/media/file/io_cache.h"
|
||||||
|
@ -29,8 +28,8 @@ class IoCacheTest : public testing::Test {
|
||||||
int sleep_between_writes,
|
int sleep_between_writes,
|
||||||
bool close_when_done) {
|
bool close_when_done) {
|
||||||
for (uint64_t write_idx = 0; write_idx < num_writes; ++write_idx) {
|
for (uint64_t write_idx = 0; write_idx < num_writes; ++write_idx) {
|
||||||
uint64_t write_result = cache_->Write(vector_as_array(&test_buffer),
|
uint64_t write_result =
|
||||||
test_buffer.size());
|
cache_->Write(test_buffer.data(), test_buffer.size());
|
||||||
if (!write_result) {
|
if (!write_result) {
|
||||||
// Cache was closed.
|
// Cache was closed.
|
||||||
cache_closed_ = true;
|
cache_closed_ = true;
|
||||||
|
@ -60,7 +59,7 @@ class IoCacheTest : public testing::Test {
|
||||||
|
|
||||||
void GenerateTestBuffer(uint64_t size, std::vector<uint8_t>* test_buffer) {
|
void GenerateTestBuffer(uint64_t size, std::vector<uint8_t>* test_buffer) {
|
||||||
test_buffer->resize(size);
|
test_buffer->resize(size);
|
||||||
uint8_t* w_ptr(vector_as_array(test_buffer));
|
uint8_t* w_ptr(test_buffer->data());
|
||||||
while (size) {
|
while (size) {
|
||||||
uint64_t copy_size(std::min(size, kBlockSize));
|
uint64_t copy_size(std::min(size, kBlockSize));
|
||||||
memcpy(w_ptr, reference_block_, copy_size);
|
memcpy(w_ptr, reference_block_, copy_size);
|
||||||
|
@ -106,8 +105,7 @@ TEST_F(IoCacheTest, VerySmallWrite) {
|
||||||
WriteToCacheThreaded(write_buffer, 1, 0, false);
|
WriteToCacheThreaded(write_buffer, 1, 0, false);
|
||||||
|
|
||||||
std::vector<uint8_t> read_buffer(kTestBytes);
|
std::vector<uint8_t> read_buffer(kTestBytes);
|
||||||
EXPECT_EQ(kTestBytes, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kTestBytes, cache_->Read(read_buffer.data(), kTestBytes));
|
||||||
kTestBytes));
|
|
||||||
EXPECT_EQ(write_buffer, read_buffer);
|
EXPECT_EQ(write_buffer, read_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +117,7 @@ TEST_F(IoCacheTest, LotsOfAlignedBlocks) {
|
||||||
WriteToCacheThreaded(write_buffer, kNumWrites, 0, false);
|
WriteToCacheThreaded(write_buffer, kNumWrites, 0, false);
|
||||||
for (uint64_t num_reads = 0; num_reads < kNumWrites; ++num_reads) {
|
for (uint64_t num_reads = 0; num_reads < kNumWrites; ++num_reads) {
|
||||||
std::vector<uint8_t> read_buffer(kBlockSize);
|
std::vector<uint8_t> read_buffer(kBlockSize);
|
||||||
EXPECT_EQ(kBlockSize, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kBlockSize, cache_->Read(read_buffer.data(), kBlockSize));
|
||||||
kBlockSize));
|
|
||||||
EXPECT_EQ(write_buffer, read_buffer);
|
EXPECT_EQ(write_buffer, read_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,8 +135,8 @@ TEST_F(IoCacheTest, LotsOfUnalignedBlocks) {
|
||||||
WriteToCacheThreaded(write_buffer2, kNumWrites, 0, false);
|
WriteToCacheThreaded(write_buffer2, kNumWrites, 0, false);
|
||||||
|
|
||||||
std::vector<uint8_t> read_buffer1(kUnalignBlockSize);
|
std::vector<uint8_t> read_buffer1(kUnalignBlockSize);
|
||||||
EXPECT_EQ(kUnalignBlockSize, cache_->Read(vector_as_array(&read_buffer1),
|
EXPECT_EQ(kUnalignBlockSize,
|
||||||
kUnalignBlockSize));
|
cache_->Read(read_buffer1.data(), kUnalignBlockSize));
|
||||||
EXPECT_EQ(write_buffer1, read_buffer1);
|
EXPECT_EQ(write_buffer1, read_buffer1);
|
||||||
std::vector<uint8> verify_buffer;
|
std::vector<uint8> verify_buffer;
|
||||||
for (uint64_t idx = 0; idx < kNumWrites; ++idx)
|
for (uint64_t idx = 0; idx < kNumWrites; ++idx)
|
||||||
|
@ -149,12 +146,10 @@ TEST_F(IoCacheTest, LotsOfUnalignedBlocks) {
|
||||||
uint64_t verify_index(0);
|
uint64_t verify_index(0);
|
||||||
while (verify_index < verify_buffer.size()) {
|
while (verify_index < verify_buffer.size()) {
|
||||||
std::vector<uint8_t> read_buffer2(kBlockSize);
|
std::vector<uint8_t> read_buffer2(kBlockSize);
|
||||||
uint64_t bytes_read = cache_->Read(vector_as_array(&read_buffer2),
|
uint64_t bytes_read = cache_->Read(read_buffer2.data(), kBlockSize);
|
||||||
kBlockSize);
|
|
||||||
EXPECT_NE(0U, bytes_read);
|
EXPECT_NE(0U, bytes_read);
|
||||||
EXPECT_FALSE(memcmp(&verify_buffer[verify_index],
|
EXPECT_FALSE(
|
||||||
vector_as_array(&read_buffer2),
|
memcmp(&verify_buffer[verify_index], read_buffer2.data(), bytes_read));
|
||||||
bytes_read));
|
|
||||||
verify_index += bytes_read;
|
verify_index += bytes_read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,8 +163,7 @@ TEST_F(IoCacheTest, SlowWrite) {
|
||||||
WriteToCacheThreaded(write_buffer, kNumWrites, kWriteDelayMs, false);
|
WriteToCacheThreaded(write_buffer, kNumWrites, kWriteDelayMs, false);
|
||||||
for (uint64_t num_reads = 0; num_reads < kNumWrites; ++num_reads) {
|
for (uint64_t num_reads = 0; num_reads < kNumWrites; ++num_reads) {
|
||||||
std::vector<uint8_t> read_buffer(kBlockSize);
|
std::vector<uint8_t> read_buffer(kBlockSize);
|
||||||
EXPECT_EQ(kBlockSize, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kBlockSize, cache_->Read(read_buffer.data(), kBlockSize));
|
||||||
kBlockSize));
|
|
||||||
EXPECT_EQ(write_buffer, read_buffer);
|
EXPECT_EQ(write_buffer, read_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,8 +177,7 @@ TEST_F(IoCacheTest, SlowRead) {
|
||||||
WriteToCacheThreaded(write_buffer, kNumWrites, 0, false);
|
WriteToCacheThreaded(write_buffer, kNumWrites, 0, false);
|
||||||
for (uint64_t num_reads = 0; num_reads < kNumWrites; ++num_reads) {
|
for (uint64_t num_reads = 0; num_reads < kNumWrites; ++num_reads) {
|
||||||
std::vector<uint8_t> read_buffer(kBlockSize);
|
std::vector<uint8_t> read_buffer(kBlockSize);
|
||||||
EXPECT_EQ(kBlockSize, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kBlockSize, cache_->Read(read_buffer.data(), kBlockSize));
|
||||||
kBlockSize));
|
|
||||||
EXPECT_EQ(write_buffer, read_buffer);
|
EXPECT_EQ(write_buffer, read_buffer);
|
||||||
base::PlatformThread::Sleep(
|
base::PlatformThread::Sleep(
|
||||||
base::TimeDelta::FromMilliseconds(kReadDelayMs));
|
base::TimeDelta::FromMilliseconds(kReadDelayMs));
|
||||||
|
@ -223,8 +216,7 @@ TEST_F(IoCacheTest, Reopen) {
|
||||||
WriteToCacheThreaded(write_buffer, 1, 0, true);
|
WriteToCacheThreaded(write_buffer, 1, 0, true);
|
||||||
|
|
||||||
std::vector<uint8_t> read_buffer(kTestBytes1);
|
std::vector<uint8_t> read_buffer(kTestBytes1);
|
||||||
EXPECT_EQ(kTestBytes1, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kTestBytes1, cache_->Read(read_buffer.data(), kTestBytes1));
|
||||||
kTestBytes1));
|
|
||||||
EXPECT_EQ(write_buffer, read_buffer);
|
EXPECT_EQ(write_buffer, read_buffer);
|
||||||
|
|
||||||
WaitForWriterThread();
|
WaitForWriterThread();
|
||||||
|
@ -235,8 +227,7 @@ TEST_F(IoCacheTest, Reopen) {
|
||||||
GenerateTestBuffer(kTestBytes2, &write_buffer);
|
GenerateTestBuffer(kTestBytes2, &write_buffer);
|
||||||
WriteToCacheThreaded(write_buffer, 1, 0, false);
|
WriteToCacheThreaded(write_buffer, 1, 0, false);
|
||||||
read_buffer.resize(kTestBytes2);
|
read_buffer.resize(kTestBytes2);
|
||||||
EXPECT_EQ(kTestBytes2, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kTestBytes2, cache_->Read(read_buffer.data(), kTestBytes2));
|
||||||
kTestBytes2));
|
|
||||||
EXPECT_EQ(write_buffer, read_buffer);
|
EXPECT_EQ(write_buffer, read_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,8 +263,7 @@ TEST_F(IoCacheTest, LargeRead) {
|
||||||
base::TimeDelta::FromMilliseconds(10));
|
base::TimeDelta::FromMilliseconds(10));
|
||||||
}
|
}
|
||||||
std::vector<uint8_t> read_buffer(kCacheSize);
|
std::vector<uint8_t> read_buffer(kCacheSize);
|
||||||
EXPECT_EQ(kCacheSize, cache_->Read(vector_as_array(&read_buffer),
|
EXPECT_EQ(kCacheSize, cache_->Read(read_buffer.data(), kCacheSize));
|
||||||
kCacheSize));
|
|
||||||
EXPECT_EQ(verify_buffer, read_buffer);
|
EXPECT_EQ(verify_buffer, read_buffer);
|
||||||
cache_->Close();
|
cache_->Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "packager/media/filters/avc_decoder_configuration.h"
|
#include "packager/media/filters/avc_decoder_configuration.h"
|
||||||
|
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/strings/string_number_conversions.h"
|
#include "packager/base/strings/string_number_conversions.h"
|
||||||
#include "packager/base/strings/string_util.h"
|
#include "packager/base/strings/string_util.h"
|
||||||
#include "packager/media/base/buffer_reader.h"
|
#include "packager/media/base/buffer_reader.h"
|
||||||
|
@ -26,7 +25,7 @@ AVCDecoderConfiguration::AVCDecoderConfiguration()
|
||||||
AVCDecoderConfiguration::~AVCDecoderConfiguration() {}
|
AVCDecoderConfiguration::~AVCDecoderConfiguration() {}
|
||||||
|
|
||||||
bool AVCDecoderConfiguration::Parse(const std::vector<uint8_t>& data) {
|
bool AVCDecoderConfiguration::Parse(const std::vector<uint8_t>& data) {
|
||||||
BufferReader reader(vector_as_array(&data), data.size());
|
BufferReader reader(data.data(), data.size());
|
||||||
RCHECK(reader.Read1(&version_) && version_ == 1 &&
|
RCHECK(reader.Read1(&version_) && version_ == 1 &&
|
||||||
reader.Read1(&profile_indication_) &&
|
reader.Read1(&profile_indication_) &&
|
||||||
reader.Read1(&profile_compatibility_) && reader.Read1(&avc_level_));
|
reader.Read1(&profile_compatibility_) && reader.Read1(&avc_level_));
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/test/test_data_util.h"
|
#include "packager/media/test/test_data_util.h"
|
||||||
#include "packager/media/filters/h264_parser.h"
|
#include "packager/media/filters/h264_parser.h"
|
||||||
|
|
||||||
|
@ -19,8 +18,7 @@ TEST(H264ParserTest, StreamFileParsing) {
|
||||||
int num_nalus = 759;
|
int num_nalus = 759;
|
||||||
|
|
||||||
H264Parser parser;
|
H264Parser parser;
|
||||||
NaluReader reader(kIsAnnexbByteStream, vector_as_array(&buffer),
|
NaluReader reader(kIsAnnexbByteStream, buffer.data(), buffer.size());
|
||||||
buffer.size());
|
|
||||||
|
|
||||||
// Parse until the end of stream/unsupported stream/error in stream is found.
|
// Parse until the end of stream/unsupported stream/error in stream is found.
|
||||||
int num_parsed_nalus = 0;
|
int num_parsed_nalus = 0;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "packager/media/filters/hevc_decoder_configuration.h"
|
#include "packager/media/filters/hevc_decoder_configuration.h"
|
||||||
|
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/strings/string_number_conversions.h"
|
#include "packager/base/strings/string_number_conversions.h"
|
||||||
#include "packager/base/strings/string_util.h"
|
#include "packager/base/strings/string_util.h"
|
||||||
#include "packager/media/base/buffer_reader.h"
|
#include "packager/media/base/buffer_reader.h"
|
||||||
|
@ -86,7 +85,7 @@ HEVCDecoderConfiguration::HEVCDecoderConfiguration()
|
||||||
HEVCDecoderConfiguration::~HEVCDecoderConfiguration() {}
|
HEVCDecoderConfiguration::~HEVCDecoderConfiguration() {}
|
||||||
|
|
||||||
bool HEVCDecoderConfiguration::Parse(const std::vector<uint8_t>& data) {
|
bool HEVCDecoderConfiguration::Parse(const std::vector<uint8_t>& data) {
|
||||||
BufferReader reader(vector_as_array(&data), data.size());
|
BufferReader reader(data.data(), data.size());
|
||||||
|
|
||||||
uint8_t profile_indication = 0;
|
uint8_t profile_indication = 0;
|
||||||
uint8_t length_size_minus_one = 0;
|
uint8_t length_size_minus_one = 0;
|
||||||
|
|
|
@ -63,7 +63,7 @@ VPCodecConfiguration::VPCodecConfiguration(
|
||||||
VPCodecConfiguration::~VPCodecConfiguration(){};
|
VPCodecConfiguration::~VPCodecConfiguration(){};
|
||||||
|
|
||||||
bool VPCodecConfiguration::Parse(const std::vector<uint8_t>& data) {
|
bool VPCodecConfiguration::Parse(const std::vector<uint8_t>& data) {
|
||||||
BitReader reader(vector_as_array(&data), data.size());
|
BitReader reader(data.data(), data.size());
|
||||||
RCHECK(reader.ReadBits(8, &profile_));
|
RCHECK(reader.ReadBits(8, &profile_));
|
||||||
RCHECK(reader.ReadBits(8, &level_));
|
RCHECK(reader.ReadBits(8, &level_));
|
||||||
RCHECK(reader.ReadBits(4, &bit_depth_));
|
RCHECK(reader.ReadBits(4, &bit_depth_));
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "packager/base/bind.h"
|
#include "packager/base/bind.h"
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/media/base/media_sample.h"
|
#include "packager/media/base/media_sample.h"
|
||||||
#include "packager/media/base/timestamp.h"
|
#include "packager/media/base/timestamp.h"
|
||||||
#include "packager/media/base/video_stream_info.h"
|
#include "packager/media/base/video_stream_info.h"
|
||||||
|
@ -157,12 +156,9 @@ void EsParserH264Test::LoadStream(const char* filename) {
|
||||||
|
|
||||||
// The input file does not have AUDs.
|
// The input file does not have AUDs.
|
||||||
std::vector<Packet> access_units_without_aud =
|
std::vector<Packet> access_units_without_aud =
|
||||||
GetAccessUnits(vector_as_array(&buffer), buffer.size());
|
GetAccessUnits(buffer.data(), buffer.size());
|
||||||
ASSERT_GT(access_units_without_aud.size(), 0u);
|
ASSERT_GT(access_units_without_aud.size(), 0u);
|
||||||
AppendAUD(vector_as_array(&buffer),
|
AppendAUD(buffer.data(), buffer.size(), access_units_without_aud, stream_,
|
||||||
buffer.size(),
|
|
||||||
access_units_without_aud,
|
|
||||||
stream_,
|
|
||||||
access_units_);
|
access_units_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ class BoxBuffer {
|
||||||
if (reader_)
|
if (reader_)
|
||||||
return reader_->ReadToVector(vector, count);
|
return reader_->ReadToVector(vector, count);
|
||||||
DCHECK_EQ(vector->size(), count);
|
DCHECK_EQ(vector->size(), count);
|
||||||
writer_->AppendArray(vector_as_array(vector), count);
|
writer_->AppendArray(vector->data(), count);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ bool SampleEncryption::ParseFromSampleEncryptionData(
|
||||||
std::vector<SampleEncryptionEntry>* sample_encryption_entries) const {
|
std::vector<SampleEncryptionEntry>* sample_encryption_entries) const {
|
||||||
DCHECK(IsIvSizeValid(iv_size));
|
DCHECK(IsIvSizeValid(iv_size));
|
||||||
|
|
||||||
BufferReader reader(vector_as_array(&sample_encryption_data),
|
BufferReader reader(sample_encryption_data.data(),
|
||||||
sample_encryption_data.size());
|
sample_encryption_data.size());
|
||||||
uint32_t sample_count = 0;
|
uint32_t sample_count = 0;
|
||||||
RCHECK(reader.Read4(&sample_count));
|
RCHECK(reader.Read4(&sample_count));
|
||||||
|
|
|
@ -445,7 +445,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
|
||||||
sampling_frequency,
|
sampling_frequency,
|
||||||
max_bitrate,
|
max_bitrate,
|
||||||
avg_bitrate,
|
avg_bitrate,
|
||||||
vector_as_array(&extra_data),
|
extra_data.data(),
|
||||||
extra_data.size(),
|
extra_data.size(),
|
||||||
is_encrypted));
|
is_encrypted));
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
|
||||||
codec_string, track->media.header.language.code, coded_width,
|
codec_string, track->media.header.language.code, coded_width,
|
||||||
coded_height, pixel_width, pixel_height,
|
coded_height, pixel_width, pixel_height,
|
||||||
0, // trick_play_rate
|
0, // trick_play_rate
|
||||||
nalu_length_size, vector_as_array(&entry.codec_config_record.data),
|
nalu_length_size, entry.codec_config_record.data.data(),
|
||||||
entry.codec_config_record.data.size(), is_encrypted));
|
entry.codec_config_record.data.size(), is_encrypted));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "packager/base/stl_util.h"
|
|
||||||
#include "packager/base/strings/string_number_conversions.h"
|
#include "packager/base/strings/string_number_conversions.h"
|
||||||
#include "packager/media/base/aes_encryptor.h"
|
#include "packager/media/base/aes_encryptor.h"
|
||||||
#include "packager/media/base/audio_stream_info.h"
|
#include "packager/media/base/audio_stream_info.h"
|
||||||
|
@ -550,7 +549,7 @@ bool WvmMediaParser::ParseIndexEntry() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t* read_ptr = vector_as_array(&index_data_);
|
const uint8_t* read_ptr = index_data_.data();
|
||||||
if (ntohlFromBuffer(read_ptr) != kIndexMagic) {
|
if (ntohlFromBuffer(read_ptr) != kIndexMagic) {
|
||||||
index_data_.clear();
|
index_data_.clear();
|
||||||
return false;
|
return false;
|
||||||
|
@ -737,16 +736,15 @@ bool WvmMediaParser::ParseIndexEntry() {
|
||||||
index_metadata_max_size -= length;
|
index_metadata_max_size -= length;
|
||||||
}
|
}
|
||||||
// End Index metadata
|
// End Index metadata
|
||||||
index_size = read_ptr - vector_as_array(&index_data_);
|
index_size = read_ptr - index_data_.data();
|
||||||
|
|
||||||
if (has_video) {
|
if (has_video) {
|
||||||
VideoCodec video_codec = kCodecH264;
|
VideoCodec video_codec = kCodecH264;
|
||||||
stream_infos_.push_back(new VideoStreamInfo(
|
stream_infos_.push_back(new VideoStreamInfo(
|
||||||
stream_id_count_, time_scale, track_duration, video_codec,
|
stream_id_count_, time_scale, track_duration, video_codec,
|
||||||
std::string(), std::string(), video_width, video_height,
|
std::string(), std::string(), video_width, video_height, pixel_width,
|
||||||
pixel_width, pixel_height, trick_play_rate, nalu_length_size,
|
pixel_height, trick_play_rate, nalu_length_size,
|
||||||
vector_as_array(&video_codec_config), video_codec_config.size(),
|
video_codec_config.data(), video_codec_config.size(), true));
|
||||||
true));
|
|
||||||
program_demux_stream_map_[base::UintToString(index_program_id_) + ":" +
|
program_demux_stream_map_[base::UintToString(index_program_id_) + ":" +
|
||||||
base::UintToString(video_pes_stream_id ?
|
base::UintToString(video_pes_stream_id ?
|
||||||
video_pes_stream_id :
|
video_pes_stream_id :
|
||||||
|
@ -759,7 +757,7 @@ bool WvmMediaParser::ParseIndexEntry() {
|
||||||
stream_infos_.push_back(new AudioStreamInfo(
|
stream_infos_.push_back(new AudioStreamInfo(
|
||||||
stream_id_count_, time_scale, track_duration, audio_codec,
|
stream_id_count_, time_scale, track_duration, audio_codec,
|
||||||
std::string(), std::string(), kAacSampleSizeBits, num_channels,
|
std::string(), std::string(), kAacSampleSizeBits, num_channels,
|
||||||
sampling_frequency, 0, 0, vector_as_array(&audio_codec_config),
|
sampling_frequency, 0, 0, audio_codec_config.data(),
|
||||||
audio_codec_config.size(), true));
|
audio_codec_config.size(), true));
|
||||||
program_demux_stream_map_[base::UintToString(index_program_id_) + ":" +
|
program_demux_stream_map_[base::UintToString(index_program_id_) + ":" +
|
||||||
base::UintToString(audio_pes_stream_id ?
|
base::UintToString(audio_pes_stream_id ?
|
||||||
|
@ -813,16 +811,14 @@ void WvmMediaParser::StartMediaSampleDemux() {
|
||||||
|
|
||||||
bool WvmMediaParser::Output(bool output_encrypted_sample) {
|
bool WvmMediaParser::Output(bool output_encrypted_sample) {
|
||||||
if (output_encrypted_sample) {
|
if (output_encrypted_sample) {
|
||||||
media_sample_->set_data(vector_as_array(&sample_data_),
|
media_sample_->set_data(sample_data_.data(), sample_data_.size());
|
||||||
sample_data_.size());
|
|
||||||
media_sample_->set_is_encrypted(true);
|
media_sample_->set_is_encrypted(true);
|
||||||
} else {
|
} else {
|
||||||
if ((prev_pes_stream_id_ & kPesStreamIdVideoMask) == kPesStreamIdVideo) {
|
if ((prev_pes_stream_id_ & kPesStreamIdVideoMask) == kPesStreamIdVideo) {
|
||||||
// Convert video stream to unit stream and get config.
|
// Convert video stream to unit stream and get config.
|
||||||
std::vector<uint8_t> nal_unit_stream;
|
std::vector<uint8_t> nal_unit_stream;
|
||||||
if (!byte_to_unit_stream_converter_.ConvertByteStreamToNalUnitStream(
|
if (!byte_to_unit_stream_converter_.ConvertByteStreamToNalUnitStream(
|
||||||
vector_as_array(&sample_data_), sample_data_.size(),
|
sample_data_.data(), sample_data_.size(), &nal_unit_stream)) {
|
||||||
&nal_unit_stream)) {
|
|
||||||
LOG(ERROR) << "Could not convert h.264 byte stream sample";
|
LOG(ERROR) << "Could not convert h.264 byte stream sample";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -898,9 +894,9 @@ bool WvmMediaParser::Output(bool output_encrypted_sample) {
|
||||||
kPesStreamIdAudio) {
|
kPesStreamIdAudio) {
|
||||||
// Set data on the audio stream.
|
// Set data on the audio stream.
|
||||||
int frame_size = media::mp2t::AdtsHeader::GetAdtsFrameSize(
|
int frame_size = media::mp2t::AdtsHeader::GetAdtsFrameSize(
|
||||||
vector_as_array(&sample_data_), kAdtsHeaderMinSize);
|
sample_data_.data(), kAdtsHeaderMinSize);
|
||||||
media::mp2t::AdtsHeader adts_header;
|
media::mp2t::AdtsHeader adts_header;
|
||||||
const uint8_t* frame_ptr = vector_as_array(&sample_data_);
|
const uint8_t* frame_ptr = sample_data_.data();
|
||||||
if (!adts_header.Parse(frame_ptr, frame_size)) {
|
if (!adts_header.Parse(frame_ptr, frame_size)) {
|
||||||
LOG(ERROR) << "Could not parse ADTS header";
|
LOG(ERROR) << "Could not parse ADTS header";
|
||||||
return false;
|
return false;
|
||||||
|
@ -1128,8 +1124,8 @@ bool WvmMediaParser::ProcessEcm() {
|
||||||
kEcmFlagsSizeBytes + kEcmContentKeySizeBytes +
|
kEcmFlagsSizeBytes + kEcmContentKeySizeBytes +
|
||||||
kEcmPaddingSizeBytes; // flags + contentKey + padding.
|
kEcmPaddingSizeBytes; // flags + contentKey + padding.
|
||||||
std::vector<uint8_t> content_key_buffer(content_key_buffer_size);
|
std::vector<uint8_t> content_key_buffer(content_key_buffer_size);
|
||||||
asset_decryptor.Decrypt(
|
asset_decryptor.Decrypt(ecm_data, content_key_buffer_size,
|
||||||
ecm_data, content_key_buffer_size, vector_as_array(&content_key_buffer));
|
content_key_buffer.data());
|
||||||
|
|
||||||
std::vector<uint8_t> decrypted_content_key_vec(
|
std::vector<uint8_t> decrypted_content_key_vec(
|
||||||
content_key_buffer.begin() + 4,
|
content_key_buffer.begin() + 4,
|
||||||
|
|
Loading…
Reference in New Issue