audio capture in metro apps - audio-recording

I need to perform low-level audio capture in my Windows 8 Metro-style app.
I guess I need to use the IAudioClient interface, but how to get that interface?
Microsoft says "A client obtains a reference to an IAudioClient interface for an audio endpoint device by using one of the techniques described in IMMDevice Interface.."
http://msdn.microsoft.com/en-us/library/windows/desktop/dd370865(v=vs.85).aspx
but IMMDevice interface is not supported for Metro-style apps.
How does one get an IAudioClient interface ?

I got an answer from the MSDN forums:
Platform::String^ id = Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId(Windows::Media::Devices::AudioDeviceRole::Console );
Microsoft::WRL::ComPtr<IAudioClient> pAudioClient = NULL;
ActivateAudioInterface( id->Data(), __uuidof( IAudioClient ), (void**)&pAudioClient );
This ActivateAudioInterface() is mysterious to meā€”there are no references to it at all in the MSDN Library; the only hits on searches for it are in the forums...

Actually, you should use ActivateAudioInterfaceAsync instead of ActivateAudioInterface. See http://msdn.microsoft.com/en-us/library/windows/desktop/jj128298(v=vs.85).aspx

Related

Phone number masking/mapping/translation APIs or services

Services like Uber provide users with masked phone numbers so that they can communicate directly with one another without exposing their actual phone number. It seems to me a form of network address translation?
Does anyone have services, OSS, API/code examples or SDK links that one might use to set up a similar system?
Primarily this would entail mapping/translating a generated phone number to a user's actual number (behind the scenes), but telemetry style analytics would also be desirable.
Preferably Node Javascript, C#, or Java... but anything is better than nothing!
Many thanks
Ricky from Twilio here.
We put together a tutorial on how to build masked phone numbers with Node.js, C#, Java, Python or Ruby:
https://www.twilio.com/docs/tutorials/walkthrough/masked-numbers/node/express
In this Node.js example, here's the block of code that masks a phone call:
router.post('/use-voice', twilio.webhook({ validate: false }), function (req, res) {
from = req.body.From;
to = req.body.To;
body = req.body.Body;
gatherOutgoingNumber(from, to)
.then(function (outgoingPhoneNumber) {
var twiml = new twilio.TwimlResponse();
twiml.play('http://howtodocs.s3.amazonaws.com/howdy-tng.mp3');
twiml.dial(outgoingPhoneNumber);
res.type('text/xml');
res.send(twiml.toString());
})
});
The gatherOutgoingNumber function uses the phone call from and to to determine who the user is intending to call, once that number is found this code forwards the call to the correct phone number.
It's MIT licensed and hopefully can help you get started.
I found what Uber uses... Twilio! So that's one option at least

how to use telegram API codes?

i registered in https://my.telegram.org/apps and got api_hash and api_id and public key ,now i want to use this function https://core.telegram.org/method/auth.sendCode
auth.sentCode#efed51d9 phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
auth.sentAppCode#e325edcf phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
---functions---
auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode;
Query example
(auth.sendCode "79991234567" 1 32 "test-hash" "en")
=
(auth.sentCode
phone_registered:(boolFalse)
phone_code_hash:"2dc02d2cda9e615c84"
)
d16ff372 3939370b 33323139 37363534 00000001 00000020 73657409 61682d74 00006873 e77e812d
=
2215bcbd bc799737 63643212 32643230 39616463 35313665 00343863 e12b7901
how can i use this query example?
and what is this binaries? ==> "d16ff372 3939370b 33323139 ...."
You can't directly start to send queries to Telegram. Creating api_hash and api_id is a basic step to start with Telegram API. Hope you know that Telegram uses its own protocol called 'MTProto'. You can get the detailed discription in Telegram's official website.
As per Telegram Protocol, the Client and Server shares the 'Authorization Key' (which is used for encryption and decryption) using Diffie-Hellman algorithm. For sample please see https://core.telegram.org/mtproto/samples-auth_key. After creating the authorization key successfully, we can start to call Telegram APIs which is called as RPC queries.
You can also refer https://github.com/ex3ndr/telegram-api for implementation.
The hexadecimal data in the example is nothing but the query made by following the algorithm.
You need to start from making a valid Telegram AuthKey.
The patterns and functions you build up along the way while doing this will help you towards building the rest of your Telegram API.
You can start with this here: https://stackoverflow.com/a/32809138/44080
And them work up, step by step until you have the AuthKey as described in these links
https://core.telegram.org/mtproto/auth_key
https://core.telegram.org/mtproto/samples-auth_key
Part of the problem you will initially face is the documentation.
Working through this step by step and getting familiar with the authors writing style is a big help too.

Asterisk catch a Incoming call and transfer it to a specific exten

