[Toxine-cvs] CVS: toxine/src commands.c,1.52,1.53 commands.h,1.4,1.5 common.h,1.22,1.23 utils.c,1.21
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2003-01-21 16:54:13
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1:/tmp/cvs-serv7645 Modified Files: commands.c commands.h common.h utils.c utils.h xine_commands.c xine_commands.h Log Message: @@made playlist works again. Some new xine api functions adding. Index: commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/commands.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- commands.c 19 Jan 2003 11:25:18 -0000 1.52 +++ commands.c 21 Jan 2003 16:53:34 -0000 1.53 @@ -435,7 +435,10 @@ __playmrloop: toxine_set_current_mrl_from_cur(tox); - _xine_play(NULL, tox, (void *)NO_ARGS); + if(xine_open(tox->stream, tox->current_mrl)) { + tox->xine_state |= XINE_OPEN; + _xine_play(NULL, tox, (void *)NO_ARGS); + } } else { if(tox->playlist.loop && tox->playlist.num) { @@ -499,7 +502,7 @@ /* * Listener of xine engine events. */ -void toxine_event_listener(void *data, xine_event_t *event) { +void toxine_event_listener(void *data, const xine_event_t *event) { toxine_t *tox = (toxine_t *) data; pthread_mutex_lock(&tox->event.mutex); @@ -754,15 +757,16 @@ */ int toxine_audio_out_init(toxine_t *tox) { - tox->audio.mixer.enable = 0; - tox->audio.mixer.caps = 0; - if(!tox->audio.name) { perr("no audio driver sets, no audio output.\n"); - return 0; + return 1; } if(tox->audio.port == NULL) { + + tox->audio.mixer.enable = 0; + tox->audio.mixer.caps = 0; + tox->audio.port = xine_open_audio_driver(tox->xine, (const char*)tox->audio.name, NULL); if(tox->audio.port == NULL) { perr("xine_load_audio_output_plugin() failed to load '%s' driver.\n", tox->audio.name); @@ -1195,7 +1199,7 @@ memset(&buffer, 0, sizeof(buffer)); sprintf(buffer, "%s %s %s", - "xine_set_video_property", toxine_get_arg(tox, 3), toxine_get_arg(tox, 4)); + "xine_set_param", toxine_get_arg(tox, 3), toxine_get_arg(tox, 4)); toxine_set_command_line(tox, buffer); toxine_handle_command(tox, NULL); @@ -1261,7 +1265,7 @@ tox->audio.mixer.volume_level = atoi(toxine_get_arg(tox, 3)); sprintf(buffer, "%s %d", - "xine_set_audio_property volume", tox->audio.mixer.volume_level); + "xine_set_param XINE_PARAM_AUDIO_VOLUME", tox->audio.mixer.volume_level); toxine_set_command_line(tox, buffer); toxine_handle_command(tox, NULL); @@ -1271,7 +1275,7 @@ } else if(toxine_is_arg_contain(tox, 2, "mute")) { - toxine_set_command_line(tox, "xine_set_audio_property mute"); + toxine_set_command_line(tox, "xine_set_param XINE_PARAM_AUDIO_MUTE"); toxine_handle_command(tox, NULL); } @@ -1293,7 +1297,8 @@ */ static void do_init(commands_t *command, toxine_t *tox, void *data) { _xine_init(command, tox, NULL); - _xine_stream_new(command, tox, NULL); + if(tox->xine) + _xine_stream_new(command, tox, NULL); } /* @@ -1320,7 +1325,10 @@ if(tox->command.num_args) toxine_set_current_mrl(tox, (toxine_get_arg(tox, 1))); - _xine_play(command, tox, (void *)NO_ARGS); + if(xine_open(tox->stream, tox->current_mrl)) { + tox->xine_state |= XINE_OPEN; + _xine_play(command, tox, (void *)NO_ARGS); + } } Index: commands.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/commands.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- commands.h 17 Jan 2003 23:39:52 -0000 1.4 +++ commands.h 21 Jan 2003 16:53:35 -0000 1.5 @@ -27,7 +27,7 @@ #define REQUIRE_ARGS 2 #define OPTIONAL_ARGS 3 -void toxine_event_listener(void *, xine_event_t *); +void toxine_event_listener(void *, const xine_event_t *); int toxine_video_out_init(toxine_t *); int toxine_audio_out_init(toxine_t *); void toxine_handle_command(toxine_t *, void *); Index: common.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/common.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- common.h 18 Jan 2003 17:01:24 -0000 1.22 +++ common.h 21 Jan 2003 16:53:35 -0000 1.23 @@ -153,7 +153,7 @@ struct toxine_s { xine_t *xine; xine_stream_t *stream; - + xine_event_queue_t *event_queue; int autoinit; int running; Index: utils.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/utils.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- utils.c 19 Jan 2003 11:25:18 -0000 1.21 +++ utils.c 21 Jan 2003 16:53:35 -0000 1.22 @@ -337,60 +337,6 @@ } /* - * Return next mrl in playlist. - */ -char *toxine_get_next_mrl(toxine_t *tox) { - if(tox) { - - if(tox->playlist.cur >= (tox->playlist.num - 1)) { - - if(tox->playlist.loop) { - - if(tox->loop_mode == PLAYLIST_LOOP) - return tox->playlist.mmk[0]->mrl; - else if(tox->loop_mode == PLAYLIST_MRL_LOOP) - return tox->playlist.mmk[tox->playlist.cur]->mrl; - - } - else - return NULL; - } - - return tox->playlist.mmk[tox->playlist.cur + 1]->mrl; - } - - return NULL; -} - -/* - * Branching was successfully accomplished, update playlist. - */ -void toxine_branched(toxine_t *tox) { - - if(tox) { - if(tox->playlist.cur < (tox->playlist.num - 1)) { - - if(tox->playlist.loop) { - if(tox->loop_mode == PLAYLIST_LOOP) - tox->playlist.cur++; - } - else - tox->playlist.cur++; - - toxine_set_current_mrl_from_cur(tox); - } - else { - - if(tox->playlist.loop && (tox->loop_mode == PLAYLIST_LOOP)) { - tox->playlist.cur = 0; - toxine_set_current_mrl_from_cur(tox); - } - - } - } -} - -/* * Execute a shell command. */ int toxine_system(int dont_run_as_root, char *command) { Index: utils.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/utils.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- utils.h 19 Jan 2003 11:25:18 -0000 1.10 +++ utils.h 21 Jan 2003 16:53:36 -0000 1.11 @@ -35,8 +35,6 @@ int toxine_is_args(toxine_t *tox); const char *toxine_get_arg(toxine_t *tox, int num); int toxine_is_arg_contain(toxine_t *tox, int pos, const char *arg); -char *toxine_get_next_mrl(toxine_t *tox); -void toxine_branched(toxine_t *tox); int toxine_mkdir_safe(char *path); void toxine_draw_bar(char *title, int min, int max, int val); Index: xine_commands.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/xine_commands.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- xine_commands.c 19 Jan 2003 11:40:47 -0000 1.37 +++ xine_commands.c 21 Jan 2003 16:53:36 -0000 1.38 @@ -433,7 +433,7 @@ pinfo("0x%x\n", (int)tox->xine); pinfo("xine_config_load()\n"); xine_config_load(tox->xine, tox->configfile); - pinfo("\n"); + pinfo(".\n"); } void _xine_stream_new(commands_t *command, toxine_t *tox, void *data) { @@ -448,13 +448,19 @@ return; } - pinfo("xine_stream_new()"); + pinfo("xine_stream_new():"); tox->stream = xine_stream_new(tox->xine, tox->audio.port, tox->video.port); pinfo("return 0x%x\n", (int) tox->stream); if(tox->stream) tox->xine_state |= XINE_STREAM; else perr("Wow, xine_stream_new() failed.\n"); + + if(tox->event_queue) + xine_event_dispose_queue(tox->event_queue); + + tox->event_queue = xine_event_new_queue(tox->stream); + xine_event_create_listener_thread(tox->event_queue, toxine_event_listener, (void *) tox); } /* @@ -475,40 +481,26 @@ pinfo("xine_init()"); xine_init(tox->xine); pinfo("\n"); - tox->xine_state |= XINE_INIT; - + tox->xine_state |= XINE_INIT; + pthread_mutex_init(&tox->event.mutex, NULL); + if(!toxine_video_out_init(tox)) { perr("unable to initialize video out plugin.\n"); + xine_exit(tox->xine); + tox->xine = NULL; + tox->xine_state &= ~(XINE_NEW | XINE_INIT); return; } - if(!toxine_audio_out_init(tox)) + if(!toxine_audio_out_init(tox)) { perr("unable to initialize audio driver, audio output disabled.\n"); + xine_exit(tox->xine); + tox->xine = NULL; + tox->xine_state &= ~(XINE_NEW | XINE_INIT); + return; + } - /* - if(xine_get_param(tox->xine, XINE_PARAM_AO_MIXER_VOL)) - tox->audio.mixer.caps |= XINE_PARAM_AO_MIXER_VOL; - if(xine_get_param(tox->xine, XINE_PARAM_AO_PCM_VOL)) - tox->audio.mixer.caps |= XINE_PARAM_AO_PCM_VOL; - if(xine_get_param(tox->xine, XINE_PARAM_AO_MUTE)) - tox->audio.mixer.caps |= XINE_PARAM_AO_MUTE; - - if(tox->audio.mixer.caps & (XINE_PARAM_AO_MIXER_VOL | XINE_PARAM_AO_PCM_VOL)) { - tox->audio.mixer.enable = 1; - tox->audio.mixer.volume_level = xine_get_param(tox->xine, XINE_PARAM_AUDIO_VOLUME); - } - - if(tox->audio.mixer.caps & XINE_PARAM_AO_MUTE) - tox->audio.mixer.mute = xine_get_param(tox->xine, XINE_PARAM_AUDIO_MUTE); - */ - pthread_mutex_init(&tox->event.mutex, NULL); -#warning FIXME -#if 0 - pinfo("xine_register_event_listener()\n"); - xine_register_event_listener(tox->xine, toxine_event_listener, (void *) tox); pinfo(".\n"); -#endif - } /* @@ -529,7 +521,7 @@ result = xine_open(tox->stream, tox->current_mrl); pinfo("returned %d\n", result); tox->xine_state |= XINE_OPEN; - pinfo("\n"); + pinfo(".\n"); } } @@ -729,7 +721,7 @@ else perr("invalid trick mode: %s.\n", trick); - pinfo("\n"); + pinfo(".\n"); } } @@ -758,7 +750,7 @@ pinfo("xine_get_stream_info(%s):\n", stream_infos[i].name); stream_info = xine_get_stream_info(tox->stream, stream_infos[i].type); toxine_show_stream_info(stream_infos[i].type, stream_info); - pinfo("\n"); + pinfo(".\n"); } } } @@ -798,7 +790,7 @@ pinfo("%s\n", (meta_info) ? (char *) meta_info : "Unavailable"); break; } - pinfo("\n"); + pinfo(".\n"); } } } @@ -839,8 +831,10 @@ return_if_no_new(tox); if(tox->xine_state & XINE_INIT) { - pinfo("xine_remove_event_listener()\n"); - // xine_remove_event_listener(tox->xine, toxine_event_listener); + if(tox->event_queue) { + pinfo("xine_event_dispose_queue()\n"); + xine_event_dispose_queue(tox->event_queue); + } } pinfo("xine_exit()\n"); @@ -855,6 +849,8 @@ tox->audio.port = NULL; + pthread_mutex_destroy(&tox->event.mutex); + pinfo(".\n"); } @@ -890,7 +886,7 @@ break; } pinfo(buffer); - pinfo("\n"); + pinfo(".\n"); } /* @@ -1143,7 +1139,7 @@ else perr("Unknown xine parameter: '%s'\n", param); - pinfo("\n"); + pinfo(".\n"); } /* @@ -1213,7 +1209,7 @@ stream, stime / (60 * 60), (stime / 60) % 60, stime % 60, time); pinfo("Total time: %02d:%02d:%02d (%dms)\n", slength / (60 * 60), (slength / 60) % 60, slength % 60, length); - pinfo("\n"); + pinfo(".\n"); } /* @@ -1261,12 +1257,11 @@ sprintf(buffer, "%s%c", log, '\n'); pinfo("%s", buffer); } - pinfo(".\n"); } else pinfo("No log entry available.\n"); - pinfo("\n"); + pinfo(".\n"); } /* @@ -1306,7 +1301,7 @@ pinfo("xine_get_log_section_count():\n"); count = xine_get_log_section_count(tox->xine); pinfo("returned %d\n", count); - pinfo("\n"); + pinfo(".\n"); } @@ -1347,7 +1342,7 @@ pinfo("xine_log(%s, '%s')\n", log, msg); xine_log(tox->xine, buftype, msg); - pinfo("\n"); + pinfo(".\n"); } /* @@ -1693,7 +1688,7 @@ else perr("xine_config_get_first_entry() returned NULL\n"); - pinfo("\n"); + pinfo(".\n"); } void _xine_config_get_next_entry(commands_t *command, toxine_t *tox, void *data) { xine_cfg_entry_t cfg_entry; @@ -1706,7 +1701,7 @@ else perr("xine_config_get_next_entry() returned NULL\n"); - pinfo("\n"); + pinfo(".\n"); } void _xine_config_lookup_entry(commands_t *command, toxine_t *tox, void *data) { const char *key; @@ -1721,7 +1716,7 @@ else perr("Entry '%s' doesn't exist.\n", key); - pinfo("\n"); + pinfo(".\n"); } void _xine_config_update_entry(commands_t *command, toxine_t *tox, void *data) { const char *key; @@ -1774,7 +1769,7 @@ else perr("Entry '%s' doesn't exist.\n", key); - pinfo("\n"); + pinfo(".\n"); } else @@ -1797,7 +1792,6 @@ xine_config_load(tox->xine, tox->configfile); pinfo(".\n"); - pinfo("\n"); } void _xine_config_save(commands_t *command, toxine_t *tox, void *data) { const char *filename = NULL; @@ -1811,7 +1805,6 @@ xine_config_save(tox->xine, ((filename) ? filename : tox->configfile)); pinfo(".\n"); - pinfo("\n"); } void _xine_config_reset(commands_t *command, toxine_t *tox, void *data) { return_if_no_init(tox); @@ -1819,8 +1812,6 @@ pinfo("xine_config_reset():\n"); xine_config_reset(tox->xine); pinfo(".\n"); - - pinfo("\n"); } /* * ****** END CONFIG ****** @@ -1879,7 +1870,7 @@ pinfo("xine_close():"); xine_close(tox->stream); tox->xine_state &= ~XINE_OPEN; - pinfo("\n"); + pinfo(".\n"); } void _xine_dispose(commands_t *command, toxine_t *tox, void *data) { @@ -1889,7 +1880,81 @@ xine_dispose(tox->stream); tox->stream = NULL; tox->xine_state &= ~(XINE_OPEN | XINE_STREAM); - pinfo("\n"); + pinfo(".\n"); +} + +void _xine_get_file_extensions(commands_t *command, toxine_t *tox, void *data) { + char *exts; + + return_if_no_init(tox); + pinfo("xine_get_file_extensions():\n"); + exts = xine_get_file_extensions(tox->xine); + pinfo("returned: '%s'\n", (exts) ? exts : "NONE"); + pinfo(".\n"); + toxine_free(exts); +} + +void _xine_get_mime_types(commands_t *command, toxine_t *tox, void *data) { + char *mimes; + + return_if_no_init(tox); + pinfo("xine_get_mime_types():\n"); + mimes = xine_get_mime_types(tox->xine); + pinfo("returned: '%s'\n", (mimes) ? mimes : "NONE"); + pinfo(".\n"); + toxine_free(mimes); +} + +void _xine_get_current_frame(commands_t *command, toxine_t *tox, void *data) { + char buffer[_PATH_MAX + _NAME_MAX + 1]; + char *filename = NULL; + FILE *fd; + int width; + int height; + int ratio_code; + int format; + uint8_t *frame = NULL; + + return_if_no_stream(tox); + + if(toxine_is_args(tox)) + filename = (char *) toxine_get_arg(tox, 1); + else { + sprintf(buffer, "xine_frame-%d.frm", (unsigned int)(time(NULL))); + filename = buffer; + } + + width = xine_get_stream_info(tox->stream,XINE_STREAM_INFO_VIDEO_WIDTH); + height = xine_get_stream_info(tox->stream,XINE_STREAM_INFO_VIDEO_HEIGHT); + + if((!width) || (!height)) + perr("Wrong frame size: %dx%d\n", width, height); + else { + int size = (width * height) * 2; + + frame = (uint8_t *) xine_xmalloc(sizeof(uint8_t) * size); + + pinfo("xine_get_current_frame():"); + if(xine_get_current_frame(tox->stream, &width, &height, &ratio_code, &format, frame)) { + + pinfo("get frame: %dx%d, ratio %d, format %d\n", width, height, ratio_code, format); + + if((fd = fopen(filename, "w+b")) != NULL) { + fwrite(frame, size, 1, fd); + fflush(fd); + fclose(fd); + pinfo("File '%s' saved\n", filename); + } + else + perr("Unable to open file '%s' in write mode\n", filename); + + } + else + perr("unable to get current frame\n"); + + toxine_free(frame); + } + } /* @@ -1924,5 +1989,5 @@ pinfo("%s: ", stream_infos[i].name); toxine_show_stream_info(stream_infos[i].type, iinfo); } - pinfo("\n"); + pinfo(".\n"); } Index: xine_commands.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/xine_commands.h,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- xine_commands.h 19 Jan 2003 11:40:47 -0000 1.23 +++ xine_commands.h 21 Jan 2003 16:53:36 -0000 1.24 @@ -65,13 +65,14 @@ void _xine_check_version(commands_t *, toxine_t *, void *); void _xine_close(commands_t *, toxine_t *, void *); void _xine_dispose(commands_t *, toxine_t *, void *); +void _xine_get_file_extensions(commands_t *, toxine_t *, void *); +void _xine_get_mime_types(commands_t *, toxine_t *, void *); +void _xine_get_current_frame(commands_t *, toxine_t *, void *); /* void _xine_stream_master_slave(...) void xine_get_current_frame(...) - void xine_get_file_extensions(...) - void xine_get_mime_types(...) void xine_gui_send_vo_data(...) void xine_config_update_entry(...) @@ -421,6 +422,18 @@ { "xine_dispose", NO_ARGS, _xine_dispose, \ "Dispose all stream related resources.", \ "xine_dispose" \ + }, \ + { "xine_get_file_extensions", NO_ARGS, _xine_get_file_extensions, \ + "Return list of file extensions supported by 'demux by extensions' stage.", \ + "xine_get_file_extensions" \ + }, \ + { "xine_get_mime_types", NO_ARGS, _xine_get_mime_types, \ + "Return list of supported mimes types.", \ + "xine_get_mime_types" \ + }, \ + { "xine_get_current_frame", OPTIONAL_ARGS, _xine_get_current_frame, \ + "Get current displayed frame, and save it into a file.", \ + "xine_get_current_frame [filename]" \ }, \ { "xine_usec_sleep", REQUIRE_ARGS, _xine_usec_sleep, \ "Sleep some µ seconds", \ |