Skip to content

Commit

Permalink
Added auth to subscribe in MoQFlvReceiverClient.cpp
Browse files Browse the repository at this point in the history
Summary: - Added auth to subscribe in MoQFlvReceiverClient.cpp

Reviewed By: afrind

Differential Revision: D68073927

fbshipit-source-id: e0acf22c569a18957571837ad5dff91e3db6e8a8
  • Loading branch information
jordicenzano authored and facebook-github-bot committed Jan 15, 2025
1 parent 22345e5 commit eaeacb6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
30 changes: 20 additions & 10 deletions READMOQMEDIA.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@ Subscribes to a relay for a video and audio track, demuxes them from MoqMi (expe
-video_track_name (Video track Name) type: string default: "video0"
```

## Stream VOD file simulating live stream
## Why FLV packager?
It is known that fmp4 would have been the more future proof option, and it will be probably the next step. But FLV checks a lot of boxes for prototyping:
- Streaming friendly (you can start send / decode bytes as they are produced)
- Very simple
- Carries AVCDecoderRecord, also used by MOQMI, so no transcoding of this header is needed
- Uses AudioSpecificCodec (ASC) header for audio, very simple to decode
- We are very familiar with it (for good and bad :-))

## Examples

### Stream VOD file simulating live stream

Important you follow the next steps in order (when fifo pipes are involved is important to send data before we connect the reader)

Expand All @@ -77,7 +87,7 @@ Note: fontfile location can change depending on OS
```
This will read and demux FLV data (expecting 1 video in h264 and 1 audio in AAC-LC) and will announce the namespace `flvstreamer` (dafeult value) to the relay

## Save stream to a file
### Save stream to a file

Assuming we already did all specified in [Stream VOD file simulating live stream](#stream-vod-file-simulating-live-stream)

Expand Down Expand Up @@ -105,7 +115,7 @@ Or if you system has UI, you can play it back with any media player, for instanc
ffplay ~/Movies/my-moq-out.flv
```

## Watch it live (OS needs UI)
### Watch it live (OS needs UI)

Assuming we already did all specified in [Stream VOD file simulating live stream](#stream-vod-file-simulating-live-stream)

Expand All @@ -127,7 +137,7 @@ ffplay ~/Movies/fifo-out.flv
![Live playback](./pics/moq-streamer-play.png)
Fig3: Live playback via ffplay

## Connect streamer app with browser (webcodecs) playback
### Connect streamer app with browser (webcodecs) playback

Assuming you have moxygen running in localhost with following params (terminal1):
```
Expand Down Expand Up @@ -159,7 +169,7 @@ This will read and demux FLV data (expecting 1 video in h264 and 1 audio in AAC-
![Live playback in browser](./pics/moq-wc-play-from-app.png)
Fig4: Live playback in the brower using Webcodecs

## Connect browser streamer (webcodecs) and play it in application
### Connect browser streamer (webcodecs) and play it in application

Assuming you have moxygen running in localhost with following params:
```
Expand All @@ -174,6 +184,9 @@ Assuming you have moxygen running in localhost with following params:
- Change audio codec to "AAC-LC"
- Click "Start"

![Encoder webpage](./pics/moq-streamer-encode-from-wc.png)
Fig5: Encoder webpage

- Create out fifo (terminal4)
```
mkfifo ~/Movies/fifo-out.flv
Expand All @@ -189,11 +202,8 @@ ffplay ~/Movies/fifo-out.flv
./_build/bin/moqflvreceiverclient --flv_outpath ~/Movies/fifo-out.flv --logging DBG1
```

**TODO: We need to define authinfo in the receiver!!!!**
You should see /listen now live playback from browser to ffplay

```
src-encoder/?local&verbose=1:809 [MOQ-SENDER] Invalid subscribe authInfo undefined does not match with {"audio":{"namespace":"flvstreamer","name":"audio0","maxInFlightRequests":60,"isHipri":true,"authInfo":"secret","moqMapping":"SubGroupPerObj"},"video":{"namespace":"flvstreamer","name":"video0","maxInFlightRequests":39,"isHipri":false,"authInfo":"secret","moqMapping":"SubGroupPerObj"}}
```

![Live playback](./pics/moq-streamer-play-from-wc.png)
Fig5: Live playback from WebCodecs via ffplay
Fig6: Live playback from WebCodecs via ffplay
10 changes: 8 additions & 2 deletions moxygen/samples/flv_receiver_client/MoQFlvReceiverClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ DEFINE_int32(
"Dejitter buffer size in ms (this translates to added latency)");
DEFINE_bool(quic_transport, false, "Use raw QUIC transport");
DEFINE_bool(fetch, false, "Use fetch rather than subscribe");
DEFINE_string(auth, "secret", "MOQ subscription auth string");

namespace {
using namespace moxygen;
Expand Down Expand Up @@ -522,6 +523,7 @@ int main(int argc, char* argv[]) {
const auto trackAliasAudio = 1;
const auto subscribeIDVideo = 1;
const auto trackAliasVideo = 2;

flvReceiverClient
.run(
{subscribeIDAudio,
Expand All @@ -535,7 +537,9 @@ int main(int argc, char* argv[]) {
LocationType::LatestObject,
folly::none,
folly::none,
{}},
{{folly::to_underlying(TrackRequestParamKey::AUTHORIZATION),
FLAGS_auth,
0}}},
{subscribeIDVideo,
trackAliasVideo,
moxygen::FullTrackName(
Expand All @@ -547,7 +551,9 @@ int main(int argc, char* argv[]) {
LocationType::LatestObject,
folly::none,
folly::none,
{}})
{{folly::to_underlying(TrackRequestParamKey::AUTHORIZATION),
FLAGS_auth,
0}}})
.scheduleOn(&eventBase)
.start()
.via(&eventBase)
Expand Down
Binary file added pics/moq-streamer-encode-from-wc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/moq-streamer-play-from-wc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eaeacb6

Please sign in to comment.