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

Updates for macOS #28

Open
wants to merge 5 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
89 changes: 89 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
###########################
# ignore generated binaries
# but not the data folder
###########################

*/bin/*
!*/bin/data/

#########
# general
#########

*/[Bb]uild/
*/[Oo]bj/
*.o
*/[Dd]ebug*/
*/[Rr]elease*/
*.mode*
*.app/
*.pyc
.svn/
*.log

########################
# IDE files which should
# be ignored
########################

# XCode
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3
# XCode 4
xcuserdata
*.xcworkspace

# Code::Blocks
*.depend
*.layout

# Visual Studio
*.sdf
*.opensdf
*.suo
*.pdb
*.ilk
*.aps
ipch/

# Eclipse
.metadata
local.properties
.externalToolBuilders

##################
# operating system
##################

# Linux
*~
# KDE
.directory
.AppleDouble

# OSX
.DS_Store
*.swp
*~.nib
# Thumbnails
._*

# Windows
# Image file caches
Thumbs.db
# Folder config file
Desktop.ini

# Android
.csettings


example*/Makefile
example*/config.make
*.xcconfig
*.xcodeproj
*.cache
*.plist
131 changes: 131 additions & 0 deletions Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Notes

## GStreamer Compilation on MacOS

These are notes rather than a step-by-step guide, so read til end;

```
# As of July 2020...
# Current stable GStreamer library: 1.16 (1.17 is nightly)
# Last available brew tap: 1.14
# Last available GStreamer.framework: "OSX Sierra" (1.14)
```

GStreamer has many dependencies and its own internal linkage using environment paths. Mismatch causes problems, so I started fresh:

```
# header locations:

ls /usr/local/include
ls /usr/local/Cellar # mix of symlinks

# dynamic lib locations:

ls /usr/local/lib

# find all gst libs:

find /usr/local -name 'gst*'
find /usr/local -name 'gst*.h' # header
find /usr/local/lib -name 'gst*.so' # dylibs

```

Remove everything:

```
brew uninstall gstreamer
brew uninstall gst-plugins-base
brew uninstall gst-libav

# double-check

find /usr/local -name 'gst*'

```

Reinstall everything.

Either manually:

```
brew install bison # must be >=2.4

# add this to $PATH if common linkage problems occur
brew info bison

# Follow gstreamer meson build
# Follow gst-plugins-base meson build

```

Or brew:

```
brew update
brew install gstreamer
brew install gst-plugins-base
brew install gst-libav
```

gst-webrtc is still classified as unstable, so found here:

```
brew install gst-plugins-bad

# macOS fix...

brew install libnice
brew edit gst-plugins-bad

# edit this line...

depends_on "libnice" => :recommended
brew reinstall —build-from-source gst-plugins-bad

# remember to refresh terminal after symlinking is done!
```

Testing gst-webrtc

```
https://gitlab.freedesktop.org/gstreamer/gst-examples
gstwebrtc-demos + build
navigate to https://webrtc.nirbheek.in
launch demo with:
webrtc-sendrecv --peer-id={ID-from-URL}
```

This produces a pipeline like so:

```
webrtcbin bundle-policy=max-bundle name=sendrecv stun-server=stun://stun.l.google.com:19302 videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=96 ! sendrecv. audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=97 ! sendrecv.
```

ofxGStreamer uses the GStreamer.framework, which was last updated for Sierra:

```
https://gstreamer.freedesktop.org/documentation/installing/on-mac-osx.html
https://github.com/autr/ofxGStreamer
```

Internally it packages up libs equivalent to what brew offers. Inside addon_config.mk there are commented-out includes for brew / manually installed gstreamer in (ie. 1.14+).

Important is the ofxGStreamerSetBundleEnvironment function. It sets internal linkage ENV variables, and the original addon seems to only call it for for a GStreamer.framework bundled Release project (ie. relative path).

For any compilation on macOS however, this must always be set, by calling ofxGStreamerSetBundleEnvironment() in setup.

