public void SendMedia(SDPMediaTypesEnum mediaType, uint sampleTimestamp, byte[] sample) { if (RemoteEndPoint != null && IsDtlsNegotiationComplete) { if (mediaType == SDPMediaTypesEnum.video) { RtpSession.SendVp8Frame(sampleTimestamp, sample); } else if (mediaType == SDPMediaTypesEnum.audio) { RtpSession.SendAudioFrame(sampleTimestamp, sample); } } }
/// <summary> /// Send a media sample to the remote party. /// </summary> /// <param name="mediaType">Whether the sample is audio or video.</param> /// <param name="sampleTimestamp">The RTP timestamp for the sample.</param> /// <param name="sample">The sample payload.</param> public void SendMedia(SDPMediaTypesEnum mediaType, uint sampleTimestamp, byte[] sample) { if (RemoteEndPoint != null && IsDtlsNegotiationComplete) { if (mediaType == SDPMediaTypesEnum.video) { //int vp8PayloadID = Convert.ToInt32(_supportedVideoFormats.Where(x => x.FormatCodec == SDPMediaFormatsEnum.VP8).Single().FormatID); int vp8PayloadID = Convert.ToInt32(RtpSession.VideoTrack.Capabilties.Single(x => x.FormatCodec == SDPMediaFormatsEnum.VP8).FormatID); RtpSession.SendVp8Frame(sampleTimestamp, vp8PayloadID, sample); } else if (mediaType == SDPMediaTypesEnum.audio) { //int pcmuPayloadID = Convert.ToInt32(_supportedAudioFormats.Where(x => x.FormatCodec == SDPMediaFormatsEnum.PCMU).Single().FormatID); int pcmuPayloadID = Convert.ToInt32(RtpSession.AudioTrack.Capabilties.Single(x => x.FormatCodec == SDPMediaFormatsEnum.PCMU).FormatID); RtpSession.SendAudioFrame(sampleTimestamp, pcmuPayloadID, sample); } } }