How to start RTP stream inside a SIP/SDP call - java

I've managed to set up a SIP call using the JAIN-SIP API for Java.
Now I would like to stream some video once a dialog has been established. I've read that this is possible with SDP and RTP, and I've found multiple examples on how to define a SDP/RTP body in a SIP packet.
But once you have negotiated capability etc. on nodes, how do you actually start the RTP stream? Do you start an RTP streaming server outside or inside your Java application? If so, how? What is the link?
In what I'm able to find online, nodes just "start exchanging RTP packets".
Thank you.

You need an RTP stack. As you are starting out, it would be best to keep everything together in the same app. JMF(Java Media Framework),(JMF-RTP Architecture) is a good place to start, though there are others like JRTP. JMF video specifics can be found here

Try to search on keyword "re-INVITE" and appropriate examples.
As soon as you found yourself in need of another audio / video stream into existing SIP call with already established media you need to start new INVITE / OK / ACK sequence.
New streams could replace your existing media streams or could be added. It's your choice and this depends on signalling. Of course you need RTP stack with capability / codecs supported to satisfy your actual needs.
People often implement this to handle T.38 fax switching inside SIP calls. You can obtain required reference logs dumping call from device which supports T.38 (or actually having any modem over IP support). Remember your voice streams should be LBR (low bit rate) codecs such as G.729 or G.723.1. This could bring you with many answers at least 'when' to start RTP and how to signal this. At least initiating INVITE with proposed new RTP stream you should be ready to receive this stream right from the start. You can start sending RTP after OK with proposed ports 'where' to send RTP.

Related

Modern way of displaying RTSP H264 stream in a browser (HTML5)

Yes, this topic keeps popping up from time to time also here on SO.
I've read a lot about this topic and also tried some solutions but I have some constraints:
browser-independency (most browsers should work)
platform-independent (major platforms should be supported)
work out-of-the-box (no plugins!)
low latency (preferred under 1 sec)
bandwidth is limited (MJPEG is not an option)
no transcode!
So going forward: an H264 stream seems perfect for constraints 1 and 2.
Also my source produce a live H264 (to be exact: MPEG-4 AVC, part 10) into an RTSP container.
But RTSP is still not supported in browser.
What I've checked:
How to embed streaming rtsp media into an html5 page
How can I display an RTSP video stream in a web page?
stream RTSP to HTML website
Displaying RTSP on website
stream RTSP to HTML website
How to get RTSP stream over web application
RTSP solution for JavaScript/HTML5
Streaming via RTSP or RTP in HTML5
All the posts above are related to this question, and a lot of valuable information was there.
Also I've read a very good article from 2014 (!) which is detailed and quite forward-looking.
So, as of today, the best solution would be this:
parse the RTSP and extract the h264 stream
restructure the stream (convert it to fragmented MP4)
websocket (see later)
fMP4 can be easily played by HTML5 video if the browser has the MSE (alternative is to use broadway.js that is cool but CPU intensive)
There are solutions where the step 1 and 2 happens on server side, then the fMP4 is pushed into a websocket. The client consumes the data from websocket and pass it to MSE components for displaying.
The article from 2014 shows that step2 can also happen on client side. In this case only step 1 happens on the server, then h264 is pushed into the websocket, and on the client side there is the restructuring and displaying of course.
Streamedian seemed a good solution for the first sight, but they doesn't publish their server side codes, and also their site returned with 502 error for a day.
I don't want to use GStreamer or ffmpeg, they are both too heavy.
However there are nice items which can help:
MP4Box.js - segment an MP4 file for use with the Media Source Extension API
mux.js - inspection and manipulation tools for video files
Going back to my list, step2 can be done with MP4Box - at least I believe / hope.
Step3 and step4 are straightforward, there are tons of howtos on these ones.
However I'm a bit puzzled with step1. It shall be done on server side, preferably in a language which can interact with websockets easily (like java).
That is the point of my question: I need to extract the h264 stream from RTSP in java, how can I do it simple but without calling external programs?
How about use WebCodecs API to decode H.264 packages in browser?
This API will take benefit of hardware acceleration offered by modern browser.
Btw, in my opinion, the delay is mainly occurred in the process of decoding.

