Using The Nex Gen Media Server (NGMS) API To Integrate Video Streaming Into Your Own C/C++ App


Recently I took a better have a look at Nex Gen Media Server (NGMS) and their API framework. NGMS is a multi-purpose streaming server which helps among the in style streaming protocols corresponding to RTSP, RTMP, Apple’s HTTP Live, and MPEG-2 Transport Stream. NGMS comes with transcoding help and is ready to seize and reformat reside video streams and adapt them to be obtained by one other kind of system, corresponding to capturing an HD video feed and changing it to be obtained by an iPhone over 3g. My focus was to combine the NGMS API to regulate the streaming options instantly from my very own C software. In this instance I’m utilizing Ubuntu Linux 10.04.

The very first thing is to obtain and browse the NGMS User Guide and the API reference information for Nex Gen Media Server. (These hyperlinks are positioned on the backside of the article) There are many configuration choices in there however we are going to simply stick with the fundamentals. Then you should obtain the NGMS bundle for linux. The model I used was NGMS v1.3.4. Once you obtain the bundle simply unzip the contents right into a listing of your alternative. I used ~/ngmsStreaming

Setting up the appliance.

To combine NGMS instantly into my C software I needed to embrace “ngms/include/ngmslib.h” into my code.

When constructing my software I needed to embrace the libraries ngms/lib/ and ngms/lib/ It appears that additionally relies on, which must be specified within the linker choices.

Here is the straightforward makefile that I’m utilizing:

#Example Makefile



INCLUDES+= -I ngms/embrace

LDFLAGS+= -L ngms/lib -lngms -xlcode -crypto

all: myapp

%.o: %.c

$(CC) $(CFLAGS) $(INCLUDES) -o [email protected] -c $<

myapp: myapp.o

$(CC) -fpic -o myapp myapp.o $(LDFLAGS)

Here is the supply to myapp.c.



* Example myapp software



typedef unsigned int uint32_t;

typedef unsigned lengthy lengthy uint64_t;

#embrace “ngmslib.h”

int predominant(int argc, char *argv[]) {


NGMS_RC_T returnCode;

returnCode = ngmslib_open(&ngmsConfig);

if(NGMS_RC_OK!= returnCode) {

fprintf(stderr, “ngmslib_open failedn”);

return -1;


ngmsConfig.inputs[0] = “mediaTestFile.mp4”;

ngmsConfig.output = “rtp://”;

returnCode = ngmslib_stream(&ngmsConfig);

if(NGMS_RC_OK!= returnCode) {

fprintf(stderr, “ngmslib_open failedn”);



return 0;


The above code makes use of the NGMSLIB_STREAM_PARAMS_T struct kind to regulate the ngms library. The very first thing that must be performed is a name to ngmslib_open to “preset” the struct. After that you could fill out any of the choices within the struct to regulate what NGMS will do. Then you’ll be able to “ngmslib_stream” to create the output video.

I’m in a position to open the stream in VLC participant and play the video.

VLC Player -> Open Network rtp://@:5004

Viola! It was that simple!!! I can now stream a media file instantly from my software!

Since the ngmslib_stream perform name is a blocking operation, to interrupt the stream I can name ngmslib_close from one other thread and the ngmslib_stream name will exit.

I used to be ready so as to add help for an embedded Flash participant by including the next strains of code.

ngmsConfig.rtmplive = “1935”;

ngmsConfig.reside = “8080”;

With my browser I hook up with localhost:8080/reside and I get again a web page with flash participant taking part in the video.

Instead of taking part in a file I can change the enter to be a reside video stream. I can create two separate cases of my software. One occasion will output the video to port 5006. The different occasion will seize the video on port 5006, and output it to port 5004. This is all you need to do.

//ngmsConfig.inputs[0] = “mediaTestFile.mp4”;

ngmsConfig.inputs[0] = “rtp://”;

ngmsConfig.strfilters[0] = “type=m2t”;


These few examples present its fairly simple so as to add video streaming help into your individual software. I’ve used C right here. If your software is C++ you’ll be able to wrap all of the calls to ngmslib utilizing the “extern “C” ” key phrase. You might additionally do it in Java however it could required constructing a JNI interface to wrap every of the calls all the way down to NGMS.

This was a fairly easy instance. In the close to future I’ll go over how the NGMS library can be utilized to construct your individual video streaming shopper.

Using The Nex Gen Media Server (NGMS) API To Integrate Video Streaming Into Your Own C/C++ App

Your Opinion Matters

Quality - 10


Total Score

Your feedback is important to us to improve our services. We constantly seek feedback to improve and evolve our service, whilst identifying opportunities to assist clients in realising their business objectives.

User Rating: 4.33 ( 3 votes)

Show More

Patricia Bakely

Earn Free Bitcoin Online with

Related Articles

Leave a Reply

Back to top button