ref: 6769586029891c240afe04dec96f7c554e3803bd
parent: ae15c6395dace8a3b0a9c4d798e28eb3b3e1e8ad
author: Paul Brossier <piem@piem.org>
date: Thu Jun 9 06:11:19 EDT 2016
src/io/source_avcodec.c: check if the uri is a network stream using av_url_split, call avformat_network_init() if needed
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -72,6 +72,21 @@
void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi);
void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples);
+uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s);
+
+uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s) {
+ char proto[20], authorization[256], hostname[128], uripath[256];
+ int proto_size = 20, authorization_size = 256, hostname_size = 128,
+ *port_ptr = 0, path_size = 256;
+ av_url_split(proto, proto_size, authorization, authorization_size, hostname,
+ hostname_size, port_ptr, uripath, path_size, s->path);
+ if (strlen(proto)) {
+ return 1;
+ }
+ return 0;
+}
+
+
aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) {
aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
int err;
@@ -98,8 +113,9 @@
// register all formats and codecs
av_register_all();
- // if path[0] != '/'
- //avformat_network_init();
+ if (aubio_source_avcodec_has_network_url(s)) {
+ avformat_network_init();
+ }
// try opening the file and get some info about it
AVFormatContext *avFormatCtx = s->avFormatCtx;