For an academic project, we are streaming encoded media from
server to client and decoding on the client. The stream is
sent through a network virtual channel(RDP) and received on client.
We wish to use avifile library to decode while it is being
received, and render.
We treat the program receiving the network stream as server and create a
serversocket. As the client (decoding thread) connects to it, open a stream
using fdopen() on the socket descriptor and fwrite() into it.
Could av_open_input_file() with tcp url of the server(receiving program)
be used to connect, open and decode on the client program?
The code will be like this:
Receiving program (Server):
Media_process(STREAM s)
{
create serversocket;
bind(); // localhost, some-port
listen();
sock = accept();
fp = fdopen(sock, "wb");
fwrite(s->data, ...,fp);
.....
}
Decoding thread (Client):
{
AVFormatContext *ic;
av_open_input_file(&ic, "tcp:localhost
ort", NULL, 0, NULL);
decode();
render();
}
We have tried to follow the source code of avifile library since we
couldnt find
any documentation or sample code about usage. Seems like tcp url will invoke
tcp_open() and corresponding read() functions. But it doesnt seem to work.
How do we link the decoding program with the received stream? What is the way
to handle this requirement? Would greatly appreciate any help and pointers or
some example code.