1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

this patch adds an fallback to playlist (any but the plaintext-list format)

after all demuxers failed. so -playlist is not needed any more!
patch by Fabian Franz <FabianFranz@gmx.de>, with some small modifications


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8926 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2003-01-12 19:41:38 +00:00
parent d31a1e04f4
commit 89875edb32
7 changed files with 66 additions and 42 deletions

View File

@ -528,7 +528,7 @@ asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) {
ptp = play_tree_parser_new(stream,parser->deep+1);
pt = play_tree_parser_get_play_tree(ptp);
pt = play_tree_parser_get_play_tree(ptp, 1);
play_tree_parser_free(ptp);
free_stream(stream);

View File

@ -882,7 +882,7 @@ if(file_format==DEMUXER_TYPE_UNKNOWN){
}
//=============== Unknown, exiting... ===========================
if(file_format==DEMUXER_TYPE_UNKNOWN || demuxer == NULL){
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
//mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized); // will be done by mplayer.c after fallback to playlist-parsing
return NULL;
// GUI_MSG( mplUnknowFileType )
}

View File

@ -391,6 +391,7 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
if(stream2){
demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2);
if(demuxer2) printf(MSGTR_UsingPass3ControllFile,frameno_filename);
else mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
}
// New config code
@ -493,6 +494,7 @@ if(stream->type==STREAMTYPE_DVD){
//demuxer=demux_open(stream,file_format,video_id,audio_id,dvdsub_id);
demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id);
if(!demuxer){
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
printf(MSGTR_CannotOpenDemuxer);
mencoder_exit(1,NULL);
}

View File

