macOS integration

This document explains how to integrate a macOS based software with Peerplug SDK.

Overview

There are several possible ways to integrate Peerplug SDK with macOS based software:

  • Standalone Proxy Integration
  • Automatic Preload Integration
  • Manual library inclusion

Please read the instruction below to see what is the most suitable integration option for you.

Standalone proxy Integration

This is the simplest integration that allows any software that is HTTP Proxy capable to start using Peerplug.

Peerplug will act as a caching forward proxy server accepting local connections on specific port. Any software using that proxy will benefit prom Peerplug usage.

What port Peerplug proxy will run can be provided in two different ways:

  1. as “PP_PROXY_PORT” environment variable
  2. as first argument to the executable

In order to start Peerplug in proxy mode, execute “pp.bin” file located at “pp_sdk/mac/pp.bin” optionally providing the port as the argument.

To test Peerplug in proxy mode, use ffplay (part of ffmpeg) to play a demo url while using a proxy.

For example:

Pros:

  • Very easy to integrate
  • No changes to your software
  • Allows sending only the relevant traffic to Peerplug if required

Cons:

  • Requires a side process to run
  • Bulky solution outside of testing environment as one process depends on the other

Automatic preload Integration

Preload integration uses “DYLD_INSERT_LIBRARIES” trick to force load Peerplug library before starting your software.

To start ffplay with Peerplug preloaded you should supply DYLD_INSERT_LIBRARIES and DYLD_FORCE_FLAT_NAMESPACE as the first argument during application launch. For example, to start ffplay while you are at “pp_sdk/mac” directory use:

DYLD_INSERT_LIBRARIES=./libpp.dylib DYLD_FORCE_FLAT_NAMESPACE=1 ffplay -i http://example.com/s.m3u8

DYLD_INSERT_LIBRARIES will preload Peerplug library and it will intercept all networking of ffplay application.

Pros:

  • Easy to integrate
  • No changes to your software
  • Single process/app

Cons:

  • Requires a custom launch command

Manual library inclusion

Finally you can include Peerplug as a library when you are building your software.

In this case, you should link your final executable with Peerplug.

Please note, you should only link it during linking phase or “dlopen” libpp.dylib library at runtime.

As Peerplug library is completely autonomous, you can “dlopen” it manually and continue even if dlopen() command has failed for some reason(like Peerplug SDK not being present). Your app will be unaffected in this case.

Pros:

  • Does not require special launch command or separate process
  • One line of code that can be executed conditionally (Peerplug on/off switch)

Cons:

  • Requires recompiling your software