bool play_video_1(void *player,void *void_params){ C_play_video_params_1 *params=(C_play_video_params_1 *)void_params; if (params->exception_string) *params->exception_string=0; std::string temp; std::vector<C_play_video_params::trigger_callback_pair> callback_pairs( params->pairs, params->pairs+params->trigger_callback_pairs_n ); if (play_video( player, params->screen, params->input, params->stop, params->user_data, params->audio_output, params->print_debug, temp, callback_pairs, params->protocol )) return 1; if (params->exception_string){ strncpy(params->exception_string,temp.c_str(),params->exception_string_size); params->exception_string[params->exception_string_size-1]=0; } return 0; }
void video_refresh(void *arg) { State *state = (State *)arg; VideoFrame *vf; double actual_delay, delay, sync_threshold, ref_clk, diff; if(state->video->stream) { if(state->video->frame_buf_size == 0) { LOGE("refresh 1"); refresh(state, 1); } else { vf = &state->video->frame_buf[state->video->frame_display_index]; state->video->video_current_pts = vf->pts; state->video->video_current_pts_time = av_gettime(); delay = vf->pts - state->video->frame_last_pts; if(delay <= 0 || delay >= 1.0) { delay = state->video->frame_last_delay; } state->video->frame_last_delay = delay; state->video->frame_last_pts = vf->pts; ref_clk = get_external_clock(); diff = vf->pts - ref_clk; sync_threshold = (delay > AV_SYNC_THRESHOLD) ? delay : AV_SYNC_THRESHOLD; if(fabs(diff) < AV_NOSYNC_THRESHOLD) { if(diff <= -sync_threshold) { delay = 0; } else if(diff > sync_threshold) { delay = 2 * delay; } } state->video->frame_timer += delay; actual_delay = state->video->frame_timer - (av_gettime() / 1000000.0); if(actual_delay < 0.010) { actual_delay = 0.010; } refresh(state, (int)(actual_delay * 1000) + 0.5); LOGI("%s : %d", "delay", (int)(actual_delay * 1000 + 0.5)); LOGW("frame buffer size : %d", state->video->frame_buf_size); // LOGW("convert : %d", state->video->frame_convert_index); // LOGW("display : %d", state->video->frame_display_index); play_video(state->video); if(++state->video->frame_display_index == MAX_VIDEO_FRAME_BUF_SIZE) { state->video->frame_display_index = 0; } SDL_LockMutex(state->video->frame_buf_mutex); state->video->frame_buf_size--; SDL_CondSignal(state->video->frame_buf_cond); SDL_UnlockMutex(state->video->frame_buf_mutex); } } }
void on_click (ClutterActor *actor, ClutterEvent *event, gpointer data) { HandCar *all = (HandCar *)data; gint x, y; gint64 pos = -1; clutter_event_get_coords (event, &x, &y); if (coord_within_actor (all->btn_actor_play, x, y)) { if (!all->playing) { play_video (all); clutter_texture_set_pixbuf (CLUTTER_TEXTURE(all->btn_actor_play), all->stop, NULL); all->playing = TRUE; } else { stop_video (all); clutter_texture_set_pixbuf (CLUTTER_TEXTURE(all->btn_actor_play), all->play, NULL); all->playing = FALSE; } } else if ((coord_within_actor (all->btn_actor_next, x, y) && (all->playing))) { if (!gst_element_query_position (all->player, &all->format, &pos)) pos = 0; gst_element_seek_simple (all->player, all->format, GST_SEEK_FLAG_FLUSH, pos + 5 * GST_SECOND); } else if ((coord_within_actor (all->btn_actor_previous, x, y) && (all->playing))) { if (!gst_element_query_position (all->player, &all->format, &pos)) pos = 5 * GST_SECOND; gst_element_seek_simple (all->player, all->format, GST_SEEK_FLAG_FLUSH, pos - 5 * GST_SECOND); } }
//---------- Begin of function WinMain ----------// //! //! WinMain - initialization, message loop //! //! Compilation constants: //! //! DEBUG - normal debugging //! //! DEMO - demo version //! ADMIN - administrator version //! NO_CDCHECK - no CD check //! NO_AUTOSAVE - no autosave //! //! Release version defines: //! Standard version: DEBUG, NO_MEM_CLASS //! Administrator version: DEBUG, NO_MEM_CLASS, ADMIN //! Demo version: DEBUG, NO_MEM_CLASS, DEMO //! int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //------ set game directory and check CD ------// sys.set_game_dir(); #ifndef NO_CDCHECK #ifndef DEMO if( !sys.cdrom_drive ) { #ifdef ADMIN char* msg = "Please insert Virtual U - Administrator Version CDROM and try again."; #else char* msg = "Please insert Virtual U CDROM and try again."; #endif MessageBox(sys.main_hwnd, msg, WIN_TITLE, MB_OK | MB_ICONERROR); return 0; } #endif #endif //----------- play movie ---------------// OSVERSIONINFO osVersion; memset( &osVersion, 0, sizeof(osVersion) ); // do not play movie in Win2000 osVersion.dwOSVersionInfoSize = sizeof(osVersion); if( !m.is_file_exist("SKIPAVI.SYS") && GetVersionEx(&osVersion) && osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { play_video(hInstance, 0); } config.init(); //--------------------------------------// if( !sys.init(hInstance) ) return FALSE; err.set_extra_handler( extra_error_handler ); // set extra error handler, save the game when a error happens #ifdef DEBUG // break at exception, for debugging if( sys.debug_session ) { // directX may change fpu control word, so change after sys.init // all exception but no inexact, underflow and denormal number exception _control87( _EM_INEXACT | _EM_UNDERFLOW | _EM_DENORMAL, _MCW_EM ); } #endif // DEBUG #ifdef DEMO audio.play_wav("DEMOOPEN",audio.int_to_DsVolume(config.sound_effect_volume)); #endif game.main_menu(); #ifdef DEMO demo_screen(); #endif sys.deinit(); return 0; }
int main(int argc, char **argv) { /* PacketQueue *a = av_mallocz(sizeof(PacketQueue)); AVPacket *p = av_mallocz(sizeof(AVPacket)); AVPacket *b = av_mallocz(sizeof(AVPacket)); add_to_queue(a, p); add_to_queue(a, p); add_to_queue(a, p); add_to_queue(a, p); get_from_queue(a, b); add_to_queue(a, p); get_from_queue(a, b); get_from_queue(a, b); get_from_queue(a, b); get_from_queue(a, b); av_free(a); av_free(p); */ FileState *file = av_mallocz(sizeof(FileState)); VideoState *video = av_mallocz(sizeof(VideoState)); AudioState *audio = av_mallocz(sizeof(AudioState)); State *state = av_mallocz(sizeof(State)); SDL_Thread *video_decode_tid; SDL_Thread *read_pkt_tid; SDL_Thread *play_tid; state->file = file; state->video = video; state->audio = audio; if(argc < 2) { fprintf(stderr, "Usage : play <file>\n"); exit(1); } av_register_all(); if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) { fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError()); exit(1); } av_strlcpy(file->fileName, argv[1], sizeof(file->fileName)); video->vFrameqMutex = SDL_CreateMutex(); video->vFrameqCond = SDL_CreateCond(); get_file_info(file); find_av_streams(file, video, audio); //find_audio_decoder(audio); init_screen(video); read_pkt_tid = SDL_CreateThread(queue_av_pkt, state); init_frame(video); video_decode_tid = SDL_CreateThread(decode_video, video); /* video->frame_timer = (double)av_gettime() / 1000000.0; video->frame_last_delay = 40e-3; video->pCodecCtx->get_buffer = our_get_buffer; video->pCodecCtx->release_buffer = our_release_buffer;*/ // play_tid = SDL_CreateThread(play_video, video); while(true) { // decode_video(video); play_video(video); } sleep(10); if(!video_decode_tid) { av_free(video_decode_tid); return -1; } if(!read_pkt_tid) { av_free(read_pkt_tid); return -1; } return 0; }