GF_Err RP_InitStream(RTPStream *ch, Bool ResetOnly) { gf_rtp_depacketizer_reset(ch->depacketizer, !ResetOnly); if (!ResetOnly) { const char *ip_ifce = NULL; u32 reorder_size = 0; if (!ch->owner->transport_mode) { const char *sOpt = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Streaming", "ReorderSize"); if (sOpt) reorder_size = atoi(sOpt); else reorder_size = 10; ip_ifce = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Network", "DefaultMCastInterface"); if (!ip_ifce) { const char *mob_on = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Network", "MobileIPEnabled"); if (mob_on && !strcmp(mob_on, "yes")) { ip_ifce = gf_modules_get_option((GF_BaseInterface *) gf_term_get_service_interface(ch->owner->service), "Network", "MobileIP"); ch->flags |= RTP_MOBILEIP; } } } return gf_rtp_initialize(ch->rtp_ch, RTP_BUFFER_SIZE, 0, 0, reorder_size, 200, (char *)ip_ifce); } //just reset the sockets gf_rtp_reset_buffers(ch->rtp_ch); return GF_OK; }
GF_Err PNC_InitRTP(GF_RTPChannel **chan, char *dest, int port, unsigned short mtu_size) { GF_Err res; GF_RTSPTransport tr; *chan = gf_rtp_new(); res = gf_rtp_set_ports(*chan, 0); if (res) { fprintf(stderr, "Cannot set RTP ports: %s\n", gf_error_to_string(res)); gf_rtp_del(*chan); return res; } tr.destination = dest; tr.IsUnicast = gf_sk_is_multicast_address(dest) ? 0 : 1; tr.Profile="RTP/AVP";//RTSP_PROFILE_RTP_AVP; tr.IsRecord = 0; tr.Append = 0; tr.source = "0.0.0.0"; tr.SSRC=rand(); tr.port_first = port; tr.port_last = port+1; if (tr.IsUnicast) { tr.client_port_first = port; tr.client_port_last = port+1; } else { tr.source = dest; tr.client_port_first = 0; tr.client_port_last = 0; } res = gf_rtp_setup_transport(*chan, &tr, dest); if (res) { fprintf(stderr, "Cannot setup RTP transport %s\n", gf_error_to_string(res)); gf_rtp_del(*chan); return res; } res = gf_rtp_initialize(*chan, 0, 1, mtu_size, 0, 0, NULL); if (res) { fprintf(stderr, "Cannot initialize RTP transport %s\n", gf_error_to_string(res)); gf_rtp_del(*chan); return res; } return GF_OK; }
static GF_Err rtp_stream_init_channel(GF_RTPStreamer *rtp, u32 path_mtu, const char * dest, int port, int ttl, const char *ifce_addr) { GF_RTSPTransport tr; GF_Err res; rtp->channel = gf_rtp_new(); gf_rtp_set_ports(rtp->channel, 0); memset(&tr, 0, sizeof(GF_RTSPTransport)); tr.IsUnicast = gf_sk_is_multicast_address(dest) ? 0 : 1; tr.Profile="RTP/AVP"; tr.destination = (char *)dest; tr.source = "0.0.0.0"; tr.IsRecord = 0; tr.Append = 0; tr.SSRC = rand(); tr.TTL = ttl; tr.port_first = port; tr.port_last = port+1; if (tr.IsUnicast) { tr.client_port_first = port; tr.client_port_last = port+1; } else { tr.source = (char *)dest; } res = gf_rtp_setup_transport(rtp->channel, &tr, dest); if (res !=0) { GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("Cannot setup RTP transport info: %s\n", gf_error_to_string(res) )); return res; } res = gf_rtp_initialize(rtp->channel, 0, 1, path_mtu, 0, 0, (char *)ifce_addr); if (res !=0) { GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("Cannot initialize RTP sockets: %s\n", gf_error_to_string(res) )); return res; } return GF_OK; }