<<>> <> <> <> <> <> <> <<>> DIRECTORY RefID USING [ID], Rope USING [ROPE], RuntimeError USING [ UNCAUGHT ], SRPCCalls USING [ Conversation, Error, GetSHandle, Handle, NewRPCConversation, ReleaseConversation, ReportProc, SHandle, TimeoutEnable], Thrush, ThrushSunRPC, ThrushSunRPCConvert, VoiceRopeServer, VoiceRopeServerSunImport, VoiceRopeServerSunRPC, VoiceRopeServerSunRPCClient ; VoiceRopeServerToVoiceRopeServerSunRPC: CEDAR PROGRAM IMPORTS RuntimeError, SRPCCalls, ThrushSunRPCConvert, VoiceRopeServerSunRPCClient EXPORTS VoiceRopeServer, VoiceRopeServerSunImport ~ { OPEN ThrushSunRPCConvert; VoiceRope: TYPE = VoiceRopeServer.VoiceRope; VoiceRopeInterval: TYPE = VoiceRopeServer.VoiceRopeInterval; InterestClass: TYPE = VoiceRopeServer.InterestClass; Users: TYPE = VoiceRopeServer.Users; <<>> <> maxEnergy: INTEGER = VoiceRopeServer.maxEnergy; EnergyRange: TYPE = VoiceRopeServer.EnergyRange; EnergySequence: TYPE = VoiceRopeServer.EnergySequence; EnergySequenceRec: TYPE = VoiceRopeServer.EnergySequenceRec; <<>> VoiceSample: TYPE = VoiceRopeServer.VoiceSample; VoiceBlock: TYPE = VoiceRopeServer.VoiceBlock; VoiceBlockRec: TYPE = VoiceRopeServer.VoiceBlockRec; <<>> Interval: TYPE = VoiceRopeServer.Interval; IntervalSpecs: TYPE = VoiceRopeServer.IntervalSpecs; sunSHHH: CARD32 = 0; SHandle: TYPE ~ SRPCCalls.SHandle; <> Record: PUBLIC PROC[shhh: Thrush.SHHH _ Thrush.none, credentials: Thrush.Credentials, serviceID: RefID.ID, recordedParty: Thrush.PartyID _ Thrush.nullID, intID: CARD _ 0, queueIt: BOOL _ TRUE] RETURNS [nb: Thrush.NB, voiceRope: VoiceRope] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srVoiceRope: VoiceRopeServerSunRPC.VoiceRope; [srNB, srVoiceRope] _ VoiceRopeServerSunRPCClient.Record[h: GetInfo[shhh], shhh: sunSHHH, credentials: CredentialsToSr[credentials], serviceID: serviceID, recordedParty: recordedParty, intID: intID, queueIt: queueIt]; nb _ SrToATOM[srNB]; voiceRope _ SrToVoiceRope[srVoiceRope]; }; <<>> Play: PUBLIC PROC[shhh: Thrush.SHHH _ Thrush.none, voiceRope: VoiceRope, credentials: Thrush.Credentials, serviceID: RefID.ID, intID: CARD _ 0, queueIt: BOOL _ TRUE] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.Play[h: GetInfo[shhh], shhh: sunSHHH, voiceRope: VoiceRopeToSr[voiceRope], credentials: CredentialsToSr[credentials], serviceID: serviceID, intID: intID, queueIt: queueIt]; nb _ SrToATOM[srNB]; }; <<>> Stop: PUBLIC PROC[shhh: Thrush.SHHH _ Thrush.none, credentials: Thrush.Credentials, serviceID: RefID.ID] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.Stop[h: GetInfo[shhh], shhh: sunSHHH, creentials: CredentialsToSr[credentials], serviceID: serviceID]; nb _ SrToATOM[srNB]; }; <<>> Pause: PUBLIC PROC[shhh: Thrush.SHHH _ Thrush.none, credentials: Thrush.Credentials, serviceID: RefID.ID] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; <> srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.Pause[h: GetInfo[shhh], shhh: sunSHHH, cedentials: CredentialsToSr[credentials], serviceID: serviceID]; nb _ SrToATOM[srNB]; }; <<>> Resume: PUBLIC PROC[shhh: Thrush.SHHH _ Thrush.none, credentials: Thrush.Credentials, serviceID: RefID.ID] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.Resume[h: GetInfo[shhh], shhh: sunSHHH, credentials: CredentialsToSr[credentials], serviceID: serviceID]; nb _ SrToATOM[srNB]; }; <> Retain: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, callerRName: Rope.ROPE, vr: VoiceRope, class: InterestClass, refID: Rope.ROPE, other: Rope.ROPE _ NIL] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.Retain[h: GetInfo[shhh], shhh: sunSHHH, callerRName: ROPEToSr[callerRName], vr: VoiceRopeToSr[vr], class: ROPEToSr[class], refID: ROPEToSr[refID], other: ROPEToSr[other] ]; nb _ SrToATOM[srNB]; }; Forget: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, vr: VoiceRope, class: InterestClass, refID: Rope.ROPE] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.Forget[h: GetInfo[shhh], shhh: sunSHHH, vr: VoiceRopeToSr[vr], class: ROPEToSr[class], refID: ROPEToSr[refID] ]; nb _ SrToATOM[srNB]; }; GetByInterest: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, class: InterestClass, refID: Rope.ROPE] RETURNS [nb: Thrush.NB, voiceRope: VoiceRope] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srVoiceRope: VoiceRopeServerSunRPC.VoiceRope; [srNB, srVoiceRope] _ VoiceRopeServerSunRPCClient.GetByInterest[h: GetInfo[shhh], shhh: sunSHHH, class: ROPEToSr[class], refID: ROPEToSr[refID] ]; nb _ SrToATOM[srNB]; voiceRope _ SrToVoiceRope[srVoiceRope]; }; <> Cat: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, callerRName: Rope.ROPE, vr1, vr2, vr3, vr4, vr5: VoiceRope _ NIL] RETURNS [nb: Thrush.NB, new: VoiceRope] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srVoiceRope: VoiceRopeServerSunRPC.VoiceRope; [srNB, srVoiceRope] _ VoiceRopeServerSunRPCClient.Cat[h: GetInfo[shhh], shhh: sunSHHH, callerRName: ROPEToSr[callerRName], vr1: VoiceRopeToSr[vr1], vr2: VoiceRopeToSr[vr2], vr3: VoiceRopeToSr[vr3], vr4: VoiceRopeToSr[vr4], vr5: VoiceRopeToSr[vr5]]; nb _ SrToATOM[srNB]; new _ SrToVoiceRope[srVoiceRope]; }; Substr: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, callerRName: Rope.ROPE, vr: VoiceRope, start: INT _ 0, len: INT _ LAST[INT]] RETURNS [nb: Thrush.NB, new: VoiceRope] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srVoiceRope: VoiceRopeServerSunRPC.VoiceRope; [srNB, srVoiceRope] _ VoiceRopeServerSunRPCClient.Substr[h: GetInfo[shhh], shhh: sunSHHH, callerRName: ROPEToSr[callerRName], vr: VoiceRopeToSr[vr], start: start, len: len]; nb _ SrToATOM[srNB]; new _ SrToVoiceRope[srVoiceRope]; }; Replace: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, callerRName: Rope.ROPE, vr: VoiceRope, start: INT _ 0, len: INT _ LAST[INT], with: VoiceRope _ NIL] RETURNS [nb: Thrush.NB, new: VoiceRope] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srVoiceRope: VoiceRopeServerSunRPC.VoiceRope; [srNB, srVoiceRope] _ VoiceRopeServerSunRPCClient.Replace[h: GetInfo[shhh], shhh: sunSHHH, callerRName: ROPEToSr[callerRName], vr: VoiceRopeToSr[vr], start: start, len: len, with: VoiceRopeToSr[with]]; nb _ SrToATOM[srNB]; new _ SrToVoiceRope[srVoiceRope]; }; <> Length: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, vr: VoiceRope] RETURNS [nb: Thrush.NB, len: INT] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; [srNB, len] _ VoiceRopeServerSunRPCClient.Length[h: GetInfo[shhh], shhh: sunSHHH, vr: VoiceRopeToSr[vr]]; nb _ SrToATOM[srNB]; }; <<>> DescribeRope: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, vr: VoiceRope, minSilence: INT _ -1] RETURNS [nb: Thrush.NB, length: INT, noise: IntervalSpecs] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srIntervalSpecs: VoiceRopeServerSunRPC.IntervalSpecs; [srNB, length, srIntervalSpecs] _ VoiceRopeServerSunRPCClient.DescribeRope[h: GetInfo[shhh], shhh: sunSHHH, vr: VoiceRopeToSr[vr], minSilence: minSilence]; nb _ SrToATOM[srNB]; noise _ SrToIntervalSpecs[srIntervalSpecs]; }; GetEnergies: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, vr: VoiceRope, samplesPerSegment: [1..8000] _ 160] RETURNS [nb: Thrush.NB, energies: EnergySequence] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srEnergySequence: VoiceRopeServerSunRPC.EnergySequence; [srNB, srEnergySequence] _ VoiceRopeServerSunRPCClient.GetEnergies[h: GetInfo[shhh], shhh: sunSHHH, vr: VoiceRopeToSr[vr], samplesPerSegment: samplesPerSegment]; nb _ SrToATOM[srNB]; energies _ SrToEnergySequence[srEnergySequence]; }; <> FetchBlock: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, vr: VoiceRope, start: INT, len: INT _ 8000, decrypt: BOOLEAN _ TRUE] RETURNS [nb: Thrush.NB, block: VoiceBlock] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srVoiceBlock: VoiceRopeServerSunRPC.VoiceBlock; [srNB, srVoiceBlock] _ VoiceRopeServerSunRPCClient.FetchBlock[h: GetInfo[shhh], shhh: sunSHHH, vr: VoiceRopeToSr[vr], start: start, len: len, decrypt: decrypt]; nb _ SrToATOM[srNB]; block _ SrToVoiceBlock[srVoiceBlock]; }; <<>> StoreBlock: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, block: VoiceBlock, key: Thrush.EncryptionKey _ Thrush.nullKey] RETURNS [nb: Thrush.NB, voiceRope: VoiceRope] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; <> srNB: ThrushSunRPC.NB; srVoiceRope: VoiceRopeServerSunRPC.VoiceRope; [srNB, srVoiceRope] _ VoiceRopeServerSunRPCClient.StoreBlock[h: GetInfo[shhh], shhh: sunSHHH, block: VoiceBlockToSr[block], key: EncryptionKeyToSr[key]]; nb _ SrToATOM[srNB]; voiceRope _ SrToVoiceRope[srVoiceRope]; }; <> SetPermissions: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, callerRName: Rope.ROPE, vr: VoiceRope, playAccess: Users, editAccess: Users] RETURNS [nb: Thrush.NB] = { <> ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ VoiceRopeServerSunRPCClient.SetPermissions[h: GetInfo[shhh], shhh: sunSHHH, callerRName: ROPEToSr[callerRName], vr: VoiceRopeToSr[vr], playAccess: UsersToSr[playAccess], editAccess: UsersToSr[editAccess]]; nb _ SrToATOM[srNB]; }; <<>> GetPermissions: PUBLIC PROC [shhh: Thrush.SHHH _ Thrush.none, vr: VoiceRope] RETURNS [nb: Thrush.NB, playAccess: Users, editAccess: Users] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srPlayAccess, srEditAccess: VoiceRopeServerSunRPC.Users; [srNB, srPlayAccess, srEditAccess] _ VoiceRopeServerSunRPCClient.GetPermissions[h: GetInfo[shhh], shhh: sunSHHH, vr: VoiceRopeToSr[vr]]; nb _ SrToATOM[srNB]; playAccess _ SrToUsers[srPlayAccess]; editAccess _ SrToUsers[srEditAccess]; }; <> GetInfo: PROC[shhh: Thrush.SHHH] RETURNS [h: SRPCCalls.Handle] ~ { sHandle: SHandle; IF shhh = NIL THEN SRPCCalls.Error[$noConversationSupplied]; sHandle _ SRPCCalls.GetSHandle[shhh]; IF sHandle=NIL THEN SRPCCalls.Error[$invalidConversationSupplied]; h _ sHandle.handle; }; <> sunPgm: CARD _ 390912; -- decimal program number for VoiceRopeServer sunPgmVersion: CARD _ 1; sunCallTimeout: INT _ 3000; sunCallRetries: INT _ 3; sunCallTimeoutEnable: SRPCCalls.TimeoutEnable _ always; ReportProblem: TYPE ~ VoiceRopeServerSunImport.ReportProblem; VRHandle: TYPE ~ REF VRHandleRec; VRHandleRec: TYPE ~ RECORD [ reportProblem: ReportProblem, reportData: REF ]; ImportInterface: PUBLIC PROC [instance: Rope.ROPE, reportProblem: ReportProblem_NIL, reportData: REF_NIL] RETURNS [shhh: Thrush.SHHH] ~ { <> vrHandle: VRHandle _ NEW[VRHandleRec _ [reportProblem, reportData]]; shhh _ SRPCCalls.NewRPCConversation[serverName: instance, rpcProgram: sunPgm, rpcVersion: sunPgmVersion, timeoutEnable: sunCallTimeoutEnable, timeoutInMs: sunCallTimeout, retries: sunCallRetries, reportProc: ForwardReports, clientData: vrHandle]; SRPCCalls.GetSHandle[shhh].enabled _ TRUE; }; UnImportInterface: PUBLIC PROC [shhh: Thrush.SHHH] ~ { SRPCCalls.ReleaseConversation[shhh]; }; ReportError: PROC[shhh: Thrush.SHHH, errCode: ATOM, explanation: Rope.ROPE_NIL] RETURNS[nb: Thrush.NB] ~ { sHandle: SHandle _ SRPCCalls.GetSHandle[shhh]; IF sHandle=NIL THEN RETURN; ForwardReports[sHandle, errCode, explanation]; nb _ $callFailed; }; ForwardReports: SRPCCalls.ReportProc ~ { vrHandle: VRHandle _ NARROW[sHandle.clientData]; IF vrHandle=NIL THEN RETURN; -- Can't report, perhaps handle has been released vrHandle.reportProblem[vrHandle.reportData, ec, expl]; }; }. <> <> <> <> <> <> <> <> <<>>