private void Socket_EndDataRecievedCallback() { if (GlobalConfiguration.isUseLossySoundDecoder) { //var data = mp3data_ms.ToArray(); encoded_frame_ms.Position = 0; if (m_Player.Opened == false) { if (GlobalConfiguration.isEncodeWithOpus) { m_Player.Open("hoge", GlobalConfiguration.SamplesPerSecond, config.BitsPerSample, config.Channels, config.BufferCount); m_Player.Play(); //concentusOpusDecoder = OpusDecoder.Create(GlobalConfiguration.SamplesPerSecond, config.Channels); concentusOpusDecoder = OpusDecoder.Create(GlobalConfiguration.SampleRateDummyForSoundEnDecoder, config.Channels); //m_DPlayer.setup(RTPConfiguration.SamplesPerSecond, config.Channels, -1, csd_0, "opus"); } else { throw new Exception("illigal flag setting on RTPConfiguration."); } } byte[] data_buf = new byte[encoded_frame_ms.Length - encoded_frame_ms.Position]; encoded_frame_ms.Read(data_buf, 0, data_buf.Length); int frameSize = GlobalConfiguration.samplesPerPacket; // must be same as framesize used in input, you can use OpusPacketInfo.GetNumSamples() to determine this dynamically short[] outputBuffer = new short[frameSize]; int thisFrameSize = concentusOpusDecoder.Decode(data_buf, 0, data_buf.Length, outputBuffer, 0, frameSize, false); m_Player.WriteData(Utils.convertShortArrToBytes(outputBuffer), false); return; } else { Byte[] justSound_buf = encoded_frame_ms.ToArray(); Byte[] linearBytes = justSound_buf; //if (!RTPConfiguration.isUseSoundDecoder && m_Player.Opened == false) //{ // m_Player.Open("hoge", RTPConfiguration.SamplesPerSecond, config.BitsPerSample, config.Channels, config.BufferCount); //} if (config.isConvertMulaw) { linearBytes = SoundUtils.MuLawToLinear(justSound_buf, config.BitsPerSample, config.Channels); } if (GlobalConfiguration.isUseDPCM) { if (dpcmDecoder == null) { dpcmDecoder = new MyDpcmCodec(); } linearBytes = dpcmDecoder.Decode(linearBytes); } if (!GlobalConfiguration.isUseLossySoundDecoder && m_Player.Opened == false) { m_Player.Open("hoge", GlobalConfiguration.SamplesPerSecond, config.BitsPerSample, config.Channels, config.BufferCount); m_Player.Play(); } m_Player.WriteData(linearBytes, false); //totalWroteSoundData += linearBytes.Length; //if(totalWroteSoundData > config.BufferCount && m_Player.isPlayingStarted == false) //{ // m_Player.Play(); //} } }