How to get started implementing a video streaming server in c/c++? - c++

In my project I need a dedicated server that dispatches the streams over to multiple clients.
More specificly, I've a callback function that gets called to gather the stream data, but no idea how to stream it over to other applications.
What's the best way to get started on this ?

What type of video are you planning to stream?
There's an open source library called liveMedia available at http://www.live555.com. This c++ library is available under LGPL and implements the RTSP, RTP/RTCP protocols and payload formats for many different media types. There is a class called DeviceSource IIRC that facilitates getting data into the library. There is an active mailing list and you should be able to find lots of information by searching the archives.
There are also a bunch of example test projects that illustrate how to stream mpeg, mp3, etc.
Should you choose to use standardized protocols, you might want to read up on RTP and RTSP.

I think you should check communication through network sockets.
There is no network concept in C++, so you have to rely on your system API or libraries ( as boost.asio for instance )

Related

Easiest way to control USB TMC device on Windows/C++

I am developing C++/Qt application which interacts with Tektronix TDS2002 oscilloscope via USB. The oscilloscope appears as "USB Test and Measurement device (IVI)".
Currently I use TekVISA library supplied by the oscilloscope's vendor. It works, but it is huge, old, buggy and poorly maintained. Therefore I would like to bypass the library and interface the device directly.
So far I have found this simple library: https://github.com/xyphro/WinUsbTmc It is exactly what I am looking for, but it uses libusb which requires to install some device filter and in addition it is advised to be more development tool than customer solution. Do you have any experience on this?
What is the easiest way to interact with USB Test and Measurement device in Windows/C++/Qt?
Thank you for your suggestions :)
You need a USB driver. My oscilloscope works with the driver included in this VISA package (the driver can be extracted very easily): http://www.keysight.com/main/software.jspx?cc=CZ&lc=eng&nid=-11143.0.00&id=2504667&pageMode=CV I assume all USB TMC devices can use the same driver, but I have no possibility to check this.
USB driver can be accessed via standard Windows functions. Guys on this forum were really close:
https://forum.tek.com/viewtopic.php?f=568&t=137573 and also this document was very useful: http://www.ivifoundation.org/downloads/Class%20Specifications/Ivi-6%202_USBTMC_2010-03-23.doc
You cannot write commands to OSC directly - data you send and receive have certain header which has to be in the correct format, otherwise the oscilloscope ignores the message. See reading and writting implementation in this simple library: https://github.com/xyphro/WinUsbTmc I didn't use this library because it uses libusb library which uses some kind of device filter and I personally do not like this concept (and in addition I have genuine working driver).
Data you read have also a simple header. To ensure you fit the header structure on input data well, you should first flush the input buffer. Then you issue reading request (using write command - see WinUsbTmc library above) and finally you receive the data and fit the header on its beginning.
I hope this will help to somebody :)
With regards
klasyc

How to live stream a video in C++ [duplicate]

In my project I need a dedicated server that dispatches the streams over to multiple clients.
More specificly, I've a callback function that gets called to gather the stream data, but no idea how to stream it over to other applications.
What's the best way to get started on this ?
What type of video are you planning to stream?
There's an open source library called liveMedia available at http://www.live555.com. This c++ library is available under LGPL and implements the RTSP, RTP/RTCP protocols and payload formats for many different media types. There is a class called DeviceSource IIRC that facilitates getting data into the library. There is an active mailing list and you should be able to find lots of information by searching the archives.
There are also a bunch of example test projects that illustrate how to stream mpeg, mp3, etc.
Should you choose to use standardized protocols, you might want to read up on RTP and RTSP.
I think you should check communication through network sockets.
There is no network concept in C++, so you have to rely on your system API or libraries ( as boost.asio for instance )

Reliable Multicast over local network

I am implementing a messaging system using C++ and Qt. After much thought, I have determined that multicasting or a multicast-style technique will work best to solve my problem. However, I have learned about UDP's unreliability and believe it to be unacceptable.
My requirements are as follows:
Messages are to be sent in a binary serialized form.
From any given node on the network, I must be able to send messages to the other nodes.
Message delivery must be insured.
I have heard of OpenPGM and NORM as alternatives for UDP. If anyone has experience with either of these, could you please share?
I am also open to the possibility of implementing "reliable" multicast by myself, in the application layer, but I would prefer not to if there is a library that already implements this.
I am using C++ and Qt, therefore .NET or Java-based solutions are not acceptable unless they are open-source and I may port them to C++.
Thank you very much.
EDIT 20120816T1853 MDT: An additional question: would either PGM or NORM have to be implemented at the hardware/IP level? Or can they be overlayed on top of existing protocols?
We have implemented our own reliable multicast protocol over UDP called RSP, since we needed something cross-platform and at the time couldn't find a good solution between Linux and Windows. The Windows PGM implementation disconnects slow clients which leave the send window, whereas our implementation throttles the sender similar to TCP. Afaik OpenPGM can be configured to do the same.
The open source NORM at http://cs.itd.nrl.navy.mil/work/norm can be built as a library and has C++ API with Python and Java language bindings. If you ping the developer (me) via the mailing list, I can help get you started.
There is a large RFC division of reliable multicast protocols, and many implementations out there. It's a long time since I looked at this but there are TRAM, LRMP, ...

C++ socket programming, multicast with compression, any good libraries/wrappers?

I am beginning to get into socket programming. Currently, I am transferring data between server and clients using scp which scales very poorly when dealing with streams of data (it seems like each new scp session needs to open a new TCP connection and this really slows down the speed).
I would like to transfer text to multiple clients, over a day, this text could reach a couple gigabytes in size so implementing some sort of compression is key.
Can anybody recommend some good libraries or wrappers which can simplify writing this code? The standard C++ sockets interface is quite cumbersome to work with. So far, my only lead is Boost ASIO but that doesn't seem to have compression capabilities. Any suggestions would be much appreciated.
For the compression part, you can use zlib. There are many C++ interfaces out there for zlib, or you can use it directly to compress and decompress messages.
try UDT.
UDT is a reliable UDP based application level data transport protocol for distributed data intensive applications over wide area high-speed networks. UDT uses UDP to transfer bulk data with its own reliability control and congestion control mechanisms.
I dont really know if the compression is available ...
Compression and multicast are two orthogonal issues. As said by previous posters, pick a compression library best suited for your data.
For multicast there are multiple options, OpenPGM and RSP are open source.

How to create simple http server with boost capable of receiving data editing it and sharing?

So using any free opensource cross platform library like boost how to create a web service capable of reciving a data stream (for example stream of mp3 frames) on one URL like http://adress:port/service1/write/ and capable of sharing latest recived data to all consumers on http://adress:port/service1/read/ so of course mp3 is just an example of packed stream-able data - generally it can be anything packed. How to create such thing?
Generaly I am honesly triing to understend how to do such thing with C++ Network Library but it is just quite unclear to me.
The boost::asio documentation has four examples of complete HTTP server implementations, each with a slightly different threading architecture.
http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/examples.html
You do not say what platform to use, but if Windows is an alternative, the Windows HTTP API easy to use and a great performer.
http://msdn.microsoft.com/en-us/library/aa364510(VS.85).aspx