Commit baf0fb51 authored by Simon Morlat's avatar Simon Morlat

fixes in player

parent 21e35e89
......@@ -64,6 +64,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,-)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README
%{_bindir}/mediastream
%{_bindir}/msaudiocmp
%{_libdir}/*.so.*
%{_datadir}/images/nowebcamCIF.jpg
%{_datadir}/locale/??/LC_MESSAGES/mediastreamer.mo
......
......@@ -181,9 +181,10 @@ static int player_open(MSFilter *f, void *arg){
player_close(f,NULL);
}
if ((fd=open(file,O_RDONLY|O_BINARY))==-1){
ms_warning("Failed to open %s: %s",file,strerror(errno));
ms_warning("MSFilePlayer[%p]: failed to open %s: %s",f,file,strerror(errno));
return -1;
}
d->state=MSPlayerPaused;
d->fd=fd;
d->ts=0;
......@@ -194,7 +195,7 @@ static int player_open(MSFilter *f, void *arg){
char err[PCAP_ERRBUF_SIZE];
d->pcap = pcap_open_offline(file, err);
if (d->pcap == NULL) {
ms_error("Failed to open pcap file: %s", err);
ms_error("MSFilePlayer[%p]: failed to open pcap file: %s",f,err);
d->fd=-1;
close(fd);
return -1;
......@@ -205,7 +206,7 @@ static int player_open(MSFilter *f, void *arg){
ms_warning("File %s has .wav extension but wav header could be found.",file);
}
ms_filter_notify_no_arg(f,MS_PLAYER_FORMAT_CHANGED);
ms_message("%s opened: rate=%i,channel=%i",file,d->rate,d->nchannels);
ms_message("MSFilePlayer[%p]: %s opened: rate=%i,channel=%i",f,file,d->rate,d->nchannels);
return 0;
}
......
......@@ -321,7 +321,8 @@ static void unplumb_av_player(AudioStream *stream){
}
ms_connection_helper_start(&ch);
ms_connection_helper_unlink(&ch,player->player,-1,player->audiopin);
ms_connection_helper_unlink(&ch,player->decoder,0,0);
if (player->decoder)
ms_connection_helper_unlink(&ch,player->decoder,0,0);
ms_connection_helper_unlink(&ch,player->resampler,0,0);
/*detach the outbound graph before attaching to the outbound mixer*/
if (reattach) ms_ticker_detach(stream->ms.sessions.ticker,stream->soundread);
......@@ -357,11 +358,14 @@ static void configure_av_player(AudioStream *stream, const MSFmtDescriptor *audi
struct _AVPlayer *player=&stream->av_player;
int stream_rate=0;
int stream_channels=0;
if (audiofmt->nchannels>0){
ms_filter_call_method(player->decoder,MS_FILTER_SET_NCHANNELS,(void*)&audiofmt->nchannels);
}
if (audiofmt->rate>0){
ms_filter_call_method(player->decoder,MS_FILTER_SET_SAMPLE_RATE,(void*)&audiofmt->rate);
if (player->decoder){
if (audiofmt->nchannels>0){
ms_filter_call_method(player->decoder,MS_FILTER_SET_NCHANNELS,(void*)&audiofmt->nchannels);
}
if (audiofmt->rate>0){
ms_filter_call_method(player->decoder,MS_FILTER_SET_SAMPLE_RATE,(void*)&audiofmt->rate);
}
}
ms_filter_call_method(player->resampler,MS_FILTER_SET_NCHANNELS,(void*)&audiofmt->nchannels);
ms_filter_call_method(player->resampler,MS_FILTER_SET_SAMPLE_RATE,(void*)&audiofmt->rate);
......@@ -390,7 +394,8 @@ static void plumb_av_player(AudioStream *stream){
}
ms_connection_helper_start(&ch);
ms_connection_helper_link(&ch,player->player,-1,player->audiopin);
ms_connection_helper_link(&ch,player->decoder,0,0);
if (player->decoder)
ms_connection_helper_link(&ch,player->decoder,0,0);
ms_connection_helper_link(&ch,player->resampler,0,0);
/*detach the outbound graph before attaching to the outbound mixer*/
if (reattach) ms_ticker_detach(stream->ms.sessions.ticker,stream->soundread);
......@@ -424,7 +429,6 @@ static int open_av_player(AudioStream *stream, const char *filename){
/*assume PCM*/
int sr=8000;
int channels=1;
player->decoder=ms_filter_new(MS_L16_DEC_ID);
ms_filter_call_method(player->player,MS_FILTER_GET_SAMPLE_RATE,&sr);
ms_filter_call_method(player->player,MS_FILTER_GET_NCHANNELS,&channels);
fmt1.fmt=ms_factory_get_audio_format(ms_factory_get_fallback(),"pcm", sr, channels, NULL);
......@@ -441,6 +445,8 @@ static int open_av_player(AudioStream *stream, const char *filename){
player->audiopin=1;
player->videopin=0;
}
}
if (strcasecmp(audiofmt->fmt->encoding,"pcm")!=0){
player->decoder=ms_filter_create_decoder(audiofmt->fmt->encoding);
if (player->decoder==NULL){
ms_warning("AudioStream[%p]: no way to decode [%s]",stream,filename);
......
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