```
void ofApp::setup() {

# working with brew installed libs

ofxGStreamerSetBundleEnvironment()

# if packaging up a Release build

string path = ofFilePath::getCurrentWorkingDirectory();
ofxGStreamerSetBundleEnvironment( path )
}

```
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,34 @@ The instructions below will only work with the latest version of the [project ge

This addon depends on the gstreamer SDK. We are using version 1.0 currently. To install it:

### For OSX (Tested with XCode 5, 10.6,7,8,9,10)
### For OSX (Tested with XCode 11, Mojave)

First you need to download gstreamer v1.0. To install it under osx install each of the packages described below from the [gstreamer install packages for osx](http://gstreamer.freedesktop.org/data/pkg/osx/)

* [gstreamer-1.0-1.7.1-x86_64.pkg](http://gstreamer.freedesktop.org/data/pkg/osx/1.7.1/gstreamer-1.0-1.7.1-x86_64.pkg) installs the necesary libraries for applications to run
See [fork notes](Notes.md), or:

* [gstreamer-1.0-devel-1.7.1-x86_64.pkg](http://gstreamer.freedesktop.org/data/pkg/osx/1.7.1/gstreamer-1.0-devel-1.7.1-x86_64.pkg) installs the development files needed to compile gst applications
```
brew update
brew install gstreamer
brew install gst-plugins-base
brew install gst-libav
```

* [gstreamer-1.0-1.7.1-x86_64-packages.dmg](http://gstreamer.freedesktop.org/data/pkg/osx/1.7.1/gstreamer-1.0-1.7.1-x86_64-packages.dmg) contains some additional packages that are needed to encode some formats like h264, some of these packages have GPL license or use patented formats. Download the dmg and install the following packages from that collection:
Be sure that ofxGStreamerSetBundleEnvironment is called when using macOS:

This package is needed to do colorspace conversion:
```

* gstreamer-1.0-libav-1.7.1-x86_64.pkg
void ofApp::setup() {

And these packages will provide h264 encoding and some network utilities to stream h264 and other data formats:

* gstreamer-1.0-codecs-restricted-1.7.1-x86_64.pkg

* gstreamer-1.0-net-restricted-1.7.1-x86_64.pkg
# working with brew installed libs

If you only want to run an osx app, the development package is not needed but for our applications we needed to the additional packages.
ofxGStreamerSetBundleEnvironment()

It has been reported that there is a big latency improvement between version `1.2.1` and `1.7.1`, see [#8](https://github.com/arturoc/ofxGstRTP/issues/8).
# if packaging up a Release build

Note: on the systems we have tested it seems it's necesary to remove or rename `/Library/Frameworks/GStreamer.framework/Headers/assert.h` or it'll clash with the assert.h in the system and some projects won't compile. In our testing we renamed the file to keep a copy instead of deleting it. Open a terminal window and paste this in:
string path = ofFilePath::getCurrentWorkingDirectory();
ofxGStreamerSetBundleEnvironment( path )
}

````
sudo mv /Library/Frameworks/GStreamer.framework/Headers/assert.h /Library/Frameworks/GStreamer.framework/Headers/assertCOPY.h
````
```

### For Windows (Tested in visual studio 2012, on Windows 7 & 8)

Expand Down
59 changes: 55 additions & 4 deletions addon_config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ common:

# when parsing the file system looking for include paths exclude this for all or
# a specific platform
# ADDON_INCLUDES_EXCLUDE =
# ADDON_INCLUDES_EXCLUDE =

linux:

Expand All @@ -87,7 +87,7 @@ msys2:
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstVideoGrabber.h
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstVideoGrabber.cpp
#ADDON_LDFLAGS += -L$(GSTREAMER_1_0_ROOT_X86_64)lib -lgstreamer-1.0 -lgstapp-1.0 -lgstvideo-1.0 -lgstbase-1.0 -lgstnet-1.0 -lgstaudio-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lffi -lws2_32 -lole32 -lwinmm -lshlwapi -lintl -lglib-2.0
ADDON_PKG_CONFIG_LIBRARIES = gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0
ADDON_PKG_CONFIG_LIBRARIES = gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0


vs:
Expand All @@ -109,15 +109,66 @@ android/armeabi:
android/armeabi-v7a:

osx:

ADDON_LDFLAGS = -F/Library/Frameworks -framework GStreamer
ADDON_INCLUDES += /Library/Frameworks/GStreamer.framework/Headers
ADDON_INCLUDES = /Library/Frameworks/GStreamer.framework/Headers

# ADDON_INCLUDES += /usr/local/include
# ADDON_INCLUDES += /usr/local/include/glib-2.0
# ADDON_INCLUDES += /usr/local/lib/glib-2.0/include
# ADDON_INCLUDES += /usr/local/include/gstreamer-1.0
# ADDON_LIBS += /usr/local/lib/libgstreamer-1.0.0.dylib /usr/local/lib/libgstapp-1.0.0.dylib /usr/local/lib/libgstvideo-1.0.0.dylib /usr/local/lib/libgstbase-1.0.0.dylib /usr/local/lib/libgstnet-1.0.0.dylib /usr/local/lib/libgstaudio-1.0.0.dylib /usr/local/lib/gstreamer-1.0/libgstgio.dylib /usr/local/lib/gstreamer-1.0/libgstpango.dylib /usr/local/lib/libcairo-gobject.dylib /usr/local/lib/libgio-2.0.dylib /usr/local/lib/libgmodule-2.0.dylib /usr/local/lib/libgobject-2.0.dylib /usr/local/lib/libgthread-2.0.dylib /usr/local/lib/libglib-2.0.0.dylib

# /usr/local/Cellar/gst-libav/1.16.2/lib/gstreamer-1.0/libgstlibav.so

# ADDON_LIBS += /usr/local/lib/libgstgl-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstallocators-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstriff-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstpbutils-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstrtsp-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstsdp-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstrtp-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstfft-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgsttag-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstcheck-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/libgstcontroller-1.0.0.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstaudiorate.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstcoretracers.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstopengl.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstplayback.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgsttypefindfunctions.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstvolume.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstadder.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstaudioresample.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstencoding.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstopus.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstrawparse.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstvideoconvert.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstvorbis.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstapp.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstaudiotestsrc.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstoverlaycomposition.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstsubparse.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstvideorate.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstaudioconvert.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstcompositor.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstlibav.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgsttcp.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstvideoscale.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstaudiomixer.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstcoreelements.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstogg.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstpbtypes.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgsttheora.dylib
# ADDON_LIBS += /usr/local/lib/gstreamer-1.0/libgstvideotestsrc.dylib

ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstUtils.h
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstUtils.cpp
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstVideoPlayer.h
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstVideoPlayer.cpp
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstVideoGrabber.h
ADDON_SOURCES += $(OF_ROOT)/libs/openFrameworks/video/ofGstVideoGrabber.cpp

ios:
ADDON_LDFLAGS = -F/Library/Frameworks -framework GStreamer
ADDON_INCLUDES = /Library/Frameworks/GStreamer.framework/Headers
Expand Down
Loading