向视频会议应用程序(C#)添加音频流?

向视频会议应用程序(C#)添加音频流?,c#,audio,video,streaming,webcam,C#,Audio,Video,Streaming,Webcam,我对C#比较陌生,我正在与一个合作伙伴设计一个简单的视频/音频流应用程序,它可以在两个摄像头之间工作。我需要将音频组件添加到我搭档的视频中,但我完全不知道该怎么做。我知道,像ImageByteConverter.cs一样,我需要将音频流转换为字节,然后再转换回声音,并将此功能添加到webcam.cs。如有任何帮助/建议,将不胜感激 Webcam.cs using System; using System.IO; using System.Linq; using System.Text; usin

我对C#比较陌生,我正在与一个合作伙伴设计一个简单的视频/音频流应用程序,它可以在两个摄像头之间工作。我需要将音频组件添加到我搭档的视频中,但我完全不知道该怎么做。我知道,像ImageByteConverter.cs一样,我需要将音频流转换为字节,然后再转换回声音,并将此功能添加到webcam.cs。如有任何帮助/建议,将不胜感激

Webcam.cs

using System;
using System.IO;
using System.Linq;
using System.Text;
using WebCam_Capture;
using System.Windows.Controls;
using System.Collections.Generic;
using System.Windows.Media.Imaging;
using System.Net;
using System.Net.Sockets;
using System.Windows; 

namespace DuckTalk
{
class WebCam
{       
    const int TEXT_VIDEO_NUM = 45674;
    private System.Windows.Controls.TextBox _hostIpAddressBox;


    private WebCamCapture webcam;
    private int FrameNumber = 30;


    public void InitializeWebCam(ref System.Windows.Controls.TextBox hostIpAddressBox)
    {
        webcam = new WebCamCapture();
        webcam.FrameNumber = ((ulong)(0ul));
        webcam.TimeToCapture_milliseconds = FrameNumber;
        webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);


        _hostIpAddressBox = hostIpAddressBox;            
    }


    void webcam_ImageCaptured(object source, WebcamEventArgs e)
    {
        TcpClient connection = null;
        NetworkStream stream = null;
        byte[] imgBytes;

        try
        {
            //Set up IPAddress
            IPAddress ipAddress = IPAddress.Parse(_hostIpAddressBox.Text);
            IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, TEXT_VIDEO_NUM);

            //Connect to TCP
            connection = new TcpClient();
            connection.Connect(ipLocalEndPoint);

            // Get a client stream for reading and writing. 
            stream = connection.GetStream();

            //Send image as bytes
            imgBytes = ImageByteConverter.ImageToBytes((System.Drawing.Bitmap)e.WebCamImage);
            stream.Write(imgBytes, 0, imgBytes.Length);
        }
        catch (Exception error)
        {
            MessageBox.Show("ERROR: " + error.Message);
        }
        finally
        {
            // Close everything.
            if (connection != null)
                connection.Close();

            if (stream != null)
                stream.Close();
        }            
    }


    public void Start()
    {
        webcam.TimeToCapture_milliseconds = FrameNumber;
        webcam.Start(0);
    }

    public void Stop()
    {
        webcam.Stop();
    }

}
}
这是ImageByteConverter.cs

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections.Generic;
using System.Windows.Media.Imaging;


namespace DuckTalk
{
class ImageByteConverter
{               
    public static byte[] ImageToBytes(System.Drawing.Bitmap bitmap)
    {
        byte[] byteArray;

        using (MemoryStream stream = new MemoryStream())
        {
            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            stream.Close();

            byteArray = stream.ToArray();
        }

        return byteArray;
    }

    public static BitmapImage BytesToImage(byte[] imgBytes)
    {
        var image = new BitmapImage();

        image.BeginInit();
        image.StreamSource = new System.IO.MemoryStream(imgBytes);
        image.EndInit();

        return image;
    }
}
}

到目前为止你试过什么了吗?可能是