diff --git a/lib/raop.h b/lib/raop.h index 6a3bca3..b6bd745 100644 --- a/lib/raop.h +++ b/lib/raop.h @@ -61,10 +61,12 @@ typedef enum video_codec_e { } video_codec_t; typedef enum reset_type_e { - RESET_TYPE_NOHOLD, - RESET_TYPE_RTP_SHUTDOWN, - RESET_TYPE_HLS_SHUTDOWN, - RESET_TYPE_HLS_EOS + RESET_TYPE_NOHOLD, + RESET_TYPE_RTP_SHUTDOWN, + RESET_TYPE_HLS_SHUTDOWN, + RESET_TYPE_HLS_EOS, + RESET_TYPE_ON_VIDEO_PLAY, + RESET_TYPE_TEARDOWN_110 } reset_type_t; struct raop_callbacks_s { diff --git a/uxplay.cpp b/uxplay.cpp index 420972f..cd5ac9d 100644 --- a/uxplay.cpp +++ b/uxplay.cpp @@ -2111,35 +2111,78 @@ static bool check_blocked_client(char *deviceid) { // Server callbacks + +//to be simplified extern "C" void video_reset(void *cls, reset_type_t type) { LOGD("video_reset"); - if (use_video) { - video_renderer_stop(); - } - if (hls_support && (type == RESET_TYPE_HLS_SHUTDOWN || type == RESET_TYPE_NOHOLD)) { - url.erase(); - raop_destroy_airplay_video(raop, -1); - } - if (type == RESET_TYPE_HLS_SHUTDOWN) { + switch (type) { + case RESET_TYPE_NOHOLD: + if (hls_support) { + url.erase(); + raop_destroy_airplay_video(raop, -1); + } + if (use_video) { + video_renderer_stop(); + /* reset the video renderer immediately to avoid a timing issue if we wait for main_loop to reset */ + video_renderer_destroy(); + video_renderer_init(render_logger, server_name.c_str(), videoflip, video_parser.c_str(), rtp_pipeline.c_str(), + video_decoder.c_str(), video_converter.c_str(), videosink.c_str(), + videosink_options.c_str(), fullscreen, video_sync, h265_support, + render_coverart, playbin_version, NULL); + video_renderer_start(); + close_window = false; // we already closed the window + } + preserve_connections = false; //we already closed all other connections + remote_clock_offset = 0; + relaunch_video = true; + break; + case RESET_TYPE_RTP_SHUTDOWN: + if (use_video) { + video_renderer_stop(); + } + remote_clock_offset = 0; + relaunch_video = true; + break; + case RESET_TYPE_HLS_SHUTDOWN: + if (use_video) { + video_renderer_stop(); + } + if (hls_support) { + url.erase(); + raop_destroy_airplay_video(raop, -1); + } raop_remove_hls_connections(raop); preserve_connections = true; + remote_clock_offset = 0; + relaunch_video = true; + break; + case RESET_TYPE_HLS_EOS: + if (use_video) { + /* reset the video renderer immediately to avoid a timing issue if we wait for main_loop to reset */ + video_renderer_stop(); + video_renderer_destroy(); + video_renderer_init(render_logger, server_name.c_str(), videoflip, video_parser.c_str(), rtp_pipeline.c_str(), + video_decoder.c_str(), video_converter.c_str(), videosink.c_str(), + videosink_options.c_str(), fullscreen, video_sync, h265_support, + render_coverart, playbin_version, NULL); + video_renderer_start(); + close_window = false; // we already closed the window + } + remote_clock_offset = 0; + relaunch_video = true; + break; + case RESET_TYPE_TEARDOWN_110: + if (use_video) { + video_renderer_stop(); + } + relaunch_video = true; + break; + case RESET_TYPE_ON_VIDEO_PLAY: + break; + default: + g_assert(FALSE); + break; } - if (use_video && (type == RESET_TYPE_NOHOLD || type == RESET_TYPE_HLS_EOS)) { - /* reset the video renderer immediately to avoid a timing issue if we wait for main_loop to reset */ - video_renderer_destroy(); - video_renderer_init(render_logger, server_name.c_str(), videoflip, video_parser.c_str(), rtp_pipeline.c_str(), - video_decoder.c_str(), video_converter.c_str(), videosink.c_str(), - videosink_options.c_str(), fullscreen, video_sync, h265_support, - render_coverart, playbin_version, NULL); - video_renderer_start(); - close_window = false; // we already closed the window - } - if (type == RESET_TYPE_NOHOLD) { - preserve_connections = false; //we already closed all other connections - } - - remote_clock_offset = 0; - relaunch_video = true; reset_loop = true; } @@ -2241,8 +2284,7 @@ extern "C" void conn_reset (void *cls, int reason) { extern "C" void conn_teardown(void *cls, bool *teardown_96, bool *teardown_110) { if (*teardown_110 && close_window) { - relaunch_video = true; - reset_loop = true; + video_reset(cls,RESET_TYPE_TEARDOWN_110); } } @@ -2582,7 +2624,7 @@ extern "C" void on_video_play(void *cls, const char* location, const float start relaunch_video = true; preserve_connections = true; LOGI("********************on_video_play: location = %s*** start position %f ********************", url.c_str(), start_position); - reset_loop = true; + video_reset(cls, RESET_TYPE_ON_VIDEO_PLAY); } extern "C" void on_video_scrub(void *cls, const float position) {