GeneratePcAudioRecorder not available in this MIP Environment. C# Console App

We are developing a C# console application with MIP SDK.

We wanted to send a PC Microphone and File audio to the Milestone Speaker. We can successfully send the File stream as follows.

public bool PlayAudioFromFile(string filePath)

{

  bool rtnVal = false;

  try

  {

    if (\_outgoingSpeakerController == null)

      \_outgoingSpeakerController = new OutgoingSpeakerController();

    else

      \_outgoingSpeakerController.Close();

    Stream soundFileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open);

    AudioStreamPlayer audioStreamPlayer = new AudioStreamPlayer(soundFileStream, true);

    \_outgoingSpeakerController.Init(audioStreamPlayer);

    \_outgoingSpeakerController.Connect(this.\_speaker.FQID, 0);

    \_outgoingSpeakerController.TransmitStart();

    rtnVal = true;

  }

  catch (Exception ex)

  {

    Console.WriteLine(ex.Message);

    return false;

  }

  return rtnVal;

}

But we can’t send the Client’s PC Mic audio to the Milestone Speaker. When we tried to use the sample code as shown in the VideoViewer2WayAudio, we got exceptions as

“GeneratePcAudioRecorder not available in this MIP Environment”.

The function is as follows.

public bool PlayAudioFromMic()

{

  bool rtnVal = false;

  try

  {

    if (\_outgoingSpeakerController == null)

      \_outgoingSpeakerController = new OutgoingSpeakerController();

    else

      \_outgoingSpeakerController.Close();

    var audioRecorder = ClientControl.Instance.GeneratePcAudioRecorder();

    audioRecorder.OutgoingAudioWaveFormatSamplesPerSecond = 8000;

    \_outgoingSpeakerController.DoRetryConnect = true;

    \_outgoingSpeakerController.Init(audioRecorder);

    \_outgoingSpeakerController.Connect(this.\_speaker.FQID, 0);

  }

  catch(Exception ex)

  {

    Console.WriteLine(ex.Message);

    return false;

  }

  return rtnVal;

}

Any idea why GeneratePcAudioRecorder is not supported in the C# Console App? What is the Alternative way to send PC audio to the Milestone speaker?

Please help.

Please try unmodified Video Viewer 2-way Audio sample and see if it works.

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/videoviewer2wayaudio/readme.html&tree=tree_2.html

One guess, you might be missing an initialization, the sample does:

VideoOS.Platform.SDK.Environment.Initialize(); // Initialize the standalone Environment

VideoOS.Platform.SDK.UI.Environment.Initialize(); // Initialize the standalone Environment

We have initialized it in the constructor.

public MileStoneAudioLite(string uri, string username, string password)

{

VideoOS.Platform.SDK.Environment.Initialize();

VideoOS.Platform.SDK.Media.Environment.Initialize();

NetworkCredential credential2 = new NetworkCredential(username, password);

Uri uri2 = new UriBuilder(uri).Uri;

CredentialCache credentials2 = new CredentialCache();

credentials2.Add(uri2, “Basic”, credential2);

VideoOS.Platform.SDK.Environment.AddServer(false, uri2, credentials2);

VideoOS.Platform.SDK.Environment.Login(uri2);

_speaker = GetSpeaker(VideoOS.Platform.Configuration.Instance.GetItems());

}

Finally, we achieved it using the NAudio library but not directly with MIP SDK.