40 int ret,
n, reply_code;
46 if (resource && strlen(resource))
53 if (resource && resource[0] ==
'/' && !strcmp((resource + 1), in_uri)) {
69 fprintf(stderr,
"Handshake performed.\n");
70 if (reply_code != 200)
72 fprintf(stderr,
"Opening input file.\n");
91 fprintf(stderr,
"Flushing client\n");
93 fprintf(stderr,
"Closing client\n");
95 fprintf(stderr,
"Closing input\n");
100 int main(
int argc,
char **argv)
104 const char *in_uri, *out_uri;
108 printf(
"usage: %s input http://hostname[:port]\n" 109 "API example program to serve http to multiple clients.\n" 119 if ((ret =
av_dict_set(&options,
"listen",
"2", 0)) < 0) {
120 fprintf(stderr,
"Failed to set listen mode for server: %s\n",
av_err2str(ret));
124 fprintf(stderr,
"Failed to open server: %s\n",
av_err2str(ret));
127 fprintf(stderr,
"Entering main loop.\n");
131 fprintf(stderr,
"Accepted client, forking process.\n");
136 perror(
"Fork failed");
141 fprintf(stderr,
"In child.\n");
152 fprintf(stderr,
"Some errors occurred: %s\n",
av_err2str(ret));
int main(int argc, char **argv)
void av_log_set_level(int level)
Set the log level.
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
#define AVERROR_HTTP_NOT_FOUND
int avio_accept(AVIOContext *s, AVIOContext **c)
Accept and allocate a client context on a server context.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
int avformat_network_init(void)
Do global initialization of network libraries.
#define AVERROR_EOF
End of file.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void process_client(AVIOContext *client, const char *in_uri)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int avio_handshake(AVIOContext *c)
Perform one step of the protocol handshake to accept a new client.
const OptionDef options[]
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)