Skip to content

Commit

Permalink
Move libMXF and libMXF projects into bmx
Browse files Browse the repository at this point in the history
  • Loading branch information
philipnbbc committed Aug 24, 2023
1 parent d448677 commit ebbc70f
Show file tree
Hide file tree
Showing 479 changed files with 120,355 additions and 40 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Configure
shell: bash
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Source release
shell: bash
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

26 changes: 8 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ bmx is a library and set of utilities to read and write the [SMPTE ST 377-1 MXF

bmx is used to support standardisation efforts in the broadcast industry. It provides utilities for creating standard compliant sample files. It serves as an example implementation for MXF file format standards.

bmx includes the [libMXF](./deps/libMXF) low-level MXF C library and the [libMXF++](./deps/libMXFpp) C++ wrapper library.

bmx provides a set of commandline applications:

* **raw2bmx**: create MXF files from raw essence files
Expand All @@ -19,7 +21,7 @@ bmx provides a set of file format text dumper and essence extraction tools:
* **movdump**: text dump Quicktime / MP4 files
* **rdd36dump**: text dump SMPTE RDD 36 (Apple ProRes) bitstream files
* **vc2dump**: text dump SMPTE ST 2042 VC-2 bitstream files
* **MXFDump**: text dumper for MXF files from the [AAF SDK](https://sourceforge.net/projects/aaf/). This utility is made available and built as part of [libMXF](https://github.com/bbc/libMXF).
* **MXFDump**: text dumper for MXF files from the [AAF SDK](https://sourceforge.net/projects/aaf/). This utility is made available and built as part of [libMXF](./deps/libMXF).

The following input and output wrapper formats and flavours are supported:

Expand Down Expand Up @@ -73,13 +75,7 @@ The build process has been tested on Ubuntu, Debian, MacOS and Windows (Microsof

### Dependencies

The [libMXF](https://github.com/bbc/libMXF) and [libMXF++](https://github.com/bbc/libMXFpp) libraries are required. They are included as git submodules in the `deps/` directory. Run

```bash
git submodule update --init
```

to ensure the submodules are available and up-to-date in the working tree.
The [libMXF](./deps/libMXF/) and [libMXF++](./deps/libMXFpp/) libraries are required.

The [uriparser](https://github.com/uriparser/uriparser) and [expat](https://github.com/libexpat/libexpat) libraries are required. These libraries are typically provided as software packages on Unix-like systems; the Ubuntu / Debian package names are `liburiparser-dev` and `libexpat1-dev`. The libraries are built from the GitHub source when building on Windows using Microsoft Visual Studio C++.

Expand All @@ -89,7 +85,7 @@ The [libcurl](https://curl.haxx.se/libcurl/) (Ubuntu / Debian package name `libc

### Commands

A basic commandline process is described here for platforms that default to the Unix Makefiles or Visual Studio cmake generators. See [./docs/build.md](./docs/build.md) for more detailed build options.
A basic commandline process is described here for platforms that default to the Unix Makefiles or Visual Studio cmake generators. See [build.md](./docs/build.md) for more detailed build options.

Replace `<build type>` in the commandlines below with `Debug` or `Release`. Note that the Visual Studio generator supports multiple build types for a configuration, which is why the build type is selected _after_ configuration.

Expand Down Expand Up @@ -167,7 +163,7 @@ add_executable(example example.cpp)
target_link_libraries(example bmx)
```

The `BMX_BUILD_LIB_ONLY` cmake option can be set to `ON` to avoid building the apps and examples in bmx, libMXF and libMXF++. Setting the option to `ON` will disable the bmx tests because they requires the apps. Add this line to the cmake
The `BMX_BUILD_LIB_ONLY` cmake option can be set to `ON` to avoid building the apps and examples in bmx, [libMXF](./deps/libMXF) and [libMXF++](./deps/libMXFpp). Setting the option to `ON` will disable the bmx tests because they requires the apps. Add this line to the cmake

```text
set(BMX_BUILD_LIB_ONLY ON CACHE BOOL "Build bmx, MXF and MXF++ libraries only")
Expand All @@ -191,19 +187,13 @@ See [Docker Run](#docker-run) for more details on the script.

### Docker Build

The [Dockerfile](./Dockerfile) is used for building a Docker image containing a set of tools from bmx, libMXF and AAF SDK.
The [Dockerfile](./Dockerfile) is used for building a Docker image containing a set of tools from bmx, [libMXF](./deps/libMXF) and [AAF SDK](https://sourceforge.net/projects/aaf/).

The Dockerfile contains a **build** and **runtime** layer:

* **build**: builds and checks the libMXF, libMXF++ and bmx code.
* **build**: builds and checks the [libMXF](./deps/libMXF), [libMXF++](./deps/libMXFpp) and bmx code.
* **runtime**: provides the commandline tool executables built in the `build` layer.

Ensure that the libMXF and libMXFpp git submodules are available and up-to-date in the `deps/` directory by running,

```bash
git submodule update --init
```

The runtime Docker image can be built in the top-level directory using docker build,

```bash
Expand Down
3 changes: 1 addition & 2 deletions cmake/libmxf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ if(BMX_BUILD_LIBMXF_LIB)
else()
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/libMXF/CMakeLists.txt)
message(FATAL_ERROR
"libMXF submodule source code does not exist at 'deps/libMXF'\n"
"Run 'git submodule update --init' to fetch the source"
"libMXF source code does not exist at 'deps/libMXF'"
)
endif()

Expand Down
3 changes: 1 addition & 2 deletions cmake/libmxfpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ if(BMX_BUILD_LIBMXFPP_LIB)
else()
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/libMXFpp/CMakeLists.txt)
message(FATAL_ERROR
"libMXF submodule source code does not exist at 'deps/libMXFpp'\n"
"Run 'git submodule update --init' to fetch the source"
"libMXF++ source code does not exist at 'deps/libMXFpp'"
)
endif()

Expand Down
1 change: 0 additions & 1 deletion deps/libMXF
Submodule libMXF deleted from 8df9cc
14 changes: 14 additions & 0 deletions deps/libMXF/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*~
build/
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
out/
88 changes: 88 additions & 0 deletions deps/libMXF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
endif()

project(libMXF
VERSION 1.1
DESCRIPTION "Low-level C library for reading and writing the SMPTE ST 377-1 MXF file format"
HOMEPAGE_URL https://github.com/bbc/libMXF
LANGUAGES C CXX
)

include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake")

if(MSVC AND LIBMXF_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# cmake version >= 3.15: Use MultiThreadedDLL runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()

if(BUILD_SHARED_LIBS)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
set(CMAKE_CXX_STANDARD 11)

# Set the test samples output directory
if(LIBMXF_TEST_SAMPLES_DIR STREQUAL "")
set(new_samples_dir ${CMAKE_CURRENT_BINARY_DIR}/test_samples)
else()
get_filename_component(new_samples_dir
${LIBMXF_TEST_SAMPLES_DIR}
REALPATH
BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
if(NOT new_samples_dir STREQUAL ${LIBMXF_TEST_SAMPLES_DIR})
set(LIBMXF_TEST_SAMPLES_DIR ${new_samples_dir})
message("-- Test samples output directory: ${LIBMXF_TEST_SAMPLES_DIR}")
endif()

if(MSVC)
add_compile_options(/W3)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

if(LIBMXF_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_LESS 3.15.0)
# cmake version < 3.15: Update compiler flags to use the MultiThreadedDLL runtime
macro(update_msvc_runtime_flags flags)
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
endmacro()

update_msvc_runtime_flags(CMAKE_C_FLAGS)
update_msvc_runtime_flags(CMAKE_CXX_FLAGS)
foreach(suffix _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
update_msvc_runtime_flags(CMAKE_C_FLAGS${suffix})
update_msvc_runtime_flags(CMAKE_CXX_FLAGS${suffix})
endforeach()
endif()
else()
add_compile_options(-W -Wall -O2)

# Enable large file support on 32-bit systems.
add_definitions(
-D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE
)
endif()

if(LIBMXF_BUILD_TESTING AND (NOT DEFINED BUILD_TESTING OR BUILD_TESTING))
enable_testing()
endif()
add_custom_target(libMXF_test_samples)
add_custom_target(libMXF_test_data)

include("${PROJECT_SOURCE_DIR}/cmake/ext_uuid.cmake")

configure_file(config.h.in config.h)

add_subdirectory(mxf)
if(LIBMXF_BUILD_TESTING AND (NOT DEFINED BUILD_TESTING OR BUILD_TESTING))
add_subdirectory(test)
endif()
if(NOT LIBMXF_BUILD_LIB_ONLY)
add_subdirectory(examples)
add_subdirectory(tools)
endif()
26 changes: 26 additions & 0 deletions deps/libMXF/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (C) 2014, British Broadcasting Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the British Broadcasting Corporation nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
78 changes: 78 additions & 0 deletions deps/libMXF/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# libMXF

libMXF is a low-level C library for reading and writing the [SMPTE ST 377-1 MXF file format](https://ieeexplore.ieee.org/document/7292073).

libMXF was originally developed as part of the [Ingex Project](http://ingex.sourceforge.net/) where it supported MXF transfer, playback and storage applications. libMXF was also used in the [BBC Archive Preservation Project](https://www.bbc.co.uk/rd/publications/whitepaper275) to migrate BBC archive content from video tapes to files.

The [MXFDump](./tools/MXFDump) MXF text dumper utility from the [AAF SDK](https://sourceforge.net/projects/aaf/) is provided in this project for convenience.

## Examples

A number of applications and library code can be found in the [examples](./examples) directory. These are not part of the core library and are not required to build [libMXF++](../libMXFpp) or [bmx](../../).

* [archive](./examples/archive): library code and utilities used in the [BBC Archive Preservation Project](https://www.bbc.co.uk/rd/publications/whitepaper275).
* [avidmxfinfo](./examples/avidmxfinfo): library and utility for extracting metadata about Avid MXF OP-Atom files. This utility has been superseded by
`mxf2raw` in the [bmx](../../) project.
* [reader](./examples/reader): library code used by the [Ingex Player](http://ingex.sourceforge.net/) for reading MXF files.
* [transfertop2](./examples/transfertop2): utilities used in the [TransferToP2](http://ingex.sourceforge.net/TransferToP2.html) application to allow edited sequences to be transferred from an editing system to a P2 card.
* [vlc](./examples/vlc): legacy code that was written to test how easy it would be to support MXF in [VLC](https://www.videolan.org/vlc/).
* [writeaviddv50](./examples/writeaviddv50): example utility for writing DV 50 MBit/s video in Avid MXF OP-Atom files.
* [writeavidmxf](./examples/writeavidmxf): library code and utility for writing Avid MXF OP-Atom files. This utility has been superseded by `raw2bmx` in the [bmx](../../) project.

## Build, Test and Install

libMXF is developed on Ubuntu Linux but is supported on other Unix-like systems and Windows.

The [cmake](https://cmake.org/) build system is used, with minimum version **3.12**. The build requires the `git` tool along with the C/C++ compilers.

The build process has been tested on Ubuntu, Debian, MacOS and Windows (Microsoft Visual C++ 2017 v15.9.51 and later versions).

### Dependencies

The uuid library (Ubuntu / Debian package name `uuid-dev`) is required for non-Apple Unix-like systems.

### Commands

A basic commandline process is described here for platforms that default to the Unix Makefiles or Visual Studio cmake generators. See [build.md](./docs/build.md) for more detailed build options.

Replace `<build type>` in the commandlines below with `Debug` or `Release`. Note that the Visual Studio generator supports multiple build types for a configuration, which is why the build type is selected _after_ configuration.

The default generator can be overridden using the cmake `-G` option. The list of available generators is shown at the end of the output of `cmake --help`.

Start by creating a build directory and change into it. The commandlines below use a `out/build` build directory in the working tree, which follows the approach taken by Microsoft Visual Studio C++.

#### Unix-like (Unix Makefiles)

```bash
mkdir -p out/build
cd out/build
cmake ../../ -DCMAKE_BUILD_TYPE=<build type>
cmake --build .
make test
sudo make install
```

Run `ldconfig` to update the runtime linker cache. This avoids library link errors similar to "error while loading shared libraries".

```bash
sudo /sbin/ldconfig
```

#### Windows (Visual Studio)

```console
mkdir out\build
cd out\build
cmake ..\..\
cmake --build . --config <build type>
ctest -C <build type>
cmake --build . --config <build type> --target install
```

## Source and Binary Distributions

Source distributions, including dependencies for the Windows build, and Windows binaries are made available as in [bmx](../../).

## License

The libMXF library is provided under the BSD 3-clause license. See the [COPYING](./COPYING) file provided with this library for more details.
28 changes: 28 additions & 0 deletions deps/libMXF/cmake/ext_uuid.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
if(uuid_link_lib)
return()
endif()


if(UNIX AND NOT APPLE)
find_library(uuid_lib
NAMES uuid
)
find_path(uuid_include_dir
NAMES uuid/uuid.h
)

if(NOT uuid_lib OR NOT uuid_include_dir)
message(FATAL_ERROR "uuid dependency not found")
endif()

add_library(libuuid UNKNOWN IMPORTED)
set_target_properties(libuuid PROPERTIES
IMPORTED_LOCATION ${uuid_lib}
INTERFACE_INCLUDE_DIRECTORIES ${uuid_include_dir}
)
set(uuid_link_lib libuuid)
else()
# MSVC: "ole" will already be linked in
# APPLE: doesn't require uuid library
set(uuid_link_lib)
endif()
39 changes: 39 additions & 0 deletions deps/libMXF/cmake/git_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
if(TARGET libmxf_git_version)
return()
endif()


# Ensure the cmake targets and code symbols are libMXF specific
set(GIT_VERSION_PROJECT_PREFIX "libmxf_")

# Set the git release tag pattern to describe relative to
set(GIT_DESCRIBE_TAG_PATTERN "v${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(GIT_WORKING_DIR ${PROJECT_SOURCE_DIR})

# Set to ignore git_version errors if there is no .git directory
set(GIT_FAIL_IF_NONZERO_EXIT FALSE)

include(FetchContent)

set(git_version_deps_source "${PROJECT_SOURCE_DIR}/deps/cmake-git-version-tracking")

if(EXISTS ${git_version_deps_source})
FetchContent_Declare(libmxf_git_version
SOURCE_DIR ${git_version_deps_source}
)
message("-- Build using git version source: ${git_version_deps_source}")
else()
FetchContent_Declare(libmxf_git_version
GIT_REPOSITORY "https://github.com/andrew-hardin/cmake-git-version-tracking.git"
GIT_TAG "904dbda1336ba4b9a1415a68d5f203f576b696bb"
PATCH_COMMAND git clean -fdx
COMMAND git reset --hard
COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/git_version_904dbda.patch"
)
endif()

FetchContent_GetProperties(libmxf_git_version)
if(NOT libmxf_git_version_POPULATED)
FetchContent_Populate(libmxf_git_version)
add_subdirectory(${libmxf_git_version_SOURCE_DIR} ${libmxf_git_version_BINARY_DIR})
endif()
Loading

0 comments on commit ebbc70f

Please sign in to comment.