Skip to content

Commit

Permalink
[Bug] GStreamer sample (#1972)
Browse files Browse the repository at this point in the history
* gst-sample-fix

* modify the message

* fix windows

* set to null

* fix pts and eos in sample

* unused var removed

* move null init
  • Loading branch information
niyatim23 authored and disa6302 committed May 2, 2024
1 parent ba10ec4 commit f2d9bdd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ jobs:
- name: Install dependencies
shell: powershell
run: |
choco install pkgconfiglite
choco install gstreamer --version=1.16.3
choco install gstreamer-devel --version=1.16.3
curl.exe -o C:\tools\pthreads-w32-2-9-1-release.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,12 @@ To run:
./samples/kvsWebrtcClientViewerGstSample <channelName> <mediaType> <audio-codec> <video-codec>
```

<<<<<<< HEAD
Allowed audio-codec: opus (default codec if nothing is specified)
Allowed video-codec: h264 (default codec if nothing is specified), h265

=======
>>>>>>> ec203eb5f6 ([Bug] GStreamer sample (#1972))
##### Known issues:
Our GStreamer samples leverage [MatroskaMux](https://gstreamer.freedesktop.org/documentation/matroska/matroskamux.html?gi-language=c) to receive media from its peer and save it to a file. However, MatroskaMux is designed for scenarios where the media's format remains constant throughout streaming. When the media's format changes mid-streaming (referred to as "caps changes"), MatroskaMux encounters limitations, its behavior cannot be predicted and it may be unable to handle these changes, resulting in an error message like:

Expand All @@ -344,6 +347,21 @@ gst-launch-1.0 videotestsrc pattern=ball num-buffers=1500 ! timeoverlay ! videoc
gst-launch-1.0 videotestsrc pattern=ball num-buffers=1500 ! timeoverlay ! videoconvert ! video/x-raw,format=I420,width=1280,height=720,framerate=25/1 ! queue ! x265enc speed-preset=veryfast bitrate=512 tune=zerolatency ! video/x-h265,stream-format=byte-stream,alignment=au,profile=main ! multifilesink location="frame-%04d.h265" index=1
```

<<<<<<< HEAD
=======
##### AAC

###### ADTS LC
```shell
gst-launch-1.0 audiotestsrc num-buffers=1500 ! audioconvert ! audioresample ! faac ! capsfilter caps=audio/mpeg,mpegversion=4,stream-format=adts,base-profile=lc,channels=2,rate=16000 ! multifilesink location="sample-%03d.aac" index=1
```

###### RAW LC
```shell
gst-launch-1.0 audiotestsrc num-buffers=1500 ! audioconvert ! audioresample ! faac ! capsfilter caps=audio/mpeg,mpegversion=4,stream-format=raw,base-profile=lc,channels=2,rate=16000 ! multifilesink location="sample-%03d.aac" index=1
```

>>>>>>> ec203eb5f6 ([Bug] GStreamer sample (#1972))
### Viewing Master Samples

After running one of the master samples, when the command line application prints "Signaling client connection to socket established", indicating that your signaling channel is created and the connected master is streaming media to it, you can view the stream. To do so, check the media playback viewer on the KVS Signaling Channels console or open the [WebRTC SDK Test Page](https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-js/examples/index.html).
Expand Down
1 change: 1 addition & 0 deletions samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE
pSampleConfiguration->trickleIce = trickleIce;
pSampleConfiguration->useTurn = useTurn;
pSampleConfiguration->enableSendingMetricsToViewerViaDc = FALSE;
pSampleConfiguration->receiveAudioVideoSource = NULL;

pSampleConfiguration->channelInfo.version = CHANNEL_INFO_CURRENT_VERSION;
pSampleConfiguration->channelInfo.pChannelName = channelName;
Expand Down
9 changes: 1 addition & 8 deletions samples/GstAudioVideoReceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

static UINT64 presentationTsIncrement = 0;
static BOOL eos = FALSE;
static RTC_CODEC audioCodec = RTC_CODEC_OPUS;

// This function is a callback for the transceiver for every single video frame it receives
// It writes these frames to a buffer and pushes it to the `appsrcVideo` element of the
Expand Down Expand Up @@ -68,13 +67,7 @@ VOID onGstAudioFrameReady(UINT64 customData, PFrame pFrame)

GST_BUFFER_DTS(buffer) = presentationTsIncrement;
GST_BUFFER_PTS(buffer) = presentationTsIncrement;

if (audioCodec == RTC_CODEC_AAC) {
GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale(pFrame->size, GST_SECOND, DEFAULT_AUDIO_AAC_BYTE_RATE);
} else {
GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale(pFrame->size, GST_SECOND, DEFAULT_AUDIO_OPUS_BYTE_RATE);
}
// TODO: check for other codecs once the pipelines are added
GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale(pFrame->size, GST_SECOND, DEFAULT_AUDIO_OPUS_BYTE_RATE);

if (gst_buffer_fill(buffer, 0, pFrame->frameData, pFrame->size) != pFrame->size) {
DLOGE("Buffer fill did not complete correctly");
Expand Down
3 changes: 1 addition & 2 deletions samples/kvsWebrtcClientMasterGstSample.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ INT32 main(INT32 argc, CHAR* argv[])

pSampleConfiguration->videoSource = sendGstreamerAudioVideo;
pSampleConfiguration->mediaType = SAMPLE_STREAMING_VIDEO_ONLY;
pSampleConfiguration->audioCodec = audioCodec;
pSampleConfiguration->videoCodec = videoCodec;

#ifdef ENABLE_DATA_CHANNEL
pSampleConfiguration->onDataChannel = onDataChannel;
#endif
Expand Down

0 comments on commit f2d9bdd

Please sign in to comment.