This example will serve a file without decoding or demuxing it over http.Multiple clients can connect and will receive the same file.
#include <unistd.h>
{
if (resource && strlen(resource))
break;
}
if (ret < 0)
if (resource && resource[0] == '/' && !strcmp((resource + 1), in_uri)) {
reply_code = 200;
} else {
}
}
if (ret < 0)
fprintf(stderr, "Handshake performed.\n");
if (reply_code != 200)
fprintf(stderr, "Opening input file.\n");
}
for(;;) {
if (n < 0) {
break;
break;
}
}
fprintf(stderr, "Flushing client\n");
fprintf(stderr, "Closing client\n");
fprintf(stderr, "Closing input\n");
}
int main(
int argc,
char **argv)
{
const char *in_uri, *out_uri;
int ret, pid;
if (argc < 3) {
printf("usage: %s input http://hostname[:port]\n"
"API example program to serve http to multiple clients.\n"
"\n", argv[0]);
return 1;
}
in_uri = argv[1];
out_uri = argv[2];
if ((ret =
av_dict_set(&options,
"listen",
"2", 0)) < 0) {
fprintf(stderr,
"Failed to set listen mode for server: %s\n",
av_err2str(ret));
return ret;
}
fprintf(stderr,
"Failed to open server: %s\n",
av_err2str(ret));
return ret;
}
fprintf(stderr, "Entering main loop.\n");
for(;;) {
fprintf(stderr, "Accepted client, forking process.\n");
pid = fork();
if (pid < 0) {
perror("Fork failed");
}
if (pid == 0) {
fprintf(stderr, "In child.\n");
exit(0);
}
if (pid > 0)
}
fprintf(stderr,
"Some errors occurred: %s\n",
av_err2str(ret));
return 1;
}
return 0;
}