@ -585,6 +585,31 @@ static int libmpdemux_was_interrupted(int eof) {
return eof;
}
int playtree_add_playlist(play_tree_t* entry)
{
if(!entry) {
entry = playtree_iter->tree;
if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {
return PT_NEXT_ENTRY;
}
if(playtree_iter->tree == entry ) { // Loop with a single file
if(play_tree_iter_up_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {
return PT_NEXT_ENTRY;
}
}
play_tree_remove(entry,1,1);
return PT_NEXT_SRC;
}
play_tree_insert_entry(playtree_iter->tree,entry);
play_tree_set_params_from(entry,playtree_iter->tree);
entry = playtree_iter->tree;
if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {
return PT_NEXT_ENTRY;
}
play_tree_remove(entry,1,1);
return PT_NEXT_SRC;
}
static int play_tree_step = 1;
/*
@ -1125,32 +1150,8 @@ if(!use_stdin && !slave_mode){
// Handle playlist
current_module="handle_playlist";
mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",filename);
entry = parse_playtree(stream);
if(!entry) {
entry = playtree_iter->tree;
if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {
eof = PT_NEXT_ENTRY;
goto goto_next_file;
}
if(playtree_iter->tree == entry ) { // Loop with a single file
if(play_tree_iter_up_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {
eof = PT_NEXT_ENTRY;
goto goto_next_file;
}
}
play_tree_remove(entry,1,1);
eof = PT_NEXT_SRC;
goto goto_next_file;
}
play_tree_insert_entry(playtree_iter->tree,entry);
play_tree_set_params_from(entry,playtree_iter->tree);
entry = playtree_iter->tree;
if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {
eof = PT_NEXT_ENTRY;
goto goto_next_file;
}
play_tree_remove(entry,1,1);
eof = PT_NEXT_SRC;
entry = parse_playtree(stream,0);
eof=playtree_add_playlist(entry);
goto goto_next_file;
}
stream->start_pos+=seek_to_byte;
@ -1223,7 +1224,21 @@ if(stream_cache_size>0){
current_module="demux_open";
demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id);
if(!demuxer) goto goto_next_file; // exit_player(MSGTR_Exit_error); // ERROR
if(!demuxer)
{
play_tree_t* entry;
// Handle playlist
current_module="handle_playlist";
mp_msg(MSGT_CPLAYER,MSGL_INFO,"Falling back on trying to parse playlist %s...\n",filename);
stream_reset(stream);
stream_seek(stream,stream->start_pos);
entry = parse_playtree(stream,0);
if(!entry)
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
else
eof=playtree_add_playlist(entry);
goto goto_next_file;
}
inited_flags|=INITED_DEMUXER;
current_module="demux_open2";

View File

@ -158,7 +158,7 @@ char*
play_tree_iter_get_file(play_tree_iter_t* iter, int d);
play_tree_t*
parse_playtree(struct stream_st *stream);
parse_playtree(struct stream_st *stream, int forced);
play_tree_t*
play_tree_cleanup(play_tree_t* pt);

View File

@ -251,7 +251,8 @@ parse_pls(play_tree_parser_t* p) {
play_tree_t *list = NULL, *entry = NULL;
mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying winamp playlist...\n");
line = play_tree_parser_get_line(p);
if (!(line = play_tree_parser_get_line(p)))
return NULL;
strstrip(line);
if(strcasecmp(line,"[playlist]"))
return NULL;
@ -339,7 +340,8 @@ parse_ref_ini(play_tree_parser_t* p) {
play_tree_t *list = NULL, *entry = NULL;
mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying reference-ini playlist...\n");
line = play_tree_parser_get_line(p);
if (!(line = play_tree_parser_get_line(p)))
return NULL;
strstrip(line);
if(strcasecmp(line,"[Reference]"))
return NULL;
@ -380,7 +382,8 @@ parse_m3u(play_tree_parser_t* p) {
play_tree_t *list = NULL, *entry = NULL;
mp_msg(MSGT_PLAYTREE,MSGL_V,"Trying extended m3u playlist...\n");
line = play_tree_parser_get_line(p);
if (!(line = play_tree_parser_get_line(p)))
return NULL;
strstrip(line);
if(strcasecmp(line,"#EXTM3U"))
return NULL;
@ -447,7 +450,7 @@ parse_textplain(play_tree_parser_t* p) {
}
play_tree_t*
parse_playtree(stream_t *stream) {
parse_playtree(stream_t *stream, int forced) {
play_tree_parser_t* p;
play_tree_t* ret;
@ -460,7 +463,7 @@ parse_playtree(stream_t *stream) {
if(!p)
return NULL;
ret = play_tree_parser_get_play_tree(p);
ret = play_tree_parser_get_play_tree(p, forced);
play_tree_parser_free(p);
return ret;
@ -509,7 +512,7 @@ parse_playlist_file(char* file) {
mp_msg(MSGT_PLAYTREE,MSGL_V,"Parsing playlist file %s...\n",file);
stream = new_stream(fd,STREAMTYPE_PLAYLIST);
ret = parse_playtree(stream);
ret = parse_playtree(stream,1);
if(close(fd) < 0)
mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Warning error while closing playlist file %s : %s\n",file,strerror(errno));
free_stream(stream);
@ -555,7 +558,7 @@ play_tree_parser_free(play_tree_parser_t* p) {
}
play_tree_t*
play_tree_parser_get_play_tree(play_tree_parser_t* p) {
play_tree_parser_get_play_tree(play_tree_parser_t* p, int forced) {
play_tree_t* tree = NULL;
#ifdef MP_DEBUG
@ -583,19 +586,23 @@ play_tree_parser_get_play_tree(play_tree_parser_t* p) {
play_tree_parser_reset(p);
// Here come the others formats ( textplain must stay the last one )
tree = parse_textplain(p);
if(tree) break;
if (forced)
{
tree = parse_textplain(p);
if(tree) break;
}
break;
}
if(tree)
mp_msg(MSGT_PLAYTREE,MSGL_V,"Playlist succefully parsed\n");
else mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Error while parsing playlist\n");
else
mp_msg(MSGT_PLAYTREE,((forced==1)?MSGL_ERR:MSGL_V),"Error while parsing playlist\n");
if(tree)
tree = play_tree_cleanup(tree);
if(!tree) mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Warning empty playlist\n");
if(!tree) mp_msg(MSGT_PLAYTREE,((forced==1)?MSGL_WARN:MSGL_V),"Warning empty playlist\n");
return tree;
}

View File

@ -19,6 +19,6 @@ void
play_tree_parser_free(play_tree_parser_t* p);
play_tree_t*
play_tree_parser_get_play_tree(play_tree_parser_t* p);
play_tree_parser_get_play_tree(play_tree_parser_t* p, int forced);
#endif