chore: Refactor public headers and macros (#1275)

This organizes all public headers for the library into
include/  and makes sure then don't rely on any headers from
other folders.

To accomplish this, this change also refactors macros.h,
media/base/macros.h, and status/status_macros.h into macros/classes.h,
macros/compiler.h, macros/crypto.h, macros/logging.h, macros/status.h,
and public/export.h.  Now the export macros from macros.h live in
include/ to keep include/ from requiring anything else.

This refactor enables an install target that includes public headers
only.

---------

Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
This commit is contained in:
Joey Parrish 2023-10-14 09:36:01 -07:00 committed by GitHub
parent 7653e1e02f
commit 0295ef182b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
291 changed files with 532 additions and 406 deletions

View File

@ -19,10 +19,6 @@ project(shaka-packager VERSION "")
# libpackager library. By default, don't.
option(LIBPACKAGER_SHARED "Build libpackager as a shared library" OFF)
# Global include paths.
# Project root, to reference packager/foo/bar/...
include_directories(.)
# Enable CMake's test infrastructure.
enable_testing()

6
include/README.md Normal file
View File

@ -0,0 +1,6 @@
# Public headers for libpackager
These are the public headers for libpackager. They can only reference other
public headers or standard system headers. They cannot reference internal
headers (in `packager/...`) or third-party dependency headers (in
`packager/third_party/...`).

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MEDIA_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_
#define PACKAGER_MEDIA_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_
#ifndef PACKAGER_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_
#define PACKAGER_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_
#include <vector>
@ -27,4 +27,4 @@ struct AdCueGeneratorParams {
} // namespace shaka
#endif // PACKAGER_MEDIA_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_
#endif // PACKAGER_PUBLIC_AD_CUE_GENERATOR_PARAMS_H_

View File

@ -4,9 +4,10 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_FILE_PUBLIC_BUFFER_CALLBACK_PARAMS_H_
#define PACKAGER_FILE_PUBLIC_BUFFER_CALLBACK_PARAMS_H_
#ifndef PACKAGER_PUBLIC_BUFFER_CALLBACK_PARAMS_H_
#define PACKAGER_PUBLIC_BUFFER_CALLBACK_PARAMS_H_
#include <cstdint>
#include <functional>
namespace shaka {
@ -32,4 +33,4 @@ struct BufferCallbackParams {
} // namespace shaka
#endif // PACKAGER_FILE_PUBLIC_BUFFER_CALLBACK_PARAMS_H_
#endif // PACKAGER_PUBLIC_BUFFER_CALLBACK_PARAMS_H_

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MEDIA_PUBLIC_CHUNKING_PARAMS_H_
#define PACKAGER_MEDIA_PUBLIC_CHUNKING_PARAMS_H_
#ifndef PACKAGER_PUBLIC_CHUNKING_PARAMS_H_
#define PACKAGER_PUBLIC_CHUNKING_PARAMS_H_
namespace shaka {
@ -35,4 +35,4 @@ struct ChunkingParams {
} // namespace shaka
#endif // PACKAGER_MEDIA_PUBLIC_CHUNKING_PARAMS_H_
#endif // PACKAGER_PUBLIC_CHUNKING_PARAMS_H_

View File

@ -4,16 +4,15 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
#define PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
#ifndef PACKAGER_PUBLIC_CRYPTO_PARAMS_H_
#define PACKAGER_PUBLIC_CRYPTO_PARAMS_H_
#include <cstdint>
#include <functional>
#include <map>
#include <string>
#include <vector>
#include <packager/status/status.h>
namespace shaka {
/// Encryption key providers. These provide keys to decrypt the content if the
@ -237,4 +236,4 @@ struct DecryptionParams {
} // namespace shaka
#endif // PACKAGER_MEDIA_PUBLIC_CRYPTO_PARAMS_H_
#endif // PACKAGER_PUBLIC_CRYPTO_PARAMS_H_

33
include/packager/export.h Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_PUBLIC_EXPORT_H_
#define PACKAGER_PUBLIC_EXPORT_H_
#if defined(SHARED_LIBRARY_BUILD)
#if defined(_WIN32)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __declspec(dllexport)
#else
#define SHAKA_EXPORT __declspec(dllimport)
#endif // defined(SHAKA_IMPLEMENTATION)
#else // defined(_WIN32)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __attribute__((visibility("default")))
#else
#define SHAKA_EXPORT
#endif
#endif // defined(_WIN32)
#else // defined(SHARED_LIBRARY_BUILD)
#define SHAKA_EXPORT
#endif // defined(SHARED_LIBRARY_BUILD)
#endif // PACKAGER_PUBLIC_EXPORT_H_

View File

@ -4,15 +4,16 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_FILE_FILE_H_
#define PACKAGER_FILE_FILE_H_
#ifndef PACKAGER_PUBLIC_FILE_H_
#define PACKAGER_PUBLIC_FILE_H_
#include <cstdint>
#include <string>
#include <packager/file/public/buffer_callback_params.h>
#include <packager/macros.h>
#include <packager/status/status.h>
#include <packager/buffer_callback_params.h>
#include <packager/export.h>
#include <packager/macros/classes.h>
#include <packager/status.h>
namespace shaka {
@ -200,4 +201,4 @@ class SHAKA_EXPORT File {
} // namespace shaka
#endif // PACKAGER_FILE_FILE_H_
#endif // PACKAGER_PUBLIC_FILE_H_

View File

@ -4,9 +4,10 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_HLS_PUBLIC_HLS_PARAMS_H_
#define PACKAGER_HLS_PUBLIC_HLS_PARAMS_H_
#ifndef PACKAGER_PUBLIC_HLS_PARAMS_H_
#define PACKAGER_PUBLIC_HLS_PARAMS_H_
#include <cstdint>
#include <string>
namespace shaka {
@ -66,4 +67,4 @@ struct HlsParams {
} // namespace shaka
#endif // PACKAGER_HLS_PUBLIC_HLS_PARAMS_H_
#endif // PACKAGER_PUBLIC_HLS_PARAMS_H_

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MEDIA_PUBLIC_MP4_OUTPUT_PARAMS_H_
#define PACKAGER_MEDIA_PUBLIC_MP4_OUTPUT_PARAMS_H_
#ifndef PACKAGER_PUBLIC_MP4_OUTPUT_PARAMS_H_
#define PACKAGER_PUBLIC_MP4_OUTPUT_PARAMS_H_
namespace shaka {
@ -30,4 +30,4 @@ struct Mp4OutputParams {
} // namespace shaka
#endif // PACKAGER_MEDIA_PUBLIC_MP4_OUTPUT_PARAMS_H_
#endif // PACKAGER_PUBLIC_MP4_OUTPUT_PARAMS_H_

View File

@ -4,8 +4,8 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MPD_PUBLIC_MPD_PARAMS_H_
#define PACKAGER_MPD_PUBLIC_MPD_PARAMS_H_
#ifndef PACKAGER_PUBLIC_MPD_PARAMS_H_
#define PACKAGER_PUBLIC_MPD_PARAMS_H_
#include <string>
#include <vector>
@ -106,4 +106,4 @@ struct MpdParams {
} // namespace shaka
#endif // PACKAGER_MPD_PUBLIC_MPD_PARAMS_H_
#endif // PACKAGER_PUBLIC_MPD_PARAMS_H_

View File

@ -4,22 +4,23 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_PACKAGER_H_
#define PACKAGER_PACKAGER_H_
#ifndef PACKAGER_PUBLIC_PACKAGER_H_
#define PACKAGER_PUBLIC_PACKAGER_H_
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include <packager/file/public/buffer_callback_params.h>
#include <packager/hls/public/hls_params.h>
#include <packager/macros.h>
#include <packager/media/public/ad_cue_generator_params.h>
#include <packager/media/public/chunking_params.h>
#include <packager/media/public/crypto_params.h>
#include <packager/media/public/mp4_output_params.h>
#include <packager/mpd/public/mpd_params.h>
#include <packager/status/status.h>
#include <packager/ad_cue_generator_params.h>
#include <packager/buffer_callback_params.h>
#include <packager/chunking_params.h>
#include <packager/crypto_params.h>
#include <packager/export.h>
#include <packager/hls_params.h>
#include <packager/mp4_output_params.h>
#include <packager/mpd_params.h>
#include <packager/status.h>
namespace shaka {
@ -152,9 +153,8 @@ class SHAKA_EXPORT Packager {
/// @param packaging_params contains the packaging parameters.
/// @param stream_descriptors a list of stream descriptors.
/// @return OK on success, an appropriate error code on failure.
Status Initialize(
const PackagingParams& packaging_params,
const std::vector<StreamDescriptor>& stream_descriptors);
Status Initialize(const PackagingParams& packaging_params,
const std::vector<StreamDescriptor>& stream_descriptors);
/// Run the pipeline to completion (or failed / been cancelled). Note
/// that it blocks until completion.
@ -202,4 +202,4 @@ class SHAKA_EXPORT Packager {
} // namespace shaka
#endif // PACKAGER_PACKAGER_H_
#endif // PACKAGER_PUBLIC_PACKAGER_H_

View File

@ -4,13 +4,13 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_STATUS_H_
#define PACKAGER_STATUS_H_
#ifndef PACKAGER_PUBLIC_STATUS_H_
#define PACKAGER_PUBLIC_STATUS_H_
#include <iostream>
#include <string>
#include <packager/macros.h>
#include <packager/export.h>
namespace shaka {
@ -136,4 +136,4 @@ std::ostream& operator<<(std::ostream& os, const Status& x);
} // namespace shaka
#endif // PACKAGER_STATUS_H_
#endif // PACKAGER_PUBLIC_STATUS_H_

View File

@ -48,6 +48,12 @@ else()
add_compile_options(-Wno-unknown-warning-option)
endif()
# Global include paths.
# Project root, to reference internal headers as packager/foo/bar/...
include_directories(..)
# Public include folder, to reference public headers as packager/foo.h
include_directories(../include)
# Include our module for gtest-based testing.
include("gtest.cmake")
@ -76,7 +82,7 @@ set(libpackager_sources
app/single_thread_job_manager.cc
app/single_thread_job_manager.h
packager.cc
packager.h
../include/packager/packager.h
)
if(LIBPACKAGER_SHARED)

View File

@ -15,7 +15,7 @@
#include <absl/synchronization/mutex.h>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -11,7 +11,7 @@
#include <string>
#include <packager/media/base/container_names.h>
#include <packager/media/public/mp4_output_params.h>
#include <packager/mp4_output_params.h>
#include <packager/mpd/base/mpd_builder.h>
namespace shaka {

View File

@ -36,7 +36,7 @@
#include <packager/app/stream_descriptor.h>
#include <packager/app/vlog_flags.h>
#include <packager/app/widevine_encryption_flags.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/kv_pairs/kv_pairs.h>
#include <packager/tools/license_notice.h>
#include <packager/utils/string_trim_split.h>

View File

@ -8,7 +8,7 @@
#include <absl/log/log.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/media/base/media_handler.h>
#include <packager/media/base/muxer_options.h>
#include <packager/media/base/playready_key_source.h>

View File

@ -11,7 +11,6 @@
#include <string>
#include <packager/packager.h>
#include <optional>
namespace shaka {

View File

@ -13,6 +13,7 @@
#include <absl/strings/numbers.h>
#include <packager/kv_pairs/kv_pairs.h>
#include <packager/macros/logging.h>
ABSL_FLAG(int,
v,

View File

@ -8,7 +8,8 @@
#include <absl/log/log.h>
#include <packager/macros.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
namespace shaka {

View File

@ -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/file/file.h>
#include <packager/file.h>
namespace shaka {

View File

@ -11,8 +11,9 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/file_closer.h>
#include <packager/macros/compiler.h>
using testing::_;
using testing::Eq;

View File

@ -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/file/file.h>
#include <packager/file.h>
#include <algorithm>
#include <cinttypes>
@ -24,7 +24,8 @@
#include <packager/file/memory_file.h>
#include <packager/file/threaded_io_file.h>
#include <packager/file/udp_file.h>
#include <packager/macros.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
ABSL_FLAG(uint64_t,
io_cache_size,

View File

@ -9,7 +9,7 @@
#include <absl/log/log.h>
#include <packager/file/file.h>
#include <packager/file.h>
namespace shaka {

View File

@ -13,7 +13,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <packager/file/file.h>
#include <packager/file.h>
namespace shaka {

View File

@ -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/file/file.h>
#include <packager/file.h>
#include <cstdio>
#include <filesystem>

View File

@ -15,7 +15,8 @@
#include <curl/curl.h>
#include <packager/file/thread_pool.h>
#include <packager/macros.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
#include <packager/version/version.h>
ABSL_FLAG(std::string,

View File

@ -12,7 +12,7 @@
#include <absl/synchronization/notification.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/io_cache.h>
typedef void CURL;

View File

@ -13,9 +13,9 @@
#include <gtest/gtest.h>
#include <nlohmann/json.hpp>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/file_closer.h>
#include <packager/macros.h>
#include <packager/macros/logging.h>
#include <packager/media/test/test_web_server.h>
#define ASSERT_JSON_STRING(json, key, value) \

View File

@ -12,7 +12,7 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros.h>
#include <packager/macros/logging.h>
namespace shaka {

View File

@ -12,7 +12,7 @@
#include <absl/synchronization/mutex.h>
#include <packager/macros.h>
#include <packager/macros/classes.h>
namespace shaka {

View File

@ -18,7 +18,7 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros.h>
#include <packager/macros/logging.h>
namespace shaka {

View File

@ -10,7 +10,8 @@
#include <cstdint>
#include <string>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/macros/classes.h>
namespace shaka {

View File

@ -16,6 +16,8 @@
#include <absl/log/log.h>
#include <absl/synchronization/mutex.h>
#include <packager/macros/logging.h>
namespace shaka {
namespace {

View File

@ -11,7 +11,8 @@
#include <string>
#include <vector>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/macros/classes.h>
namespace shaka {

View File

@ -8,7 +8,7 @@
#include <gtest/gtest.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/file_closer.h>
namespace shaka {

View File

@ -13,7 +13,7 @@
#include <absl/base/thread_annotations.h>
#include <absl/synchronization/mutex.h>
#include <packager/macros.h>
#include <packager/macros/classes.h>
namespace shaka {

View File

@ -12,9 +12,10 @@
#include <absl/synchronization/mutex.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/file_closer.h>
#include <packager/file/io_cache.h>
#include <packager/macros/classes.h>
namespace shaka {

View File

@ -32,6 +32,9 @@
#include <absl/log/log.h>
#include <packager/file/udp_options.h>
#include <packager/macros/classes.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
namespace shaka {

View File

@ -17,7 +17,8 @@
typedef int SOCKET;
#endif // defined(OS_WIN)
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/macros/classes.h>
namespace shaka {

View File

@ -15,7 +15,6 @@
#include <absl/strings/str_split.h>
#include <packager/kv_pairs/kv_pairs.h>
#include <packager/macros.h>
ABSL_FLAG(std::string,
udp_interface_address,

View File

@ -16,7 +16,6 @@ add_library(hls_builder
base/simple_hls_notifier.h
base/tag.cc
base/tag.h
public/hls_params.h
)
target_link_libraries(hls_builder

View File

@ -10,7 +10,7 @@
#include <string>
#include <vector>
#include <packager/hls/public/hls_params.h>
#include <packager/hls_params.h>
#include <packager/mpd/base/media_info.pb.h>
namespace shaka {

View File

@ -16,9 +16,10 @@
#include <absl/strings/str_format.h>
#include <absl/strings/str_join.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/hls/base/media_playlist.h>
#include <packager/hls/base/tag.h>
#include <packager/macros/logging.h>
#include <packager/version/version.h>
namespace shaka {

View File

@ -11,7 +11,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/hls/base/media_playlist.h>
#include <packager/hls/base/mock_media_playlist.h>
#include <packager/version/version.h>

View File

@ -16,9 +16,9 @@
#include <absl/strings/numbers.h>
#include <absl/strings/str_format.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/hls/base/tag.h>
#include <packager/macros.h>
#include <packager/macros/logging.h>
#include <packager/media/base/language_utils.h>
#include <packager/media/base/muxer_util.h>
#include <packager/version/version.h>

View File

@ -13,8 +13,8 @@
#include <string>
#include <vector>
#include <packager/hls/public/hls_params.h>
#include <packager/macros.h>
#include <packager/hls_params.h>
#include <packager/macros/classes.h>
#include <packager/mpd/base/bandwidth_estimator.h>
#include <packager/mpd/base/media_info.pb.h>

View File

@ -10,7 +10,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/file_closer.h>
#include <packager/file/file_test_util.h>
#include <packager/version/version.h>

View File

@ -6,7 +6,7 @@
#include <packager/hls/base/mock_media_playlist.h>
#include <packager/hls/public/hls_params.h>
#include <packager/hls_params.h>
namespace shaka {
namespace hls {

View File

@ -18,8 +18,8 @@
#include <packager/hls/base/hls_notifier.h>
#include <packager/hls/base/master_playlist.h>
#include <packager/hls/base/media_playlist.h>
#include <packager/hls/public/hls_params.h>
#include <packager/macros.h>
#include <packager/hls_params.h>
#include <packager/macros/classes.h>
namespace shaka {
namespace hls {

View File

@ -1,84 +0,0 @@
// Copyright 2022 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MACROS_H_
#define PACKAGER_MACROS_H_
#include <type_traits>
#include <absl/log/globals.h>
#include <absl/log/log.h>
/// A macro to disable copying and assignment. Usage:
/// class Foo {
/// private:
/// DISALLOW_COPY_AND_ASSIGN(Foo);
/// }
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
/// A macro to disable all implicit constructors (copy, assignment, and default
/// constructor). Usage:
/// class Foo {
/// private:
/// DISALLOW_IMPLICIT_CONSTRUCTORS(Foo);
/// }
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName);
/// A macro to declare that you intentionally did not use a parameter. Useful
/// when implementing abstract interfaces.
#define UNUSED(x) (void)(x)
/// A macro to declare that you intentionally did not implement a method.
/// You can use the insertion operator to add specific logs to this.
#define NOTIMPLEMENTED() LOG(ERROR) << "NOTIMPLEMENTED: "
/// AES block size in bytes, regardless of key size.
#define AES_BLOCK_SIZE 16
#define VLOG(verboselevel) \
LOG(LEVEL(static_cast<absl::LogSeverity>(-verboselevel)))
#define VLOG_IS_ON(verboselevel) \
(static_cast<int>(absl::MinLogLevel()) <= -verboselevel)
#ifndef NDEBUG
#define DVLOG(verboselevel) VLOG(verboselevel)
#else
// We need this expression to work with << after it, so this is a simple way to
// turn DVLOG into a no-op in release builds.
#define DVLOG(verboselevel) \
if (false) \
VLOG(verboselevel)
#endif
#if defined(SHARED_LIBRARY_BUILD)
#if defined(_WIN32)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __declspec(dllexport)
#else
#define SHAKA_EXPORT __declspec(dllimport)
#endif // defined(SHAKA_IMPLEMENTATION)
#else // defined(_WIN32)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __attribute__((visibility("default")))
#else
#define SHAKA_EXPORT
#endif
#endif // defined(_WIN32)
#else // defined(SHARED_LIBRARY_BUILD)
#define SHAKA_EXPORT
#endif // defined(SHARED_LIBRARY_BUILD)
#endif // PACKAGER_MACROS_H_

29
packager/macros/classes.h Normal file
View File

@ -0,0 +1,29 @@
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MACROS_CLASSES_H_
#define PACKAGER_MACROS_CLASSES_H_
/// A macro to disable copying and assignment. Usage:
/// class Foo {
/// private:
/// DISALLOW_COPY_AND_ASSIGN(Foo);
/// }
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
/// A macro to disable all implicit constructors (copy, assignment, and default
/// constructor). Usage:
/// class Foo {
/// private:
/// DISALLOW_IMPLICIT_CONSTRUCTORS(Foo);
/// }
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName);
#endif // PACKAGER_MACROS_CLASSES_H_

View File

@ -1,11 +1,15 @@
// Copyright 2016 Google LLC. All rights reserved.
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MEDIA_BASE_MACROS_H_
#define PACKAGER_MEDIA_BASE_MACROS_H_
#ifndef PACKAGER_MACROS_COMPILER_H_
#define PACKAGER_MACROS_COMPILER_H_
/// A macro to declare that you intentionally did not use a parameter. Useful
/// when implementing abstract interfaces.
#define UNUSED(x) (void)(x)
// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through
// between switch labels:
@ -49,4 +53,4 @@
#define FALLTHROUGH_INTENDED [[fallthrough]]
#endif
#endif // PACKAGER_MEDIA_BASE_MACROS_H_
#endif // PACKAGER_MACROS_COMPILER_H_

13
packager/macros/crypto.h Normal file
View File

@ -0,0 +1,13 @@
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MACROS_CRYPTO_H_
#define PACKAGER_MACROS_CRYPTO_H_
/// AES block size in bytes, regardless of key size.
#define AES_BLOCK_SIZE 16
#endif // PACKAGER_MACROS_CRYPTO_H_

33
packager/macros/logging.h Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2023 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_MACROS_LOGGING_H_
#define PACKAGER_MACROS_LOGGING_H_
#include <absl/log/globals.h>
#include <absl/log/log.h>
/// A macro to declare that you intentionally did not implement a method.
/// You can use the insertion operator to add specific logs to this.
#define NOTIMPLEMENTED() LOG(ERROR) << "NOTIMPLEMENTED: "
#define VLOG(verboselevel) \
LOG(LEVEL(static_cast<absl::LogSeverity>(-verboselevel)))
#define VLOG_IS_ON(verboselevel) \
(static_cast<int>(absl::MinLogLevel()) <= -verboselevel)
#ifndef NDEBUG
#define DVLOG(verboselevel) VLOG(verboselevel)
#else
// We need this expression to work with << after it, so this is a simple way to
// turn DVLOG into a no-op in release builds.
#define DVLOG(verboselevel) \
if (false) \
VLOG(verboselevel)
#endif
#endif // PACKAGER_MACROS_LOGGING_H_

View File

@ -4,10 +4,10 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#ifndef PACKAGER_STATUS_MACROS_H_
#define PACKAGER_STATUS_MACROS_H_
#ifndef PACKAGER_MACROS_STATUS_H_
#define PACKAGER_MACROS_STATUS_H_
#include <packager/status/status.h>
#include <packager/status.h>
// Evaluates an expression that produces a `Status`. If the status is not
// ok, returns it from the current function.
@ -21,4 +21,4 @@
// TODO(kqyang): Support build Status and update Status message through "<<".
#endif // PACKAGER_STATUS_MACROS_H_
#endif // PACKAGER_MACROS_STATUS_H_

View File

@ -13,6 +13,9 @@
#include <absl/log/log.h>
#include <mbedtls/entropy.h>
#include <packager/macros/compiler.h>
#include <packager/macros/crypto.h>
namespace {
// According to ISO/IEC 23001-7:2016 CENC spec, IV should be either

View File

@ -13,7 +13,7 @@
#include <mbedtls/cipher.h>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/fourccs.h>
namespace shaka {

View File

@ -11,6 +11,8 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros/crypto.h>
namespace shaka {
namespace media {

View File

@ -11,7 +11,7 @@
#include <vector>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/aes_cryptor.h>
#include <packager/media/base/aes_encryptor.h>

View File

@ -9,6 +9,8 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros/crypto.h>
namespace {
// Increment an 8-byte counter by 1. Return true if overflowed.

View File

@ -12,7 +12,7 @@
#include <string>
#include <vector>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/aes_cryptor.h>
namespace shaka {

View File

@ -11,6 +11,8 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros/crypto.h>
namespace shaka {
namespace media {

View File

@ -6,7 +6,7 @@
#include <memory>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/aes_cryptor.h>
namespace shaka {

View File

@ -11,7 +11,8 @@
#include <absl/log/log.h>
#include <absl/strings/str_format.h>
#include <packager/macros.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
#include <packager/media/base/limits.h>
namespace shaka {

View File

@ -7,7 +7,7 @@
#include <cstdint>
#include <packager/macros.h>
#include <packager/macros/classes.h>
namespace shaka {
namespace media {

View File

@ -8,6 +8,7 @@
#include <gtest/gtest.h>
#include <packager/macros/classes.h>
#include <packager/media/base/timestamp.h>
namespace shaka {

View File

@ -11,7 +11,7 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros.h>
#include <packager/macros/classes.h>
namespace shaka {
namespace media {

View File

@ -11,7 +11,7 @@
#include <string>
#include <vector>
#include <packager/macros.h>
#include <packager/macros/classes.h>
namespace shaka {
namespace media {

View File

@ -10,7 +10,7 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/file/file.h>
#include <packager/file.h>
namespace shaka {
namespace media {

View File

@ -10,8 +10,8 @@
#include <cstdint>
#include <vector>
#include <packager/macros.h>
#include <packager/status/status.h>
#include <packager/macros/classes.h>
#include <packager/status.h>
namespace shaka {

View File

@ -12,8 +12,9 @@
#include <absl/log/log.h>
#include <packager/file/file.h>
#include <packager/file.h>
#include <packager/file/file_test_util.h>
#include <packager/macros/classes.h>
#include <packager/media/base/buffer_reader.h>
#include <packager/status/status_test_util.h>

View File

@ -8,7 +8,7 @@
#include <cstdint>
#include <memory>
#include <packager/macros.h>
#include <packager/macros/classes.h>
namespace shaka {
namespace media {

View File

@ -11,7 +11,7 @@
#include <packager/media/base/media_handler.h>
#include <packager/media/base/text_sample.h>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -6,7 +6,9 @@
#include <packager/media/base/common_pssh_generator.h>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
#include <packager/media/base/protection_system_ids.h>
namespace shaka {

View File

@ -9,7 +9,7 @@
#include <string>
#include <vector>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/fourccs.h>
namespace shaka {

View File

@ -11,6 +11,7 @@
#include <memory>
#include <vector>
#include <packager/macros/classes.h>
#include <packager/media/base/aes_decryptor.h>
#include <packager/media/base/decrypt_config.h>
#include <packager/media/base/key_source.h>

View File

@ -11,7 +11,6 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <packager/macros.h>
#include <packager/media/base/raw_key_source.h>
using ::testing::_;

View File

@ -10,9 +10,9 @@
#include <string>
#include <packager/file/http_file.h>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/key_fetcher.h>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -7,8 +7,8 @@
#ifndef PACKAGER_MEDIA_BASE_KEY_FETCHER_H_
#define PACKAGER_MEDIA_BASE_KEY_FETCHER_H_
#include <packager/macros.h>
#include <packager/status/status.h>
#include <packager/macros/classes.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -12,11 +12,11 @@
#include <string>
#include <vector>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/fourccs.h>
#include <packager/media/base/protection_system_specific_info.h>
#include <packager/media/base/pssh_generator.h>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -11,8 +11,6 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros.h>
namespace {
// A map from 3-letter language codes (ISO 639-2) to 2-letter language codes

View File

@ -6,7 +6,7 @@
#include <packager/media/base/media_handler.h>
#include <packager/status/status_macros.h>
#include <packager/macros/status.h>
namespace shaka {
namespace media {

View File

@ -14,7 +14,7 @@
#include <packager/media/base/media_sample.h>
#include <packager/media/base/stream_info.h>
#include <packager/media/base/text_sample.h>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -8,6 +8,7 @@
#include <absl/log/check.h>
#include <packager/macros/compiler.h>
#include <packager/media/base/audio_stream_info.h>
#include <packager/media/base/text_stream_info.h>
#include <packager/media/base/video_stream_info.h>

View File

@ -12,7 +12,7 @@
#include <string>
#include <vector>
#include <packager/macros.h>
#include <packager/macros/classes.h>
#include <packager/media/base/container_names.h>
namespace shaka {

View File

@ -15,6 +15,7 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/macros/classes.h>
#include <packager/media/base/decrypt_config.h>
namespace shaka {

View File

@ -9,10 +9,11 @@
#include <algorithm>
#include <chrono>
#include <packager/macros.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
#include <packager/macros/status.h>
#include <packager/media/base/media_sample.h>
#include <packager/media/base/muxer_util.h>
#include <packager/status/status_macros.h>
namespace shaka {
namespace media {

View File

@ -17,7 +17,7 @@
#include <packager/media/event/muxer_listener.h>
#include <packager/media/event/progress_listener.h>
#include <packager/mpd/base/mpd_builder.h>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -10,7 +10,7 @@
#include <cstdint>
#include <string>
#include <packager/media/public/mp4_output_params.h>
#include <packager/mp4_output_params.h>
namespace shaka {
namespace media {

View File

@ -11,7 +11,7 @@
#include <cstdint>
#include <packager/status/status.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -8,7 +8,7 @@
#include <absl/log/log.h>
#include <packager/macros.h>
#include <packager/macros/logging.h>
namespace shaka {
namespace media {

View File

@ -7,6 +7,7 @@
#include <cstdint>
#include <packager/macros/classes.h>
#include <packager/media/base/byte_queue.h>
namespace shaka {

View File

@ -13,12 +13,13 @@
#include <absl/log/log.h>
#include <absl/strings/escaping.h>
#include <packager/macros.h>
#include <packager/macros/compiler.h>
#include <packager/macros/logging.h>
#include <packager/macros/status.h>
#include <packager/media/base/buffer_writer.h>
#include <packager/media/base/http_key_fetcher.h>
#include <packager/media/base/key_source.h>
#include <packager/media/base/protection_system_ids.h>
#include <packager/status/status_macros.h>
#include <packager/utils/hex_parser.h>
namespace shaka {

View File

@ -11,6 +11,7 @@
#include <string>
#include <vector>
#include <packager/macros/classes.h>
#include <packager/media/base/key_source.h>
namespace shaka {

View File

@ -16,6 +16,9 @@
#include <absl/strings/escaping.h>
#include <mbedtls/cipher.h>
#include <packager/macros/compiler.h>
#include <packager/macros/crypto.h>
#include <packager/macros/logging.h>
#include <packager/media/base/buffer_writer.h>
#include <packager/media/base/protection_system_ids.h>

View File

@ -16,8 +16,8 @@
#include <absl/synchronization/mutex.h>
#include <absl/time/time.h>
#include <packager/macros.h>
#include <packager/status/status.h>
#include <packager/macros/classes.h>
#include <packager/status.h>
namespace shaka {
namespace media {

View File

@ -12,6 +12,8 @@
#include <absl/synchronization/notification.h>
#include <gtest/gtest.h>
#include <packager/macros/classes.h>
#include <packager/macros/logging.h>
#include <packager/status/status_test_util.h>
namespace shaka {

View File

@ -14,7 +14,7 @@
#include <absl/log/check.h>
#include <absl/log/log.h>
#include <packager/media/public/crypto_params.h>
#include <packager/crypto_params.h>
namespace shaka {
namespace media {

Some files were not shown because too many files have changed in this diff Show More