Exemple #1
0
    public void ReceiveAudio(byte[] data)
    {
        //SDK进行音频数据的解码及音频播放
        PbAudioPacket packet = PbAudioPacket.Parser.ParseFrom(data);

        UnityChatSDK.Instance.DecodeAudioData(packet.Id, GetAudioPacket(packet));
    }
    public void ReceiveAudio(byte[] data)
    {
        //decoded audio data by google.protobuf
        PbAudioPacket packet = PbAudioPacket.Parser.ParseFrom(data);

        //decode audio data by UnityChatSDK
        UnityChatSDK.Instance.DecodeAudioData(GetAudioPacket(packet));
    }
Exemple #3
0
    AudioPacket GetAudioPacket(PbAudioPacket packet)
    {
        AudioPacket aduio = new AudioPacket();

        aduio.Position  = packet.Position;
        aduio.Length    = packet.Length;
        aduio.Data      = packet.Data.ToByteArray();
        aduio.Timestamp = packet.Timestamp;
        return(aduio);
    }
    PbAudioPacket GetPbAudioPacket(AudioPacket audio)
    {
        PbAudioPacket pbPacket = new PbAudioPacket();

        pbPacket.Id        = audio.Id;
        pbPacket.Position  = audio.Position;
        pbPacket.Length    = audio.Length;
        pbPacket.Data      = ByteString.CopyFrom(audio.Data);
        pbPacket.Timestamp = audio.Timestamp;
        return(pbPacket);
    }