Java RTP/HTTP Streaming - java

i'm decoding and encoding a videofile via Xuggle to FLV-video format and send it via Sockets to my java server (not the entire file, only parts of it every X seconds). On the server-side I get the encoded file as ByteArrayInputStream. Is it possible to stream this ByteArrayInputStream via rtp or http-streaming? Or do i need a finished encoded file for that? I'm creating a video streaming server, where the client encodes the video file and sends it to the server in parts. This is already done. I'm now stuck on the server side, to stream the ByteArrayInputStream via RTP or HTTP, so I can watch it via VLC. Are there any good examples for it?
I've already tested to save the ByteArrayInputStream to file. This works but I don't wanna save the file on the server. I wanna stream it ;)
Thank you

1) See Server implementation
http://cs.anu.edu.au/student/comp3310/2004/Labs/lab6/lab5.html
2) http://code.google.com/p/vlcj/ and see http://code.google.com/p/vlcj/wiki/Streaming

Related

How does seek work in peerflix?

i was checking peerflix and it was really awesome that it support seek feature in videos.
i tried to understand how it works , i think it create a stream pipe on HTTP file server and write video data on it when a required piece is downloaded and the video player reads data from other end of pipe.
i tried to do this in java using Pipedinputstream and pipedoutputstream using nanohttpd server but cannot make it work.
is there something i am missing?
peerflix: it is a lib that stream torrent videos , you can watch videos with seek feature. you do not have to wait for the download to finish.
Peerflix selects the biggest file in the torrent or you can select one on your own. Then it begins downloading the file sequentially from the first piece. This file is served on a standard HTTP static file server.
When you seek in a video player, it checks the video container to find which bytes in the video file that corresponds to the given time stamp. The video player then sends a HTTP range request for the bytes corresponding to the video time plus some buffer. Then, Peerflix's HTTP server reads this range request and checks the .torrent file to find which piece corresponds to the requested bytes. It starts downloading sequentially from the requested piece onwards, and responds to the HTTP request when the requested bytes are available.

UDP Client Server File Transfer PDF

I am doing a project on UDP client server file transfer in which a client successfully reads a file and transfers it to the server. But this works only as long as the file is a .txt
Any suggestions on how to make it work for .pdf files also. Thanks in advance :)
I already implemented tcp and it works fine. I figured out that what I was converting the byte array to string and then writing to file and thus some error was occuring
I fixed it by directly writing byte array to file rather than first converting it to string. Thanks for the help. :)

Buffer Memory in a Client-Server Model

I am writing a basic client-server program where I send a file from the client to the server. I using a BufferedReader to upload the file from the client to the server, but I had a question about where it would exactly be stored on the server.
From my understanding, buffer memory is only temporary and doesn't necessarily save information. So how would I ensure that a file would be saved on the server? Thanks in advance.
BufferedReader doesn't store the whole stream in memory, just parts of the stream so you are aren't reading a byte at a time from I/O.
You'll need to read in the entire stream with BufferedReader, and store it in memory, assuming you have enough space, using something like StringBuilder, or store it on the server file system by using a FileWriter.

Store a file inside an object

I have a Java client/server desktop application, where the communication between client and server is based on Sockets, and the messages exchanged between client and server are serialized objects (message objects, that incapsulate requests and responses).
Now I need to make the client able to upload a file from the local computer to the server, but I can't send the File through the buffer, since the Buffer is already used for exchanging the message objects.
Should i open another stream to send the file, or is there any better way to upload a file for my situation?
I need to make the client able to upload a file from the local computer to the server
- Open a Solely Dedicated Connection to the Server for File uploading.
- Use File Transfer Protocol to ease your work, and moreover its quite easy and reliable to use the Apache's common lib for File uploading and downloading....
See this link:
http://commons.apache.org/net/
You really only have two options:
Open another connection dedicated to the file upload and send it through that.
Make a message object representing bits of a file being uploaded, and send the file in chunks via these message objects.
The former seems simpler & cleaner to me, requiring less overhead and less complicated code.
You can keep your solution and pass the file content as an object, for example as a String - use Base64 encoding (or similar) of the content if it contains troublesome characters

FIle transfer - XML based notifications and data exchange

I am playing around with Android Sockets and I currently I am trying to send a file via WiFi. I have a simple protocol that uses few notification classes. Everything works OK on Java client and Java server, but I want to do the same thing with C# (or C++) server/client and Java client/server. I need to decide how to serialize my notification data.
I was thinking about XML format. It would contain a notification ID, client ID and some data (i.ex. chunk of a file).
How can I save a chunk of a file (or any byte array) into a XML file (or text based file)?
Maybe I am thinking completely wrong way?
Run your data through a Base64 encoder and then stick that data into a CDATA section in your xml file. Apache makes a Base64 library for Java. I'm sure it wouldn't be too hard to find one for C#/C++.

Categories