Commit 8d04070b authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

Add support for http, https, and file URLs.

This is pretty preliminary for now.
Seeking performance isn't great, and there's no caching.
I'm sure there's also lots of bugs.
parent f4c72321
......@@ -38,19 +38,23 @@ int main(int _argc,const char **_argv){
OpusFileCallbacks cb={NULL,NULL,NULL,NULL};
of=op_open_callbacks(op_fdopen(&cb,fileno(stdin),"rb"),&cb,NULL,0,&ret);
}
#if 0
/*For debugging: force a file to not be seekable.*/
else{
OpusFileCallbacks cb={NULL,NULL,NULL,NULL};
void *fp;
fp=op_fopen(&cb,_argv[1],"rb");
cb.seek=NULL;
cb.tell=NULL;
of=op_open_callbacks(fp,&cb,NULL,0,NULL);
}
/*Try to treat the argument as a URL.*/
of=op_open_url(_argv[1],OP_SSL_SKIP_CERTIFICATE_CHECK,&ret);
#if 0
if(of==NULL){
OpusFileCallbacks cb={NULL,NULL,NULL,NULL};
void *fp;
/*For debugging: force a file to not be seekable.*/
fp=op_fopen(&cb,_argv[1],"rb");
cb.seek=NULL;
cb.tell=NULL;
of=op_open_callbacks(fp,&cb,NULL,0,NULL);
}
#else
else of=op_open_file(_argv[1],&ret);
if(of==NULL)of=op_open_file(_argv[1],&ret);
#endif
}
if(of==NULL){
fprintf(stderr,"Failed to open file '%s': %i\n",_argv[1],ret);
return EXIT_FAILURE;
......
This diff is collapsed.
This diff is collapsed.
......@@ -1259,6 +1259,20 @@ OggOpusFile *op_open_memory(const unsigned char *_data,size_t _size,
_error);
}
OggOpusFile *op_open_url(const char *_url,int _flags,int *_error){
OpusFileCallbacks cb;
return op_open_close_on_failure(
op_url_stream_create(&cb,_url,_flags),&cb,_error);
}
OggOpusFile *op_open_url_with_proxy(const char *_url,int _flags,
const char *_proxy_host,unsigned _proxy_port,
const char *_proxy_user,const char *_proxy_pass,int *_error){
OpusFileCallbacks cb;
return op_open_close_on_failure(op_url_stream_create_with_proxy(&cb,_url,
_flags,_proxy_host,_proxy_port,_proxy_pass,_proxy_user),&cb,_error);
}
/*Convenience routine to clean up from failure for the open functions that
create their own streams.*/
static OggOpusFile *op_test_close_on_failure(void *_source,
......@@ -1285,6 +1299,20 @@ OggOpusFile *op_test_memory(const unsigned char *_data,size_t _size,
_error);
}
OggOpusFile *op_test_url(const char *_url,int _flags,int *_error){
OpusFileCallbacks cb;
return op_test_close_on_failure(
op_url_stream_create(&cb,_url,_flags),&cb,_error);
}
OggOpusFile *op_test_url_with_proxy(const char *_url,int _flags,
const char *_proxy_host,unsigned _proxy_port,
const char *_proxy_user,const char *_proxy_pass,int *_error){
OpusFileCallbacks cb;
return op_test_close_on_failure(op_url_stream_create_with_proxy(&cb,_url,
_flags,_proxy_host,_proxy_port,_proxy_pass,_proxy_user),&cb,_error);
}
int op_test_open(OggOpusFile *_of){
int ret;
if(OP_UNLIKELY(_of->ready_state!=OP_PARTOPEN))return OP_EINVAL;
......
......@@ -13,25 +13,36 @@ FOO_TARGET = foo
# The command to use to generate dependency information
MAKEDEPEND = ${CC} -MM
#MAKEDEPEND = makedepend -f- -Y --
# The location of include files.
# Modify these to point to your Ogg and Vorbis include directories if they are
# not installed in a standard location.
CINCLUDE = `pkg-config --cflags ogg opus`
# These are gcc-only, but not actually critical.
# Optional features to enable
#CFLAGS := $(CFLAGS) -DOP_HAVE_LRINTF
CFLAGS := $(CFLAGS) -DOP_ENABLE_HTTP
# Extra compilation flags.
# You may get speed increases by including flags such as -O2 or -O3 or
# -ffast-math, or additional flags, depending on your system and compiler.
# The -g flag will generally include debugging information.
CFLAGS := -g $(CFLAGS)
CFLAGS := -DOP_ENABLE_ASSERTIONS $(CFLAGS)
# These are gcc-only, but not actually critical.
CFLAGS := -fPIC $(CFLAGS)
CFLAGS := -std=c89 -pedantic $(CFLAGS)
CFLAGS := -fvisibility=hidden $(CFLAGS)
CFLAGS := -Wextra -Wno-parentheses -Wno-long-long $(CFLAGS)
CFLAGS := -Wall $(CFLAGS)
# The list of pkg-config packages we depend on.
PACKAGES := ogg opus
ifeq ($(findstring -DOP_ENABLE_HTTP,${CFLAGS}),-DOP_ENABLE_HTTP)
PACKAGES += openssl
endif
# The location of include files.
# Modify these to point to your Ogg and Vorbis include directories if they are
# not installed in a standard location.
CINCLUDE := `pkg-config --cflags ${PACKAGES}`
# Libraries to link with, and the location of library files.
LIBS = `pkg-config --libs ogg opus`
LIBS := `pkg-config --libs ${PACKAGES}`
ifeq ($(findstring -DOP_HAVE_LRINTF,${CFLAGS}),-DOP_HAVE_LRINTF)
LIBS := -lm $(LIBS)
endif
#TODO: tests
FOO_LIBS =
......@@ -45,6 +56,7 @@ WORKDIR = objs
# C source file lists
LIBOPUSFILE_CSOURCES = \
http.c \
info.c \
internal.c \
opusfile.c \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment