Skip to content

Commit

Permalink
fix: add RTP RTCP in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
emiago committed Mar 9, 2024
1 parent 13b82cd commit 068df78
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ phone := sipgox.NewPhone(ua)

// Run dial
ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)

// Blocks until call is answered
dialog, err := phone.Dial(ctx, sip.Uri{User:"bob", Host: "localhost", Port:5060}, sipgox.DialOptions{})
if err != nil {
// handle error
Expand All @@ -61,13 +63,15 @@ case <-time.After(5 *time.Second):
### Receiver

```go
ctx, _ := context.WithCancel(context.Background())

ua, _ := sipgo.NewUA()
defer ua.Close()

// Create a phone
phone := sipgox.NewPhone(ua)

ctx, _ := context.WithCancel(context.Background())
// Blocks until call is answered
dialog, err := phone.Answer(ctx, sipgox.AnswerOptions{
Ringtime: 5* time.Second,
})
Expand All @@ -83,4 +87,18 @@ case <-dialog.Done():
case <-time.After(10 *time.Second):
dialog.Hangup(context.TODO())
}
```
```

### Reading/Writing RTP/RTCP on dialog

After you Answer or Dial on phone, you receive dialog.

**RTP**
```go
pkt, err := dialog.ReadRTP()

err := dialog.WriteRTP(pkt)

```

similar is for RTCP

0 comments on commit 068df78

Please sign in to comment.