Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPS-1569-SFU-mode #5

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions examples/rtp-receiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Squawk WebSocket client implementation for connecting to squawk and receiving RT
2. [Maven](https://maven.apache.org/download.cgi)
3. API key for Benzinga Squawk. Contact Benzinga licensing team at  [email protected], if you don't have one.
4. Squawk WebSocket address. Contact Benzinga licensing team at  [email protected] for that.
5. Publicly open and accessible IP:Port on your end.
5. Publicly open and accessible IP and few ports, 5 should be enough, on your end. Multiple ports needed in case there are more than one broadcaster is active
6. [ffmpeg](https://www.ffmpeg.org/) command-line utility. It is for saving the incoming audio stream in a file using [StreamingSessionListener](src/main/java/com/benzinga/squawk/StreamingSessionListener.java). You can comment/remove that part from [SquawkWSClient](src/main/java/com/benzinga/squawk/SquawkWSClient.java) if you want to consume the incoming RTP differently.

## Installing and Executing

Expand All @@ -28,15 +29,13 @@ Please note that the execution is dependent on configuration, which can be done
| bz.squawk.room      | BZ_SQUAWK_ROOM | Room to join. It must be `PRO`
| bz.squawk.role      | BZ_SQUAWK_ROLE | Room to join. It must be `rtpreceiver`
| receiver.ip      | RECEIVER_IP | The IP address where you want to receive RTP stream. It must be publicly accessible IP
| receiver.port      | RECEIVER_PORT | An open port to receive RTP stream.
| receiver.sdpoffer.file      | RECEIVER_SDP_OFFER_FILE | File path containing your custom SDP Offer. This SDP offer should have public IP and port. Please note that this configuration will be given precedence over  `receiver.ip` and `receiver.port`. So either set SDP file path or IP & port.
| receiver.ports      | RECEIVER_PORTS | Some open ports to receive RTP streams. It should be comma-separated int values and not consecutive ports. There should be some gap between ports because RTP uses the next available port for RTCP. Need multiple ports opened in case of more than one broadcaster is active. Max 5 ports should be more than enough.


Please note that if you set the environment variable for a config parameter, then the `application.conf` value will be overridden by the env value. 
 Please note that if you set the environment variable for a config parameter, then the `application.conf` value will be overridden by the env values. 

## Verifying

Once the authentication and SDP negotiation is successful, you should start receiving stream at configured `IP:Port`. The generated SDP offer will be saved under `<USER_HOME>/Documents/bz-squawk-sdpoffer/inputAudio.sdp` You can use this file to verify the streaming. There are a couple of ways to do that:
Once the authenticated and joined the room, there should be SDP negotiation when any Benzinga broadcaster joins in or right away if any active after joined room. SDP offer will use any available port from configured receiver.ports. On successful SDP negotiation, the generated SDP offer will be saved in a file named `input_audio_<broadcasterID>.sdp` under `<USER_HOME>/Documents/bz-squawk-sdpoffer`. So if there are multiple active broadcasters, there will be multiple files per broadcaster's session. You can use this file to verify the streaming. There are a couple of ways to do that.

- **Using ffmpeg:** This is the preferred way to verify the RTP stream. The idea is to dump the incoming RTP audio stream into the file and play it.

Expand All @@ -48,6 +47,12 @@ And if you want an output file rotation with segments, for e.g. every 15 minutes

```
sudo ffmpeg -protocol_whitelist file,crypto,udp,rtp -acodec opus -i your-sdp-offer-file.sdp -acodec libopus -f segment -segment_atclocktime 1 -segment_time 900 -reset_timestamps 1 -strftime 1 out-%Y%m%dT%H%M.ogg
```Keep the streaming ON for few minutes to receive several squawks. And then play the output file in any supported player.
```
Keep the streaming ON for few minutes to receive several squawks. And then play the output file in any supported player.

- **Using VLC:**  Open the SDP offer file in the VLC player (Media > Open File) and wait for the next squawk from the Benzinga team. This option will probably work only if the VLC player is on the same machine where the stream is being delivered.


## Consuming the Incoming Streams

Consuming incoming stream mostly include forward/rebroadcast. The squawk RTP client provides [StreamingSessionListener](src/main/java/com/benzinga/squawk/StreamingSessionListener.java), which has callbacks `onBroadcasterJoined` and `onBroadcasterLeft`. It provides the associated [StreamingSession](src/main/java/com/benzinga/squawk/models/StreamingSession.java) for the broadcaster. It contains all the information required to consume/cutoff the stream.
10 changes: 0 additions & 10 deletions examples/rtp-receiver/log4j.properties

This file was deleted.

2 changes: 1 addition & 1 deletion examples/rtp-receiver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.4.0</version>
<version>1.5.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
Expand Down
Loading