Example #1
0
int rtp_start_stream (media_stream_t* stream)
{
   if(stream->status == MP_STREAM_STREAMING)
      return MP_OK;
      
   if(!stream->player)
   {
      rtp_debug(("\rrtp_start_stream: no player\n"));
      return MP_FAIL;
   }

   stream->player->start(stream->player);

   if(stream->maker)
      stream->maker->start(stream->maker);

   stream->status = MP_STREAM_STREAMING;
   rtp_debug(("\rrtp_start_stream: stream started\n"));
         
   return MP_OK;
}
Example #2
0
int rtp_stream_on_member_update(void *gen, uint32 ssrc, char *cn, int cnlen)
{
   media_stream_t *strm = (media_stream_t*)gen;
   rtp_stream_t *rtpstrm = (rtp_stream_t*)gen;

   if(strcmp(rtpstrm->source_cname, cn) != 0)
   {
      rtp_log(("rtp_stream_on_member_update: start stream[%s]\n", cn));
      rtpstrm->source_cname = xstr_clone(cn);
   }

   rtp_debug(("\rrtp_stream_on_member_update: stream[%s] ok\n\n\n", cn));   
   strm->start(strm);
   
   return MP_OK;
}
Example #3
0
media_player_t* rtp_new_stream_player(media_format_t *mf, int strmno, media_control_t* ctrl, char* mode, void* mode_param)
{
	media_stream_t *cur = mf->first;

   if(!mode)
      mode = "rtp";

	while (cur != NULL)
	{
		rtp_stream_t* rtp_strm = (rtp_stream_t*)cur;
		if (rtp_strm->sno == strmno)
		{
			cur->player = ctrl->find_player(ctrl, mode, cur->media_info->mime, cur->media_info->fourcc);

			if(!cur->player)
			{
				rtp_debug(("rtp_new_stream_player: stream can't be played\n"));
				cur->playable = -1;
				return NULL;

			}

			if( cur->player->open_stream(cur->player, cur, cur->media_info) < MP_OK)
			{
				cur->playable = -1;
				return NULL;
			}

			cur->playable = 1;

			rtp_log(("rtp_new_stream_player: player ok\n"));

			return cur->player;
		}

		cur = cur->next;
	}


	return NULL;
}
Example #4
0
int stream_debug(struct re_printf *pf, const struct stream *s)
{
	struct sa rrtcp;
	int err;

	if (!s)
		return 0;

	err  = re_hprintf(pf, " %s dir=%s pt_enc=%d\n", sdp_media_name(s->sdp),
			  sdp_dir_name(sdp_media_dir(s->sdp)),
			  s->pt_enc);

	sdp_media_raddr_rtcp(s->sdp, &rrtcp);
	err |= re_hprintf(pf, " remote: %J/%J\n",
			  sdp_media_raddr(s->sdp), &rrtcp);

	err |= rtp_debug(pf, s->rtp);
	err |= jbuf_debug(pf, s->jbuf);

	return err;
}
Example #5
0
media_player_t * rtp_new_mime_player(media_format_t * mf, char * mime, media_control_t* ctrl, char* mode, void* mode_param)
{
	media_stream_t *cur = mf->first;

    if(!mode)
        mode = "rtp";

	while (cur != NULL)
	{
		if (!strcmp(cur->mime, mime))
		{
			cur->player = ctrl->find_player(ctrl, mode, mime, NULL);

			if(!cur->player)
			{
				rtp_debug(("rtp_new_mime_player: stream can't be played\n"));
				cur->playable = -1;
				return NULL;
			}

			if( cur->player->open_stream(cur->player, cur, cur->media_info) < MP_OK)
			{
				cur->playable = -1;
				return NULL;
			}

			cur->playable = 1;

			rtp_log(("rtp_new_mime_player: player ok\n"));
		}

		cur = cur->next;
	}


	return NULL;
}
Example #6
0
int rtp_set_player (media_format_t * mf, media_player_t * player)
{
   int ret;
   char * type;

   type = player->media_type(player);
   if ( (ret = rtp_set_mime_player (mf, type, player)) >= MP_OK )
   {
      rtp_log (("rtp_set_player: '%s' stream playable\n", type));
      return ret;
   }
   
   type = player->codec_type(player);
   if ( (ret = rtp_set_mime_player (mf, type, player)) >= MP_OK )
   {
      rtp_log (("rtp_set_player: play '%s' stream\n", type));
      return ret;
   }

   rtp_debug(("rtp_set_player: can't play the media with player\n"));


   return ret;
}
Example #7
0
rtp_stream_t* rtp_open_stream(rtp_format_t *rtp_format, int sno, rtpcap_descript_t *rtpcap, media_control_t *ctrl, char *mode, int bw_budget, void* extra)
{
	unsigned char stype;
	rtp_stream_t *strm;
   rtp_stream_t *peer;

   rtp_setting_t *rset = NULL;

   int rtp_portno, rtcp_portno;

	module_catalog_t *cata = ctrl->modules(ctrl);
   
	rtpcap_set_t* rtpcapset = (rtpcap_set_t*)extra;
	user_profile_t* user_prof = rtpcapset->user_profile;

	char* remote_nettype;
	char* remote_addrtype;
	char* remote_netaddr;

   if(strncmp(rtpcap->profile_mime, "audio", 5) == 0)
	{
		rtp_log(("rtp_open_stream: audio media\n"));

		stype = MP_AUDIO;
	}
	else if(strncmp(rtpcap->profile_mime, "video", 5) == 0)
	{
		rtp_log(("rtp_open_stream: video media type\n"));
		stype = MP_VIDEO;
	}
	else if(strncmp(rtpcap->profile_mime, "text", 4) == 0)
	{
		rtp_log(("rtp_open_stream: text media type\n"));
		stype = MP_TEXT;
	}
	else
	{
		rtp_debug(("rtp_open_stream: Unknown media type\n"));
		return NULL;
	}

	strm = xmalloc(sizeof(rtp_stream_t));
	if(!strm)
	{
		rtp_debug(("rtp_open_stream: No memory for rtp stream\n"));
		return NULL;
	}   

	peer = xmalloc(sizeof(rtp_stream_t));
	if(!peer)
	{
		rtp_debug(("rtp_open_stream: No memory for rtp stream\n"));
      xfree(strm);
		return NULL;
	}
   
	memset(strm, 0, sizeof(rtp_stream_t));
	memset(peer, 0, sizeof(rtp_stream_t));

   strm->stream.peer = (media_stream_t*)peer;
   peer->stream.peer = (media_stream_t*)strm;

	rset = (rtp_setting_t*)ctrl->fetch_setting(ctrl, "rtp", (media_device_t*)rtp_format->rtp_in);
	if(!rset)
	{
		rtp_debug(("rtp_open_stream: No rtp setting\n"));
		xfree(strm);
		return NULL;

	}

	strm->session = rtp_format->rtp_in->rtp_session(rtp_format->rtp_in, cata, ctrl,
									user_prof->cname, strlen(user_prof->cname)+1,
									user_prof->user->nettype, user_prof->user->addrtype, 
									user_prof->user->netaddr, 
									rset->default_rtp_portno, rset->default_rtcp_portno,
									rtpcap->profile_no, rtpcap->profile_mime, 
									rtpcap->clockrate, rtpcap->coding_param,
									bw_budget, rtpcap);

	if(!strm->session)
	{
		xfree(strm);
        
		rtp_debug(("rtp_open_stream: no session created\n"));

		return NULL;
	}

   strm->session->media_stream = strm;
	rtp_debug(("\rrtp_open_stream: strm@%x\n", (int)strm));

	/* get real portno and payload type */
	session_portno(strm->session, &rtp_portno, &rtcp_portno);
	rtpcap->profile_no = session_payload_type(strm->session);

	strm->rtp_format = rtp_format;
	peer->rtp_format = rtp_format;

   strm->rtp_cap = rtpcap;
   peer->rtp_cap = rtpcap;

   strm->stream.media_info = session_mediainfo(strm->session);
   peer->stream.media_info = strm->stream.media_info;
   
   peer->session = strm->session;
   
   strm->stream.start = rtp_start_stream;
   strm->stream.stop = rtp_stop_stream;
   
   peer->stream.start = rtp_start_stream;
   peer->stream.stop = rtp_stop_stream;

	rtp_log(("rtp_open_stream: FIXME - stream mime string overflow possible!!\n"));
	strcpy(strm->stream.mime, rtpcap->profile_mime);

	rtp_add_stream((media_format_t*)rtp_format, (media_stream_t*)strm, sno, stype);

	if(rtpcap->netaddr)
	{
		remote_nettype = rtpcap->nettype;
		remote_addrtype = rtpcap->addrtype;
		remote_netaddr = rtpcap->netaddr;
	}
	else
	{
		remote_nettype = rtpcapset->nettype;
		remote_addrtype = rtpcapset->addrtype;
		remote_netaddr = rtpcapset->netaddr;
	}
	
	rtp_log(("rtp_open_stream: for %s:%s(%u|%u)\n", rtpcapset->cname, remote_netaddr, rtpcap->rtp_portno, rtpcap->rtcp_portno));
	rtp_log(("rtp_open_stream: mime[%s] pt[%d]\n", rtpcap->profile_mime, rtpcap->profile_no));
   
	session_add_cname(strm->session, rtpcapset->cname, strlen(rtpcapset->cname), remote_netaddr, rtpcap->rtp_portno, rtpcap->rtcp_portno, rtpcap, ctrl);
	
	/* waiting to source to be available */
	strm->source_cname = xstr_clone(rtpcapset->cname);
	strm->bandwidth = session_bandwidth(strm->session);
   
	peer->source_cname = xstr_clone(user_prof->cname);
	peer->bandwidth = strm->bandwidth;

	rtp_format->bandwidth += strm->bandwidth + peer->bandwidth;

	session_set_callback(strm->session, CALLBACK_SESSION_MEMBER_UPDATE, rtp_stream_on_member_update, strm);

	rtp_log(("rtp_open_stream: stream opened, bandwidth[%d]\n", strm->bandwidth));

	return strm;
}