Skip to content

Commit

Permalink
feat: CMake port media/trick_play (#1146)
Browse files Browse the repository at this point in the history
Issue #1047 (CMake porting)

---------

Co-authored-by: Joey Parrish <joeyparrish@google.com>
  • Loading branch information
zdanek and joeyparrish committed May 1, 2023
1 parent 6c1d4f3 commit 901013c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 49 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

# Root-level CMake build file.

# Project name. May not contain spaces. Versioning is managed elsewhere.
cmake_policy(SET CMP0048 NEW)
project(shaka-packager VERSION "")

# Minimum CMake version.
# We could require as low as 3.10, but glog requires 3.16.
cmake_minimum_required(VERSION 3.16)

# Project name. May not contain spaces. Versioning is managed elsewhere.
cmake_policy(SET CMP0048 NEW)
project(shaka-packager VERSION "")

# The only build option for Shaka Packager is whether to build a shared
# libpackager library. By default, don't.
option(LIBPACKAGER_SHARED "Build libpackager as a shared library" OFF)
Expand Down
5 changes: 3 additions & 2 deletions packager/media/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

# Subdirectories with their own CMakeLists.txt, all of whose targets are built.
add_subdirectory(base)
add_subdirectory(codecs)
add_subdirectory(formats)
add_subdirectory(origin)
add_subdirectory(replicator)
add_subdirectory(test)
add_subdirectory(codecs)
add_subdirectory(formats)
add_subdirectory(trick_play)
11 changes: 8 additions & 3 deletions packager/media/base/media_handler_test_base.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google LLC. All rights reserved.
// 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
Expand All @@ -11,8 +11,10 @@
#include <gtest/gtest.h>

#include "absl/strings/escaping.h"
#include "absl/strings/numbers.h"
#include "packager/media/base/media_handler.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/utils/bytes_to_string_view.h"

namespace shaka {
namespace media {
Expand Down Expand Up @@ -145,8 +147,11 @@ MATCHER_P6(MatchEncryptionConfig,
constant_iv,
key_id,
"") {
const std::string constant_iv_hex = absl::BytesToHexString(arg.constant_iv);
const std::string key_id_hex = absl::BytesToHexString(arg.key_id);
const std::string_view constant_iv_data =
byte_vector_to_string_view(constant_iv);
const std::string constant_iv_hex = absl::BytesToHexString(constant_iv_data);
const std::string key_id_data(arg.key_id.data(), arg.key_id.size());
const std::string key_id_hex = absl::BytesToHexString(key_id_data);
const std::string protection_scheme_as_string =
FourCCToString(arg.protection_scheme);
// Convert to integers so that they will print as a number and not a uint8_t
Expand Down
25 changes: 25 additions & 0 deletions packager/media/trick_play/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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

add_library(media_trick_play STATIC
trick_play_handler.cc)
target_link_libraries(media_trick_play
media_base
absl::base
glog)

add_executable(media_trick_play_unittest
trick_play_handler_unittest.cc)
target_link_libraries(media_trick_play_unittest
media_base
media_trick_play
media_handler_test_base
status
gmock
gtest
gtest_main)

add_test(NAME media_trick_play_unittest COMMAND media_trick_play_unittest)
38 changes: 0 additions & 38 deletions packager/media/trick_play/trick_play.gyp

This file was deleted.

3 changes: 2 additions & 1 deletion packager/media/trick_play/trick_play_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

#include "packager/media/trick_play/trick_play_handler.h"

#include "packager/base/logging.h"
#include "glog/logging.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/status/status.h"

namespace shaka {
namespace media {
Expand Down
2 changes: 1 addition & 1 deletion packager/media/trick_play/trick_play_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "packager/media/base/audio_stream_info.h"
#include "packager/media/base/media_handler_test_base.h"
#include "packager/media/base/video_stream_info.h"
#include "packager/status_test_util.h"
#include "packager/status/status_test_util.h"

using ::testing::_;

Expand Down
3 changes: 3 additions & 0 deletions packager/third_party/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ set(protobuf_DISABLE_RTTI ON)
# The latest version of protobuf requires a path to ABSL.
set(ABSL_ROOT_DIR get_filename_component(ABSOLUTE_PATH ../abseil-cpp/source ABSOLUTE))

# Make sure protoc links against the same MSVC runtime as internal libs.
set(protobuf_MSVC_STATIC_RUNTIME OFF)

# Disable these errors/warnings:
if(MSVC)
add_compile_options(
Expand Down

0 comments on commit 901013c

Please sign in to comment.