Move packager/media/file to packager/file
Change-Id: Idc0d75a7ceab7c8ce460ef896fdefdec088124bb
This commit is contained in:
parent
a4c227f74a
commit
eb98a87f7d
|
@ -23,7 +23,7 @@
|
|||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_split.h"
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/packager.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -108,7 +108,7 @@ bool GetWidevineSigner(WidevineSigner* signer) {
|
|||
signer->aes.iv = FLAGS_aes_signing_iv_bytes;
|
||||
} else if (!FLAGS_rsa_signing_key_path.empty()) {
|
||||
signer->signing_key_type = WidevineSigner::SigningKeyType::kRsa;
|
||||
if (!media::File::ReadFileToString(FLAGS_rsa_signing_key_path.c_str(),
|
||||
if (!File::ReadFileToString(FLAGS_rsa_signing_key_path.c_str(),
|
||||
&signer->rsa.key)) {
|
||||
LOG(ERROR) << "Failed to read from '" << FLAGS_rsa_signing_key_path
|
||||
<< "'.";
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "packager/base/logging.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_split.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/fixed_key_source.h"
|
||||
#include "packager/media/base/media_handler.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "packager/media/base/widevine_key_source.h"
|
||||
#include "packager/media/chunking/chunking_handler.h"
|
||||
#include "packager/media/crypto/encryption_handler.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/mpd/base/mpd_options.h"
|
||||
#include "packager/packager.h"
|
||||
#include "packager/status.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include <algorithm>
|
||||
|
@ -12,10 +12,10 @@
|
|||
#include "packager/base/files/important_file_writer.h"
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/strings/string_piece.h"
|
||||
#include "packager/media/file/local_file.h"
|
||||
#include "packager/media/file/memory_file.h"
|
||||
#include "packager/media/file/threaded_io_file.h"
|
||||
#include "packager/media/file/udp_file.h"
|
||||
#include "packager/file/local_file.h"
|
||||
#include "packager/file/memory_file.h"
|
||||
#include "packager/file/threaded_io_file.h"
|
||||
#include "packager/file/udp_file.h"
|
||||
|
||||
DEFINE_uint64(io_cache_size,
|
||||
32ULL << 20,
|
||||
|
@ -31,7 +31,6 @@ DEFINE_uint64(io_block_size,
|
|||
#endif // CopyFile
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
const char* kLocalFilePrefix = "file://";
|
||||
const char* kUdpFilePrefix = "udp://";
|
||||
|
@ -91,20 +90,9 @@ static const FileTypeInfo kFileTypeInfo[] = {
|
|||
&DeleteLocalFile,
|
||||
&WriteLocalFileAtomically,
|
||||
},
|
||||
{
|
||||
kUdpFilePrefix,
|
||||
strlen(kUdpFilePrefix),
|
||||
&CreateUdpFile,
|
||||
nullptr,
|
||||
nullptr
|
||||
},
|
||||
{
|
||||
kMemoryFilePrefix,
|
||||
strlen(kMemoryFilePrefix),
|
||||
&CreateMemoryFile,
|
||||
&DeleteMemoryFile,
|
||||
nullptr
|
||||
},
|
||||
{kUdpFilePrefix, strlen(kUdpFilePrefix), &CreateUdpFile, nullptr, nullptr},
|
||||
{kMemoryFilePrefix, strlen(kMemoryFilePrefix), &CreateMemoryFile,
|
||||
&DeleteMemoryFile, nullptr},
|
||||
};
|
||||
|
||||
const FileTypeInfo* GetFileTypeInfo(base::StringPiece file_name,
|
||||
|
@ -214,7 +202,8 @@ bool File::ReadFileToString(const char* file_name, std::string* contents) {
|
|||
return len == 0;
|
||||
}
|
||||
|
||||
bool File::WriteFileAtomically(const char* file_name, const std::string& contents) {
|
||||
bool File::WriteFileAtomically(const char* file_name,
|
||||
const std::string& contents) {
|
||||
base::StringPiece real_file_name;
|
||||
const FileTypeInfo* file_type = GetFileTypeInfo(file_name, &real_file_name);
|
||||
DCHECK(file_type);
|
||||
|
@ -230,7 +219,7 @@ bool File::WriteFileAtomically(const char* file_name, const std::string& content
|
|||
<< " is not guaranteed to be atomic.";
|
||||
}
|
||||
|
||||
std::unique_ptr<File, FileCloser> file(media::File::Open(file_name, "w"));
|
||||
std::unique_ptr<File, FileCloser> file(File::Open(file_name, "w"));
|
||||
if (!file) {
|
||||
LOG(ERROR) << "Failed to open file " << file_name;
|
||||
return false;
|
||||
|
@ -317,5 +306,4 @@ int64_t File::CopyFile(File* source, File* destination, int64_t max_copy) {
|
|||
return bytes_copied;
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{
|
||||
'includes': [
|
||||
'../../common.gypi',
|
||||
'../common.gypi',
|
||||
],
|
||||
'targets': [
|
||||
{
|
||||
|
@ -32,9 +32,8 @@
|
|||
'udp_options.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../base/base.gyp:base',
|
||||
'../../third_party/gflags/gflags.gyp:gflags',
|
||||
'../base/media_base.gyp:media_base',
|
||||
'../base/base.gyp:base',
|
||||
'../third_party/gflags/gflags.gyp:gflags',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -48,9 +47,9 @@
|
|||
'udp_options_unittest.cc',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../testing/gtest.gyp:gtest',
|
||||
'../../third_party/gflags/gflags.gyp:gflags',
|
||||
'../test/media_test.gyp:run_tests_with_atexit_manager',
|
||||
'../media/test/media_test.gyp:run_tests_with_atexit_manager',
|
||||
'../testing/gtest.gyp:gtest',
|
||||
'../third_party/gflags/gflags.gyp:gflags',
|
||||
'file',
|
||||
],
|
||||
},
|
|
@ -14,7 +14,6 @@
|
|||
#include "packager/base/macros.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
extern const char* kLocalFilePrefix;
|
||||
extern const char* kMemoryFilePrefix;
|
||||
|
@ -154,7 +153,6 @@ class File {
|
|||
DISALLOW_COPY_AND_ASSIGN(File);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // PACKAGER_FILE_FILE_H_
|
|
@ -8,10 +8,9 @@
|
|||
#define MEDIA_FILE_FILE_CLOSER_H_
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Used by std::unique_ptr to automatically close the file when it goes out of
|
||||
/// scope.
|
||||
|
@ -20,14 +19,12 @@ struct FileCloser {
|
|||
if (file != NULL) {
|
||||
const std::string filename = file->file_name();
|
||||
if (!file->Close()) {
|
||||
LOG(WARNING) << "Failed to close the file properly: "
|
||||
<< filename;
|
||||
LOG(WARNING) << "Failed to close the file properly: " << filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // MEDIA_FILE_FILE_CLOSER_H_
|
|
@ -12,15 +12,14 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
#define ASSERT_FILE_EQ(file_name, array) \
|
||||
do { \
|
||||
std::string temp_data; \
|
||||
ASSERT_TRUE(media::File::ReadFileToString((file_name), &temp_data)); \
|
||||
ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
|
||||
const char* array_ptr = reinterpret_cast<const char*>(array); \
|
||||
ASSERT_EQ(std::string(array_ptr, arraysize(array)), temp_data); \
|
||||
} while (false)
|
||||
|
@ -28,20 +27,19 @@ namespace media {
|
|||
#define ASSERT_FILE_STREQ(file_name, str) \
|
||||
do { \
|
||||
std::string temp_data; \
|
||||
ASSERT_TRUE(media::File::ReadFileToString((file_name), &temp_data)); \
|
||||
ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
|
||||
ASSERT_EQ(str, temp_data); \
|
||||
} while (false)
|
||||
|
||||
#define ASSERT_FILE_ENDS_WITH(file_name, array) \
|
||||
do { \
|
||||
std::string temp_data; \
|
||||
ASSERT_TRUE(media::File::ReadFileToString((file_name), &temp_data)); \
|
||||
ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
|
||||
EXPECT_THAT(temp_data, \
|
||||
::testing::EndsWith(std::string( \
|
||||
reinterpret_cast<const char*>(array), sizeof(array)))); \
|
||||
} while (false)
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // MEDIA_FILE_FILE_TEST_UTIL_H_
|
|
@ -8,7 +8,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/base/files/file_util.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
DECLARE_uint64(io_cache_size);
|
||||
DECLARE_uint64(io_block_size);
|
||||
|
@ -18,7 +18,6 @@ const int kDataSize = 1024;
|
|||
}
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
using base::FilePath;
|
||||
|
||||
|
@ -57,8 +56,7 @@ class LocalFileTest : public testing::Test {
|
|||
|
||||
TEST_F(LocalFileTest, ReadNotExist) {
|
||||
// Remove test file if it exists.
|
||||
base::DeleteFile(FilePath::FromUTF8Unsafe(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);
|
||||
}
|
||||
|
||||
|
@ -73,21 +71,18 @@ TEST_F(LocalFileTest, Copy) {
|
|||
base::WriteFile(test_file_path_, data_.data(), kDataSize));
|
||||
|
||||
FilePath temp_dir;
|
||||
ASSERT_TRUE(base::CreateNewTempDirectory(FilePath::StringType(),
|
||||
&temp_dir));
|
||||
ASSERT_TRUE(base::CreateNewTempDirectory(FilePath::StringType(), &temp_dir));
|
||||
|
||||
// Copy the test file to temp dir as filename "a".
|
||||
FilePath destination =
|
||||
temp_dir.Append(FilePath::FromUTF8Unsafe("a"));
|
||||
ASSERT_TRUE(
|
||||
File::Copy(FilePath::FromUTF8Unsafe(local_file_name_).AsUTF8Unsafe().c_str(),
|
||||
FilePath destination = temp_dir.Append(FilePath::FromUTF8Unsafe("a"));
|
||||
ASSERT_TRUE(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.
|
||||
char copied_file_content_buffer[kDataSize * 2] = {};
|
||||
ASSERT_EQ(kDataSize, base::ReadFile(destination,
|
||||
copied_file_content_buffer,
|
||||
ASSERT_EQ(kDataSize, base::ReadFile(destination, copied_file_content_buffer,
|
||||
arraysize(copied_file_content_buffer)));
|
||||
|
||||
ASSERT_EQ(data_, std::string(copied_file_content_buffer, kDataSize));
|
||||
|
@ -192,8 +187,7 @@ TEST_F(LocalFileTest, WriteFlushCheckSize) {
|
|||
}
|
||||
|
||||
class ParamLocalFileTest : public LocalFileTest,
|
||||
public ::testing::WithParamInterface<uint8_t> {
|
||||
};
|
||||
public ::testing::WithParamInterface<uint8_t> {};
|
||||
|
||||
TEST_P(ParamLocalFileTest, SeekWriteAndSeekRead) {
|
||||
const uint32_t kBlockSize(10);
|
||||
|
@ -297,5 +291,4 @@ TEST_F(LocalFileTest, DISABLED_ReadSeekOutOfBounds) {
|
|||
EXPECT_TRUE(file->Close());
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/file_util.h"
|
||||
#include "packager/file/file_util.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/file_util.h"
|
||||
#include "packager/file/file_util.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/io_cache.h"
|
||||
#include "packager/file/io_cache.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -17,8 +17,6 @@ namespace shaka {
|
|||
using base::AutoLock;
|
||||
using base::AutoUnlock;
|
||||
|
||||
namespace media {
|
||||
|
||||
IoCache::IoCache(uint64_t cache_size)
|
||||
: cache_size_(cache_size),
|
||||
read_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
|
||||
|
@ -47,8 +45,8 @@ uint64_t IoCache::Read(void* buffer, uint64_t size) {
|
|||
}
|
||||
|
||||
size = std::min(size, BytesCachedInternal());
|
||||
uint64_t first_chunk_size(std::min(size, static_cast<uint64_t>(
|
||||
end_ptr_ - r_ptr_)));
|
||||
uint64_t first_chunk_size(
|
||||
std::min(size, static_cast<uint64_t>(end_ptr_ - r_ptr_)));
|
||||
memcpy(buffer, r_ptr_, first_chunk_size);
|
||||
r_ptr_ += first_chunk_size;
|
||||
DCHECK_GE(end_ptr_, r_ptr_);
|
||||
|
@ -80,8 +78,8 @@ uint64_t IoCache::Write(const void* buffer, uint64_t size) {
|
|||
return 0;
|
||||
|
||||
uint64_t write_size(std::min(bytes_left, BytesFreeInternal()));
|
||||
uint64_t first_chunk_size(std::min(write_size, static_cast<uint64_t>(
|
||||
end_ptr_ - w_ptr_)));
|
||||
uint64_t first_chunk_size(
|
||||
std::min(write_size, static_cast<uint64_t>(end_ptr_ - w_ptr_)));
|
||||
memcpy(w_ptr_, r_ptr, first_chunk_size);
|
||||
w_ptr_ += first_chunk_size;
|
||||
DCHECK_GE(end_ptr_, w_ptr_);
|
||||
|
@ -152,5 +150,4 @@ void IoCache::WaitUntilEmptyOrClosed() {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -14,7 +14,6 @@
|
|||
#include "packager/base/synchronization/waitable_event.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Declaration of class which implements a thread-safe circular buffer.
|
||||
class IoCache {
|
||||
|
@ -80,7 +79,6 @@ class IoCache {
|
|||
DISALLOW_COPY_AND_ASSIGN(IoCache);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // PACKAGER_FILE_IO_CACHE_H
|
|
@ -4,22 +4,36 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/file/io_cache.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include "packager/base/bind.h"
|
||||
#include "packager/base/bind_helpers.h"
|
||||
#include "packager/base/threading/platform_thread.h"
|
||||
#include "packager/media/base/closure_thread.h"
|
||||
#include "packager/media/file/io_cache.h"
|
||||
#include "packager/base/threading/simple_thread.h"
|
||||
|
||||
namespace {
|
||||
const uint64_t kBlockSize = 256;
|
||||
const uint64_t kCacheSize = 16 * kBlockSize;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
class ClosureThread : public base::SimpleThread {
|
||||
public:
|
||||
ClosureThread(const std::string& name_prefix, const base::Closure& task)
|
||||
: base::SimpleThread(name_prefix), task_(task) {}
|
||||
|
||||
~ClosureThread() {
|
||||
if (HasBeenStarted() && !HasBeenJoined())
|
||||
Join();
|
||||
}
|
||||
|
||||
void Run() { task_.Run(); }
|
||||
|
||||
private:
|
||||
const base::Closure task_;
|
||||
};
|
||||
|
||||
class IoCacheTest : public testing::Test {
|
||||
public:
|
||||
|
@ -53,9 +67,7 @@ class IoCacheTest : public testing::Test {
|
|||
cache_closed_ = false;
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
WaitForWriterThread();
|
||||
}
|
||||
void TearDown() override { WaitForWriterThread(); }
|
||||
|
||||
void GenerateTestBuffer(uint64_t size, std::vector<uint8_t>* test_buffer) {
|
||||
test_buffer->resize(size);
|
||||
|
@ -72,18 +84,14 @@ class IoCacheTest : public testing::Test {
|
|||
uint64_t num_writes,
|
||||
int sleep_between_writes,
|
||||
bool close_when_done) {
|
||||
writer_thread_.reset(new ClosureThread("WriterThread",
|
||||
base::Bind(
|
||||
&IoCacheTest::WriteToCache,
|
||||
base::Unretained(this),
|
||||
test_buffer,
|
||||
num_writes,
|
||||
sleep_between_writes,
|
||||
writer_thread_.reset(new ClosureThread(
|
||||
"WriterThread",
|
||||
base::Bind(&IoCacheTest::WriteToCache, base::Unretained(this),
|
||||
test_buffer, num_writes, sleep_between_writes,
|
||||
close_when_done)));
|
||||
writer_thread_->Start();
|
||||
}
|
||||
|
||||
|
||||
void WaitForWriterThread() {
|
||||
if (writer_thread_) {
|
||||
writer_thread_->Join();
|
||||
|
@ -140,8 +148,7 @@ TEST_F(IoCacheTest, LotsOfUnalignedBlocks) {
|
|||
EXPECT_EQ(write_buffer1, read_buffer1);
|
||||
std::vector<uint8_t> verify_buffer;
|
||||
for (uint64_t idx = 0; idx < kNumWrites; ++idx)
|
||||
verify_buffer.insert(verify_buffer.end(),
|
||||
write_buffer2.begin(),
|
||||
verify_buffer.insert(verify_buffer.end(), write_buffer2.begin(),
|
||||
write_buffer2.end());
|
||||
uint64_t verify_index(0);
|
||||
while (verify_index < verify_buffer.size()) {
|
||||
|
@ -191,8 +198,7 @@ TEST_F(IoCacheTest, CloseByReader) {
|
|||
GenerateTestBuffer(kBlockSize, &write_buffer);
|
||||
WriteToCacheThreaded(write_buffer, kNumWrites, 0, false);
|
||||
while (cache_->BytesCached() < kCacheSize) {
|
||||
base::PlatformThread::Sleep(
|
||||
base::TimeDelta::FromMilliseconds(10));
|
||||
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
|
||||
}
|
||||
cache_->Close();
|
||||
WaitForWriterThread();
|
||||
|
@ -254,13 +260,11 @@ TEST_F(IoCacheTest, LargeRead) {
|
|||
WriteToCacheThreaded(write_buffer, kNumWrites, 0, false);
|
||||
std::vector<uint8_t> verify_buffer;
|
||||
while (verify_buffer.size() < kCacheSize) {
|
||||
verify_buffer.insert(verify_buffer.end(),
|
||||
write_buffer.begin(),
|
||||
verify_buffer.insert(verify_buffer.end(), write_buffer.begin(),
|
||||
write_buffer.end());
|
||||
}
|
||||
while (cache_->BytesCached() < kCacheSize) {
|
||||
base::PlatformThread::Sleep(
|
||||
base::TimeDelta::FromMilliseconds(10));
|
||||
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
|
||||
}
|
||||
std::vector<uint8_t> read_buffer(kCacheSize);
|
||||
EXPECT_EQ(kCacheSize, cache_->Read(read_buffer.data(), kCacheSize));
|
||||
|
@ -268,5 +272,4 @@ TEST_F(IoCacheTest, LargeRead) {
|
|||
cache_->Close();
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/local_file.h"
|
||||
#include "packager/file/local_file.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined(OS_WIN)
|
||||
|
@ -14,15 +14,12 @@
|
|||
#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;
|
||||
}
|
||||
|
@ -74,8 +71,8 @@ bool LocalFile::Flush() {
|
|||
|
||||
bool LocalFile::Seek(uint64_t position) {
|
||||
#if defined(OS_WIN)
|
||||
return _fseeki64(internal_file_, static_cast<__int64>(position),
|
||||
SEEK_SET) == 0;
|
||||
return _fseeki64(internal_file_, static_cast<__int64>(position), SEEK_SET) ==
|
||||
0;
|
||||
#else
|
||||
return fseeko(internal_file_, position, SEEK_SET) >= 0;
|
||||
#endif // !defined(OS_WIN)
|
||||
|
@ -96,8 +93,8 @@ bool LocalFile::Tell(uint64_t* position) {
|
|||
LocalFile::~LocalFile() {}
|
||||
|
||||
bool LocalFile::Open() {
|
||||
internal_file_ =
|
||||
base::OpenFile(base::FilePath::FromUTF8Unsafe(file_name()), file_mode_.c_str());
|
||||
internal_file_ = base::OpenFile(base::FilePath::FromUTF8Unsafe(file_name()),
|
||||
file_mode_.c_str());
|
||||
return (internal_file_ != NULL);
|
||||
}
|
||||
|
||||
|
@ -105,5 +102,4 @@ bool LocalFile::Delete(const char* file_name) {
|
|||
return base::DeleteFile(base::FilePath::FromUTF8Unsafe(file_name), false);
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -12,10 +12,9 @@
|
|||
#include <string>
|
||||
|
||||
#include "packager/base/compiler_specific.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Implement LocalFile which deals with local storage.
|
||||
class LocalFile : public File {
|
||||
|
@ -53,7 +52,6 @@ class LocalFile : public File {
|
|||
DISALLOW_COPY_AND_ASSIGN(LocalFile);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // PACKAGER_FILE_LOCAL_FILE_H_
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/memory_file.h"
|
||||
#include "packager/file/memory_file.h"
|
||||
|
||||
#include <string.h> // for memcpy
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
|||
#include "packager/base/logging.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
namespace {
|
||||
|
||||
// A helper filesystem object. This holds the data for the memory files.
|
||||
|
@ -136,6 +135,4 @@ void MemoryFile::Delete(const std::string& file_name) {
|
|||
FileSystem::Instance()->Delete(file_name);
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
|
@ -12,10 +12,9 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Implements a File that is stored in memory. This should be only used for
|
||||
/// testing, since this does not support larger files.
|
||||
|
@ -54,8 +53,6 @@ class MemoryFile : public File {
|
|||
DISALLOW_COPY_AND_ASSIGN(MemoryFile);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // MEDIA_FILE_MEDIA_FILE_H_
|
||||
|
|
@ -2,26 +2,23 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "packager/file/memory_file.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include <memory>
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/media/file/memory_file.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/file/file_closer.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
namespace {
|
||||
|
||||
const uint8_t kWriteBuffer[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
const int64_t kWriteBufferSize = sizeof(kWriteBuffer);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
class MemoryFileTest : public testing::Test {
|
||||
protected:
|
||||
void TearDown() override {
|
||||
MemoryFile::DeleteAll();
|
||||
}
|
||||
void TearDown() override { MemoryFile::DeleteAll(); }
|
||||
};
|
||||
|
||||
TEST_F(MemoryFileTest, ModifiesSameFile) {
|
||||
|
@ -110,5 +107,4 @@ TEST_F(MemoryFileTest, WriteExistingFileDeletes) {
|
|||
EXPECT_EQ(0, file2->Size());
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/threaded_io_file.h"
|
||||
#include "packager/file/threaded_io_file.h"
|
||||
|
||||
#include "packager/base/bind.h"
|
||||
#include "packager/base/bind_helpers.h"
|
||||
|
@ -12,7 +12,6 @@
|
|||
#include "packager/base/threading/worker_pool.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
using base::subtle::NoBarrier_Load;
|
||||
using base::subtle::NoBarrier_Store;
|
||||
|
@ -49,8 +48,9 @@ bool ThreadedIoFile::Open() {
|
|||
position_ = 0;
|
||||
size_ = internal_file_->Size();
|
||||
|
||||
base::WorkerPool::PostTask(FROM_HERE, base::Bind(&ThreadedIoFile::TaskHandler,
|
||||
base::Unretained(this)),
|
||||
base::WorkerPool::PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&ThreadedIoFile::TaskHandler, base::Unretained(this)),
|
||||
true /* task_is_slow */);
|
||||
return true;
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ int64_t ThreadedIoFile::Read(void* buffer, uint64_t length) {
|
|||
if (NoBarrier_Load(&internal_file_error_))
|
||||
return NoBarrier_Load(&internal_file_error_);
|
||||
|
||||
|
||||
uint64_t bytes_read = cache_.Read(buffer, length);
|
||||
position_ += bytes_read;
|
||||
|
||||
|
@ -120,8 +119,10 @@ bool ThreadedIoFile::Flush() {
|
|||
bool ThreadedIoFile::Seek(uint64_t position) {
|
||||
if (mode_ == kOutputMode) {
|
||||
// Writing. Just flush the cache and seek.
|
||||
if (!Flush()) return false;
|
||||
if (!internal_file_->Seek(position)) return false;
|
||||
if (!Flush())
|
||||
return false;
|
||||
if (!internal_file_->Seek(position))
|
||||
return false;
|
||||
} else {
|
||||
// Reading. Close cache, wait for thread task to exit, seek, and re-post
|
||||
// the task.
|
||||
|
@ -140,7 +141,8 @@ bool ThreadedIoFile::Seek(uint64_t position) {
|
|||
FROM_HERE,
|
||||
base::Bind(&ThreadedIoFile::TaskHandler, base::Unretained(this)),
|
||||
true /* task_is_slow */);
|
||||
if (!result) return false;
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
position_ = position;
|
||||
return true;
|
||||
|
@ -166,8 +168,8 @@ void ThreadedIoFile::RunInInputMode() {
|
|||
DCHECK_EQ(kInputMode, mode_);
|
||||
|
||||
while (true) {
|
||||
int64_t read_result = internal_file_->Read(&io_buffer_[0],
|
||||
io_buffer_.size());
|
||||
int64_t read_result =
|
||||
internal_file_->Read(&io_buffer_[0], io_buffer_.size());
|
||||
if (read_result <= 0) {
|
||||
NoBarrier_Store(&eof_, read_result == 0);
|
||||
NoBarrier_Store(&internal_file_error_, read_result);
|
||||
|
@ -210,5 +212,4 @@ void ThreadedIoFile::RunInOutputMode() {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -10,20 +10,16 @@
|
|||
#include <memory>
|
||||
#include "packager/base/atomicops.h"
|
||||
#include "packager/base/synchronization/waitable_event.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/media/file/io_cache.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/file/file_closer.h"
|
||||
#include "packager/file/io_cache.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Declaration of class which implements a thread-safe circular buffer.
|
||||
class ThreadedIoFile : public File {
|
||||
public:
|
||||
enum Mode {
|
||||
kInputMode,
|
||||
kOutputMode
|
||||
};
|
||||
enum Mode { kInputMode, kOutputMode };
|
||||
|
||||
ThreadedIoFile(std::unique_ptr<File, FileCloser> internal_file,
|
||||
Mode mode,
|
||||
|
@ -69,7 +65,6 @@ class ThreadedIoFile : public File {
|
|||
DISALLOW_COPY_AND_ASSIGN(ThreadedIoFile);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // PACKAGER_FILE_THREADED_IO_FILE_H
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/udp_file.h"
|
||||
#include "packager/file/udp_file.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
|
@ -22,10 +22,9 @@
|
|||
#include <limits>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/media/file/udp_options.h"
|
||||
#include "packager/file/udp_options.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -35,9 +34,8 @@ bool IsIpv4MulticastAddress(const struct in_addr& addr) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
UdpFile::UdpFile(const char* file_name) :
|
||||
File(file_name),
|
||||
socket_(INVALID_SOCKET) {}
|
||||
UdpFile::UdpFile(const char* file_name)
|
||||
: File(file_name), socket_(INVALID_SOCKET) {}
|
||||
|
||||
UdpFile::~UdpFile() {}
|
||||
|
||||
|
@ -60,8 +58,8 @@ int64_t UdpFile::Read(void* buffer, uint64_t length) {
|
|||
|
||||
int64_t result;
|
||||
do {
|
||||
result = recvfrom(socket_, reinterpret_cast<char *>(buffer),
|
||||
length, 0, NULL, 0);
|
||||
result =
|
||||
recvfrom(socket_, reinterpret_cast<char*>(buffer), length, 0, NULL, 0);
|
||||
} while ((result == -1) && (errno == EINTR));
|
||||
|
||||
return result;
|
||||
|
@ -103,7 +101,8 @@ class LibWinsockInitializer {
|
|||
}
|
||||
|
||||
~LibWinsockInitializer() {
|
||||
if (error_ == 0) WSACleanup();
|
||||
if (error_ == 0)
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
int error() const { return error_; }
|
||||
|
@ -115,8 +114,7 @@ class LibWinsockInitializer {
|
|||
|
||||
class ScopedSocket {
|
||||
public:
|
||||
explicit ScopedSocket(SOCKET sock_fd)
|
||||
: sock_fd_(sock_fd) {}
|
||||
explicit ScopedSocket(SOCKET sock_fd) : sock_fd_(sock_fd) {}
|
||||
|
||||
~ScopedSocket() {
|
||||
if (sock_fd_ != INVALID_SOCKET)
|
||||
|
@ -161,8 +159,7 @@ bool UdpFile::Open() {
|
|||
}
|
||||
|
||||
struct in_addr local_in_addr = {0};
|
||||
if (inet_pton(AF_INET, options->address().c_str(),
|
||||
&local_in_addr) != 1) {
|
||||
if (inet_pton(AF_INET, options->address().c_str(), &local_in_addr) != 1) {
|
||||
LOG(ERROR) << "Malformed IPv4 address " << options->address();
|
||||
return false;
|
||||
}
|
||||
|
@ -237,5 +234,4 @@ bool UdpFile::Open() {
|
|||
return true;
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -12,7 +12,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "packager/base/compiler_specific.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <winsock2.h>
|
||||
|
@ -21,7 +21,6 @@ typedef int SOCKET;
|
|||
#endif // defined(OS_WIN)
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Implements UdpFile, which receives UDP unicast and multicast streams.
|
||||
class UdpFile : public File {
|
||||
|
@ -52,7 +51,6 @@ class UdpFile : public File {
|
|||
DISALLOW_COPY_AND_ASSIGN(UdpFile);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
||||
|
||||
#endif // MEDIA_FILE_UDP_FILE_H_
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/udp_options.h"
|
||||
#include "packager/file/udp_options.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
|
@ -17,7 +17,6 @@ DEFINE_string(udp_interface_address,
|
|||
" or multicast streams");
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -101,7 +100,8 @@ std::unique_ptr<UdpOptions> UdpOptions::ParseFromString(
|
|||
break;
|
||||
case kTimeoutField:
|
||||
if (!base::StringToUint(pair.second, &options->timeout_us_)) {
|
||||
LOG(ERROR) << "Invalid udp option for timeout field " << pair.second;
|
||||
LOG(ERROR) << "Invalid udp option for timeout field "
|
||||
<< pair.second;
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
|
@ -128,5 +128,4 @@ std::unique_ptr<UdpOptions> UdpOptions::ParseFromString(
|
|||
return options;
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -10,7 +10,6 @@
|
|||
#include "packager/base/strings/string_piece.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
/// Options parsed from UDP url string of the form: udp://ip:port[?options]
|
||||
class UdpOptions {
|
||||
|
@ -42,5 +41,4 @@ class UdpOptions {
|
|||
unsigned timeout_us_ = 0;
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -4,7 +4,7 @@
|
|||
// license that can be found in the LICENSE file or at
|
||||
// https://developers.google.com/open-source/licenses/bsd
|
||||
|
||||
#include "packager/media/file/udp_options.h"
|
||||
#include "packager/file/udp_options.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
@ -12,7 +12,6 @@
|
|||
DECLARE_string(udp_interface_address);
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
class UdpOptionsTest : public testing::Test {
|
||||
public:
|
||||
|
@ -96,5 +95,4 @@ TEST_F(UdpOptionsTest, InvalidTimeout) {
|
|||
"224.1.2.30:88?source=10.11.12.13&timeout=1a9"));
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
} // namespace shaka
|
|
@ -11,8 +11,8 @@
|
|||
#include "packager/base/files/file_path.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/hls/base/media_playlist.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -161,7 +161,7 @@ bool MasterPlaylist::WriteMasterPlaylist(const std::string& base_url,
|
|||
base::FilePath::FromUTF8Unsafe(output_dir)
|
||||
.Append(base::FilePath::FromUTF8Unsafe(file_name_))
|
||||
.AsUTF8Unsafe();
|
||||
if (!media::File::WriteFileAtomically(file_path.c_str(), content)) {
|
||||
if (!File::WriteFileAtomically(file_path.c_str(), content)) {
|
||||
LOG(ERROR) << "Failed to write master playlist to: " << file_path;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/base/files/file_path.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/hls/base/master_playlist.h"
|
||||
#include "packager/hls/base/media_playlist.h"
|
||||
#include "packager/hls/base/mock_media_playlist.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -77,8 +77,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistOneVideo) {
|
|||
EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_));
|
||||
|
||||
std::string actual;
|
||||
ASSERT_TRUE(
|
||||
media::File::ReadFileToString(master_playlist_path_.c_str(), &actual));
|
||||
ASSERT_TRUE(File::ReadFileToString(master_playlist_path_.c_str(), &actual));
|
||||
|
||||
const std::string expected =
|
||||
"#EXTM3U\n"
|
||||
|
@ -158,8 +157,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistVideoAndAudio) {
|
|||
EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_));
|
||||
|
||||
std::string actual;
|
||||
ASSERT_TRUE(
|
||||
media::File::ReadFileToString(master_playlist_path_.c_str(), &actual));
|
||||
ASSERT_TRUE(File::ReadFileToString(master_playlist_path_.c_str(), &actual));
|
||||
|
||||
const std::string expected =
|
||||
"#EXTM3U\n"
|
||||
|
@ -229,8 +227,7 @@ TEST_F(MasterPlaylistTest, WriteMasterPlaylistMultipleAudioGroups) {
|
|||
EXPECT_TRUE(master_playlist_.WriteMasterPlaylist(kBaseUrl, test_output_dir_));
|
||||
|
||||
std::string actual;
|
||||
ASSERT_TRUE(
|
||||
media::File::ReadFileToString(master_playlist_path_.c_str(), &actual));
|
||||
ASSERT_TRUE(File::ReadFileToString(master_playlist_path_.c_str(), &actual));
|
||||
|
||||
const std::string expected =
|
||||
"#EXTM3U\n"
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include "packager/base/logging.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/stringprintf.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/language_utils.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -392,7 +392,7 @@ bool MediaPlaylist::WriteToFile(const std::string& file_path) {
|
|||
content += "#EXT-X-ENDLIST\n";
|
||||
}
|
||||
|
||||
if (!media::File::WriteFileAtomically(file_path.c_str(), content)) {
|
||||
if (!File::WriteFileAtomically(file_path.c_str(), content)) {
|
||||
LOG(ERROR) << "Failed to write playlist to: " << file_path;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
namespace shaka {
|
||||
|
||||
namespace media {
|
||||
class File;
|
||||
} // namespace media
|
||||
|
||||
namespace hls {
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/file/file_test_util.h"
|
||||
#include "packager/hls/base/media_playlist.h"
|
||||
#include "packager/media/file/file_test_util.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
],
|
||||
'dependencies': [
|
||||
'../base/base.gyp:base',
|
||||
'../file/file.gyp:file',
|
||||
'../media/base/media_base.gyp:media_base',
|
||||
'../media/base/media_base.gyp:widevine_pssh_data_proto',
|
||||
'../media/file/file.gyp:file',
|
||||
'../mpd/mpd.gyp:media_info_proto',
|
||||
],
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/sys_byteorder.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
|
|
@ -13,10 +13,11 @@
|
|||
#include "packager/status.h"
|
||||
|
||||
namespace shaka {
|
||||
namespace media {
|
||||
|
||||
class File;
|
||||
|
||||
namespace media {
|
||||
|
||||
/// A simple buffer writer implementation which appends various data types to
|
||||
/// buffer.
|
||||
class BufferWriter {
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include <memory>
|
||||
|
||||
#include "packager/base/files/file_util.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/status_test_util.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -157,10 +157,10 @@
|
|||
'widevine_key_source_unittest.cc',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../file/file.gyp:file',
|
||||
'../../testing/gmock.gyp:gmock',
|
||||
'../../testing/gtest.gyp:gtest',
|
||||
'../../third_party/boringssl/boringssl.gyp:boringssl',
|
||||
'../file/file.gyp:file',
|
||||
'../test/media_test.gyp:media_test_support',
|
||||
'media_base',
|
||||
],
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
#include "packager/base/bind.h"
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/decryptor_source.h"
|
||||
#include "packager/media/base/key_source.h"
|
||||
#include "packager/media/base/media_sample.h"
|
||||
#include "packager/media/base/stream_info.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/formats/mp2t/mp2t_media_parser.h"
|
||||
#include "packager/media/formats/mp4/mp4_media_parser.h"
|
||||
#include "packager/media/formats/webm/webm_media_parser.h"
|
||||
|
|
|
@ -17,10 +17,12 @@
|
|||
#include "packager/status.h"
|
||||
|
||||
namespace shaka {
|
||||
|
||||
class File;
|
||||
|
||||
namespace media {
|
||||
|
||||
class Decryptor;
|
||||
class File;
|
||||
class KeySource;
|
||||
class MediaParser;
|
||||
class MediaSample;
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
'vod_media_info_dump_muxer_listener.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../file/file.gyp:file',
|
||||
'../../mpd/mpd.gyp:media_info_proto',
|
||||
# Depends on full protobuf to read/write with TextFormat.
|
||||
'../../third_party/protobuf/protobuf.gyp:protobuf_full_do_not_use',
|
||||
'../base/media_base.gyp:media_base',
|
||||
'../codecs/codecs.gyp:codecs',
|
||||
'../file/file.gyp:file',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
#include <google/protobuf/text_format.h>
|
||||
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/base/stream_info.h"
|
||||
#include "packager/media/base/protection_system_specific_info.h"
|
||||
#include "packager/media/base/stream_info.h"
|
||||
#include "packager/media/event/muxer_listener_internal.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/mpd/base/media_info.pb.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -100,7 +100,7 @@ bool VodMediaInfoDumpMuxerListener::WriteMediaInfoToFile(
|
|||
return false;
|
||||
}
|
||||
|
||||
media::File* file = File::Open(output_file_path.c_str(), "w");
|
||||
File* file = File::Open(output_file_path.c_str(), "w");
|
||||
if (!file) {
|
||||
LOG(ERROR) << "Failed to open " << output_file_path;
|
||||
return false;
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
#include "packager/base/files/file_path.h"
|
||||
#include "packager/base/files/file_util.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/fourccs.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/base/video_stream_info.h"
|
||||
#include "packager/media/event/muxer_listener_test_helper.h"
|
||||
#include "packager/media/event/vod_media_info_dump_muxer_listener.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/mpd/base/media_info.pb.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#define PACKAGER_MEDIA_FORMATS_MP2T_TS_SEGMENTER_H_
|
||||
|
||||
#include <memory>
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/formats/mp2t/pes_packet_generator.h"
|
||||
#include "packager/media/formats/mp2t/ts_writer.h"
|
||||
#include "packager/status.h"
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/file/file_closer.h"
|
||||
#include "packager/media/formats/mp2t/continuity_counter.h"
|
||||
#include "packager/media/formats/mp2t/pes_packet.h"
|
||||
#include "packager/media/formats/mp2t/program_map_table_writer.h"
|
||||
|
|
|
@ -64,9 +64,9 @@
|
|||
'track_run_iterator_unittest.cc',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../../file/file.gyp:file',
|
||||
'../../../testing/gtest.gyp:gtest',
|
||||
'../../../testing/gmock.gyp:gmock',
|
||||
'../../file/file.gyp:file',
|
||||
'../../test/media_test.gyp:media_test_support',
|
||||
'mp4',
|
||||
]
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "packager/base/callback_helpers.h"
|
||||
#include "packager/base/logging.h"
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/file/file_closer.h"
|
||||
#include "packager/media/base/audio_stream_info.h"
|
||||
#include "packager/media/base/buffer_reader.h"
|
||||
#include "packager/media/base/decrypt_config.h"
|
||||
|
@ -23,8 +25,6 @@
|
|||
#include "packager/media/codecs/es_descriptor.h"
|
||||
#include "packager/media/codecs/hevc_decoder_configuration_record.h"
|
||||
#include "packager/media/codecs/vp_codec_configuration_record.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/media/formats/mp4/box_definitions.h"
|
||||
#include "packager/media/formats/mp4/box_reader.h"
|
||||
#include "packager/media/formats/mp4/track_run_iterator.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "packager/base/time/clock.h"
|
||||
#include "packager/base/time/time.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/aes_encryptor.h"
|
||||
#include "packager/media/base/audio_stream_info.h"
|
||||
#include "packager/media/base/fourccs.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "packager/media/base/video_stream_info.h"
|
||||
#include "packager/media/codecs/es_descriptor.h"
|
||||
#include "packager/media/event/muxer_listener.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/formats/mp4/box_definitions.h"
|
||||
#include "packager/media/formats/mp4/multi_segment_segmenter.h"
|
||||
#include "packager/media/formats/mp4/single_segment_segmenter.h"
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_util.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/base/muxer_util.h"
|
||||
#include "packager/media/event/muxer_listener.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/formats/mp4/box_definitions.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/file/file_util.h"
|
||||
#include "packager/media/base/buffer_writer.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/event/progress_listener.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/file/file_util.h"
|
||||
#include "packager/media/formats/mp4/box_definitions.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#ifndef MEDIA_FORMATS_MP4_SINGLE_SEGMENT_SEGMENTER_H_
|
||||
#define MEDIA_FORMATS_MP4_SINGLE_SEGMENT_SEGMENTER_H_
|
||||
|
||||
#include "packager/file/file_closer.h"
|
||||
#include "packager/media/event/muxer_listener.h"
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/media/formats/mp4/segmenter.h"
|
||||
|
||||
namespace shaka {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/file/file_closer.h"
|
||||
#include "packager/status.h"
|
||||
#include "packager/third_party/libwebm/src/mkvmuxer.hpp"
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "packager/media/formats/webm/segmenter_test_base.h"
|
||||
|
||||
#include "packager/media/file/memory_file.h"
|
||||
#include "packager/file/memory_file.h"
|
||||
#include "packager/media/formats/webm/webm_constants.h"
|
||||
#include "packager/version/version.h"
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packager/file/file_closer.h"
|
||||
#include "packager/file/file_test_util.h"
|
||||
#include "packager/file/memory_file.h"
|
||||
#include "packager/media/base/media_sample.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/base/stream_info.h"
|
||||
#include "packager/media/base/video_stream_info.h"
|
||||
#include "packager/media/file/file_closer.h"
|
||||
#include "packager/media/file/file_test_util.h"
|
||||
#include "packager/media/file/memory_file.h"
|
||||
#include "packager/media/formats/webm/mkv_writer.h"
|
||||
#include "packager/media/formats/webm/segmenter.h"
|
||||
#include "packager/media/formats/webm/webm_parser.h"
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "packager/file/file_util.h"
|
||||
#include "packager/media/base/media_sample.h"
|
||||
#include "packager/media/base/muxer_options.h"
|
||||
#include "packager/media/base/stream_info.h"
|
||||
#include "packager/media/file/file_util.h"
|
||||
#include "packager/third_party/libwebm/src/mkvmuxer.hpp"
|
||||
#include "packager/third_party/libwebm/src/mkvmuxerutil.hpp"
|
||||
#include "packager/third_party/libwebm/src/webmids.hpp"
|
||||
|
|
|
@ -83,10 +83,10 @@
|
|||
'webm_webvtt_parser_unittest.cc',
|
||||
],
|
||||
'dependencies': [
|
||||
'../../../file/file.gyp:file',
|
||||
'../../../testing/gtest.gyp:gtest',
|
||||
'../../../testing/gmock.gyp:gmock',
|
||||
'../../../third_party/libwebm/libwebm.gyp:mkvmuxer',
|
||||
'../../file/file.gyp:file',
|
||||
'../../test/media_test.gyp:media_test_support',
|
||||
'webm',
|
||||
]
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include "packager/base/synchronization/lock.h"
|
||||
#include "packager/base/time/default_clock.h"
|
||||
#include "packager/base/time/time.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/media/base/language_utils.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/mpd/base/content_protection_element.h"
|
||||
#include "packager/mpd/base/mpd_utils.h"
|
||||
#include "packager/mpd/base/xml/xml_node.h"
|
||||
|
|
|
@ -39,11 +39,8 @@
|
|||
// element.
|
||||
namespace shaka {
|
||||
|
||||
namespace media {
|
||||
class File;
|
||||
} // namespace media
|
||||
|
||||
class AdaptationSet;
|
||||
class File;
|
||||
class Representation;
|
||||
|
||||
namespace xml {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "packager/base/strings/string_number_conversions.h"
|
||||
#include "packager/base/strings/string_util.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/mpd/base/mpd_utils.h"
|
||||
|
||||
namespace shaka {
|
||||
|
@ -22,7 +22,7 @@ bool WriteMpdToFile(const std::string& output_path, MpdBuilder* mpd_builder) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!media::File::WriteFileAtomically(output_path.c_str(), mpd)) {
|
||||
if (!File::WriteFileAtomically(output_path.c_str(), mpd)) {
|
||||
LOG(ERROR) << "Failed to write mpd to: " << output_path;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
],
|
||||
'dependencies': [
|
||||
'../base/base.gyp:base',
|
||||
'../media/file/file.gyp:file',
|
||||
'../file/file.gyp:file',
|
||||
'../media/base/media_base.gyp:media_base',
|
||||
'../third_party/libxml/libxml.gyp:libxml',
|
||||
'../version/version.gyp:version',
|
||||
'media_info_proto',
|
||||
|
@ -91,7 +92,7 @@
|
|||
],
|
||||
'dependencies': [
|
||||
'../base/base.gyp:base',
|
||||
'../media/file/file.gyp:file',
|
||||
'../file/file.gyp:file',
|
||||
'../media/test/media_test.gyp:run_tests_with_atexit_manager',
|
||||
'../testing/gmock.gyp:gmock',
|
||||
'../testing/gtest.gyp:gtest',
|
||||
|
@ -108,7 +109,7 @@
|
|||
'util/mpd_writer.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'../media/file/file.gyp:file',
|
||||
'../file/file.gyp:file',
|
||||
'../third_party/gflags/gflags.gyp:gflags',
|
||||
'mpd_builder',
|
||||
'mpd_mocks',
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "packager/base/files/file_path.h"
|
||||
#include "packager/base/files/file_util.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/mpd/base/dash_iop_mpd_notifier.h"
|
||||
#include "packager/mpd/base/mpd_builder.h"
|
||||
#include "packager/mpd/base/mpd_notifier.h"
|
||||
|
@ -70,8 +70,7 @@ MpdWriter::~MpdWriter() {}
|
|||
bool MpdWriter::AddFile(const std::string& media_info_path,
|
||||
const std::string& mpd_path) {
|
||||
std::string file_content;
|
||||
if (!media::File::ReadFileToString(media_info_path.c_str(),
|
||||
&file_content)) {
|
||||
if (!File::ReadFileToString(media_info_path.c_str(), &file_content)) {
|
||||
LOG(ERROR) << "Failed to read " << media_info_path << " to string.";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "packager/base/strings/stringprintf.h"
|
||||
#include "packager/base/threading/simple_thread.h"
|
||||
#include "packager/base/time/clock.h"
|
||||
#include "packager/file/file.h"
|
||||
#include "packager/hls/base/hls_notifier.h"
|
||||
#include "packager/hls/base/simple_hls_notifier.h"
|
||||
#include "packager/media/base/container_names.h"
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include "packager/media/event/hls_notify_muxer_listener.h"
|
||||
#include "packager/media/event/mpd_notify_muxer_listener.h"
|
||||
#include "packager/media/event/vod_media_info_dump_muxer_listener.h"
|
||||
#include "packager/media/file/file.h"
|
||||
#include "packager/media/formats/mp2t/ts_muxer.h"
|
||||
#include "packager/media/formats/mp4/mp4_muxer.h"
|
||||
#include "packager/media/formats/webm/webm_muxer.h"
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
'app/packager_util.h',
|
||||
],
|
||||
'dependencies': [
|
||||
'file/file.gyp:file',
|
||||
'hls/hls.gyp:hls_builder',
|
||||
'media/codecs/codecs.gyp:codecs',
|
||||
'media/chunking/chunking.gyp:chunking',
|
||||
'media/demuxer/demuxer.gyp:demuxer',
|
||||
'media/event/media_event.gyp:media_event',
|
||||
'media/file/file.gyp:file',
|
||||
'media/formats/mp2t/mp2t.gyp:mp2t',
|
||||
'media/formats/mp4/mp4.gyp:mp4',
|
||||
'media/formats/mpeg/mpeg.gyp:mpeg',
|
||||
|
@ -83,8 +83,8 @@
|
|||
],
|
||||
'dependencies': [
|
||||
'base/base.gyp:base',
|
||||
'file/file.gyp:file',
|
||||
'libpackager',
|
||||
'media/file/file.gyp:file',
|
||||
'third_party/gflags/gflags.gyp:gflags',
|
||||
],
|
||||
'conditions': [
|
||||
|
@ -172,6 +172,7 @@
|
|||
'target_name': 'packager_builder_tests',
|
||||
'type': 'none',
|
||||
'dependencies': [
|
||||
'file/file.gyp:file_unittest',
|
||||
'hls/hls.gyp:hls_unittest',
|
||||
'media/base/media_base.gyp:media_base_unittest',
|
||||
'media/chunking/chunking.gyp:chunking_unittest',
|
||||
|
@ -179,7 +180,6 @@
|
|||
'media/crypto/crypto.gyp:crypto_unittest',
|
||||
'media/demuxer/demuxer.gyp:demuxer_unittest',
|
||||
'media/event/media_event.gyp:media_event_unittest',
|
||||
'media/file/file.gyp:file_unittest',
|
||||
'media/formats/mp2t/mp2t.gyp:mp2t_unittest',
|
||||
'media/formats/mp4/mp4.gyp:mp4_unittest',
|
||||
'media/formats/webm/webm.gyp:webm_unittest',
|
||||
|
|
Loading…
Reference in New Issue