input/ffmpeg: use the new AVIOContext API
URLContext is deprecated.
This commit is contained in:
		
							
								
								
									
										2
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								NEWS
									
									
									
									
									
								
							| @@ -1,4 +1,6 @@ | |||||||
| ver 0.16.7 (2011/??/??) | ver 0.16.7 (2011/??/??) | ||||||
|  | * input: | ||||||
|  |   - ffmpeg: support libavformat 0.7 | ||||||
| * output: | * output: | ||||||
|   - httpd: fix excessive buffering |   - httpd: fix excessive buffering | ||||||
|   - openal: force 16 bit playback, as 8 bit doesn't work |   - openal: force 16 bit playback, as 8 bit doesn't work | ||||||
|   | |||||||
| @@ -39,7 +39,11 @@ | |||||||
| struct input_ffmpeg { | struct input_ffmpeg { | ||||||
| 	struct input_stream base; | 	struct input_stream base; | ||||||
|  |  | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	AVIOContext *h; | ||||||
|  | #else | ||||||
| 	URLContext *h; | 	URLContext *h; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	bool eof; | 	bool eof; | ||||||
| }; | }; | ||||||
| @@ -50,6 +54,17 @@ ffmpeg_quark(void) | |||||||
| 	return g_quark_from_static_string("ffmpeg"); | 	return g_quark_from_static_string("ffmpeg"); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static inline bool | ||||||
|  | input_ffmpeg_supported(void) | ||||||
|  | { | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	void *opaque = NULL; | ||||||
|  | 	return avio_enum_protocols(&opaque, 0) != NULL; | ||||||
|  | #else | ||||||
|  | 	return av_protocol_next(NULL) != NULL; | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
| static bool | static bool | ||||||
| input_ffmpeg_init(G_GNUC_UNUSED const struct config_param *param, | input_ffmpeg_init(G_GNUC_UNUSED const struct config_param *param, | ||||||
| 		  G_GNUC_UNUSED GError **error_r) | 		  G_GNUC_UNUSED GError **error_r) | ||||||
| @@ -58,7 +73,7 @@ input_ffmpeg_init(G_GNUC_UNUSED const struct config_param *param, | |||||||
|  |  | ||||||
| #if LIBAVFORMAT_VERSION_MAJOR >= 52 | #if LIBAVFORMAT_VERSION_MAJOR >= 52 | ||||||
| 	/* disable this plugin if there's no registered protocol */ | 	/* disable this plugin if there's no registered protocol */ | ||||||
| 	if (av_protocol_next(NULL) == NULL) { | 	if (!input_ffmpeg_supported()) { | ||||||
| 		g_set_error(error_r, ffmpeg_quark(), 0, | 		g_set_error(error_r, ffmpeg_quark(), 0, | ||||||
| 			    "No protocol"); | 			    "No protocol"); | ||||||
| 		return false; | 		return false; | ||||||
| @@ -84,7 +99,11 @@ input_ffmpeg_open(const char *uri, GError **error_r) | |||||||
| 	i = g_new(struct input_ffmpeg, 1); | 	i = g_new(struct input_ffmpeg, 1); | ||||||
| 	input_stream_init(&i->base, &input_plugin_ffmpeg, uri); | 	input_stream_init(&i->base, &input_plugin_ffmpeg, uri); | ||||||
|  |  | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	int ret = avio_open(&i->h, uri, AVIO_FLAG_READ); | ||||||
|  | #else | ||||||
| 	int ret = url_open(&i->h, uri, URL_RDONLY); | 	int ret = url_open(&i->h, uri, URL_RDONLY); | ||||||
|  | #endif | ||||||
| 	if (ret != 0) { | 	if (ret != 0) { | ||||||
| 		g_free(i); | 		g_free(i); | ||||||
| 		g_set_error(error_r, ffmpeg_quark(), ret, | 		g_set_error(error_r, ffmpeg_quark(), ret, | ||||||
| @@ -95,8 +114,13 @@ input_ffmpeg_open(const char *uri, GError **error_r) | |||||||
| 	i->eof = false; | 	i->eof = false; | ||||||
|  |  | ||||||
| 	i->base.ready = true; | 	i->base.ready = true; | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	i->base.seekable = (i->h->seekable & AVIO_SEEKABLE_NORMAL) != 0; | ||||||
|  | 	i->base.size = avio_size(i->h); | ||||||
|  | #else | ||||||
| 	i->base.seekable = !i->h->is_streamed; | 	i->base.seekable = !i->h->is_streamed; | ||||||
| 	i->base.size = url_filesize(i->h); | 	i->base.size = url_filesize(i->h); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	/* hack to make MPD select the "ffmpeg" decoder plugin - since | 	/* hack to make MPD select the "ffmpeg" decoder plugin - since | ||||||
| 	   avio.h doesn't tell us the MIME type of the resource, we | 	   avio.h doesn't tell us the MIME type of the resource, we | ||||||
| @@ -113,7 +137,11 @@ input_ffmpeg_read(struct input_stream *is, void *ptr, size_t size, | |||||||
| { | { | ||||||
| 	struct input_ffmpeg *i = (struct input_ffmpeg *)is; | 	struct input_ffmpeg *i = (struct input_ffmpeg *)is; | ||||||
|  |  | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	int ret = avio_read(i->h, ptr, size); | ||||||
|  | #else | ||||||
| 	int ret = url_read(i->h, ptr, size); | 	int ret = url_read(i->h, ptr, size); | ||||||
|  | #endif | ||||||
| 	if (ret <= 0) { | 	if (ret <= 0) { | ||||||
| 		if (ret < 0) | 		if (ret < 0) | ||||||
| 			g_set_error(error_r, ffmpeg_quark(), 0, | 			g_set_error(error_r, ffmpeg_quark(), 0, | ||||||
| @@ -132,7 +160,11 @@ input_ffmpeg_close(struct input_stream *is) | |||||||
| { | { | ||||||
| 	struct input_ffmpeg *i = (struct input_ffmpeg *)is; | 	struct input_ffmpeg *i = (struct input_ffmpeg *)is; | ||||||
|  |  | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	avio_close(i->h); | ||||||
|  | #else | ||||||
| 	url_close(i->h); | 	url_close(i->h); | ||||||
|  | #endif | ||||||
| 	input_stream_deinit(&i->base); | 	input_stream_deinit(&i->base); | ||||||
| 	g_free(i); | 	g_free(i); | ||||||
| } | } | ||||||
| @@ -150,7 +182,11 @@ input_ffmpeg_seek(struct input_stream *is, goffset offset, int whence, | |||||||
| 		  G_GNUC_UNUSED GError **error_r) | 		  G_GNUC_UNUSED GError **error_r) | ||||||
| { | { | ||||||
| 	struct input_ffmpeg *i = (struct input_ffmpeg *)is; | 	struct input_ffmpeg *i = (struct input_ffmpeg *)is; | ||||||
|  | #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0) | ||||||
|  | 	int64_t ret = avio_seek(i->h, offset, whence); | ||||||
|  | #else | ||||||
| 	int64_t ret = url_seek(i->h, offset, whence); | 	int64_t ret = url_seek(i->h, offset, whence); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (ret >= 0) { | 	if (ret >= 0) { | ||||||
| 		i->eof = false; | 		i->eof = false; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann