Reputation: 172
I am trying to record the incoming buffer data on Microsoft.Skype.Bots.Media audioSocket.AudioMediaReceived.
As per findings till now it might be like saving incoming buffer data to the disk and use tools like ffmpeg to convert that buffer data into the required audio format file.
Some of the code snippet:
this.audioSocket.AudioMediaReceived += this.OnAudioMediaReceived;
private void OnAudioMediaReceived(object sender, AudioMediaReceivedEventArgs e)
{
this.GraphLogger.Info($"Received Audio: [VideoMediaReceivedEventArgs(Data=
<{e.Buffer.Data.ToString()}>, Length={e.Buffer.Length}, Timestamp={e.Buffer.Timestamp})]");
// To Do Recording i.e saving each incoming buffer data and create a audio file after the record ends.
e.Buffer.Dispose();
}
Note: Above snippet is from git hub sample of Compliance recording bot.
One possible way I figured out is:
private void OnAudioMediaReceived(object sender, AudioMediaReceivedEventArgs e)
{
this.GraphLogger.Info($"Received Audio:
[VideoMediaReceivedEventArgs(Data=<{e.Buffer.Data.ToString()}>,
Length={e.Buffer.Length}, Timestamp={e.Buffer.Timestamp})]");
byte[] managedArray = new byte[e.Buffer.Length];
var handler = e.Buffer.Data;
int start = 0;
int length = (int)e.Buffer.Length;
Marshal.Copy(handler, managedArray, start, length);
var path = @"D:\files";
var filePath = Path.Combine(path, "test.wav");
File.WriteAllBytes(filePath, managedArray);
// TBD: Compliance Recording bots can record the Audio here
e.Buffer.Dispose();
}
But the problem is that audio media buffer data continues to come(stream) as long as the call/recording continues and this solution doesn't work.
Any help would be appreciated.
Upvotes: 2
Views: 936