From a9c8d2236d56ebd8a53ea7ae0df19eb547d86930 Mon Sep 17 00:00:00 2001 From: Victor Gaydov Date: Thu, 6 Jun 2024 19:31:22 +0400 Subject: [PATCH] Update README examples --- README.md | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6df1527..46aac9e 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,13 @@ if err != nil { defer context.Close() sender, err := roc.OpenSender(roc.SenderConfig{ - FrameSampleRate: 44100, - FrameChannels: roc.ChannelSetStereo, - FrameEncoding: roc.FrameEncodingPcmFloat, - FecEncoding: roc.FecEncodingRs8m, - ClockSource: roc.ClockInternal, + FrameEncoding: roc.MediaEncoding{ + Rate: 44100, + Format: roc.FormatPcmFloat32, + Channels: roc.ChannelLayoutStereo, + }, + FecEncoding: roc.FecEncodingRs8m, + ClockSource: roc.ClockSourceInternal, }) if err != nil { panic(err) @@ -65,6 +67,11 @@ if err != nil { panic(err) } +controlEndpoint, err := roc.ParseEndpoint("rtcp://192.168.0.1:10003") +if err != nil { + panic(err) +} + err = sender.Connect(roc.SlotDefault, roc.InterfaceAudioSource, sourceEndpoint) if err != nil { panic(err) @@ -75,6 +82,11 @@ if err != nil { panic(err) } +err = sender.Connect(roc.SlotDefault, roc.InterfaceAudioControl, controlEndpoint) +if err != nil { + panic(err) +} + for { samples := make([]float32, 320) @@ -101,10 +113,12 @@ if err != nil { defer context.Close() receiver, err := roc.OpenReceiver(roc.ReceiverConfig{ - FrameSampleRate: 44100, - FrameChannels: roc.ChannelSetStereo, - FrameEncoding: roc.FrameEncodingPcmFloat, - ClockSource: roc.ClockInternal, + FrameEncoding: roc.MediaEncoding{ + Rate: 44100, + Format: roc.FormatPcmFloat32, + Channels: roc.ChannelLayoutStereo, + }, + ClockSource: roc.ClockSourceInternal, }) if err != nil { panic(err) @@ -121,6 +135,11 @@ if err != nil { panic(err) } +controlEndpoint, err := roc.ParseEndpoint("rtcp://0.0.0.0:10003") +if err != nil { + panic(err) +} + err = receiver.Bind(roc.SlotDefault, roc.InterfaceAudioSource, sourceEndpoint) if err != nil { panic(err) @@ -131,6 +150,11 @@ if err != nil { panic(err) } +err = receiver.Bind(roc.SlotDefault, roc.InterfaceAudioControl, controlEndpoint) +if err != nil { + panic(err) +} + for { samples := make([]float32, 320)