Mercurial > mplayer.hg
changeset 8925:5c15777f1c07
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
author | arpi |
---|---|
date | Sun, 12 Jan 2003 19:41:38 +0000 |
parents | e0ec616c5985 |
children | 497e3b284a10 |
files | asxparser.c libmpdemux/demuxer.c mencoder.c mplayer.c playtree.h playtreeparser.c playtreeparser.h |
diffstat | 7 files changed, 66 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/asxparser.c Sun Jan 12 19:32:56 2003 +0000 +++ b/asxparser.c Sun Jan 12 19:41:38 2003 +0000 @@ -528,7 +528,7 @@ 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);
--- a/libmpdemux/demuxer.c Sun Jan 12 19:32:56 2003 +0000 +++ b/libmpdemux/demuxer.c Sun Jan 12 19:41:38 2003 +0000 @@ -882,7 +882,7 @@ } //=============== 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 ) }
--- a/mencoder.c Sun Jan 12 19:32:56 2003 +0000 +++ b/mencoder.c Sun Jan 12 19:41:38 2003 +0000 @@ -391,6 +391,7 @@ 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 @@ //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); }
--- a/mplayer.c Sun Jan 12 19:32:56 2003 +0000 +++ b/mplayer.c Sun Jan 12 19:41:38 2003 +0000 @@ -585,6 +585,31 @@ 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 @@ // 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 @@ 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";
--- a/playtree.h Sun Jan 12 19:32:56 2003 +0000 +++ b/playtree.h Sun Jan 12 19:41:38 2003 +0000 @@ -158,7 +158,7 @@ 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);
--- a/playtreeparser.c Sun Jan 12 19:32:56 2003 +0000 +++ b/playtreeparser.c Sun Jan 12 19:41:38 2003 +0000 @@ -251,7 +251,8 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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_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_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; }
--- a/playtreeparser.h Sun Jan 12 19:32:56 2003 +0000 +++ b/playtreeparser.h Sun Jan 12 19:41:38 2003 +0000 @@ -19,6 +19,6 @@ 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