How to stream a scheduled playlist of video files

I'm looking for a way or a streaming server that allows streaming a list of local video files to multiple receivers, and all the receivers are synced, so they will all see the same video output at the same time.
I am not focused on a specific programming language or framework, I know there is a way of doing it in Actionscript & FMS , but since Flash is dying I'm not considering it a solution.
I suspect that by local video files you actually mean some files hosted on a server. Instead of WebRTC, which is peer-to-peer you'll better be using a media stream server and create some kind of "live" stream for all those files, so that the receivers are synced.
On the client side, just use the video tag with the appropriate URL.

How to stream server webcam to servlet

I want to show in my servlet the webcam connected to the server, I read in many sites that I may use getUserMedia(); but that only gets the video webcam on the user, and not on the server.
How can I do that? My servlet is programmed in Javascript
First, I heavily doubt that your servlet is written in JavaScript. Are you sure we aren't talking of Java?
What you describe sound like you want to do a live stream of your webcam. Compared to video on demand, this is a demanding task and needs quite some knowledge and experience.
We are not talking of streaming from one point to the other ("unicast streaming"), but a multicast stream where somebody would open a web site and connect to the stream. In order to do that, you have to send the video stream of your webcam to a multicaster, encoded in a way suitable for the intended audience. So what basically happens ist that you capture the video data of your webcam, encode it to a format capable of being streamed, send it to a multicaster which copies the stream to every client that connects to that multicaster. This client can either be a stand alone media player such as Quicktime, VLC or WMP or a player embedded into a website.
So in short and a bit more specific, you have to do the following:
Capture the output of the webcam and encode it according to your intended audience. VLC is a good tool for that.
Set up a multicaster such as the excellent Darwin Streaming Server to which you send the stream to. This server has to be publicly accessible.
Create a link to the stream's description file (rdp file) usually generated by the Darwin Streaming Server. This will connect the client to the stream. An alternative may be a player embedded to your website, which basically is your choice.
Doing this right is not only programmers work, but a lot of sysadmin work, too. You have to do some bandwidth and capacity planning, optimizing the encoder, choosing the right codec and much, much more. All those choices are heavily influenced by the type and size of your intended audience, the purpose of the stream and a lot more.

Use image as video stream while recording on media server

I'm creating application where user can record voice message, problem is that recorded file is passed to other encoding servers, that requires both video and audio streams to be present.
So my question is how can I use static image to emulate webcam and attach it to NetStream?
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, watchRecording);
//ns.attachCamera(cam);
ns.attachAudio(mic);
ns.publish(fileName.text, "record");
[+]
Although I don't have access to application on WOWZA server I can negotiate with some one to add few lines and recompile it. So server-side solution in java is also an option here.
I'd recommend you use a server side solution, as creating a client side solution would involve sending more packets than is actually needed. Plus, I'm sure Java has better tools to emulate 'video'.

Stream relay with Red5 Media Server

I write an (Java-) application that streams a video from one peer to another. I use a library that is able to produce and consume an RTP stream (Xuggler that is). I thought about using Red5 Media Server to relay the stream. What I need next is to send and my video stream.
The documentation I read so far always deals with recording streams or streaming prerecorded videos (and of course the web cam). Also there is quiet some amount of Actionscript code that does not help me at the time. (I belief...)
So my question is: Can Red5 help me? (I.e. should I continue reading or is there another - more direct - solution?) Could you please give me some pointer where I would find suitable documentation?
Red5 is primarily for streaming to Flash clients over RTMP,RTMPT,RTMPS etc. It is not limited to these protocols, but they are the ones available "out of the box". If you want to run xuggler inside red5 to consume RTP and then publish to RTMP then you are in luck as this is very ez to do. If you want to republish as RTP, you have some additional work cut out for you.

Categories

Resources