Пример #1
0
void avb_init(chanend media_ctl[],
              chanend listener_ctl[],
              chanend talker_ctl[],
              chanend media_clock_ctl,
              chanend c_mac_rx0,
              chanend c_mac_tx0,
              chanend c_ptp0) 
{

#if AVB_OSC
  OSC_SET_RANGE(avb_source, 0, AVB_NUM_SOURCES-1);
  OSC_SET_RANGE(device_media_clock, 0, AVB_NUM_MEDIA_CLOCKS-1);
  OSC_SET_RANGE(avb_sink, 0, AVB_NUM_SINKS-1);
  OSC_SET_RANGE(media_in, 0, AVB_NUM_MEDIA_INPUTS-1);
  OSC_SET_RANGE(media_out, 0, AVB_NUM_MEDIA_OUTPUTS-1);
#endif

  mac_get_macaddr(c_mac_tx0, mac_addr);

  mrp_init((char *)mac_addr);
  register_talkers(talker_ctl);
  register_listeners(listener_ctl);
  register_media(media_ctl);
  init_media_clock_server(media_clock_ctl);

  avb_1722_maap_init(mac_addr);

#ifdef AVB_ENABLE_1722_1
  {
	  unsigned char serial_number[2] = { 0,1 };
	  avb_1722_1_init(mac_addr, serial_number);
  }
#endif

  c_mac_rx = c_mac_rx0;
  c_mac_tx = c_mac_tx0;
  c_ptp = c_ptp0;

  domain_attr = mrp_get_attr();
  mrp_attribute_init(domain_attr, MSRP_DOMAIN_VECTOR, NULL);

#ifdef AVB_INCLUDE_MMRP
  avb_mmrp_init();
#endif

#ifndef AVB_EXCLUDE_MVRP
  avb_mvrp_init();
#endif

  xc_abi_outuint(c_mac_tx, ETHERNET_TX_INIT_AVB_ROUTER);

  mac_set_custom_filter(c_mac_rx, MAC_FILTER_AVB_CONTROL);
}
int validate_stream(media_entry * p, SD_descr ** sd_descr)
{

	RTP_static_payload pt_info;
	char object[255], server[255];
	unsigned short port;
	int res;

	if (!(p->flags & ME_FILENAME)) {
		return ERR_PARSE;
	}
	if (!(p->description.flags & MED_PAYLOAD_TYPE)) {
		return ERR_PARSE;
	}
	if (!(p->description.flags & MED_PRIORITY)) {
		return ERR_PARSE;
	}

	/*
	 *- validate multicast
	 *- validate twin
	 * */
	if (parse_url
	    ((*sd_descr)->twin, server, sizeof(server), &port, object,
	     sizeof(object)))
		(*sd_descr)->flags &= ~SD_FL_TWIN;

	if (!is_valid_multicast_address((*sd_descr)->multicast))
		strcpy((*sd_descr)->multicast, DEFAULT_MULTICAST_ADDRESS);

	if (p->description.payload_type >= 96) {
		// Basic information needed for a dynamic payload type (96-127)
		if (!(p->description.flags & MED_ENCODING_NAME)) {
			return ERR_PARSE;
		}
		if (!(p->description.flags & MED_CLOCK_RATE)) {
			return ERR_PARSE;
		}
	} else {
		// Set payload type for well-kwnown encodings and some default configurations if i know them
		// see include/fenice/rtpptdefs.h
		pt_info = RTP_payload[p->description.payload_type];
		if (!(p->description.flags & MED_ENCODING_NAME)
		    || (strcmp(p->description.encoding_name, "RTP_SHM")))
			strcpy(p->description.encoding_name, pt_info.EncName);
		p->description.clock_rate     = pt_info.ClockRate;
		p->description.audio_channels = pt_info.Channels;
		p->description.bit_per_sample = pt_info.BitPerSample;
		p->description.coding_type    = pt_info.Type;
		p->description.pkt_len        = pt_info.PktLen;
		p->description.flags |= MED_ENCODING_NAME;
		p->description.flags |= MED_CLOCK_RATE;
		p->description.flags |= MED_AUDIO_CHANNELS;
		p->description.flags |= MED_BIT_PER_SAMPLE;
		p->description.flags |= MED_CODING_TYPE;
		// p->description.flags|=MED_PKT_LEN;
	}
	res = register_media(p);
	if (res == ERR_NOERROR)
		return p->media_handler->load_media(p);
	else
		return res;
}