GF_Err LIBPLAYER_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { LibPlayerIn *read = (LibPlayerIn *) plug->priv; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIN] instance %d disconnect channel\n", read->player_id)); gf_term_on_disconnect(read->service, channel, GF_OK); return GF_OK; }
static GF_Err VTT_CloseService(GF_InputService *plug) { VTTIn *vttin; if (!plug) return GF_BAD_PARAM; vttin = (VTTIn *)plug->priv; if (!vttin) return GF_BAD_PARAM; //if (vttin->szFile) { // gf_delete_file(vttin->szFile); // gf_free(vttin->szFile); //} //vttin->szFile = NULL; if (vttin->dnload) { gf_term_download_del(vttin->dnload); } vttin->dnload = NULL; if (vttin->service) { gf_term_on_disconnect(vttin->service, NULL, GF_OK); } vttin->service = NULL; return GF_OK; }
static GF_Err TTIn_CloseService(GF_InputService *plug) { TTIn *tti; if (!plug) return GF_BAD_PARAM; tti = (TTIn *)plug->priv; if (!tti) return GF_BAD_PARAM; if (tti->samp) gf_isom_sample_del(&tti->samp); tti->samp = NULL; if (tti->mp4) gf_isom_delete(tti->mp4); tti->mp4 = NULL; if (tti->szFile) { gf_delete_file(tti->szFile); gf_free(tti->szFile); tti->szFile = NULL; } if (tti->dnload) gf_term_download_del(tti->dnload); tti->dnload = NULL; if (tti->service) gf_term_on_disconnect(tti->service, NULL, GF_OK); tti->service = NULL; return GF_OK; }
static GF_Err FFD_CloseService(GF_InputService *plug) { FFDemux *ffd = plug->priv; ffd->is_running = 0; if (ffd->ctx) av_close_input_file(ffd->ctx); ffd->ctx = NULL; ffd->audio_ch = ffd->video_ch = NULL; ffd->audio_run = ffd->video_run = 0; if (ffd->dnload) { if (ffd->is_running) { while (!ffd->is_running) gf_sleep(1); ffd->is_running = 0; } gf_term_download_del(ffd->dnload); ffd->dnload = NULL; } if (ffd->buffer) gf_free(ffd->buffer); ffd->buffer = NULL; gf_term_on_disconnect(ffd->service, NULL, GF_OK); #ifdef FFMPEG_DUMP_REMOTE if (ffd->outdbg) fclose(ffd->outdbg); #endif return GF_OK; }
static GF_Err MP3_CloseService(GF_InputService *plug) { MP3Reader *read = plug->priv; if (read->stream) fclose(read->stream); read->stream = NULL; if (read->dnload) gf_term_download_del(read->dnload); read->dnload = NULL; if (read->data) gf_free(read->data); read->data = NULL; if (read->liveDataCopy){ gf_free(read->liveDataCopy); read->liveDataCopy = NULL; read->liveDataCopySize = 0; } if (read->icy_name) gf_free(read->icy_name); read->icy_name = NULL; if (read->icy_genre) gf_free(read->icy_genre); read->icy_genre = NULL; if (read->icy_track_name) gf_free(read->icy_track_name); read->icy_track_name = NULL; gf_term_on_disconnect(read->service, NULL, GF_OK); return GF_OK; }
GF_Err DC_CloseService(GF_InputService *plug) { DCReader *read = (DCReader *) plug->priv; if (read->dnload) gf_term_download_del(read->dnload); read->dnload = NULL; gf_term_on_disconnect(read->service, NULL, GF_OK); return GF_OK; }
static GF_Err V4_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { V4Service *v4serv = (V4Service *)plug->priv; Bool had_ch; had_ch = v4serv->V4_RemoveChannel(v4serv, channel); gf_term_on_disconnect(v4serv->GetService(), channel, had_ch ? GF_OK : GF_STREAM_NOT_FOUND); return GF_OK; }
GF_Err DC_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { Bool had_ch; DCReader *read = (DCReader *) plug->priv; had_ch = DC_RemoveChannel(read, channel); gf_term_on_disconnect(read->service, channel, had_ch ? GF_OK : GF_STREAM_NOT_FOUND); return GF_OK; }
static GF_Err HYB_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { GF_HYB_In *hyb_in = (GF_HYB_In*)plug->priv; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[HYB_IN] Received Channel Disconnect Service (%p) request from terminal\n", hyb_in->service)); gf_term_on_disconnect(hyb_in->service, channel, GF_OK); hyb_in->master->channel = NULL; return GF_OK; }
static GF_Err M2TS_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { M2TSIn *m2ts = plug->priv; GF_Err e = GF_STREAM_NOT_FOUND; GF_M2TS_PES *pes = M2TS_GetChannel(m2ts, channel); if (pes) { pes->user = NULL; e = GF_OK; } gf_term_on_disconnect(m2ts->service, channel, e); return GF_OK; }
static GF_Err TTIn_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { TTIn *tti = (TTIn *)plug->priv; GF_Err e = GF_STREAM_NOT_FOUND; if (tti->ch == channel) { tti->ch = NULL; e = GF_OK; } gf_term_on_disconnect(tti->service, channel, e); return GF_OK; }
/* Indicate that the media source object is unused anymore */ static GF_Err MSE_CloseService(GF_InputService *plug) { GF_MSE_In *msein = (GF_MSE_In*) plug->priv; assert( msein ); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MSE_IN] Received Close Service request on Service %p from terminal for URL '%s'\n", msein->mediasource->service, msein->mediasource->blobURI)); if (msein->mediasource) { gf_term_on_disconnect(msein->mediasource->service, NULL, GF_OK); gf_mse_mediasource_del(msein->mediasource, GF_FALSE); msein->mediasource = NULL; } return GF_OK; }
static GF_Err AC3_CloseService(GF_InputService *plug) { AC3Reader *read = plug->priv; if (read->stream) fclose(read->stream); read->stream = NULL; if (read->dnload) gf_term_download_del(read->dnload); read->dnload = NULL; if (read->data) gf_free(read->data); read->data = NULL; gf_term_on_disconnect(read->service, NULL, GF_OK); return GF_OK; }
static GF_Err MP3_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { MP3Reader *read = plug->priv; GF_Err e = GF_STREAM_NOT_FOUND; if (read->ch == channel) { read->ch = NULL; if (read->data) gf_free(read->data); read->data = NULL; e = GF_OK; } gf_term_on_disconnect(read->service, channel, e); return GF_OK; }
GF_Err MPD_CloseService(GF_InputService *plug) { GF_MPD_In *mpdin = (GF_MPD_In*) plug->priv; assert( mpdin ); GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[MPD_IN] Received Close Service (%p) request from terminal\n", mpdin->service)); if (mpdin->dash) gf_dash_close(mpdin->dash); gf_term_on_disconnect(mpdin->service, NULL, GF_OK); return GF_OK; }
static GF_Err VTT_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { VTTIn *vttin = (VTTIn *)plug->priv; GF_Err e = GF_STREAM_NOT_FOUND; if (!vttin) return GF_BAD_PARAM; if (vttin->channel == channel) { vttin->channel = NULL; e = GF_OK; } gf_term_on_disconnect(vttin->service, channel, e); return GF_OK; }
static GF_Err M2TS_CloseService(GF_InputService *plug) { M2TSIn *m2ts = plug->priv; GF_M2TS_Demuxer* ts = m2ts->ts; TSDemux_CloseDemux(ts); if (ts->dnload) gf_term_download_del(ts->dnload); ts->dnload = NULL; gf_term_on_disconnect(m2ts->service, NULL, GF_OK); return GF_OK; }
static GF_Err SAF_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { SAFChannel *ch; SAFIn *read = (SAFIn *)plug->priv; GF_Err e = GF_STREAM_NOT_FOUND; ch = saf_get_channel(read, 0, channel); if (ch) { gf_list_del_item(read->channels, ch); if (ch->esd) gf_odf_desc_del((GF_Descriptor*)ch->esd); gf_free(ch); e = GF_OK; } gf_term_on_disconnect(read->service, channel, e); return GF_OK; }
static GF_Err RP_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { RTPStream *ch; RTPClient *priv = (RTPClient *)plug->priv; GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP] Disconnecting channel @%08x\n", channel)); ch = RP_FindChannel(priv, channel, 0, NULL, 0); if (!ch) return GF_STREAM_NOT_FOUND; gf_mx_p(priv->mx); /*disconnect stream BUT DO NOT DELETE IT since we don't store SDP*/ ch->flags &= ~RTP_CONNECTED; ch->channel = NULL; gf_mx_v(priv->mx); gf_term_on_disconnect(priv->service, channel, GF_OK); return GF_OK; }
static GF_Err RP_CloseService(GF_InputService *plug) { u32 i; const char *opt; RTSPSession *sess; RTPClient *rtp = (RTPClient *)plug->priv; GF_LOG(GF_LOG_DEBUG, GF_LOG_RTP, ("[RTP] Closing service\n")); RP_FlushCommands(rtp); if (rtp->session_migration) { opt = gf_modules_get_option((GF_BaseInterface *) plug, "Streaming", "SessionMigrationPause"); if (opt && !strcmp(opt, "yes")) { GF_NetworkCommand com; com.command_type = GF_NET_CHAN_PAUSE; com.base.on_channel = NULL; /*send pause on all sessions*/ i=0; while ((sess = (RTSPSession *)gf_list_enum(rtp->sessions, &i))) { RP_UserCommand(sess, NULL, &com); } } RP_SaveSessionState(rtp); } else { /*remove session state file*/ if (rtp->session_state_data) { gf_free(rtp->session_state_data); rtp->session_state_data = NULL; } /*send teardown on all sessions*/ i=0; while ((sess = (RTSPSession *)gf_list_enum(rtp->sessions, &i))) { RP_Teardown(sess, NULL); } } RP_FlushCommands(rtp); /*shutdown thread*/ if (rtp->th_state==1) rtp->th_state = 0; /*confirm close*/ gf_term_on_disconnect(rtp->service, NULL, GF_OK); return GF_OK; }
static GF_Err FFD_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { GF_Err e; FFDemux *ffd = plug->priv; e = GF_STREAM_NOT_FOUND; if (ffd->audio_ch == channel) { e = GF_OK; ffd->audio_ch = NULL; ffd->audio_run = 0; } else if (ffd->video_ch == channel) { e = GF_OK; ffd->video_ch = NULL; ffd->video_run = 0; } gf_term_on_disconnect(ffd->service, channel, e); return GF_OK; }
static GF_Err SAF_CloseService(GF_InputService *plug) { SAFIn *read = (SAFIn *)plug->priv; if (read->th) { if (read->run_state == 1) { read->run_state=0; while (read->run_state!=2) gf_sleep(2); } gf_th_del(read->th); read->th = NULL; } if (read->stream) fclose(read->stream); read->stream = NULL; if (read->dnload) gf_term_download_del(read->dnload); read->dnload = NULL; gf_term_on_disconnect(read->service, NULL, GF_OK); return GF_OK; }
static GF_Err HYB_CloseService(GF_InputService *plug) { GF_Err e; GF_HYB_In *hyb_in = (GF_HYB_In*)plug->priv; GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[HYB_IN] Received Close Service (%p) request from terminal\n", ((GF_HYB_In*)plug->priv)->service)); /*force to stop and disconnect the master*/ hyb_in->master->SetState(hyb_in->master, GF_NET_CHAN_STOP); e = hyb_in->master->Disconnect(hyb_in->master); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[HYB_IN] Error - cannot disconnect service %p\n", hyb_in->service)); gf_term_on_connect(hyb_in->service, NULL, GF_BAD_PARAM); return e; } gf_term_on_disconnect(hyb_in->service, NULL, GF_OK); return GF_OK; }
GF_Err LIBPLAYER_CloseService(GF_InputService *plug) { LibPlayerIn *read = (LibPlayerIn *) plug->priv; if(libplayer_id >= 0){ #ifndef TEST_LIBPLAYER printf("in do loop\n"); printf("[LibPlayerIN]read->url: %s\n", read->url); player_playback_stop(read->player); printf("[LibPlayerIN]player_playback_stop\n"); player_uninit(read->player); printf("[LibPlayerIN]player_uninit\n"); read->player = NULL; libplayer_id--; #endif read->state = 0; } gf_term_on_disconnect(read->service, NULL, GF_OK); GF_LOG(GF_LOG_DEBUG, GF_LOG_MODULE, ("[LibPlayerIn] Closing libplayer instance %d\n", read->player_id)); return GF_OK; }
GF_Err ISOR_CloseService(GF_InputService *plug) { GF_Err reply; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; reply = GF_OK; if (read->mov) gf_isom_close(read->mov); read->mov = NULL; while (gf_list_count(read->channels)) { ISOMChannel *ch = (ISOMChannel *)gf_list_get(read->channels, 0); gf_list_rem(read->channels, 0); isor_delete_channel(read, ch); } if (read->dnload) gf_term_download_del(read->dnload); read->dnload = NULL; gf_term_on_disconnect(read->service, NULL, reply); return GF_OK; }
GF_Err ISOR_DisconnectChannel(GF_InputService *plug, LPNETCHANNEL channel) { ISOMChannel *ch; GF_Err e; ISOMReader *read; if (!plug || !plug->priv) return GF_SERVICE_ERROR; read = (ISOMReader *) plug->priv; if (!read->mov) return GF_SERVICE_ERROR; e = GF_OK; ch = isor_get_channel(read, channel); assert(ch); if (!ch) { e = GF_STREAM_NOT_FOUND; goto exit; } /*signal the service is broken but still process the delete*/ isor_delete_channel(read, ch); assert(!isor_get_channel(read, channel)); exit: gf_term_on_disconnect(read->service, channel, e); return e; }
GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_evt, s32 group_idx, GF_Err error_code) { GF_Err e; u32 i; GF_MPD_In *mpdin = (GF_MPD_In *)dashio->udta; if (dash_evt==GF_DASH_EVENT_PERIOD_SETUP_ERROR) { if (!mpdin->connection_ack_sent) { gf_term_on_connect(mpdin->service, NULL, error_code); mpdin->connection_ack_sent= GF_TRUE; } return GF_OK; } if (dash_evt==GF_DASH_EVENT_SELECT_GROUPS) { //configure buffer in dynamic mode without low latency: we indicate how much the player will buffer if (gf_dash_is_dynamic_mpd(mpdin->dash) && !mpdin->use_low_latency) { u32 buffer_ms = 0; const char *opt = gf_modules_get_option((GF_BaseInterface *)mpdin->plug, "Network", "BufferLength"); if (opt) buffer_ms = atoi(opt); //use min buffer from MPD if (mpdin->buffer_mode>=MPDIN_BUFFER_MIN) { u32 mpd_buffer_ms = gf_dash_get_min_buffer_time(mpdin->dash); if (mpd_buffer_ms > buffer_ms) buffer_ms = mpd_buffer_ms; } if (buffer_ms) { gf_dash_set_user_buffer(mpdin->dash, buffer_ms); } } //let the player decide which group to play: we declare everything return GF_OK; } /*for all selected groups, create input service and connect to init/first segment*/ if (dash_evt==GF_DASH_EVENT_CREATE_PLAYBACK) { /*select input services if possible*/ for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { const char *mime, *init_segment; //let the player decide which group to play if (!gf_dash_is_group_selectable(mpdin->dash, i)) continue; mime = gf_dash_group_get_segment_mime(mpdin->dash, i); init_segment = gf_dash_group_get_segment_init_url(mpdin->dash, i, NULL, NULL); e = MPD_LoadMediaService(mpdin, i, mime, init_segment); if (e != GF_OK) { gf_dash_group_select(mpdin->dash, i, 0); } else { u32 w, h; /*connect our media service*/ GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); gf_dash_group_get_video_info(mpdin->dash, i, &w, &h); if (w && h && w>mpdin->width && h>mpdin->height) { mpdin->width = w; mpdin->height = h; } e = group->segment_ifce->ConnectService(group->segment_ifce, mpdin->service, init_segment); if (e) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[MPD_IN] Unable to connect input service to %s\n", init_segment)); gf_dash_group_select(mpdin->dash, i, 0); } else { group->service_connected = 1; } } } if (!mpdin->connection_ack_sent) { gf_term_on_connect(mpdin->service, NULL, GF_OK); mpdin->connection_ack_sent=1; } return GF_OK; } /*for all running services, stop service*/ if (dash_evt==GF_DASH_EVENT_DESTROY_PLAYBACK) { mpdin->service->subservice_disconnect = 1; gf_term_on_disconnect(mpdin->service, NULL, GF_OK); mpdin->service->subservice_disconnect = 2; for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); if (!group) continue; if (group->segment_ifce) { if (group->service_connected) { group->segment_ifce->CloseService(group->segment_ifce); group->service_connected = 0; } gf_modules_close_interface((GF_BaseInterface *) group->segment_ifce); } gf_free(group); gf_dash_set_group_udta(mpdin->dash, i, NULL); } mpdin->service->subservice_disconnect = 0; return GF_OK; } if (dash_evt==GF_DASH_EVENT_BUFFERING) { u32 tot, done; gf_dash_get_buffer_info_buffering(mpdin->dash, &tot, &done); fprintf(stderr, "DASH: Buffering %g%% out of %d ms\n", (100.0*done)/tot, tot); return GF_OK; } if (dash_evt==GF_DASH_EVENT_SEGMENT_AVAILABLE) { if (group_idx>=0) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, group_idx); if (group) MPD_NotifyData(group, 0); } } return GF_OK; }
GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_evt, GF_Err error_code) { GF_Err e; u32 i; GF_MPD_In *mpdin = (GF_MPD_In *)dashio->udta; if (dash_evt==GF_DASH_EVENT_PERIOD_SETUP_ERROR) { if (!mpdin->connection_ack_sent) { gf_term_on_connect(mpdin->service, NULL, error_code); mpdin->connection_ack_sent=1; } return GF_OK; } if (dash_evt==GF_DASH_EVENT_SELECT_GROUPS) { const char *opt; for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { /*todo: select groups based on user criteria*/ gf_dash_group_select(mpdin->dash, i, 1); } opt = gf_modules_get_option((GF_BaseInterface *)mpdin->plug, "Systems", "Language3CC"); if (opt && strcmp(opt, "und")) gf_dash_groups_set_language(mpdin->dash, opt); return GF_OK; } /*for all selected groups, create input service and connect to init/first segment*/ if (dash_evt==GF_DASH_EVENT_CREATE_PLAYBACK) { /*select input services if possible*/ for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { const char *mime, *init_segment; if (!gf_dash_is_group_selected(mpdin->dash, i)) continue; mime = gf_dash_group_get_segment_mime(mpdin->dash, i); init_segment = gf_dash_group_get_segment_init_url(mpdin->dash, i, NULL, NULL); e = MPD_LoadMediaService(mpdin, i, mime, init_segment); if (e != GF_OK) { gf_dash_group_select(mpdin->dash, i, 0); } else { /*connect our media service*/ GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); e = group->segment_ifce->ConnectService(group->segment_ifce, mpdin->service, init_segment); if (e) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[MPD_IN] Unable to connect input service to %s\n", init_segment)); gf_dash_group_select(mpdin->dash, i, 0); } else { u32 w, h; group->service_connected = 1; w = h = 0; gf_dash_group_get_video_info(mpdin->dash, i, &w, &h); if (w && h && w>mpdin->width && h>mpdin->height) { mpdin->width = w; mpdin->height = h; } } } } if (!mpdin->connection_ack_sent) { gf_term_on_connect(mpdin->service, NULL, GF_OK); mpdin->connection_ack_sent=1; } return GF_OK; } /*for all running services, stop service*/ if (dash_evt==GF_DASH_EVENT_DESTROY_PLAYBACK) { mpdin->service->subservice_disconnect = 1; gf_term_on_disconnect(mpdin->service, NULL, GF_OK); mpdin->service->subservice_disconnect = 2; for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); if (!group) continue; if (group->segment_ifce) { if (group->service_connected) { group->segment_ifce->CloseService(group->segment_ifce); group->service_connected = 0; } gf_modules_close_interface((GF_BaseInterface *) group->segment_ifce); } gf_free(group); gf_dash_set_group_udta(mpdin->dash, i, NULL); } mpdin->service->subservice_disconnect = 0; } return GF_OK; }
static GF_Err V4_CloseService(GF_InputService *plug) { V4Service *v4serv = (V4Service *)plug->priv; gf_term_on_disconnect(v4serv->GetService(), NULL, GF_OK); return GF_OK; }