Skip to content

Commit

Permalink
Merge pull request #16 from fluendo/audiotestrsc-update-html-page
Browse files Browse the repository at this point in the history
samples: audiotestsrc: Update HTML page to accept pipeline as input
  • Loading branch information
cfoch authored Jun 17, 2024
2 parents 3c94ce8 + 9a5cdd1 commit 6f04f61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions gst.wasm/subprojects/samples/audiotestsrc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<input type="text" id="pipeline" name="Pipeline" value="audiotestsrc ! audio/x-raw,format=F32LE,layout=non-interleaved,rate=44100,channels=2" style="width: 80%;">
<input type="button" id="play" value="Play" />

{{{ SCRIPT }}}
Expand Down
16 changes: 8 additions & 8 deletions gst.wasm/subprojects/samples/audiotestsrc/src/audioplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ class AudioPlayer
public:
GAsyncQueue *queue;

AudioPlayer (val parent) : m_parent (parent)
AudioPlayer (val parent, std::string pipeline_desc) : m_parent (parent)
{
GST_DEBUG_CATEGORY_INIT (
GST_CAT_DEFAULT, "audioplayer", 0, "audiotestsrc player");

char *full_pipeline_desc = g_strdup_printf ("%s! appsink name=sink emit-signals=true",
pipeline_desc.c_str());

queue = g_async_queue_new_full ((GDestroyNotify) gst_sample_unref);
pipe = gst_parse_launch (
"audiotestsrc ! "
"audio/"
"x-raw,format=F32LE,layout=non-interleaved,rate=44100,channels=2 ! "
"appsink name=sink emit-signals=true",
NULL);
pipe = gst_parse_launch (full_pipeline_desc, NULL);
g_free (full_pipeline_desc);

g_assert (pipe != NULL);
sink = gst_bin_get_by_name (GST_BIN (pipe), "sink");
g_assert (sink != NULL);
Expand Down Expand Up @@ -141,6 +141,6 @@ output_sample (AudioPlayer *decoder)
EMSCRIPTEN_BINDINGS (my_class_example2)
{
class_<AudioPlayer> ("AudioPlayer")
.constructor<val> ()
.constructor<val, std::string> ()
.function ("play", &AudioPlayer::Play);
}
3 changes: 2 additions & 1 deletion gst.wasm/subprojects/samples/audiotestsrc/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ AudioData = class extends AudioData {
AudioPlayer = class {
constructor(options) {
// FIXME: EMBIND forbids extending Module.AudioPlayer.
this._audioDecoder = new Module.AudioPlayer(this);
const pipeline_desc = document.getElementById("pipeline").value;
this._audioDecoder = new Module.AudioPlayer(this, pipeline_desc);
this.options = options;
}

Expand Down

0 comments on commit 6f04f61

Please sign in to comment.