Log in Register

Login to your account

Username *
Password *
Remember Me

Create an account

Fields marked with an asterisk (*) are required.
Name *
Username *
Password *
Verify password *
Email *
Verify email *
Captcha *







Android Broadcaster API Integration and Usage







  • Introduction


  • Package


  • Content


  • Bootstrapping


  • Authentication


  • Publishing


  • Snapshotting





Website integration is a special mode of Android Broadcaster where-in it can mimics a standard web application. You can have it load broadcast settings from your own website. You can even brand its broadcast window with your own logo.


How this works?



  1. You download and integrate android broadcaster api files on your own webserver. Follow instructions in this document to correctly setup everything.


  2. Main us at : This email address is being protected from spambots. You need JavaScript enabled to view it. to register your domain for android broadcaster service.


  3. Your users download android broadcaster from google play store.


  4. User installs and runs android broadcaster in website mode.


  5. User enters your domain name (abc.com) in the domain text box and presses connect.


  6. Android broadcaster connects to your website and loads necessary details.


  7. User selects publish mode (audio/video)


  8. Android broadcast prompts for authentication


  9. User enters username and password and presses “ok”


  10. Android broadcaster authenticates user on your own code via authURL on your server (see Authentication section of this document)


  11. Android broadcaster then loads publisher settings such as rtmp url, stream name and other settings from your server via publishURL (see Publishing section of this document).


  12. User then sees publishing screen where your logo can be seen.


  13. User can then press the publish button (red button) to start publishing to your server.






The android broadcaster website integration package can be downloaded from rtmpworld.com freebies section: http://rtmpworld.com/downloads/freebies You need to register for free to login and download the package archive.


Once downloaded you can extract and upload the content to a folder on your webserver. Make sure the location is accessible and you can access rest of your website resources from there. This package comes with pre built php code. However you can translate the same in any programming language since the data format used to communicate is JSON.

Android Broadcaster Website mode integration kit

File Name: aub.zip

File Size: 86.43 kB

Version: 0.0.1

Date: 26. January 2014














  • authenticate.php – Authentication file used to authenticate a user supplied username/password aganst your own system.


  • bootstrap.php – Initialization file which initializes api gateway for your domain. This is the first file loaded by android broadcaster when connecting to your domain. It contains url address and other settings required to communicate to the api files.


  • config.php - Configuration file to hold rtmp service url for publishing


  • encoderpresets.xml – Encoder settings file which contains different encoding settings. You can define your own presets here and configure them accordingly.


  • logo.png – Your logo file which will be loaded into android broadcaster's broadcasting window. Make sure to maintain dimensions as per the sample provided.


  • publisher.php – Publisher file , which load publishing settings such as rtmp url, stream name and other session details from your server.


  • snapshot.php – Snapshot collector file , which recieves camera snapshot from android broadcaster and saves it to disk.




  • captured – The location where snapshot.php writes snapshot images.






define( 'AMFSERVICE', "HawkEye" );


$aubroot = $aubconf['server'];

$timestamp = $_POST['timestamp'];

$signature = $_POST['signature'];

$lastupdate = $_POST['lastupdate'];


$response["status"] = 0;

$response["logoURL"] = $aubroot."/logo.png"; // your logo

$response["authURL"] = $aubroot."/authenticate.php"; // url of auth provider

$response["publishURL"] = $aubroot."/publisher.php"; // url of publish provider

$response["iconURL"] = $aubroot."/iconURL.php"; // Not applicable

$response["header"] = $aubroot."/header.php"; // Not applicable

$response["footer"] = $aubroot."/footer.php"; // Not applicable

$response["categoriesURL"] = $aubroot."/categories.php"; // Not applicable

$response["mediaURL"] = $aubroot."/medias.php"; // Not applicable

$response["signupURL"] = $aubroot."/signup.php"; // Not applicable

$response["uploadURL"] = $aubroot."/uploader.php"; // Not applicable

$response["playbackURL"] = $aubroot."/playback.php"; // Not applicable

$response["themeColor"] = "#ffccff"; // Not applicable

$response["chromeColor"] = "#cc00ff"; // Not applicable

$response["contentBackgroundColor"] = "#000000"; // Not applicable

$response["textColor"] = "#ffffff"; // Not applicable

$response["actionBarColor"] = "#000000"; // Not applicable

$response["refresh"] = false; // Not applicable

$response["timestamp"] = time(); // timestamp

$response["signature"] = null; // Not applicable

$response["lastupdate"] = time(); // Not applicable

$response["publisherHint"] = "Publish"; // label to show on broadcast buttons

$response["avMode"] = "duplex"; // publishing mode (audio/video/duplex)

$response["appmode"] = 1;

$response["status"] = 1;


header('Content-type: application/json');

echo json_encode($response);




When a user starts android broadcaster in website mode and attempts to connect to a domain, the application checks for the existence of this file on the server first. If found it loads url addresses and other settings from this file and then proceeds to next screen to show publishing options. The bootstrap file is used to help android broadcaster locate api resources on your web server.


