Linux integration

This part explains how to integrate a Linux based software with Peerplug SDK

Overview

There are several possible ways to integrate Peerplug SDK with Linux 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/linux64/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:

ffplay -http_proxy http://127.0.0.1:<port>/ -i http://test.com/s.m3u8

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 “LD_PRELOAD” trick to force load Peerplug library before starting your software.

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

LD_PRELOAD=libpp.so ffplay -http_proxy http://127.0.0.1:<port>/ -i http://test.com/s.m3u8

LD_PRELOAD 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.so library on runtime.

As Peerplug library is completely autonomous, you can “dlopen” it manually and continue even if dlopen() command has failed for some reason. 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