def create(self): ''' Start service and create stream TODO: If stream_type of a SCO Processing Service instance is easily available, raise a RuntimeError if we are trying to start two instances with the same stream_type and hci_handle. ''' if self.__config.stream is not None: stream = get_instance('stream_sco') if stream.get_type() == self.get_type(): raise RuntimeError('trying to start two sco streams of same type') self.__data.sco_service = stream.get_sco_service() else: if self.__config.service_tag is not None: service_tag = self.__config.service_tag else: service_tag = get_instance_num('sco_processing_service') + 100 self.__data.sco_service = HydraScoProcessingService(service_tag=service_tag, **self._sco_kwargs) register_instance('sco_processing_service', self.__data.sco_service) self.__data.sco_service.start() self.__data.sco_service.config() return super(StreamHydraSco, self).create()
def _compute_audioslot(self, stream_type): # to compute the audioslot we have to count how many instances have # we registered of name stream_XXX that are of our type (source or sink) # and that are of type StreamHw val = 0 names = get_instance_names() for stream_name in names: if stream_name.startswith('stream_'): val += sum([ get_instance(stream_name, ind).get_type() == stream_type for ind in range(get_instance_num(stream_name)) if isinstance(get_instance(stream_name, ind), StreamHw) ]) return val
def create(self): if self.__config.service_tag is not None: service_tag = self.__config.service_tag else: service_tag = get_instance_num('hydra_service') + 1 md_buffer_size = self.__config.metadata_buffer_size * self.__config.metadata_enable md_length = METADATA_HEADER_LENGTH[ self.__config.metadata_format] - METADATA_BASE_LENGTH if self._stream_type == STREAM_TYPE_SOURCE: callback = None if (self.__config.backing == BACKING_FILE and self.__config.sample_rate == 0 and not self.__data.source_packetiser): callback = self._space_available self.__helper.audio_hydra = HydraAudioSink( self.__helper.hydra_prot, device_type=self.__config.device_type, service_tag=service_tag, data_buffer_size=self.__config.data_buffer_size, metadata_buffer_size=md_buffer_size, metadata_header_length=md_length, space_handler=callback) self.__helper.audio_hydra.start() else: self.__helper.audio_hydra = HydraAudioSource( self.__helper.hydra_prot, device_type=self.__config.device_type, service_tag=service_tag, data_buffer_size=self.__config.data_buffer_size, metadata_buffer_size=md_buffer_size, metadata_header_length=md_length, space_handler=self._space_available) self.__helper.audio_hydra.start() register_instance('hydra_service', self.__helper.audio_hydra) if self.__config.metadata_enable: self.__data.stream2.create() return super(StreamHydraAudioData, self).create()
def map_endpoint(interface, endpoint_type, kwargs): ''' Remap kymera endpoint Args: interface (str): Interface type endpoint_type (str): Type of endpoint (source or sink) kwargs (dict): Endpoint parameters Returns: dict: Modified (remapped) endpoint parameters ''' outp = kwargs if get_instance_num('uut_mapping'): mapping = get_instance('uut_mapping') entry = copy.deepcopy(kwargs) inp = {'interface': interface, 'type': endpoint_type} inp.update(entry) instance0 = inp.get('instance', None) channel0 = inp.get('channel', None) outp = mapping.map(inp) if outp: instance1 = outp.get('instance', None) channel1 = outp.get('channel', None) logging.getLogger(__name__).info( 'interface:%s endpoint_type:%s instance:%s channel:%s remapped to ' 'instance:%s channel:%s', interface, endpoint_type, instance0, channel0, instance1, channel1) else: outp = {} entry.update(outp) outp = entry outp.pop('interface', None) outp.pop('type', None) return outp
def _compute_audioslot(self, stream_type): return sum([ get_instance('stream_pcm', ind).get_type() == stream_type for ind in range(get_instance_num('stream_pcm')) ])