POST params are optional to consider.












define( 'AMFSERVICE', "HawkEye" );

define( 'SERVICE', "service" );

define( 'AUTHENTICATE', "auth" );


$response["status"] = 0;

$aubroot = $aubconf['server'];

$response["authenticated"] = false;

$username = $_POST['username'];

$password = $_POST['password'];

$timestamp = $_POST['timestamp'];

$signature = $_POST['signature'];


// do authentication stuff with your database etc or set $response["authenticated"] = true; if you dont want to authenticate

if(1){// authenticate here and check inside if

$response["authenticated"] = true;

$response["status"] = 1;



header('Content-type: application/json');

echo json_encode($response);





After the bootsrap is successful, and user selects a publishing option such as audio/video mode, the application then attempts to authenticate the user on your server. In this process the user is presented with a prompt to enter username/password pair. This data is then sent to the android broadcaster gateway securely where it may be encrypted optionally and then sent back to your authentication url (authURL) on your server mentioned in bootstrap.


The application passes username and password in a regular POST array. You can use these values to authenticate the user against your own database and return a value based on success/failure.


$response["authenticated"] = true; indicates a successful authentication

$response["authenticated"] = false; indicates failed authentication












define( 'AMFSERVICE', "HawkEye" );


$aubroot = $aubconf['server'];


$encoderpresets_file = "encoderpresets.xml"; // presets file

$encoderpresets = simplexml_load_string(file_get_contents($encoderpresets_file));


$response["status"] = 0;

$username = $_POST['username'];

$password = $_POST['password'];

$timestamp = $_POST['timestamp'];

$signature = $_POST['signature'];


/* start authentication */

if(1){ // authenticate here and check inside if

$response["publishMode"] = 1; // 1 -> live broadcast, 0 -> record

$response["securecode"] = ""; // Not applicable

$response["destination"] = $aubconf['rtmp'];

$response["stream"] = ""; // stream name goes here

$response["playbackURL"] = ""; // rtmp playback url to share with others

$response["snapshotURL"] = $aubroot."/snapshot.php"; // url of snapshot collector

$response["encoderpresets"] = $encoderpresets;

$response["forceQuality"] = "QVGA MEDIUM"; // default quality to use from presets

$response["snapShotInterval"] = 0; // snapshot interval(how often to snapshot)

$response["status"] = 1;



header('Content-type: application/json');

echo json_encode($response);



Once the user has successfully authenticated on your server android broadcaster will request for publisher settings. The publisher url (publishURL) provides with necessary publishing settings, such as publishing point url, stream name, preset quality (label of a preset in encoderpresets.xml), snapshot interval (in seconds) etc. You can additionally authenticate here once more if you wish to (for deeper security).












define( 'AMFSERVICE', "HawkEye" );

define( 'CAPTURE_DIRECTORY', $aubconf['thumbs'].'/');


$response["status"] = 0;

$filename = $_REQUEST['stream'];

$snapshot = $_POST['snapshot'];

$username = $_POST['username'];

$password = $_POST['password'];

$snapshot = base64_decode($snapshot);



/* start authentication */

if(1) // authenticate here and check inside if


$thumb = $filename.".png";

$thumb_jpeg = $filename.".jpg";

$outputfile = CAPTURE_DIRECTORY.$thumb;

$jpeg_outputfile = CAPTURE_DIRECTORY.$thumb_jpeg;




pngToJpeg($outputfile, $jpeg_outputfile);





$response["status"] = 1;



header('Content-type: application/json');

echo json_encode($response);





function pngToJpeg($input_file, $output_file)


$input = imagecreatefrompng($input_file);

list($width, $height) = getimagesize($input_file);

$output = imagecreatetruecolor($width, $height);

$white = imagecolorallocate($output, 255, 255, 255);

imagefilledrectangle($output, 0, 0, $width, $height, $white);

imagecopy($output, $input, 0, 0, 0, 0, $width, $height);

imagejpeg($output, $output_file);





function generateThumb($img,$output,$w,$h)


$x = @getimagesize($img);

$sw = $x[0];

$sh = $x[1];


$im = @ImageCreateFromJPEG ($img) or $im = false;


if ($im) {

$thumb = @ImageCreateTrueColor ($w, $h);

@ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh);

@ImageJPEG ($thumb,$output,100);








While the user broadcasts live stream from his/her android device you may also want to show a thumbnail of the broadcast on your server. This is can be controlled by setting $response["snapShotInterval"] in publisher file to a non zero value, like 15 or 30. This will instruct android broadcaster to send camera snapshots to your server in 15 or 30 seconds interval. Snapshot is sent as base64 encoded data for easier integration. Most languages haver a base64 decoder to decode the data into image. The image is in png format and hence can be saved to server disk with a .png extension or can be converted to .jpg usign image processing libraries on server.


You can additionally authenticate user once again here for security concerns since content is being written to disk.