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