HLS from raspberry pi to mobile (Android or iOS) through server - android

I'm trying to make a live stream from raspberry to Android through the internet.
I searched through the web and I'm actually able to stream from the raspberry, and read the stream from mobile when the mobile is directly connected to the raspberry.
But if I want to make it online, there is something I'm missing on how to "pipe" this stream through another server.
So mainly I want to check how to post the stream to a server, and how to retrieve it from a mobile in realtime.
I already checked the following :
Http Live Streaming with the Apache web server
https://raspberrypi.stackexchange.com/questions/7446/how-can-i-stream-h-264-video-from-the-raspberry-pi-camera-module-via-a-web-serve
https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/

You have to forward your port to an external port on a web server.
There are some tutorials which you able to find them by this keywords:
raspberry pi streaming port forwarding tutorial
Some of the useful links are:
https://www.raspberrypi.org/forums/viewtopic.php?t=56149
https://iot.stackexchange.com/a/1562
https://raspberrypi.stackexchange.com/questions/53954/how-to-connect-to-raspberry-pi-outside-of-local-network-without-port-forwarding
https://raspberrypi.stackexchange.com/a/71493
Especially these:
https://jacobsalmela.com/2014/05/31/raspberry-pi-webcam-using-mjpg-streamer-over-internet/
https://videos.cctvcamerapros.com/raspberry-pi/ip-camera-raspberry-pi-youtube-live-video-streaming-server.html

Related

Android how to transfer real-time stream videos to a node js server

I'm an android developer but a noob in nodejs.I want to create a live radio appliction so I use android to create the client app and nodejs to create the server.
Step:
Android : MediaRecord to record video and transfer to nodejs server.
Nodejs server : Receive the stream and transfer it to another clients or save it in the database.
I read the MediaRecord apis and found the native way to send stream videos to server.
Socket socket = new Socket(“xxx.xxx.x.xxx”, 8890);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
MediaRecorder.setOutputFile(pfd.getFileDescriptor());
But it the NATIVE socket. NOT suit for nodejs server.
I use the Socket.io to establish the socket server and the socket.io-client in android client to connect to the socket server. But it doesn't support to transfer the stream video info from android to server. Then I found socket.io-stream. It supports to transfer the stream info but no any android api. So I want to know what should I do or what should I use to transfer stream videos from Android to a nodejs server? Do I need to estabilsh my own nodejs socket libs to finish this work?
Any help will be appreciated. Thanks anyway.

Playing sdp file (rtsp stream) from http url in android