I have been building a Window Form desktop application using C# that interfaces with Asterisk using Asterisk.NET.
My first problem is catch a Incoming call and transfer it to specific exten.
The first my idea is using OriginateAction, when a call come, I use Dial event and catch it and use OriginateAction to call to a specific exten.
RedirectAction originateAction = new RedirectAction();
originateAction.Channel = e.Channel;
originateAction.Context = "default";
originateAction.Exten = "203";
originateAction.Priority = 1;
ManagerResponse originateResponse = manager.SendAction(originateAction);
Console.WriteLine(originateResponse);
But it not work like my wish.
The second my idea is using RedirectAction:
RedirectAction originateAction = new RedirectAction();
originateAction.Channel = e.Channel;
originateAction.Context = "default";
originateAction.Exten = "203";
originateAction.Priority = 1;
ManagerResponse originateResponse = manager.SendAction(originateAction);
Console.WriteLine(originateResponse);
And it not work.
I have find on many websites but the documents is very little.
How can I solve this issue?
Thanks!
I would suggest using some kind of dynamic dialplan instead of "catching" calls reactively. Why not use an AGI script?
Essentially, your application tells a database or other central system what to do when calls matching certain criteria come in. Then Asterisk runs the script you setup when calls reach a certain context (such as all incoming calls), and then the script routes the call dynamically based on the inputs given by your application.
Since you seem to like .NET, here's a .NET AGI project to help you get started: AsterNET. It looks like the library you mentioned, Asterisk.NET, is also capable of Fast CGI (what AGI uses), but the last release was in 2009, whereas AsterNet is active as recently as 3 months ago.
I personally use phpAGI to do all kinds of neat ACD and call routing stuff in our call center.
For more info on AGI, see the official docs.
Edit:
I should probably also explain some basic call flow terminology (from the docs):
Originate: Generates an outgoing call to a Extension/Context/Priority or Application/Data. Example: User clicks a button, Originate a call to their desk phone, when they answer that call, it executes dialplan, or a dialplan application.
Redirect: Redirect (transfer) a call. Example: Agent and Customer are talking, but Manager wants to take over the call. Use Redirect to "take" the call from Agent and ring the Manager.
Dial: (in dialplan only, not AMI) Dial the technology/channel specified. Note that you can only Originate from your .NET application, not Dial.
Can you show your event handler code? It looks like that library would say something like manager.NewChannel += new ManagerEventHandler(new_channel);

How can share/unshare alfresco content programmatic in OpenCMIS

I need to share and unshare the content in alfresco using OpenCMIS, i read the documentation here for Apache Chemistry but i don't find this API functionality to share and unshare Documents.
So how can i do it programmatically?
I'm going to interpret your requirement as following:
You'd like to use Alfresco Share's "Quick Share"-Feature that is available in Alfresco Community 4.2 & Alfresco Cloud.
Alfresco Share uses the following internal API (REST/Webscript) to trigger a Quick Share:
POST /api/internal/shared/share/{store_protocol}/{store_id}/{node_id}
which return the generated quick share id as json:
{
"sharedId": "IHR65hlGT9yOTKwqPYMbRw"
}
The WebScript is implemented as Java-backed WebScript. Controller is
org.alfresco.repo.web.scripts.quickshare.ShareContentPost
that uses the following Service:
org.alfresco.repo.quickshare.QuickShareServiceImpl
As you can see here this Service generates a UUID (the link id) & sets the value as property qshare:sharedId (Aspect qshare:shared):
UUID uuid = UUIDGenerator.getInstance().generateRandomBasedUUID();
sharedId = Base64.encodeBase64URLSafeString(uuid.toByteArray()); // => 22 chars (eg. q3bEKPeDQvmJYgt4hJxOjw)
Map<QName,Serializable> props = new HashMap<QName,Serializable>(2);
props.put(QuickShareModel.PROP_QSHARE_SHAREDID, sharedId);
props.put(QuickShareModel.PROP_QSHARE_SHAREDBY, AuthenticationUtil.getRunAsUser());
nodeService.addAspect(nodeRef, QuickShareModel.ASPECT_QSHARE, props);
You should be able to do this via CMIS, but this Service also sets an Attribute via AttributeService (stores all shared-IDs per tenant):
attributeService.setAttribute(tenantNodeRef, ATTR_KEY_SHAREDIDS_ROOT, sharedId)
I'm not sure for which purpose this is used & if it is a MUST have for your requirement.

Core Service 2011 - Address books

Is it possible to create Audience Manager Address Books using the Core Service (Tridion 2011 SP1)?
(Or automate creating them in any other way - db script, Interop?)
Cheers
There is no Audience Manager functionality in the Core Service; only Content Manager functionality is exposed there.
You can, however, use the public API (Tridion.AudienceManagement.API) on the server to create any item you want. You didn't specify the kind of Address Book you want to create - but I'm going to assume you want a static one to create Contacts in.
Here is some sample code to do that:
StaticAddressBook denmark = new StaticAddressBook();
denmark.Title = "Denmark";
denmark.Key = "DK";
denmark.Save();
If you want to create a Dynamic Address Book instead, you'll need to specify a filter too; let me know if that's the case and I can provide some sample code for that too.
You can use the Tridion.OutboundEmail.ContentManagement namespace. In there is an AddressBook object (or you can use StaticAddressBook depending on the type of AB you want to create). Something like this should work:
AddressBook ab = new AddressBook();
ab.Title = "The title of my new Address Book";
ab.Save();
Looking at the API for StaticAddressBook (it's documented) there's a static method StaticAddressBook.CreateLocalAddressBook that might actually be more relevant in this instance. I'd check it out if I were you ;) You can download the docs from SDLTridionWorld.com

Resources