Example #1
0
OrtpZrtpContext* ortp_zrtp_multistream_new(OrtpZrtpContext* activeContext, RtpSession *s, OrtpZrtpParams *params) {
	int32_t length;
	char *multiparams=NULL;
	int i=0;
	
	if (!zrtp_isMultiStreamAvailable(activeContext->zrtpContext)) {
		ortp_warning("could't add stream: mutlistream not supported by peer");
	}

	if (zrtp_isMultiStream(activeContext->zrtpContext)) {
		ortp_fatal("Error: should derive multistream from DH or preshared modes only");
	}

	multiparams=zrtp_getMultiStrParams(activeContext->zrtpContext, &length);
	
	ortp_message("ZRTP multiparams length is %d", length);
	for (;i<length;i++) {
		ortp_message("%d", multiparams[i]);
	}

	ortp_message("Initializing ZRTP context");
	ZrtpContext *context = zrtp_CreateWrapper();
	OrtpZrtpContext *userData=createUserData(context);
	userData->session=s;
	ortp_zrtp_configure(context);
	
	zrtp_initializeZrtpEngine(context, &userData->zrtp_cb, userAgentStr, params->zid_file, userData, 0);

	ortp_message("setting zrtp_setMultiStrParams");
	zrtp_setMultiStrParams(context,multiparams,length);

	return ortp_zrtp_configure_context(userData,s,params);
}
Example #2
0
OrtpZrtpContext* ortp_zrtp_context_new(RtpSession *s, OrtpZrtpParams *params){
	ZrtpContext *context = zrtp_CreateWrapper();
	OrtpZrtpContext *userData=createUserData(context);
	userData->session=s;
	ortp_zrtp_configure(context);
	ortp_message("Initialized ZRTP context");
	zrtp_initializeZrtpEngine(context, &userData->zrtp_cb, userAgentStr, params->zid_file, userData, 0);
	return ortp_zrtp_configure_context(userData,s,params);
}
Example #3
0
void FileProcess()
{
    if (firstUse())
    {
        createUserData();
    }
    else
        return;

}
Example #4
0
bool VoicerBaseUGenInternal::sendMidiNote(const int midiChannel, 
										  const int midiNote,
										  const int velocity) throw()
{
	const int userData = createUserData(midiChannel, midiNote);
	
	ugen_assert(userData != UGen::defaultUserData);
	ugen_assert(velocity >= 0);

	if(velocity > 0)
	{
		if(numVoices_ > 0)
		{
			const int voicesUsed = countNonstealingVoices();
			if(voicesUsed >= numVoices_)
			{
				UGen stealee = chooseStealee();
					
				if(stealee.isNotNull())
				{
					stealee.userData = stealingUserData;
					stealee.steal(forcedSteal_);
				}
			}
		}
		
		// stop double notes, AU lab was sending two ons but only one off 
		// stealNote(midiChannel, midiNote, false, true);  // let's only do this in the Juce version..
		
		UGen newEvent = spawnEvent(*this, currentEventIndex++, midiChannel, midiNote, velocity);
        
        if(newEvent.isNotNull())
        {
            newEvent.userData = userData;
            events.add(newEvent);
        }        
	}
	else
	{
		UGen releasee = chooseReleasee(midiChannel, midiNote);
		
		if(releasee.isNotNull())
		{
			//releasee.userData = UGen::defaultUserData; // need to rethink why I really wanted to do this
			releasee.release();
		}
	}
	
	return true;
}
Example #5
0
MSZrtpContext* ms_zrtp_multistream_new(MSMediaStreamSessions *sessions, MSZrtpContext* activeContext, MSZrtpParams *params) {
	int retval;
	MSZrtpContext *userData;
	if ((retval = bzrtp_addChannel(activeContext->zrtpContext, sessions->rtp_session->snd.ssrc)) != 0) {
		ms_warning("could't add stream: multistream not supported by peer %x", retval);
	}

	ms_message("Initializing multistream ZRTP context");
	userData=createUserData(activeContext->zrtpContext, params);
	userData->stream_sessions = sessions;
	userData->self_ssrc = sessions->rtp_session->snd.ssrc;
	bzrtp_setClientData(activeContext->zrtpContext, sessions->rtp_session->snd.ssrc, (void *)userData);

	return ms_zrtp_configure_context(userData, sessions->rtp_session);
}
Example #6
0
MSZrtpContext* ms_zrtp_context_new(MSMediaStreamSessions *sessions, MSZrtpParams *params) {
	MSZrtpContext *userData;
	bzrtpContext_t *context;
	bzrtpCallbacks_t cbs={0};

	ms_message("Creating ZRTP engine on rtp session [%p]",sessions->rtp_session);
	context = bzrtp_createBzrtpContext(sessions->rtp_session->snd.ssrc); /* create the zrtp context, provide the SSRC of first channel */
	
	/* set callback functions */
	cbs.bzrtp_sendData=ms_zrtp_sendDataZRTP;
	cbs.bzrtp_srtpSecretsAvailable=ms_zrtp_srtpSecretsAvailable;
	cbs.bzrtp_startSrtpSession=ms_zrtp_startSrtpSession;
	
	if (params->zid_file) {
		/*enabling cache*/
		cbs.bzrtp_loadCache=ms_zrtp_loadCache;
		cbs.bzrtp_writeCache=ms_zrtp_writeCache;
		
		/* enable exportedKeys computation only if we have an uri to associate them */
		if (params->uri && strlen(params->uri)>0) {
			cbs.bzrtp_contextReadyForExportedKeys=ms_zrtp_addExportedKeysInZidCache;
		}
	}
	bzrtp_setCallbacks(context, &cbs);
	/* create and link user data */
	userData=createUserData(context, params);
	userData->stream_sessions=sessions;
	userData->self_ssrc = sessions->rtp_session->snd.ssrc;

	/* get the sip URI of peer and store it into the context to set it in the cache. Done only for the first channel as it is useless for the other ones which doesn't update the cache */
	if (params->uri && strlen(params->uri)>0) {
		userData->peerURI = strdup(params->uri);
	} else {
		userData->peerURI = NULL;
	}

	bzrtp_setClientData(context, sessions->rtp_session->snd.ssrc, (void *)userData);

	/* set crypto params */
	set_hash_suites(context, params->hashes, params->hashesCount);
	set_cipher_suites(context, params->ciphers, params->ciphersCount);
	set_auth_tag_suites(context, params->authTags, params->authTagsCount);
	set_key_agreement_suites(context, params->keyAgreements, params->keyAgreementsCount);
	set_sas_suites(context, params->sasTypes, params->sasTypesCount);

	bzrtp_initBzrtpContext(context); /* init is performed only when creating the first channel context */
	return ms_zrtp_configure_context(userData, sessions->rtp_session);
}
Example #7
0
bool VoicerBaseUGenInternal::stealNote(const int midiChannel, 
									   const int midiNote, 
									   const bool forcedSteal,
									   const bool stealAll) throw()
{
	const int userData = createUserData(midiChannel, midiNote);
	bool didSteal = false;
	
	for(int i = 0; i < events.size(); i++)
	{
		UGen& event = events[i];
		if(event.userData == userData)
		{
			event.userData = stealingUserData;
			event.steal(forcedSteal);
			if(stealAll)
				didSteal = true;
			else
				return true;
		}
	}
	
	return didSteal;
}
Example #8
0
char OSISXHTMLXS::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
	char *from;
	char token[4096];
	int tokpos = 0;
	bool intoken = false;
	bool inEsc = false;
	SWBuf lastTextNode;
	MyUserDataXS *userData = (MyUserDataXS *)createUserData(module, key);
	

	SWBuf orig = text;
	from = orig.getRawData();
	text = "";

	for (;*from; from++) {

		if (*from == '<') {
			intoken = true;
			tokpos = 0;
			token[0] = 0;
			token[1] = 0;
			token[2] = 0;
			inEsc = false;
			continue;
		}

		if (*from == '&') {
			intoken = true;
			tokpos = 0;
			token[0] = 0;
			token[1] = 0;
			token[2] = 0;
			inEsc = true;
			continue;
		}

		if (inEsc) {
			if (*from == ';') {
				intoken = inEsc = false;
				userData->lastTextNode = lastTextNode;
				
				if (!userData->suspendTextPassThru)  { //if text through is disabled no tokens should pass, too
					handleEscapeString(text, token, userData);
				}
				lastTextNode = "";
				continue;
			}
		}

		if (!inEsc) {
			if (*from == '>') {
				intoken = false;
				userData->lastTextNode = lastTextNode;
				handleToken(text, token, userData);
				lastTextNode = "";
				continue;
			}
		}

		if (intoken) {
			if (tokpos < 4090) {
				token[tokpos++] = *from;
				token[tokpos+2] = 0;
			}
		}
		else {
 			if ((!userData->supressAdjacentWhitespace) || (*from != ' ')) {
				if (!userData->suspendTextPassThru) {
					text.append(*from);
					userData->lastSuspendSegment.size(0);
				}
				else	userData->lastSuspendSegment.append(*from);
				lastTextNode.append(*from);
 			}
			userData->supressAdjacentWhitespace = false;
		}

	}
	
	// THE MAIN PURPOSE OF THIS OVERRIDE FUNCTION: is to insure all opened HTML tags are closed
	while (!userData->htmlTagStack->empty()) {
		text.append((SWBuf)"</" + userData->htmlTagStack->top().c_str() + ">");
		userData->htmlTagStack->pop();
	}

	delete userData;
	return 0;
}
Example #9
0
void VoicerUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int /*channel*/) throw()
{	
	if(shouldStopAllEvents() == true) initEvents();
	
	if(midiMessages.isEmpty() == true)
	{
		const ScopedLock sl(lock);
		SpawnBaseUGenInternal::processBlock(shouldDelete, blockID, -1);
	}
	else
	{
		const int blockSize = uGenOutput.getBlockSize();
		MidiBuffer::Iterator iter(midiMessages);
		MidiMessage message(0xf4, 0.0);
		
		int samplePos = 0;
		int startSample = 0;
		
		const int numChannels = getNumChannels();
		const int midiChannel = midiChannel_;
		
		while(iter.getNextEvent(message, samplePos) && (samplePos < blockSize))
		{
			const ScopedLock sl(lock);
				
			if(samplePos < 0) samplePos = 0;
			
			const int numSamples = samplePos - startSample;
		
			if(numSamples > 0)
			{				
				for(int channel = 0; channel < numChannels; channel++)
				{
					bufferData[channel] = proxies[channel]->getSampleData() + startSample;
				}
				
				mixer.prepareForBlock(numSamples, blockID + startSample, -1);
				mixer.setOutputs(bufferData, numSamples, numChannels);
				mixer.processBlock(shouldDelete, blockID + startSample, -1);				
			}
			
			startSample = samplePos;
			
			if(message.isForChannel(midiChannel))
			{
				if(message.isNoteOnOrOff())
				{
					const int midiNote = message.getNoteNumber();
					const int velocity = message.getVelocity();
										
					if(velocity > 0)
					{
						if(numVoices_ > 0)
						{
							const int voicesUsed = countNonstealingVoices();
							if(voicesUsed >= numVoices_)
							{
								UGen stealee = chooseStealee();
								
								if(stealee.isNotNull())
								{
									stealee.userData = stealingUserData;
									stealee.steal(forcedSteal_);
								}
							}
						}
						
						// stop double notes, AU lab was sending two ons but one off - seems fixed in Au Lab 2.2
						//stealNote(midiChannel, midiNote, false, true); 
						
						UGen newEvent = spawnEvent(*this, currentEventIndex++, midiChannel, midiNote, velocity);
						newEvent.userData = createUserData(midiChannel, midiNote);
						events.add(newEvent);
					}
					else
					{
						UGen releasee = chooseReleasee(midiChannel, midiNote);
						if(releasee.isNotNull()) releasee.release();
					}
				}
				else if(message.isController())
				{
					getController(message.getControllerNumber()) = message.getControllerValue() / 127.f;
				}
				else if(message.isPitchWheel())
				{
					getPitchWheel() = (jlimit(-8191, 8191, message.getPitchWheelValue() - 8192) / 8191.f);
				}
				else if(message.isChannelPressure())
				{
					getChannelPressure() = (message.getChannelPressureValue() / 127.f);
				}
				else if(message.isAftertouch())
				{
					getKeyPressure(message.getNoteNumber()) = (message.getAfterTouchValue() / 127.f);
				}
				else if(message.isProgramChange())
				{
					getProgram() = (message.getProgramChangeNumber());
				}
				else if(message.isAllNotesOff())
				{
					initEvents();
				}
			}
		}
		
		const ScopedLock sl(lock);
		
		const int numSamples = blockSize - startSample;
		
		if(numSamples > 0)
		{			
			for(int channel = 0; channel < numChannels; channel++)
			{
				bufferData[channel] = proxies[channel]->getSampleData() + startSample;
			}
			
			mixer.prepareForBlock(numSamples, blockID + startSample, -1);
			mixer.setOutputs(bufferData, numSamples, numChannels);
			mixer.processBlock(shouldDelete, blockID + startSample, -1);
		}
				
		midiMessages.clear();
		events.removeNulls();
	}	
}
Example #10
0
char SWBasicFilter::processText(std::string &text, const SWKey *key, const SWModule *module) {
    char *from;
    char token[4096];
    int tokpos = 0;
    bool intoken = false;
    bool inEsc = false;
    int escStartPos = 0, escEndPos = 0;
    int tokenStartPos = 0, tokenEndPos = 0;
    std::string lastTextNode;
    BasicFilterUserData *userData = createUserData(module, key);

    std::string orig = text;
    from = &orig[0u];
    text = "";

    if (processStages & INITIALIZE) {
        if (processStage(INITIALIZE, text, from, userData)) {    // processStage handled it all
            delete userData;
            return 0;
        }
    }

    for (;*from; from++) {

        if (processStages & PRECHAR) {
            if (processStage(PRECHAR, text, from, userData))    // processStage handled this char
                continue;
        }

        if (*from == tokenStart[tokenStartPos]) {
            if (tokenStartPos == (tokenStartLen - 1)) {
                intoken = true;
                tokpos = 0;
                token[0] = 0;
                token[1] = 0;
                token[2] = 0;
                inEsc = false;
            }
            else tokenStartPos++;
            continue;
        }

        if (*from == escStart[escStartPos]) {
            if (escStartPos == (escStartLen - 1)) {
                intoken = true;
                tokpos = 0;
                token[0] = 0;
                token[1] = 0;
                token[2] = 0;
                inEsc = true;
            }
            else escStartPos++;
            continue;
        }

        if (inEsc) {
            if (*from == escEnd[escEndPos]) {
                if (escEndPos == (escEndLen - 1)) {
                    intoken = inEsc = false;
                    userData->lastTextNode = lastTextNode;

                    if (!userData->suspendTextPassThru)  { //if text through is disabled no tokens should pass, too
                        if ((!handleEscapeString(text, token, userData)) && (passThruUnknownEsc)) {
                            appendEscapeString(text, token);
                        }
                    }
                    escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
                    lastTextNode = "";
                    continue;
                }
            }
        }

        if (!inEsc) {
            if (*from == tokenEnd[tokenEndPos]) {
                if (tokenEndPos == (tokenEndLen - 1)) {
                    intoken = false;
                    userData->lastTextNode = lastTextNode;
                    if ((!handleToken(text, token, userData)) && (passThruUnknownToken)) {
                        text += tokenStart;
                        text += token;
                        text += tokenEnd;
                    }
                    escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
                    lastTextNode = "";
                    continue;
                }
            }
        }

        if (intoken) {
            if (tokpos < 4090) {
                token[tokpos++] = *from;
                token[tokpos+2] = 0;
            }
        }
        else {
             if ((!userData->supressAdjacentWhitespace) || (*from != ' ')) {
                if (!userData->suspendTextPassThru) {
                    text.push_back(*from);
                    userData->lastSuspendSegment.clear();
                }
                else    userData->lastSuspendSegment.push_back(*from);
                lastTextNode.push_back(*from);
             }
            userData->supressAdjacentWhitespace = false;
        }

        if (processStages & POSTCHAR)
            processStage(POSTCHAR, text, from, userData);

    }

    if (processStages & FINALIZE)
        processStage(FINALIZE, text, from, userData);

    delete userData;
    return 0;
}