I have a rtsp stream on my rtsp server in localhost.
I would to play this file with the android class MediaPlayer.
If I do setDataSource(rtsp://localhost/file.sdp) it works!!
My problem is... if I copy the file on my http server and I do
setDataSource(http://localhost/file.sdp)
it does not work!! I receive an I/O exception.
filePath = "http://localhost/file.sdp";
mediaPlayer.setDataSource(filePath);
mediaPlayer.prepare();
mediaPlayer.start();
If I play this file with vlc application it works.
RTSP and HTTP are different protocols. An HTTP server is not going to serve the data in the same way. It's going to send HTTP headers, etc. VLC may be somehow smart enough to infer the protocol based on the data it receives, but Android's NuPlayer is probably not so sophisticated.
RTSP "Real Time Streaming Protocol" is for streaming media server. You can watch live video broadcasting from remote server on your computer/mobile device through RTSP protocol. This protocol only handle playback of media files. Below are some features of RTSP:
This works on TCP connection
RTSP requests are all sent on the same TCP connection
This protocol has very less end-to-end delay
This is also called "true streaming"
No file is downloaded to user's system
Play movie in real time
Can do live broadcast
Some firewall blocks this protocol on user's machine
HTTP "Hypertext Transfer Protocol" is for transferring files (text, graphic images, sound, video, and other multimedia files) on the World Wide Web. HTTP protocol communicate between Web pages (Contain text, graphic images, sound, video and other multimedia) hosted on remote server and the user's browsers on their system. We can watch streaming video through HTTP protocol. Below are some features of HTTP:
This works on TCP connection
HTTP will typically send each request on a separate TCP
This protocol has high end-to-end delay as compared to RTSP
Serve content from standard web server
This support progressive download from a web server
File is downloaded to user's system but can start playing before completely downloaded
This works on all firewall because it uses standard HTTP protocol
SDP "Session Description Protocol" consists of a set of communications end points along with a series of interactions among them. SDP contains information about streaming media. It contains mainly three parts about media - Session description, Time description and Media description. SDP not itself is a file type but it is a protocol and responsible for steaming media. HTTP and RTSP both support SDP.

Client Server Programming In Unity using JavaScript

I'm new to Network programming in Unity3D and basically I would like to make a connection between two android devices, through WiFi using the Client Server Model. And I have some questions.. such as
How it is possible to make a server with a specific IP Address?
How can I make a client, who will connect to that server?
How can I transfer messages between client(s) and server?
Any help would be appreciated..
.......
I have write this simple code...
function OnGUI()
{
if(GUILayout.Button(" Initlized server"))
{
Network.InitializeServer(32,25001,false);
Debug.Log("Server has been Initlized");
}
if(GUILayout.Button("connect to server"))
{
Network.Connect("127.0.0.1",25001);
}
}
function OnConnectedToServer() {
Debug.Log("Connected to server");
// Send local player name to server ...
}
I have write this simple code but OnConnectedToServer doesnot give me any responce...
How it is possible to make a server with a specific IP Address?
For the IP address part, you will need a static IP. If you are behind a router, that means you will have to first ensure your ISP gives you a static IP. If they don't, you should try a service such as FreeDNS, which will route your dynamic IP to a web address. You will then need to port forward the specific ports to the server, which should have a static local IP for easy port forwarding.
As for the code itself, I would highly recommend you take a look at THIS website. It has great video tutorials on making a client-server game using Unity's built in networking.
http://www.gamertogamedeveloper.com/
As for your code, you don't state how you run that code. You SHOULD NOT have the client and server being run in the SAME instance. What you need to do to test this is run the Server inside the Unity3d debugger then build the client and run it as a standalone app.
Raknet seems interesting,
have a look here:
RakNet
unity-Raknet

detect mobile phone by web server

I would like to know what field within the http packet which was sent by client browser to WEB server can i look to detect whether the request was made from mobile device or from a PC.
My web server is open source which uses C programming language and runs a TCP socket and listens on HTTP port.
Can anyone please let me know.
You need to see for HTTP header called "User-Agent". The value of this will help you determine where the request was made from.
For further details you can check this answer: Auto detect mobile browser (via user-agent?)

Playing Live RTP streams on android

I am trying to build a client on android that will receive RTP streams and play it.
I have searched on stackoverflow and Google, and found that MediaPlayer class can be used for this. But the MediaPlayer is used when a URL or a file is used as data source.
In my scenario, my streaming server send RTP streams on a particular port of my client.
So, is there any way to play MediaPlayer to play this stream without writing it into a file.
Have you tried it out?
Your 'data source' for MediaPLayer is your rtsp link - rtsp://127.0.0.0:550/mystream.3gp
I have done this with a VideoView, MediaPlayer is jsut an abstraction of this, so it shouldn't be too different.
The MedaiPlayer will parse the rtsp url and start the Android RTSPEngine which will communicate with the RTP Server an establish the relevants ports to transfer the data.
The method described above works - you need to supply the rtsp link (you likely won't need the port since RTSP defaults to port 554, not 550).
rtsp://se.rv.er.ip/mystream
Essentially an RTSP conversation occurs between the client and server (DESCRIBE, SETUP, PLAY) which will contain the information a .sdp file for an RTP broadcast would have.
You cannot receive an RTP stream unless the server sending it supports RTSP.
If you need more details, I'd recommend just running wireshark on a streaming client or server. I found that helped supplement reading the RFCs.
Good luck!

Categories

Resources