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