#import "../CCNMediaTerm/CCNSMT/CCNSMT.tlb" no_namespace, raw_interfaces_only
|
|
|
#include <stdio.h>
|
|
|
|
|
int altavoz = 50;
|
int micro = 50;
|
int port = 6666;
|
BSTR direccionSOS;
|
char * sos;
|
|
|
DWORD WINAPI controladorIn (LPVOID args)
|
{
|
HRESULT hr = CoInitialize(NULL);
|
ICCNMediaTermPtr pICCNMediaTerm(__uuidof(CCNMediaTerm));
|
pICCNMediaTerm->Initialize();
|
|
// Call this function to inform WINRTP of the audio codec used to encode the incoming RTP stream.
|
// This function may be called before StartRX is called. (so you may need to call StopRX before making this call).
|
// If called before StartRX is called, it sets the codec for the next invocation of StartRX.
|
// If it is called while receiving audio (i.e. after StartRX) it may return an error.
|
// [in] long CompressionType: The following values are supported
|
// 2 : G.711 Alaw 64kbps
|
// 4 : G.711 Ulaw 64kbps
|
// [in] long MillisecPacketSize: Specifies the length of audio in each incoming RTP audio packets
|
// [in] long EchoCancellationValue: Ignored. Put any value here. Echo cancellation is not supported in the WINRTP
|
// [in] long G723BitRate: Ignored
|
pICCNMediaTerm->SetAudioCodecRX(2, 20, 0, 0);
|
|
// Informs the WINRTP of the UDP port number where it should listen for the incoming RTP audio stream.
|
// Note: StartAudioReceive must be called before any audio from the incoming stream is played to the speaker.
|
// [in] long nUDPPortNumber: UDP port number
|
pICCNMediaTerm->SetAudioReceivePort(port);
|
|
|
// Sets the audio codec for the transmit stream (outgoing stream). Should be called while NOT streaming (i.e. before StartTX/after StopT
|
// [in] long CompressionType: See SetAudioCodecRX
|
// 2 : G.711 Alaw 64kbps
|
// 4 : G.711 Ulaw 64kbps
|
// [in] long MillisecPacketSize: See SetAudioCodecRX
|
// [in] long PrecedenceValue: Ignored
|
// [in] long SilenceSuppression: Specifies whether to do silence suppression in the transmit stream
|
// 0 : Silence suppression is turned OFF
|
// 1 : Silence suppression is turned ON
|
// [in] unsigned short MaxFramesPerPacket: Ignored
|
// [in] long G723BitRate: See SetAudioCodecRX
|
pICCNMediaTerm->SetAudioCodecTX(2, 20, 0, 0, 0, 0);
|
|
// Sets the destination [IP Address, UDP Port] where the send side audio stream should be transmitted.
|
// Must be called while not streaming (i.e. Before StartTX/after StopTX).
|
// [in] BSTR strHostName: IP address of the destination. E.g. 171.69.12.34
|
// [in] long nUDPortNumber: UDP port number where to send the stream
|
pICCNMediaTerm->SetAudioDestination(direccionSOS, 6666);
|
|
// Sets up WINRTP to start the receive side. It also starts playing the received audio to the speaker.
|
// unsigned long waveoutDeviceID: specifies which audio device to use for playback/speaker.
|
// These device ID's are numbered 0 ... (# of playback devices - 1), and -1 means use the default playback device.
|
// Check out waveOutOpen() and waveOutGetDevCaps() functions in the windows API.. If you are confused, -1 actually means (unsigned long) 1.
|
pICCNMediaTerm->StartRX(-1);
|
|
// Starts streaming on the transmit side. This method must be called before StartPlayingFileTX is called.
|
// Calling this method starts transmitting the users voice
|
// unsigned long waveinDeviceID: specifies which audio device to use for audio capture/recording. device ID's are numbered 0...(#of recording audio devices-1),
|
// and -1 means use default audio device for windows. Check out waveInOpen() and waveInGetDevCaps() in the windows API. If you are confused, -1 actually means (unsigned long) 1.
|
pICCNMediaTerm->StartTX(-1);
|
|
// Sets the speaker volume on the PC. This setting sets the WAVEOUT volume of the system (not the master volume).
|
// [in] unsigned long volume: value between 0 and 100 where 0 = silence, and 100 = max volume. The scale is linear, so 50 = half volume
|
pICCNMediaTerm->SetSpeakerVolume(-1, altavoz);
|
|
// Sets the microphone volume. This setting changes the PCs microphone volume or audio capture volume.
|
// [in] unsigned long volume: value between 0 and 100 where 0 = silence, and 100 = max volume. The scale is linear, so 50 = half volume
|
pICCNMediaTerm->SetMicrophoneVolume(-1, micro);
|
|
|
//char mensaje[1024];
|
//sprintf(mensaje, "%s %s %d %d %d\n",sos, direccionSOS, port, altavoz, micro);
|
//MessageBox(NULL, mensaje, NULL, 0);
|
//MessageBox(NULL, (LPCSTR)direccionSOS, NULL, 0);
|
|
char comando[1024];
|
|
while (true)
|
{
|
fscanf (stdin, "%s",comando);
|
|
MessageBox(NULL, comando, NULL, 0);
|
|
|
if (strcmp(comando, "pause") == 0)
|
{
|
pICCNMediaTerm->StopRX();
|
pICCNMediaTerm->StopTX();
|
}
|
else if (strcmp(comando, "resume") == 0)
|
{
|
pICCNMediaTerm->StartRX(-1);
|
pICCNMediaTerm->StartTX(-1);
|
}
|
else if (strcmp(comando, "StartRX") == 0)
|
{
|
pICCNMediaTerm->StartRX(-1);
|
}
|
else if (strcmp(comando, "StopRX") == 0)
|
{
|
pICCNMediaTerm->StopRX();
|
}
|
else if (strcmp(comando, "StartTX") == 0)
|
{
|
pICCNMediaTerm->StartTX(-1);
|
}
|
else if (strcmp(comando, "StopTX") == 0)
|
{
|
pICCNMediaTerm->StopTX();
|
}
|
else if (strcmp(comando, "SetSpeakerVolume") == 0)
|
{
|
fscanf (stdin, "%d",&altavoz);
|
pICCNMediaTerm->SetSpeakerVolume(-1, altavoz);
|
}
|
else if (strcmp(comando, "SetMicrophoneVolume") == 0)
|
{
|
fscanf (stdin, "%d",µ);
|
pICCNMediaTerm->SetMicrophoneVolume(-1, micro);
|
}
|
else if ((strcmp(comando, "close") == 0) || (strcmp(comando, "stop") == 0))
|
{
|
|
// Desconexion
|
|
pICCNMediaTerm->StopRX();
|
pICCNMediaTerm->StopTX();
|
pICCNMediaTerm->UnInitialize();
|
pICCNMediaTerm = 0;
|
CoUninitialize();
|
exit(0);
|
}
|
else if (strcmp(comando, "GetSpeakerVolume") == 0)
|
{
|
fprintf(stdout, "%d\r", altavoz);
|
fflush(stdout);
|
}
|
else if (strcmp(comando, "GetMicrophoneVolume") == 0)
|
{
|
fprintf(stdout, "%d\r", micro);
|
fflush(stdout);
|
}
|
|
}
|
|
return 0;
|
}
|
|
|
|
|
|
|
|
int main(int argc, char * argv[])
|
{
|
|
//altavoz = atoi(argv[1]);
|
//micro = atoi(argv[2]);
|
//port = atoi(argv[3]);
|
//sos = argv[4];
|
|
altavoz = 50;
|
micro = 50;
|
port = 6666;
|
sos = "172.16.11.209";
|
|
#ifndef _UNICODE
|
OLECHAR* oleChar = NULL;
|
oleChar = (OLECHAR*)calloc(strlen(sos)+1, sizeof(OLECHAR));
|
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sos, -1, oleChar, strlen(sos)+1);
|
direccionSOS = SysAllocString(oleChar);
|
free(oleChar);
|
oleChar = NULL;
|
#else
|
direccionSOS = SysAllocString(sos);
|
#endif
|
|
|
// Control
|
|
DWORD threadId;
|
CreateThread( NULL, 0, controladorIn, NULL, 0, &threadId);
|
|
while (true)
|
{
|
Sleep(60000);
|
}
|
|
|
return 0;
|
}
|