[Alsaplayer-devel]http support...

Andy Lo A Foe andy@alsaplayer.org
Tue, 1 Jan 2002 15:09:45 +0100


Hello!

Thanks for the update! I'm having some (serious) computer trouble here
back home. I hope to get things going again early next week (my main
dev. box is back in Europe).

To everyone else on alsaplayer-dev, sorry for not responding to emails
for the last couple of weeks. I've been having trouble connecting + I
got married 3 days ago so things are still busy around here :)

TTY,
Andy

On Sun, Dec 30, 2001 at 03:33:09AM +0100, Karl-Anders Wallin wrote:
> Hi!
> 
> As you might now the bbc are testing streaming of ogg. Well 
> anyway I like to listen to radio when I'm using my computer and 
> realplayer is no favorite of mine. I use alsaplayer to play my
> ogg audio files so why not use this excellent application...!
> 
> To accomplish this, I implemented som basic http functionality 
> that enables alsaplayer to play a ogg stream via http.
> The modified version of vorbis_engine.cpp connects to a http 
> server if the requested path starts with http:// 
> Some minor changes to Playlist.cpp enables a http:// path
> to be forwarded to the input plugin. 
> 
> Ohh I'm to tired to continue writing in english... 
> I will continue this message when the short-circuit in brain has 
> been resolved. :)
> 
> 
> To test try the following..
>   alsaplayer http://ogg.bbc.co.uk:8001/radio4.ogg
>   alsaplayer http://ogg.bbc.co.uk:8001/radio1-broad.ogg
> if the server is down, check http://support.bbc.co.uk/ogg/
> 
> 
> Attached files:
> 
> New files:
>   http.c => apps/http.c 
>   http.h => include/http.h
> 
> Modified files in apps/ 
>   Makefile.am.patch    - adds http.c to alsaplayer sources
>   Playlist.cpp.patch   - enables a http URI (http://)
> 
> Modified files in input/vorbis/ 
>   vorbis_engine.cpp.patch 
> 
> 
> God Jul & Gott Nytt ?r
> /Kalle (Karl-Anders Wallin) 
> 
> 
> 




> Index: Playlist.cpp
> ===================================================================
> RCS file: /cvsroot/alsaplayer/alsaplayer/app/Playlist.cpp,v
> retrieving revision 1.13
> diff -r1.13 Playlist.cpp
> 36a37
> > #include "http.h"
> 621a623,629
> > 	// check if path is a http url 
> > 	if( IS_HTTP_URL(path.c_str()) ) {
> > 		input_plugin *plugin = coreplayer->GetPlayer(path.c_str());
> > 		if (plugin) 
> > 			return true; 
> > 	}
> > 
> 650a659,665
> > 
> > 	// check if path is a http url
> > 	if( IS_HTTP_URL(path.c_str()) ) {
> > 		printf( "additems() - a http url found!\n" );
> > 		items->push_back(path);
> > 		return;
> > 	}

> Index: vorbis_engine.cpp
> ===================================================================
> RCS file: /cvsroot/alsaplayer/alsaplayer/input/vorbis/vorbis_engine.cpp,v
> retrieving revision 1.2
> diff -r1.2 vorbis_engine.cpp
> 30a31
> > #include "http.h"
> 37a39
> > 		http_info_t *http;
> 137c139,144
> < 			case -1:
> ---
> > 		case OV_HOLE:
> > 				/* hole in the stream, probably harmless */
> > 				ret = 0;
> > 				break;
> > 			case OV_EBADLINK:
> > 					/* invalid stream section */
> 242a250,261
> > 
> > 	/* work to TODO here - view this as an example */	  
> > 	if( data && data->http )
> > 			{
> > 					char *htinfo;
> >       
> > 					if( (htinfo=http_get_header_field("ice-name",data->http)) )
> > 							{
> > 									strcpy( info->title, htinfo );
> > 							}
> > 			}
> > 
> 326a346
> > 		http_info_t *http = NULL;
> 333,335c353,377
> < 		if ((stream = fopen(path, "r")) == NULL) {
> < 				return 0;
> < 		}
> ---
> >   if( IS_HTTP_URL(path) )
> >     {
> >       http = http_init( NULL, 0 );
> > 						/* connect to server */
> >       if ((stream = http_open(path,http)) == NULL)
> > 								return 0;
> >       /* check status-code */
> >       if( http->header.status_code != 200 )
> > 								{
> > 										fprintf( stderr, 
> > 																			"Error: %d %s\n", 
> > 																			http->header.status_code,
> > 																			http_status_code2string( http->header.status_code ) );
> > 										fclose( stream );
> > 										http_close( http );
> > 										return 0;
> > 								}
> >       /* TODO: check content-type (application/x-ogg) */
> >     }
> >   else	
> >     {
> >       if ((stream = fopen(path, "r")) == NULL)
> > 								return 0;
> >     }
> > 
> 339a382,383
> >     if( http )
> >       http_close( http );
> 344a389,390
> >     if( http )
> >       http_close( http );
> 349a396,397
> >     if( http )
> >       http_close( http );
> 356a405,406
> >     if( http )
> >       http_close( http );
> 360a411
> > 		data->http = http;
> 362a414
> > 
> 374,375c426,430
> < 	if (data)
> < 		ov_clear(&data->vf);
> ---
> > 	if (data)	{
> > 			ov_clear(&data->vf);
> > 			if( data->http )
> > 					http_close( data->http );
> > 	}
> 377,378c432,433
> < 		free(obj->local_data);
> < 		obj->local_data = NULL;
> ---
> > 			free(obj->local_data);
> > 			obj->local_data = NULL;