Windows build working
Change-Id: I6d9cfa0a310c4c6125c839e4d6a085903e981c9c
This commit is contained in:
parent
5278f9cb89
commit
336ea5cb34
2
DEPS
2
DEPS
|
@ -55,7 +55,7 @@ deps = {
|
|||
Var("chromium_git") + "/chromium/src/third_party/tcmalloc/chromium@fa1492f75861094061043a17c0f779c3d35780bf",
|
||||
|
||||
"src/packager/third_party/zlib":
|
||||
Var("chromium_git") + "/chromium/src/third_party/zlib@bcf81d2e5f3a62b698d179c1fadba94604c5dad3",
|
||||
Var("chromium_git") + "/chromium/src/third_party/zlib@830b5c25b5fbe37e032ea09dd011d57042dd94df",
|
||||
|
||||
"src/packager/tools/clang":
|
||||
Var("chromium_git") + "/chromium/src/tools/clang@0de8f3bb6af64e13876273c601704795d5e00faf",
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
#include "packager/mpd/util/mpd_writer.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <codecvt>
|
||||
#include <functional>
|
||||
#include <locale>
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
namespace shaka {
|
||||
namespace {
|
||||
const char kUsage[] =
|
||||
|
@ -103,6 +109,29 @@ int MpdMain(int argc, char** argv) {
|
|||
} // namespace
|
||||
} // namespace shaka
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Windows wmain, which converts wide character arguments to UTF-8.
|
||||
int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) {
|
||||
std::unique_ptr<char* [], std::function<void(char**)>> utf8_argv(
|
||||
new char*[argc], [argc](char** utf8_args) {
|
||||
// TODO(tinskip): This leaks, but if this code is enabled, it crashes.
|
||||
// Figure out why. I suspect gflags does something funny with the
|
||||
// argument array.
|
||||
// for (int idx = 0; idx < argc; ++idx)
|
||||
// delete[] utf8_args[idx];
|
||||
delete[] utf8_args;
|
||||
});
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||
for (int idx = 0; idx < argc; ++idx) {
|
||||
std::string utf8_arg(converter.to_bytes(argv[idx]));
|
||||
utf8_arg += '\0';
|
||||
utf8_argv[idx] = new char[utf8_arg.size()];
|
||||
memcpy(utf8_argv[idx], &utf8_arg[0], utf8_arg.size());
|
||||
}
|
||||
return shaka::MpdMain(argc, utf8_argv.get());
|
||||
}
|
||||
#else
|
||||
int main(int argc, char** argv) {
|
||||
return shaka::MpdMain(argc, argv);
|
||||
}
|
||||
#endif // !defined(OS_WIN)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "packager/base/command_line.h"
|
||||
#include "packager/base/files/file_path.h"
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/path_service.h"
|
||||
#include "packager/base/stl_util.h"
|
||||
#include "packager/base/strings/string_split.h"
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
|
@ -46,6 +47,12 @@
|
|||
#include "packager/mpd/base/simple_mpd_notifier.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <codecvt>
|
||||
#include <functional>
|
||||
#include <locale>
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
DEFINE_bool(use_fake_clock_for_muxer,
|
||||
false,
|
||||
"Set to true to use a fake clock for muxer. With this flag set, "
|
||||
|
@ -480,13 +487,14 @@ bool RunPackager(const StreamDescriptorList& stream_descriptors) {
|
|||
|
||||
scoped_ptr<hls::HlsNotifier> hls_notifier;
|
||||
if (!FLAGS_hls_master_playlist_output.empty()) {
|
||||
base::FilePath master_playlist_path(FLAGS_hls_master_playlist_output);
|
||||
base::FilePath master_playlist_path(
|
||||
base::FilePath::FromUTF8Unsafe(FLAGS_hls_master_playlist_output));
|
||||
base::FilePath master_playlist_name = master_playlist_path.BaseName();
|
||||
|
||||
hls_notifier.reset(new hls::SimpleHlsNotifier(
|
||||
hls::HlsNotifier::HlsProfile::kOnDemandProfile, FLAGS_hls_base_url,
|
||||
master_playlist_path.DirName().AsEndingWithSeparator().value(),
|
||||
master_playlist_name.value()));
|
||||
master_playlist_path.DirName().AsEndingWithSeparator().AsUTF8Unsafe(),
|
||||
master_playlist_name.AsUTF8Unsafe()));
|
||||
}
|
||||
|
||||
std::vector<RemuxJob*> remux_jobs;
|
||||
|
@ -521,7 +529,16 @@ int PackagerMain(int argc, char** argv) {
|
|||
base::AtExitManager exit;
|
||||
// Needed to enable VLOG/DVLOG through --vmodule or --v.
|
||||
base::CommandLine::Init(argc, argv);
|
||||
CHECK(logging::InitLogging(logging::LoggingSettings()));
|
||||
|
||||
// Set up logging.
|
||||
logging::LoggingSettings log_settings;
|
||||
base::FilePath log_filename;
|
||||
PathService::Get(base::DIR_EXE, &log_filename);
|
||||
log_filename = log_filename.AppendASCII("packager.log");
|
||||
log_settings.logging_dest = logging::LOG_TO_ALL;
|
||||
log_settings.log_file = log_filename.value().c_str();
|
||||
log_settings.delete_old = logging::DELETE_OLD_LOG_FILE;
|
||||
CHECK(logging::InitLogging(log_settings));
|
||||
|
||||
google::SetUsageMessage(base::StringPrintf(kUsage, argv[0]));
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
@ -552,6 +569,29 @@ int PackagerMain(int argc, char** argv) {
|
|||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Windows wmain, which converts wide character arguments to UTF-8.
|
||||
int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) {
|
||||
std::unique_ptr<char* [], std::function<void(char**)>> utf8_argv(
|
||||
new char*[argc], [argc](char** utf8_args) {
|
||||
// TODO(tinskip): This leaks, but if this code is enabled, it crashes.
|
||||
// Figure out why. I suspect gflags does something funny with the
|
||||
// argument array.
|
||||
// for (int idx = 0; idx < argc; ++idx)
|
||||
// delete[] utf8_args[idx];
|
||||
delete[] utf8_args;
|
||||
});
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||
for (int idx = 0; idx < argc; ++idx) {
|
||||
std::string utf8_arg(converter.to_bytes(argv[idx]));
|
||||
utf8_arg += '\0';
|
||||
utf8_argv[idx] = new char[utf8_arg.size()];
|
||||
memcpy(utf8_argv[idx], &utf8_arg[0], utf8_arg.size());
|
||||
}
|
||||
return shaka::media::PackagerMain(argc, utf8_argv.get());
|
||||
}
|
||||
#else
|
||||
int main(int argc, char** argv) {
|
||||
return shaka::media::PackagerMain(argc, argv);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"""Test wrapper for the sample packager binary."""
|
||||
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
import test_env
|
||||
|
@ -17,7 +18,10 @@ class PackagerApp(object):
|
|||
"""Main integration class for testing the packager binary."""
|
||||
|
||||
def __init__(self):
|
||||
self.binary = os.path.join(test_env.SCRIPT_DIR, 'packager')
|
||||
packager_name = 'packager'
|
||||
if platform.system() == 'Windows':
|
||||
packager_name += '.exe'
|
||||
self.binary = os.path.join(test_env.SCRIPT_DIR, packager_name)
|
||||
assert os.path.exists(self.binary), ('Please run from output directory, '
|
||||
'e.g. out/Debug/packager_test.py')
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import filecmp
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
@ -66,6 +67,7 @@ class PackagerAppTest(unittest.TestCase):
|
|||
' num_channels: 2\n'
|
||||
' sampling_frequency: 44100\n'
|
||||
' language: und\n')
|
||||
stream_info = stream_info.replace('\r\n', '\n')
|
||||
self.assertIn(expected_stream_info, stream_info,
|
||||
'\nExpecting: \n %s\n\nBut seeing: \n%s' %
|
||||
(expected_stream_info, stream_info))
|
||||
|
@ -527,7 +529,10 @@ class PackagerAppTest(unittest.TestCase):
|
|||
else:
|
||||
match = filecmp.cmp(test_output, golden_file)
|
||||
if not match:
|
||||
p = subprocess.Popen(['git', '--no-pager', 'diff', '--color=auto',
|
||||
git = 'git'
|
||||
if platform.system() == 'Windows':
|
||||
git += '.bat'
|
||||
p = subprocess.Popen([git, '--no-pager', 'diff', '--color=auto',
|
||||
'--no-ext-diff', '--no-index', golden_file,
|
||||
test_output],
|
||||
stdout=subprocess.PIPE,
|
||||
|
@ -538,11 +543,13 @@ class PackagerAppTest(unittest.TestCase):
|
|||
# '*.media_info' outputs contain media file names, which is changing for
|
||||
# every test run. These needs to be replaced for comparison.
|
||||
def _DiffMediaInfoGold(self, test_output, golden_file_name):
|
||||
if platform.system() == 'Windows':
|
||||
test_output = test_output.replace('\\', '\\\\')
|
||||
media_info_output = test_output + '.media_info'
|
||||
# Replaces filename, which is changing for every test run.
|
||||
with open(media_info_output, 'r') as f:
|
||||
with open(media_info_output, 'rb') as f:
|
||||
content = f.read()
|
||||
with open(media_info_output, 'w') as f:
|
||||
with open(media_info_output, 'wb') as f:
|
||||
f.write(content.replace(test_output, 'place_holder'))
|
||||
self._DiffGold(media_info_output, golden_file_name + '.media_info')
|
||||
|
||||
|
@ -565,7 +572,7 @@ class PackagerAppTest(unittest.TestCase):
|
|||
# Live mpd contains current availabilityStartTime and publishTime, which
|
||||
# needs to be replaced for comparison.
|
||||
def _DiffLiveMpdGold(self, test_output, golden_file_name):
|
||||
with open(test_output, 'r') as f:
|
||||
with open(test_output, 'rb') as f:
|
||||
content = f.read()
|
||||
|
||||
# Extract availabilityStartTime.
|
||||
|
@ -579,7 +586,7 @@ class PackagerAppTest(unittest.TestCase):
|
|||
self.assertIsNotNone(m)
|
||||
publish_time = m.group(0)
|
||||
print publish_time
|
||||
with open(test_output, 'w') as f:
|
||||
with open(test_output, 'wb') as f:
|
||||
f.write(content.replace(
|
||||
availability_start_time,
|
||||
'availabilityStartTime="some_availability_start_time"').replace(
|
||||
|
|
|
@ -32,6 +32,14 @@
|
|||
'-Wno-reserved-user-defined-literal',
|
||||
],
|
||||
}],
|
||||
['OS == "win"', {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'WarnAsError': 'true',
|
||||
'DisableSpecificWarnings': ['4125']
|
||||
},
|
||||
},
|
||||
}],
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ using ::testing::AtLeast;
|
|||
using ::testing::Return;
|
||||
using ::testing::ReturnRef;
|
||||
using ::testing::_;
|
||||
using base::FilePath;
|
||||
|
||||
namespace {
|
||||
const char kDefaultMasterPlaylistName[] = "playlist.m3u8";
|
||||
|
@ -39,7 +40,7 @@ class MasterPlaylistTest : public ::testing::Test {
|
|||
}
|
||||
|
||||
MasterPlaylist master_playlist_;
|
||||
base::FilePath test_output_dir_path_;
|
||||
FilePath test_output_dir_path_;
|
||||
std::string test_output_dir_;
|
||||
|
||||
private:
|
||||
|
@ -48,12 +49,13 @@ class MasterPlaylistTest : public ::testing::Test {
|
|||
// using base::File* related API.
|
||||
// |output_dir| is set to an equivalent value to |temp_dir_path| but formatted
|
||||
// so that media::File interface can Open it.
|
||||
void GetOutputDir(base::FilePath* temp_dir_path, std::string* output_dir) {
|
||||
void GetOutputDir(FilePath* temp_dir_path, std::string* output_dir) {
|
||||
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
||||
ASSERT_TRUE(temp_dir_.IsValid());
|
||||
*temp_dir_path = temp_dir_.path();
|
||||
// TODO(rkuroiwa): Use memory file sys once prefix is exposed.
|
||||
*output_dir = media::kLocalFilePrefix + temp_dir_.path().value() + "/";
|
||||
*output_dir = media::kLocalFilePrefix + temp_dir_.path().AsUTF8Unsafe()
|
||||
+ "/";
|
||||
}
|
||||
|
||||
base::ScopedTempDir temp_dir_;
|
||||
|
@ -78,8 +80,9 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneVideo) {
|
|||
const char kBaseUrl[] = "http://myplaylistdomain.com/";
|
||||
EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_));
|
||||
|
||||
base::FilePath master_playlist_path =
|
||||
test_output_dir_path_.Append(kDefaultMasterPlaylistName);
|
||||
FilePath master_playlist_path =
|
||||
test_output_dir_path_.Append(FilePath::FromUTF8Unsafe(
|
||||
kDefaultMasterPlaylistName));
|
||||
ASSERT_TRUE(base::PathExists(master_playlist_path))
|
||||
<< "Cannot find " << master_playlist_path.value();
|
||||
|
||||
|
@ -149,8 +152,9 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideoAndAudio) {
|
|||
const char kBaseUrl[] = "http://playlists.org/";
|
||||
EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_));
|
||||
|
||||
base::FilePath master_playlist_path =
|
||||
test_output_dir_path_.Append(kDefaultMasterPlaylistName);
|
||||
FilePath master_playlist_path =
|
||||
test_output_dir_path_.Append(FilePath::FromUTF8Unsafe(
|
||||
kDefaultMasterPlaylistName));
|
||||
ASSERT_TRUE(base::PathExists(master_playlist_path))
|
||||
<< "Cannot find " << master_playlist_path.value();
|
||||
|
||||
|
@ -216,8 +220,8 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistMultipleAudioGroups) {
|
|||
const char kBaseUrl[] = "http://anydomain.com/";
|
||||
EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_));
|
||||
|
||||
base::FilePath master_playlist_path =
|
||||
test_output_dir_path_.Append(kDefaultMasterPlaylistName);
|
||||
FilePath master_playlist_path = test_output_dir_path_.Append(
|
||||
FilePath::FromUTF8Unsafe(kDefaultMasterPlaylistName));
|
||||
ASSERT_TRUE(base::PathExists(master_playlist_path))
|
||||
<< "Cannot find " << master_playlist_path.value();
|
||||
|
||||
|
@ -266,15 +270,17 @@ TEST_F(MasterPlaylistTest, WriteAllPlaylists) {
|
|||
EXPECT_CALL(mock_playlist, SetTargetDuration(10)).WillOnce(Return(true));
|
||||
master_playlist_.AddMediaPlaylist(&mock_playlist);
|
||||
|
||||
EXPECT_CALL(mock_playlist,
|
||||
WriteToFile(FileNameMatches(
|
||||
test_output_dir_path_.Append("media1.m3u8").value())))
|
||||
EXPECT_CALL(
|
||||
mock_playlist,
|
||||
WriteToFile(FileNameMatches(
|
||||
test_output_dir_path_.Append(FilePath::FromUTF8Unsafe("media1.m3u8"))
|
||||
.AsUTF8Unsafe())))
|
||||
.WillOnce(Return(true));
|
||||
|
||||
const char kBaseUrl[] = "http://domain.com/";
|
||||
EXPECT_TRUE(master_playlist_.WriteAllPlaylists(kBaseUrl, test_output_dir_));
|
||||
base::FilePath master_playlist_path =
|
||||
test_output_dir_path_.Append(kDefaultMasterPlaylistName);
|
||||
FilePath master_playlist_path = test_output_dir_path_.Append(
|
||||
FilePath::FromUTF8Unsafe(kDefaultMasterPlaylistName));
|
||||
ASSERT_TRUE(base::PathExists(master_playlist_path))
|
||||
<< "Cannot find master playlist at " << master_playlist_path.value();
|
||||
}
|
||||
|
|
|
@ -53,9 +53,9 @@ void MakePathsRelativeToOutputDirectory(const std::string& output_dir,
|
|||
return;
|
||||
|
||||
std::string directory_with_separator(
|
||||
base::FilePath(prefix_stripped_output_dir)
|
||||
.AsEndingWithSeparator()
|
||||
.value());
|
||||
base::FilePath::FromUTF8Unsafe(prefix_stripped_output_dir)
|
||||
.AsEndingWithSeparator()
|
||||
.AsUTF8Unsafe());
|
||||
if (directory_with_separator.empty())
|
||||
return;
|
||||
|
||||
|
|
|
@ -40,6 +40,15 @@ class BitReader {
|
|||
return ret;
|
||||
}
|
||||
|
||||
// Explicit T=bool overload to make MSVC happy.
|
||||
bool ReadBits(int num_bits, bool* out) {
|
||||
DCHECK_EQ(num_bits, 1);
|
||||
uint64_t temp;
|
||||
bool ret = ReadBitsInternal(num_bits, &temp);
|
||||
*out = temp != 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Skip a number of bits from stream.
|
||||
/// @param num_bits specifies the number of bits to be skipped.
|
||||
/// @return false if the given number of bits cannot be skipped (not enough
|
||||
|
|
|
@ -164,7 +164,7 @@ TEST_F(BufferWriterTest, WriteToFile) {
|
|||
LOG(INFO) << "Created temporary file: " << path.value();
|
||||
|
||||
// Append an array to buffer and then write to the temporary file.
|
||||
File* const output_file = File::Open(path.value().c_str(), "w");
|
||||
File* const output_file = File::Open(path.AsUTF8Unsafe().c_str(), "w");
|
||||
writer_->AppendArray(kuint8Array, sizeof(kuint8Array));
|
||||
ASSERT_EQ(sizeof(kuint8Array), writer_->Size());
|
||||
ASSERT_OK(writer_->WriteToFile(output_file));
|
||||
|
@ -172,12 +172,11 @@ TEST_F(BufferWriterTest, WriteToFile) {
|
|||
ASSERT_TRUE(output_file->Close());
|
||||
|
||||
// Read the file and verify.
|
||||
File* const input_file = File::Open(path.value().c_str(), "r");
|
||||
File* const input_file = File::Open(path.AsUTF8Unsafe().c_str(), "r");
|
||||
ASSERT_TRUE(input_file != NULL);
|
||||
std::vector<uint8_t> data_read(sizeof(kuint8Array), 0);
|
||||
EXPECT_EQ(
|
||||
sizeof(kuint8Array),
|
||||
static_cast<size_t>(input_file->Read(&data_read[0], data_read.size())));
|
||||
EXPECT_EQ(sizeof(kuint8Array), static_cast<size_t>(input_file->Read(
|
||||
&data_read[0], data_read.size())));
|
||||
ASSERT_TRUE(input_file->Close());
|
||||
|
||||
for (size_t i = 0; i < sizeof(kuint8Array); ++i)
|
||||
|
|
|
@ -142,9 +142,9 @@ bool AACAudioSpecificConfig::ConvertToADTS(std::vector<uint8_t>* buffer) const {
|
|||
adts[1] = 0xf1;
|
||||
adts[2] = ((audio_object_type_ - 1) << 6) + (frequency_index_ << 2) +
|
||||
(channel_config_ >> 2);
|
||||
adts[3] = ((channel_config_ & 0x3) << 6) + (size >> 11);
|
||||
adts[4] = (size & 0x7ff) >> 3;
|
||||
adts[5] = ((size & 7) << 5) + 0x1f;
|
||||
adts[3] = ((channel_config_ & 0x3) << 6) + static_cast<uint8_t>(size >> 11);
|
||||
adts[4] = static_cast<uint8_t>((size & 0x7ff) >> 3);
|
||||
adts[5] = static_cast<uint8_t>(((size & 7) << 5) + 0x1f);
|
||||
adts[6] = 0xfc;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -140,15 +140,17 @@ void ESDescriptor::Write(BufferWriter* writer) const {
|
|||
const std::vector<uint8_t> kEmptyDecodingBufferSize(3, 0);
|
||||
const uint8_t kNoEsFlags = 0;
|
||||
|
||||
const uint8_t decoder_specific_info_size = decoder_specific_info_.size();
|
||||
const uint8_t decoder_specific_info_size =
|
||||
static_cast<uint8_t>(decoder_specific_info_.size());
|
||||
|
||||
// 6 bit stream type. The last bit is reserved with 1.
|
||||
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_t decoder_config_size =
|
||||
static_cast<uint8_t>(decoder_specific_info_size + kHeaderSize +
|
||||
sizeof(uint8_t) + // object_type_.
|
||||
sizeof(stream_type) +
|
||||
kEmptyDecodingBufferSize.size() +
|
||||
sizeof(kUnknownBitrate) * 2);
|
||||
|
||||
const uint8_t sl_config_size = sizeof(uint8_t); // predefined.
|
||||
const uint8_t es_size = decoder_config_size + kHeaderSize + sl_config_size +
|
||||
|
@ -178,7 +180,8 @@ void ESDescriptor::Write(BufferWriter* writer) const {
|
|||
|
||||
size_t ESDescriptor::ComputeSize() const {
|
||||
// A bit magical. Refer to ESDescriptor::Write for details.
|
||||
const uint8_t decoder_specific_info_size = decoder_specific_info_.size();
|
||||
const uint8_t decoder_specific_info_size =
|
||||
static_cast<uint8_t>(decoder_specific_info_.size());
|
||||
const uint8_t decoder_config_size = decoder_specific_info_size + kHeaderSize +
|
||||
sizeof(uint8_t) * 5 +
|
||||
sizeof(uint32_t) * 2;
|
||||
|
|
|
@ -161,7 +161,8 @@ void VPCodecConfigurationRecord::WriteMP4(std::vector<uint8_t>* data) const {
|
|||
uint8_t chroma = (chroma_subsampling_ << 4) | (transfer_function_ << 1) |
|
||||
(video_full_range_flag_ ? 1 : 0);
|
||||
writer.AppendInt(chroma);
|
||||
uint16_t codec_initialization_data_size = codec_initialization_data_.size();
|
||||
uint16_t codec_initialization_data_size =
|
||||
static_cast<uint16_t>(codec_initialization_data_.size());
|
||||
writer.AppendInt(codec_initialization_data_size);
|
||||
writer.AppendVector(codec_initialization_data_);
|
||||
writer.SwapBuffer(data);
|
||||
|
|
|
@ -65,7 +65,8 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test {
|
|||
ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path_));
|
||||
DLOG(INFO) << "Created temp file: " << temp_file_path_.value();
|
||||
|
||||
listener_.reset(new VodMediaInfoDumpMuxerListener(temp_file_path_.value()));
|
||||
listener_.reset(new VodMediaInfoDumpMuxerListener(temp_file_path_
|
||||
.AsUTF8Unsafe()));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
@ -106,7 +107,7 @@ class VodMediaInfoDumpMuxerListenerTest : public ::testing::Test {
|
|||
|
||||
void ExpectTempFileToEqual(const std::string& expected_protobuf) {
|
||||
std::string temp_file_media_info_str;
|
||||
ASSERT_TRUE(File::ReadFileToString(temp_file_path_.value().c_str(),
|
||||
ASSERT_TRUE(File::ReadFileToString(temp_file_path_.AsUTF8Unsafe().c_str(),
|
||||
&temp_file_media_info_str));
|
||||
ASSERT_TRUE(!temp_file_media_info_str.empty());
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@ DEFINE_uint64(io_block_size,
|
|||
2ULL << 20,
|
||||
"Size of the block size used for threaded I/O, in bytes.");
|
||||
|
||||
// Needed for Windows weirdness which somewhere defines CopyFile as CopyFileW.
|
||||
#ifdef CopyFile
|
||||
#undef CopyFile
|
||||
#endif // CopyFile
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ const int kDataSize = 1024;
|
|||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
using base::FilePath;
|
||||
|
||||
class LocalFileTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
|
@ -29,7 +31,7 @@ class LocalFileTest : public testing::Test {
|
|||
|
||||
// Test file path for file_util API.
|
||||
ASSERT_TRUE(base::CreateTemporaryFile(&test_file_path_));
|
||||
local_file_name_no_prefix_ = test_file_path_.value();
|
||||
local_file_name_no_prefix_ = test_file_path_.AsUTF8Unsafe();
|
||||
|
||||
// Local file name with prefix for File API.
|
||||
local_file_name_ = kLocalFilePrefix;
|
||||
|
@ -38,13 +40,14 @@ class LocalFileTest : public testing::Test {
|
|||
|
||||
void TearDown() override {
|
||||
// Remove test file if created.
|
||||
base::DeleteFile(base::FilePath(local_file_name_no_prefix_), false);
|
||||
base::DeleteFile(FilePath::FromUTF8Unsafe(local_file_name_no_prefix_),
|
||||
false);
|
||||
}
|
||||
|
||||
std::string data_;
|
||||
|
||||
// Path to the temporary file for this test.
|
||||
base::FilePath test_file_path_;
|
||||
FilePath test_file_path_;
|
||||
// Same as |test_file_path_| but in string form.
|
||||
std::string local_file_name_no_prefix_;
|
||||
|
||||
|
@ -54,7 +57,8 @@ class LocalFileTest : public testing::Test {
|
|||
|
||||
TEST_F(LocalFileTest, ReadNotExist) {
|
||||
// Remove test file if it exists.
|
||||
base::DeleteFile(base::FilePath(local_file_name_no_prefix_), false);
|
||||
base::DeleteFile(FilePath::FromUTF8Unsafe(local_file_name_no_prefix_),
|
||||
false);
|
||||
ASSERT_TRUE(File::Open(local_file_name_.c_str(), "r") == NULL);
|
||||
}
|
||||
|
||||
|
@ -68,13 +72,16 @@ TEST_F(LocalFileTest, Copy) {
|
|||
ASSERT_EQ(kDataSize,
|
||||
base::WriteFile(test_file_path_, data_.data(), kDataSize));
|
||||
|
||||
base::FilePath temp_dir;
|
||||
ASSERT_TRUE(base::CreateNewTempDirectory("", &temp_dir));
|
||||
FilePath temp_dir;
|
||||
ASSERT_TRUE(base::CreateNewTempDirectory(FilePath::StringType(),
|
||||
&temp_dir));
|
||||
|
||||
// Copy the test file to temp dir as filename "a".
|
||||
base::FilePath destination = temp_dir.Append("a");
|
||||
FilePath destination =
|
||||
temp_dir.Append(FilePath::FromUTF8Unsafe("a"));
|
||||
ASSERT_TRUE(
|
||||
File::Copy(local_file_name_.c_str(), destination.value().c_str()));
|
||||
File::Copy(FilePath::FromUTF8Unsafe(local_file_name_).AsUTF8Unsafe().c_str(),
|
||||
destination.AsUTF8Unsafe().c_str()));
|
||||
|
||||
// Make a buffer bigger than the expected file content size to make sure that
|
||||
// there isn't extra stuff appended.
|
||||
|
|
|
@ -7,15 +7,25 @@
|
|||
#include "packager/media/file/local_file.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif // defined(OS_WIN)
|
||||
#include "packager/base/files/file_util.h"
|
||||
#include "packager/base/logging.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
// Always open files in binary mode.
|
||||
const char kAdditionalFileMode[] = "b";
|
||||
|
||||
LocalFile::LocalFile(const char* file_name, const char* mode)
|
||||
: File(file_name), file_mode_(mode), internal_file_(NULL) {}
|
||||
: File(file_name),
|
||||
file_mode_(mode),
|
||||
internal_file_(NULL) {
|
||||
if (file_mode_.find(kAdditionalFileMode) == std::string::npos)
|
||||
file_mode_ += kAdditionalFileMode;
|
||||
}
|
||||
|
||||
bool LocalFile::Close() {
|
||||
bool result = true;
|
||||
|
@ -49,7 +59,8 @@ int64_t LocalFile::Size() {
|
|||
}
|
||||
|
||||
int64_t file_size;
|
||||
if (!base::GetFileSize(base::FilePath(file_name()), &file_size)) {
|
||||
if (!base::GetFileSize(base::FilePath::FromUTF8Unsafe(file_name()),
|
||||
&file_size)) {
|
||||
LOG(ERROR) << "Cannot get file size.";
|
||||
return -1;
|
||||
}
|
||||
|
@ -62,14 +73,23 @@ bool LocalFile::Flush() {
|
|||
}
|
||||
|
||||
bool LocalFile::Seek(uint64_t position) {
|
||||
#if defined(OS_WIN)
|
||||
return _fseeki64(internal_file_, static_cast<__int64>(position),
|
||||
SEEK_SET) == 0;
|
||||
#else
|
||||
return fseeko(internal_file_, position, SEEK_SET) >= 0;
|
||||
#endif // !defined(OS_WIN)
|
||||
}
|
||||
|
||||
bool LocalFile::Tell(uint64_t* position) {
|
||||
#if defined(OS_WIN)
|
||||
__int64 offset = _ftelli64(internal_file_);
|
||||
#else
|
||||
off_t offset = ftello(internal_file_);
|
||||
#endif // !defined(OS_WIN)
|
||||
if (offset < 0)
|
||||
return false;
|
||||
*position = offset;
|
||||
*position = static_cast<uint64_t>(offset);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -77,12 +97,12 @@ LocalFile::~LocalFile() {}
|
|||
|
||||
bool LocalFile::Open() {
|
||||
internal_file_ =
|
||||
base::OpenFile(base::FilePath(file_name()), file_mode_.c_str());
|
||||
base::OpenFile(base::FilePath::FromUTF8Unsafe(file_name()), file_mode_.c_str());
|
||||
return (internal_file_ != NULL);
|
||||
}
|
||||
|
||||
bool LocalFile::Delete(const char* file_name) {
|
||||
return base::DeleteFile(base::FilePath(file_name), false);
|
||||
return base::DeleteFile(base::FilePath::FromUTF8Unsafe(file_name), false);
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -171,7 +171,7 @@ void EsParserH26xTest::RunTest(const H265NaluType* types,
|
|||
cur_sample_data.push_back(0);
|
||||
cur_sample_data.push_back(0);
|
||||
cur_sample_data.push_back(0);
|
||||
cur_sample_data.push_back(es_data.size());
|
||||
cur_sample_data.push_back(static_cast<uint8_t>(es_data.size()));
|
||||
cur_sample_data.insert(cur_sample_data.end(), es_data.begin(),
|
||||
es_data.end());
|
||||
es_data.insert(es_data.begin(), kStartCode,
|
||||
|
|
|
@ -378,7 +378,7 @@ bool AacProgramMapTableWriter::EncryptedSegmentPmtWithParameters(
|
|||
// -12 because there are 12 bytes between 'descriptor_length' in
|
||||
// registration_descriptor and 'setup_data_length' in audio_setup_information.
|
||||
if (aac_audio_specific_config_.size() >
|
||||
std::numeric_limits<uint8_t>::max() - 12) {
|
||||
std::numeric_limits<uint8_t>::max() - 12U) {
|
||||
LOG(ERROR) << "AACAudioSpecificConfig of size: "
|
||||
<< aac_audio_specific_config_.size()
|
||||
<< " will not fit in the descriptor.";
|
||||
|
|
|
@ -108,7 +108,8 @@ class TsWriterTest : public ::testing::Test {
|
|||
void SetUp() override {
|
||||
base::CreateTemporaryFile(&test_file_path_);
|
||||
// TODO(rkuroiwa): Use memory file prefix once its exposed.
|
||||
test_file_name_ = kLocalFilePrefix + test_file_path_.value();
|
||||
test_file_name_ =
|
||||
std::string(kLocalFilePrefix) + test_file_path_.AsUTF8Unsafe();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
|
|
@ -46,7 +46,7 @@ const size_t kInvalidIvSize = 1;
|
|||
// According to ISO/IEC FDIS 23001-7: CENC spec, IV should be either
|
||||
// 64-bit (8-byte) or 128-bit (16-byte).
|
||||
// |per_sample_iv_size| of 0 means constant_iv is used.
|
||||
bool IsIvSizeValid(size_t per_sample_iv_size) {
|
||||
bool IsIvSizeValid(uint8_t per_sample_iv_size) {
|
||||
return per_sample_iv_size == 0 || per_sample_iv_size == 8 ||
|
||||
per_sample_iv_size == 16;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ bool SampleEncryptionEntry::ReadWrite(uint8_t iv_size,
|
|||
return true;
|
||||
}
|
||||
|
||||
uint16_t subsample_count = subsamples.size();
|
||||
uint16_t subsample_count = static_cast<uint16_t>(subsamples.size());
|
||||
RCHECK(buffer->ReadWriteUInt16(&subsample_count));
|
||||
RCHECK(subsample_count > 0);
|
||||
subsamples.resize(subsample_count);
|
||||
|
@ -289,7 +289,7 @@ bool SampleEncryptionEntry::ParseFromBuffer(uint8_t iv_size,
|
|||
|
||||
uint32_t SampleEncryptionEntry::ComputeSize() const {
|
||||
const uint32_t subsample_entry_size = sizeof(uint16_t) + sizeof(uint32_t);
|
||||
const uint16_t subsample_count = subsamples.size();
|
||||
const uint16_t subsample_count = static_cast<uint16_t>(subsamples.size());
|
||||
return initialization_vector.size() +
|
||||
(subsample_count > 0 ? (sizeof(subsample_count) +
|
||||
subsample_entry_size * subsample_count)
|
||||
|
@ -331,7 +331,7 @@ bool SampleEncryption::ReadWriteInternal(BoxBuffer* buffer) {
|
|||
sample_encryption_entries.resize(sample_count);
|
||||
for (auto& sample_encryption_entry : sample_encryption_entries) {
|
||||
RCHECK(sample_encryption_entry.ReadWrite(
|
||||
iv_size, flags & kUseSubsampleEncryption, buffer));
|
||||
iv_size, (flags & kUseSubsampleEncryption) != 0, buffer) != 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ uint32_t SampleEncryption::ComputeSizeInternal() {
|
|||
}
|
||||
|
||||
bool SampleEncryption::ParseFromSampleEncryptionData(
|
||||
size_t iv_size,
|
||||
uint8_t iv_size,
|
||||
std::vector<SampleEncryptionEntry>* sample_encryption_entries) const {
|
||||
DCHECK(IsIvSizeValid(iv_size));
|
||||
|
||||
|
@ -369,7 +369,7 @@ bool SampleEncryption::ParseFromSampleEncryptionData(
|
|||
sample_encryption_entries->resize(sample_count);
|
||||
for (auto& sample_encryption_entry : *sample_encryption_entries) {
|
||||
RCHECK(sample_encryption_entry.ParseFromBuffer(
|
||||
iv_size, flags & kUseSubsampleEncryption, &reader));
|
||||
iv_size, (flags & kUseSubsampleEncryption) != 0, &reader) != 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -439,7 +439,8 @@ bool TrackEncryption::ReadWriteInternal(BoxBuffer* buffer) {
|
|||
|
||||
if (default_is_protected == 1) {
|
||||
if (default_per_sample_iv_size == 0) { // For constant iv.
|
||||
uint8_t default_constant_iv_size = default_constant_iv.size();
|
||||
uint8_t default_constant_iv_size =
|
||||
static_cast<uint8_t>(default_constant_iv.size());
|
||||
RCHECK(buffer->ReadWriteUInt8(&default_constant_iv_size));
|
||||
RCHECK(default_constant_iv_size == 8 || default_constant_iv_size == 16);
|
||||
RCHECK(buffer->ReadWriteVector(&default_constant_iv,
|
||||
|
@ -960,7 +961,7 @@ bool CencSampleEncryptionInfoEntry::ReadWrite(BoxBuffer* buffer) {
|
|||
|
||||
if (is_protected == 1) {
|
||||
if (per_sample_iv_size == 0) { // For constant iv.
|
||||
uint8_t constant_iv_size = constant_iv.size();
|
||||
uint8_t constant_iv_size = static_cast<uint8_t>(constant_iv.size());
|
||||
RCHECK(buffer->ReadWriteUInt8(&constant_iv_size));
|
||||
RCHECK(constant_iv_size == 8 || constant_iv_size == 16);
|
||||
RCHECK(buffer->ReadWriteVector(&constant_iv, constant_iv_size));
|
||||
|
@ -2369,7 +2370,7 @@ bool TrackFragmentRun::ReadWriteInternal(BoxBuffer* buffer) {
|
|||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
uint32_t first_sample_flags;
|
||||
uint32_t first_sample_flags(0);
|
||||
|
||||
if (buffer->Reading()) {
|
||||
if (first_sample_flags_present)
|
||||
|
@ -2541,7 +2542,7 @@ bool SegmentIndex::ReadWriteInternal(BoxBuffer* buffer) {
|
|||
buffer->ReadWriteUInt64NBytes(&earliest_presentation_time, num_bytes) &&
|
||||
buffer->ReadWriteUInt64NBytes(&first_offset, num_bytes));
|
||||
|
||||
uint16_t reference_count = references.size();
|
||||
uint16_t reference_count = static_cast<uint16_t>(references.size());
|
||||
RCHECK(buffer->IgnoreBytes(2) && // reserved.
|
||||
buffer->ReadWriteUInt16(&reference_count));
|
||||
references.resize(reference_count);
|
||||
|
|
|
@ -117,14 +117,14 @@ struct SampleEncryption : FullBox {
|
|||
/// entries.
|
||||
/// @return true on success, false otherwise.
|
||||
bool ParseFromSampleEncryptionData(
|
||||
size_t iv_size,
|
||||
uint8_t iv_size,
|
||||
std::vector<SampleEncryptionEntry>* sample_encryption_entries) const;
|
||||
|
||||
/// We may not know @a iv_size before reading this box. In this case, we will
|
||||
/// store sample encryption data for parsing later when @a iv_size is known.
|
||||
std::vector<uint8_t> sample_encryption_data;
|
||||
|
||||
size_t iv_size;
|
||||
uint8_t iv_size;
|
||||
std::vector<SampleEncryptionEntry> sample_encryption_entries;
|
||||
};
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ class BoxDefinitionsTestGeneral : public testing::Test {
|
|||
|
||||
void Modify(WebVTTConfigurationBox* vttc) {
|
||||
vttc->config = "WEBVTT\n"
|
||||
"Region: id=someting width=40\% lines=3";
|
||||
"Region: id=someting width=40% lines=3";
|
||||
}
|
||||
|
||||
void Fill(WebVTTSourceLabelBox* vlab) {
|
||||
|
|
|
@ -173,8 +173,9 @@ void EncryptingFragmenter::FinalizeFragmentForEncryption() {
|
|||
traf()->auxiliary_offset.offsets.push_back(0);
|
||||
|
||||
// For 'cbcs' scheme, Constant IVs SHALL be used.
|
||||
const size_t per_sample_iv_size =
|
||||
(protection_scheme_ == FOURCC_cbcs) ? 0 : encryptor_->iv().size();
|
||||
const uint8_t per_sample_iv_size =
|
||||
(protection_scheme_ == FOURCC_cbcs) ? 0 :
|
||||
static_cast<uint8_t>(encryptor_->iv().size());
|
||||
traf()->sample_encryption.iv_size = per_sample_iv_size;
|
||||
|
||||
// Optimize saiz box.
|
||||
|
@ -189,7 +190,7 @@ void EncryptingFragmenter::FinalizeFragmentForEncryption() {
|
|||
// |sample_info_sizes| table is filled in only for subsample encryption,
|
||||
// otherwise |sample_info_size| is just the IV size.
|
||||
DCHECK(!IsSubsampleEncryptionRequired());
|
||||
saiz.default_sample_info_size = per_sample_iv_size;
|
||||
saiz.default_sample_info_size = static_cast<uint8_t>(per_sample_iv_size);
|
||||
}
|
||||
|
||||
// It should only happen with full sample encryption + constant iv, i.e.
|
||||
|
@ -266,7 +267,8 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
|
|||
const bool is_superframe = vpx_frames.size() > 1;
|
||||
for (const VPxFrameInfo& frame : vpx_frames) {
|
||||
SubsampleEntry subsample;
|
||||
subsample.clear_bytes = frame.uncompressed_header_size;
|
||||
subsample.clear_bytes =
|
||||
static_cast<uint16_t>(frame.uncompressed_header_size);
|
||||
subsample.cipher_bytes =
|
||||
frame.frame_size - frame.uncompressed_header_size;
|
||||
|
||||
|
@ -296,7 +298,7 @@ Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
|
|||
DCHECK_LE(index_size, 2 + vpx_frames.size() * 4);
|
||||
DCHECK_GE(index_size, 2 + vpx_frames.size() * 1);
|
||||
SubsampleEntry subsample;
|
||||
subsample.clear_bytes = index_size;
|
||||
subsample.clear_bytes = static_cast<uint16_t>(index_size);
|
||||
subsample.cipher_bytes = 0;
|
||||
sample_encryption_entry.subsamples.push_back(subsample);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ Status KeyRotationFragmenter::PrepareFragmentForEncryption(
|
|||
bool enable_encryption) {
|
||||
bool need_to_refresh_encryptor = !encryptor();
|
||||
|
||||
size_t current_crypto_period_index =
|
||||
int64_t current_crypto_period_index =
|
||||
traf()->decode_time.decode_time / crypto_period_duration_;
|
||||
if (current_crypto_period_index != prev_crypto_period_index_) {
|
||||
scoped_ptr<EncryptionKey> encryption_key(new EncryptionKey());
|
||||
|
@ -123,7 +123,8 @@ Status KeyRotationFragmenter::PrepareFragmentForEncryption(
|
|||
sample_group_entry.per_sample_iv_size = 0;
|
||||
sample_group_entry.constant_iv = encryptor()->iv();
|
||||
} else {
|
||||
sample_group_entry.per_sample_iv_size = encryptor()->iv().size();
|
||||
sample_group_entry.per_sample_iv_size =
|
||||
static_cast<uint8_t>(encryptor()->iv().size());
|
||||
}
|
||||
sample_group_entry.crypt_byte_block = crypt_byte_block();
|
||||
sample_group_entry.skip_byte_block = skip_byte_block();
|
||||
|
|
|
@ -66,7 +66,7 @@ class KeyRotationFragmenter : public EncryptingFragmenter {
|
|||
KeySource* encryption_key_source_;
|
||||
KeySource::TrackType track_type_;
|
||||
const int64_t crypto_period_duration_;
|
||||
size_t prev_crypto_period_index_;
|
||||
int64_t prev_crypto_period_index_;
|
||||
|
||||
// For notifying new pssh boxes to the event handler.
|
||||
MuxerListener* const muxer_listener_;
|
||||
|
|
|
@ -99,7 +99,7 @@ class MP4MediaParserTest : public testing::Test {
|
|||
|
||||
bool ParseMP4File(const std::string& filename, int append_bytes) {
|
||||
InitializeParser(NULL);
|
||||
if (!parser_->LoadMoov(GetTestDataFilePath(filename).value()))
|
||||
if (!parser_->LoadMoov(GetTestDataFilePath(filename).AsUTF8Unsafe()))
|
||||
return false;
|
||||
std::vector<uint8_t> buffer = ReadTestDataFile(filename);
|
||||
return AppendDataInPieces(buffer.data(), buffer.size(), append_bytes);
|
||||
|
|
|
@ -304,8 +304,8 @@ void MP4Muxer::GenerateAudioTrak(const AudioStreamInfo* audio_info,
|
|||
// values.
|
||||
const uint64_t kNanosecondsPerSecond = 1000000000ull;
|
||||
sample_group_description.audio_roll_recovery_entries[0].roll_distance =
|
||||
-(audio_info->seek_preroll_ns() * audio.samplerate +
|
||||
kNanosecondsPerSecond / 2) /
|
||||
(0 - (audio_info->seek_preroll_ns() * audio.samplerate +
|
||||
kNanosecondsPerSecond / 2)) /
|
||||
kNanosecondsPerSecond;
|
||||
|
||||
sample_table.sample_to_groups.resize(1);
|
||||
|
|
|
@ -102,7 +102,8 @@ void GenerateSinf(const EncryptionKey& encryption_key,
|
|||
track_encryption.default_per_sample_iv_size = 0;
|
||||
track_encryption.default_constant_iv = encryption_key.iv;
|
||||
} else {
|
||||
track_encryption.default_per_sample_iv_size = encryption_key.iv.size();
|
||||
track_encryption.default_per_sample_iv_size =
|
||||
static_cast<uint8_t>(encryption_key.iv.size());
|
||||
}
|
||||
track_encryption.default_crypt_byte_block = pattern.crypt_byte_block;
|
||||
track_encryption.default_skip_byte_block = pattern.skip_byte_block;
|
||||
|
|
|
@ -83,10 +83,11 @@ Status SingleSegmentSegmenter::DoInitialize() {
|
|||
LOG(ERROR) << "Failed to create temporary file.";
|
||||
return Status(error::FILE_FAILURE, "Unable to create temporary file.");
|
||||
}
|
||||
temp_file_name_ = temp_file_path.value();
|
||||
temp_file_name_ = temp_file_path.AsUTF8Unsafe();
|
||||
} else {
|
||||
temp_file_name_ =
|
||||
base::FilePath(options().temp_dir).Append(TempFileName()).value();
|
||||
base::FilePath::FromUTF8Unsafe(options().temp_dir)
|
||||
.Append(base::FilePath::FromUTF8Unsafe(TempFileName())).AsUTF8Unsafe();
|
||||
}
|
||||
temp_file_.reset(File::Open(temp_file_name_.c_str(), "w"));
|
||||
return temp_file_
|
||||
|
|
|
@ -57,7 +57,7 @@ int64_t MkvWriter::WriteFromFile(File* source) {
|
|||
return WriteFromFile(source, kWholeFile);
|
||||
}
|
||||
|
||||
int64_t MkvWriter::WriteFromFile(File* source, uint64_t max_copy) {
|
||||
int64_t MkvWriter::WriteFromFile(File* source, int64_t max_copy) {
|
||||
DCHECK(file_);
|
||||
|
||||
const int64_t size = File::CopyFile(source, file_.get(), max_copy);
|
||||
|
|
|
@ -56,7 +56,7 @@ class MkvWriter : public mkvmuxer::IMkvWriter {
|
|||
/// Writes the contents of the given file to this file, up to a maximum
|
||||
/// number of bytes. If @a max_copy is negative, will copy to EOF.
|
||||
/// @return The number of bytes written; or < 0 on error.
|
||||
int64_t WriteFromFile(File* source, uint64_t max_copy);
|
||||
int64_t WriteFromFile(File* source, int64_t max_copy);
|
||||
|
||||
File* file() { return file_.get(); }
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ std::string TempFileName(const MuxerOptions& options) {
|
|||
}
|
||||
std::string file_prefix =
|
||||
base::StringPrintf("packager-tempfile-%x-%" PRIx64 ".tmp", tid, rand);
|
||||
return base::FilePath(options.temp_dir).Append(file_prefix).value();
|
||||
return base::FilePath::FromUTF8Unsafe(options.temp_dir).Append(
|
||||
base::FilePath::FromUTF8Unsafe(file_prefix)).AsUTF8Unsafe();
|
||||
}
|
||||
|
||||
// Skips a given number of bytes in a file by reading. This allows
|
||||
|
|
|
@ -88,7 +88,7 @@ class WvmMediaParserTest : public testing::Test {
|
|||
int video_frame_count_;
|
||||
int encrypted_sample_count_;
|
||||
int64_t video_max_dts_;
|
||||
uint32_t current_track_id_;
|
||||
int32_t current_track_id_;
|
||||
EncryptionKey encryption_key_;
|
||||
|
||||
void OnInit(const std::vector<scoped_refptr<StreamInfo> >& stream_infos) {
|
||||
|
@ -103,7 +103,7 @@ class WvmMediaParserTest : public testing::Test {
|
|||
bool OnNewSample(uint32_t track_id,
|
||||
const scoped_refptr<MediaSample>& sample) {
|
||||
std::string stream_type;
|
||||
if (track_id != current_track_id_) {
|
||||
if (static_cast<int32_t>(track_id) != current_track_id_) {
|
||||
// onto next track.
|
||||
video_max_dts_ = kNoTimestamp;
|
||||
current_track_id_ = track_id;
|
||||
|
|
|
@ -87,7 +87,8 @@ class PackagerTestBasic : public ::testing::TestWithParam<const char*> {
|
|||
|
||||
void SetUp() override {
|
||||
// Create a test directory for testing, will be deleted after test.
|
||||
ASSERT_TRUE(base::CreateNewTempDirectory("packager_", &test_directory_));
|
||||
ASSERT_TRUE(base::CreateNewTempDirectory(
|
||||
base::FilePath::FromUTF8Unsafe("packager_").value(), &test_directory_));
|
||||
|
||||
// Copy the input to test directory for easy reference.
|
||||
ASSERT_TRUE(base::CopyFile(GetTestDataFilePath(GetParam()),
|
||||
|
@ -118,7 +119,8 @@ class PackagerTestBasic : public ::testing::TestWithParam<const char*> {
|
|||
};
|
||||
|
||||
std::string PackagerTestBasic::GetFullPath(const std::string& file_name) {
|
||||
return test_directory_.AppendASCII(file_name).value();
|
||||
return test_directory_.Append(
|
||||
base::FilePath::FromUTF8Unsafe(file_name)).AsUTF8Unsafe();
|
||||
}
|
||||
|
||||
bool PackagerTestBasic::ContentsEqual(const std::string& file1,
|
||||
|
@ -140,7 +142,7 @@ MuxerOptions PackagerTestBasic::SetupOptions(const std::string& output,
|
|||
|
||||
options.output_file_name = GetFullPath(output);
|
||||
options.segment_template = GetFullPath(kSegmentTemplate);
|
||||
options.temp_dir = test_directory_.value();
|
||||
options.temp_dir = test_directory_.AsUTF8Unsafe();
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,15 +8,27 @@
|
|||
|
||||
#include "packager/base/at_exit.h"
|
||||
#include "packager/base/command_line.h"
|
||||
#include "packager/base/files/file_path.h"
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/path_service.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
base::AtExitManager exit;
|
||||
|
||||
// Needed to enable VLOG/DVLOG through --vmodule or --v.
|
||||
base::CommandLine::Init(argc, argv);
|
||||
CHECK(logging::InitLogging(logging::LoggingSettings()));
|
||||
|
||||
base::AtExitManager exit;
|
||||
// Set up logging.
|
||||
logging::LoggingSettings log_settings;
|
||||
base::FilePath log_filename;
|
||||
PathService::Get(base::DIR_EXE, &log_filename);
|
||||
log_filename = log_filename.AppendASCII("test.log");
|
||||
log_settings.logging_dest = logging::LOG_TO_ALL;
|
||||
log_settings.log_file = log_filename.value().c_str();
|
||||
log_settings.delete_old = logging::DELETE_OLD_LOG_FILE;
|
||||
CHECK(logging::InitLogging(log_settings));
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class DashIopMpdNotifierTest
|
|||
|
||||
void SetUp() override {
|
||||
ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path_));
|
||||
output_path_ = temp_file_path_.value();
|
||||
output_path_ = temp_file_path_.AsUTF8Unsafe();
|
||||
ON_CALL(*default_mock_adaptation_set_, Group())
|
||||
.WillByDefault(Return(kDefaultGroupId));
|
||||
}
|
||||
|
|
|
@ -332,8 +332,7 @@ std::string RoleToText(AdaptationSet::Role role) {
|
|||
case AdaptationSet::kRoleDub:
|
||||
return "dub";
|
||||
default:
|
||||
NOTREACHED();
|
||||
return "";
|
||||
break;
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
|
@ -653,8 +652,8 @@ void MpdBuilder::MakePathsRelativeToMpd(const std::string& mpd_path,
|
|||
: mpd_path;
|
||||
|
||||
if (!mpd_file_path.empty()) {
|
||||
std::string mpd_dir(
|
||||
FilePath(mpd_file_path).DirName().AsEndingWithSeparator().value());
|
||||
std::string mpd_dir(FilePath::FromUTF8Unsafe(mpd_file_path)
|
||||
.DirName().AsEndingWithSeparator().AsUTF8Unsafe());
|
||||
if (!mpd_dir.empty()) {
|
||||
if (media_info->has_media_file_name()) {
|
||||
media_info->set_media_file_name(
|
||||
|
|
|
@ -194,14 +194,14 @@ class DynamicMpdBuilderTest : public MpdBuilderTest<MpdBuilder::kDynamic> {
|
|||
|
||||
// Injects a clock that always returns 2016 Jan 11 15:10:24 in UTC.
|
||||
void InjectTestClock() {
|
||||
base::Time::Exploded test_time = {.year = 2016,
|
||||
.month = 1,
|
||||
.day_of_week = 1, // Monday.
|
||||
.day_of_month = 11,
|
||||
.hour = 15,
|
||||
.minute = 10,
|
||||
.second = 24,
|
||||
.millisecond = 0};
|
||||
base::Time::Exploded test_time = { 2016, // year.
|
||||
1, // month
|
||||
1, // day_of_week = Monday.
|
||||
11, // day_of_month
|
||||
15, // hour.
|
||||
10, // minute.
|
||||
24, // second.
|
||||
0 }; // millisecond.
|
||||
ASSERT_TRUE(test_time.HasValidValues());
|
||||
mpd_.InjectClockForTesting(scoped_ptr<base::Clock>(
|
||||
new TestClock(base::Time::FromUTCExploded(test_time))));
|
||||
|
@ -1975,7 +1975,7 @@ TEST_F(StaticMpdBuilderTest, WriteToFile) {
|
|||
|
||||
base::FilePath file_path;
|
||||
ASSERT_TRUE(base::CreateTemporaryFile(&file_path));
|
||||
media::File* file = media::File::Open(file_path.value().data(), "w");
|
||||
media::File* file = media::File::Open(file_path.AsUTF8Unsafe().c_str(), "w");
|
||||
ASSERT_TRUE(file);
|
||||
ASSERT_TRUE(mpd_.WriteMpdToFile(file));
|
||||
ASSERT_TRUE(file->Close());
|
||||
|
@ -2472,17 +2472,22 @@ TEST_F(TimeShiftBufferDepthTest, ManySegments) {
|
|||
}
|
||||
|
||||
TEST(RelativePaths, PathsModified) {
|
||||
const std::string kCommonPath(FilePath("foo").Append("bar").value());
|
||||
const FilePath kCommonPath(
|
||||
FilePath::FromUTF8Unsafe("foo").Append(FilePath::FromUTF8Unsafe("bar")));
|
||||
const std::string kMediaFileBase("media.mp4");
|
||||
const std::string kInitSegmentBase("init.mp4");
|
||||
const std::string kSegmentTemplateBase("segment-$Number$.mp4");
|
||||
const std::string kMediaFile(
|
||||
FilePath(kCommonPath).Append(kMediaFileBase).value());
|
||||
kCommonPath.Append(FilePath::FromUTF8Unsafe(kMediaFileBase))
|
||||
.AsUTF8Unsafe());
|
||||
const std::string kInitSegment(
|
||||
FilePath(kCommonPath).Append(kInitSegmentBase).value());
|
||||
kCommonPath.Append(FilePath::FromUTF8Unsafe(kInitSegmentBase))
|
||||
.AsUTF8Unsafe());
|
||||
const std::string kSegmentTemplate(
|
||||
FilePath(kCommonPath).Append(kSegmentTemplateBase).value());
|
||||
const std::string kMpd(FilePath(kCommonPath).Append("media.mpd").value());
|
||||
kCommonPath.Append(FilePath::FromUTF8Unsafe(kSegmentTemplateBase))
|
||||
.AsUTF8Unsafe());
|
||||
const std::string kMpd(
|
||||
kCommonPath.Append(FilePath::FromUTF8Unsafe("media.mpd")).AsUTF8Unsafe());
|
||||
MediaInfo media_info;
|
||||
|
||||
media_info.set_media_file_name(kMediaFile);
|
||||
|
@ -2495,18 +2500,24 @@ TEST(RelativePaths, PathsModified) {
|
|||
}
|
||||
|
||||
TEST(RelativePaths, PathsNotModified) {
|
||||
const std::string kMediaCommon(FilePath("foo").Append("bar").value());
|
||||
const FilePath kMediaCommon(
|
||||
FilePath::FromUTF8Unsafe("foo").Append(FilePath::FromUTF8Unsafe("bar")));
|
||||
const std::string kMediaFileBase("media.mp4");
|
||||
const std::string kInitSegmentBase("init.mp4");
|
||||
const std::string kSegmentTemplateBase("segment-$Number$.mp4");
|
||||
const std::string kMediaFile(
|
||||
FilePath(kMediaCommon).Append(kMediaFileBase).value());
|
||||
kMediaCommon.Append(FilePath::FromUTF8Unsafe(kMediaFileBase))
|
||||
.AsUTF8Unsafe());
|
||||
const std::string kInitSegment(
|
||||
FilePath(kMediaCommon).Append(kInitSegmentBase).value());
|
||||
kMediaCommon.Append(FilePath::FromUTF8Unsafe(kInitSegmentBase))
|
||||
.AsUTF8Unsafe());
|
||||
const std::string kSegmentTemplate(
|
||||
FilePath(kMediaCommon).Append(kSegmentTemplateBase).value());
|
||||
const std::string kMpd(
|
||||
FilePath("foo").Append("baz").Append("media.mpd").value());
|
||||
kMediaCommon.Append(FilePath::FromUTF8Unsafe(kSegmentTemplateBase))
|
||||
.AsUTF8Unsafe());
|
||||
const std::string kMpd(FilePath::FromUTF8Unsafe("foo")
|
||||
.Append(FilePath::FromUTF8Unsafe("baz"))
|
||||
.Append(FilePath::FromUTF8Unsafe("media.mpd"))
|
||||
.AsUTF8Unsafe());
|
||||
MediaInfo media_info;
|
||||
|
||||
media_info.set_media_file_name(kMediaFile);
|
||||
|
|
|
@ -44,7 +44,7 @@ class SimpleMpdNotifierTest
|
|||
|
||||
void SetUp() override {
|
||||
ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path_));
|
||||
output_path_ = temp_file_path_.value();
|
||||
output_path_ = temp_file_path_.AsUTF8Unsafe();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
|
|
@ -78,7 +78,7 @@ bool ValidateMpdSchema(const std::string& mpd) {
|
|||
xml::scoped_xml_ptr<xmlDoc> schema_as_doc(
|
||||
xmlReadMemory(schema_str.data(),
|
||||
schema_str.size(),
|
||||
schema_path.value().c_str(),
|
||||
schema_path.AsUTF8Unsafe().c_str(),
|
||||
NULL,
|
||||
0));
|
||||
DCHECK(schema_as_doc);
|
||||
|
|
|
@ -92,14 +92,14 @@ TEST_F(MpdWriterTest, WriteMpdToFile) {
|
|||
GetTestDataFilePath(kFileNameVideoMediaInfo2);
|
||||
|
||||
SetMpdNotifierFactoryForTest();
|
||||
EXPECT_TRUE(mpd_writer_.AddFile(media_info_file1.value(), ""));
|
||||
EXPECT_TRUE(mpd_writer_.AddFile(media_info_file2.value(), ""));
|
||||
EXPECT_TRUE(mpd_writer_.AddFile(media_info_file1.AsUTF8Unsafe(), ""));
|
||||
EXPECT_TRUE(mpd_writer_.AddFile(media_info_file2.AsUTF8Unsafe(), ""));
|
||||
mpd_writer_.AddBaseUrl(kBaseUrl1);
|
||||
mpd_writer_.AddBaseUrl(kBaseUrl2);
|
||||
|
||||
base::FilePath mpd_file_path;
|
||||
ASSERT_TRUE(base::CreateTemporaryFile(&mpd_file_path));
|
||||
EXPECT_TRUE(mpd_writer_.WriteMpdToFile(mpd_file_path.value().c_str()));
|
||||
EXPECT_TRUE(mpd_writer_.WriteMpdToFile(mpd_file_path.AsUTF8Unsafe().c_str()));
|
||||
}
|
||||
|
||||
} // namespace shaka
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# https://developers.google.com/open-source/licenses/bsd
|
||||
"""This script is used to generate version string for packager."""
|
||||
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
# To support python version before 2.7, which does not have
|
||||
|
@ -30,9 +31,13 @@ if 'check_output' not in dir(subprocess):
|
|||
subprocess.check_output = check_output_implementation
|
||||
|
||||
if __name__ == '__main__':
|
||||
git = 'git'
|
||||
if platform.system() == 'Windows':
|
||||
git += '.bat'
|
||||
|
||||
try:
|
||||
version_tag = subprocess.check_output(
|
||||
['git', 'tag', '--points-at', 'HEAD'],
|
||||
[git, 'tag', '--points-at', 'HEAD'],
|
||||
stderr=subprocess.STDOUT).rstrip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
# git tag --points-at is not supported in old versions of git. Just ignore
|
||||
|
@ -41,7 +46,7 @@ if __name__ == '__main__':
|
|||
|
||||
try:
|
||||
version_hash = subprocess.check_output(
|
||||
['git', 'rev-parse', '--short', 'HEAD'],
|
||||
[git, 'rev-parse', '--short', 'HEAD'],
|
||||
stderr=subprocess.STDOUT).rstrip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
version_hash = 'unknown-version'
|
||||
|
|
Loading…
Reference in New Issue