Using the GStreamer SDK in openFrameworks under OSX 10.8 Mountain Lion

Using the GStreamer SDK in openFrameworks under OSX 10.8 Mountain Lion

It looks like developing streaming audio/video applications in OSX 10.8 Mountain Lion has just gotten easier. The GStreamer website has gotten a fresh new look at http://www.gstreamer.com and there is a new precompiled application framework for use in developing OSX applications. This framework is a universal binary version meaning it can be used under both the i386 and x86_64 architectures. Good news is that openFrameworks application using it can be compiled under Mountain Lion 10.8.

Using the framework is pretty straight forward, yet there are a couple of tricks to get it working 100% which I will go over. I will be using the videoPlayerExample to help me describe the process and to show how to use the GStreamer framework below.

Download and Install the GStreamer Framework

  1. Goto http://docs.gstreamer.com/display/GstSDK/Installing+on+Mac+OS+X to download the GStreamer files.
  2. There are three (3) files that need to be downloaded. Find them under the section Download and Install the SDK.
    • Runtime
    • Development files
    • Deployment Packages
  3. They will be .dmg files which once clicked on will mount as drives. Go into each drive that is mounted and click on/install the packages inside.
  4. To be safe, install all packages inside each mounted drive.
  5. This will create a framework in the /Library/Frameworks folder named GStreamer.framework
  6. This framework will be the one to include in your openFrameworks/application projects.

Download openFrameworks

  1. Goto http://www.openframeworks.cc/download/ and download the OSX openFrameworks package. The version at the time of this writing was 0073.

Modify the ofConstants.h file:

From the openFrameworks directory goto the directory /libs/openFrameworks/utils/ and open the file ofConstants.h for editing.

  1. Search for “OF_VIDEO_CAPTURE_GSTREAMER” without the quotes. It should be on or around line 202.
  2. Find the section with the following:
    #elif defined(TARGET_OSX)
    //on 10.6 and below we can use the old grabber
    #ifndef MAC_OS_X_VERSION_10_7
    #define OF_VIDEO_CAPTURE_QUICKTIME
    #else
    #define OF_VIDEO_CAPTURE_QTKIT
    #endif
  3. Modify this section as follows: (Add OF_VIDEO_CAPTURE_GSTREAMER)
    #elif defined(TARGET_OSX)
    //on 10.6 and below we can use the old grabber
    #ifndef MAC_OS_X_VERSION_10_7
    #define OF_VIDEO_CAPTURE_QUICKTIME
    #else
    //#define OF_VIDEO_CAPTURE_QTKIT
    #define OF_VIDEO_CAPTURE_GSTREAMER
    #endif
  1. Search for “OF_VIDEO_PLAYER_GSTREAMER” without the quotes. It should be on or around line 244.
  2. Find the section with the following:
    #elif defined(TARGET_OSX)
    //for 10.7 and 10.8 users we use QTKit for 10.6 users we use QuickTime
    #ifndef MAC_OS_X_VERSION_10_7
    #define OF_VIDEO_PLAYER_QUICKTIME
    #else
    #define OF_VIDEO_PLAYER_GSTREAMER
    #endif
  3. Modify this section as follows: (Add OF_VIDEO_PLAYER_GSTREAMER)
    #elif defined(TARGET_OSX)
    //for 10.7 and 10.8 users we use QTKit for 10.6 users we use QuickTime
    #ifndef MAC_OS_X_VERSION_10_7
    #define OF_VIDEO_PLAYER_QUICKTIME
    #else
    //#define OF_VIDEO_PLAYER_QTKIT
    #define OF_VIDEO_PLAYER_GSTREAMER
    #endif

This will enable the GStreamer headers in openFrameworks to work under OSX 10.8 Mountain Lion. If you want to use GStreamer under OSX 10.6 modify that section accordingly to enable GStreamer.

Modify the ofGstVideoGrabber.cpp file:

  1. From the openFrameworks directory goto the directory /libs/openFrameworks/video/ and open the file ofGstVideoGrabber.cpp for editing.
  2. Add #include <gst/gst.h> right above #ifdef TARGET_LINUX. This should be on or around line 17

Include the GStreamer framework in your XCode project:

Add the GStreamer.framework located at /Library/Frameworks to your project. The videoPlayerExample project is being used here.

 

Include the GStreamer Framework

Add the openFrameworks GStreamer header files to your XCode project:

By default for the OSX distribution version of openFrameworks GStreamer is not enabled. So the header files are not included in the example XCode project files. To fix this, add the openFrameworks GStreamer header files to the openFrameworks project within your XCode project.

 

Add the GStreamer header files to your project.

Update the project build setting:

There are two build settings that need to be modified in both the application project and the openFrameworks project. The Header Search Path and the Frameworks Search Path. Don’t know why but for some reason the user frameworks path /Library/Frameworks is not defined and causes problems when compiling with GStreamer. So it needs to be defined…

Frameworks Search Path: /Library/Frameworks

Header Search Path: /Library/Frameworks/GStreamer.framework/Headers

Application Project Build Settings:

 

Applications Project Build Settings

openFrameworks Project Build Settings:

 

openFrameworks Project Build Settings

Using GStreamer in openFrameworks:

After all of that you should be setup to now start using the GStreamer features. If you were following along using the videoPlayerExample, you should be able to compile the project and openFrameworks will now be using GStreamer to play the video fingers video file.

To go further I will demonstrate how to play an rtsp:// stream using this same videoPlayerExample project.

  1. Find an rtsp:// test stream at http://wiki.multimedia.cx/index.php?title=RTSP
  2. Modify the testApp.cpp file
    <code>void testApp::setup(){
    ofBackground(255,255,255);frameByframe = false;// Uncomment this to show movies with alpha channels
    // fingerMovie.setPixelFormat(OF_PIXELS_RGBA);
    fingerMovie.loadMovie("rtsp://media.lscube.org/tests/tc.mov");
    fingerMovie.play();
    }
    void testApp::draw(){
    ofSetHexColor(0xFFFFFF);

    fingerMovie.draw(20,20);
    }

This will play the rtsp:// stream that you specified in setup()….

Leave a Reply

Your email address will not be published. Required fields are marked *