Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build scream in build.rs for gstscream #60

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ TARGET_LINK_LIBRARIES (
scream_bw_test_rx
${screamLibs} pthread
)

add_subdirectory(wrapper_lib)

2 changes: 1 addition & 1 deletion code/ScreamRx.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ScreamRx {
* It is up to the wrapper application to prepend this RTCP
* with SR or RR when needed
*/
bool ScreamRx::createStandardizedFeedbackOoo(uint32_t time_ntp, bool isMark, unsigned char* buf, int& size);
bool createStandardizedFeedbackOoo(uint32_t time_ntp, bool isMark, unsigned char* buf, int& size);

/*
* Get last feedback transmission time in NTP domain (Q16)
Expand Down
27 changes: 16 additions & 11 deletions code/wrapper_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

#set(CMAKE_VERBOSE_MAKEFILE ON)

set(BUILD_SHARED_LIBS on)
# set(BUILD_SHARED_LIBS on)

SET(HEADERS
../ScreamTx.h
../RtpQueue.h
../ScreamTx.h
../RtpQueue.h
)

SET(SRCS
../RtpQueue.cpp
../ScreamTx.cpp
../ScreamV2Tx.cpp
../ScreamV2TxStream.cpp
screamtxbw_plugin_wrapper.cpp
screamtx_plugin_wrapper.cpp
../RtpQueue.cpp
../ScreamTx.cpp
../ScreamV2Tx.cpp
../ScreamV2TxStream.cpp
screamtxbw_plugin_wrapper.cpp
screamtx_plugin_wrapper.cpp
)

set(CMAKE_BUILD_TYPE Debug)
Expand All @@ -25,12 +25,17 @@ if(BUILD_SHARED_LIBS)
add_library(scream SHARED ${SRCS})

else()

set(CMAKE_CXX_FLAGS " -DV2 -g -I .. ${CMAKE_CXX_FLAGS_INIT} -fPIC")
add_library(scream STATIC ${SRCS})
endif()


INCLUDE_DIRECTORIES(
${screamIncludes}
${screamIncludes}
)

# Add install instructions for the library for automated buildscripts
install(TARGETS scream
ARCHIVE DESTINATION lib
)

4 changes: 2 additions & 2 deletions code/wrapper_lib/screamtx_plugin_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Scream sender side wrapper
#include "ScreamTx.h"
#include "RtpQueue.h"
#include "../ScreamTx.h"
#include "../RtpQueue.h"
#include "sys/types.h"
#include <sys/time.h>
#include <pthread.h>
Expand Down
4 changes: 2 additions & 2 deletions code/wrapper_lib/screamtxbw_plugin_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ScreamTx.h"
#include "RtpQueue.h"
#include "../ScreamTx.h"
#include "../RtpQueue.h"
#include "sys/types.h"
#include <sys/time.h>
#include <pthread.h>
Expand Down
1 change: 1 addition & 0 deletions gstscream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ name="scream_receiver"
path="src/receiver.rs"

[build-dependencies]
cmake = "0.1.35"
gst-plugin-version-helper = { git = "https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git" }

[features]
Expand Down
9 changes: 7 additions & 2 deletions gstscream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
# Building gstscream and sample applications
Should be possible to build and run on Windows (not tested)
However SCReAM BW can't be built for Windows.
Therefore modify build.sh to remove --features screamtxbw-enabled
Therefore you cannot build with --features screamtxbw-enabled

```bash
./scripts/build.sh
# To build with L4S and with SCReAM BW
cargo build --features=ecn-enabled,screamtxbw-enabled

# To build without SCReAM BW
cargo build --features=ecn-enabled
```

# Environment Variables are set in script/env.sh
Expand Down
56 changes: 55 additions & 1 deletion gstscream/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
//! Builds the rust abstraction for the `SCREAMV2` protocol.
//!
//! This build script builds the c++ scream library and
//! provides the needed linker arguments needed to statically
//! link the library to this rust code.

#![deny(warnings)]
#![deny(clippy::all)]

use std::path::PathBuf;

fn main() {
gst_plugin_version_helper::info()
gst_plugin_version_helper::info();

let source_dir = PathBuf::from(
std::env::var("CARGO_MANIFEST_DIR")
.expect("Cannot find \"CARGO_MANIFEST_DIR\", please build the project using cargo"),
);

let parent_dir = source_dir.parent().unwrap_or_else(|| {
panic!(
"Cannot find parent of {} (project root)",
source_dir.display()
)
});

build_and_link_scream(parent_dir);

// re-run if any code in the gstscream directory changes.
println!("cargo:rerun-if-changed={}", source_dir.display());

// re-run if any of the c++ code changes.
println!(
"cargo:rerun-if-changed={}",
parent_dir.join("code").display()
);
println!(
"cargo:rerun-if-changed={}",
parent_dir.join("CMakeList.txt").display()
);
}

/// Builds the c++ scream library and provides the needed linker arguments.
fn build_and_link_scream(parent_dir: &std::path::Path) {
let code_dir = parent_dir.join("code");
let built = cmake::Config::new(code_dir).build();

println!(
"cargo:rustc-link-search=all={}",
built.join("lib").display()
);

// Statically link scream.
println!("cargo:rustc-link-lib=static=scream");
// Dynamically link stdc++ as this is generally available.
println!("cargo:rustc-link-lib=dylib=stdc++");
}
17 changes: 0 additions & 17 deletions gstscream/scripts/build.sh

This file was deleted.

1 change: 0 additions & 1 deletion gstscream/src/screamrx/ecn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct GstNetEcnMeta {
pub cp: GstNetEcnCp,
}

#[link(name = "gstnet-1.0")]
extern "C" {

//=========================================================================
Expand Down
2 changes: 1 addition & 1 deletion gstscream/src/screamtx/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ extern "C" fn callback(stx: *const Screamtx, buf: gst::Buffer, is_push: u8) {
drop(buf);
}
}
#[link(name = "scream")]

extern "C" {
fn ScreamSenderPush(
buf: *mut gst_sys::GstBuffer,
Expand Down
2 changes: 1 addition & 1 deletion gstscream/src/screamtxbw/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ extern "C" fn callback(
.expect("Screamtxbw callback srcpad.push failed");
}
}
#[link(name = "scream")]

extern "C" {
#[allow(improper_ctypes)]
fn ScreamTxBwPluginInit(
Expand Down