-
Notifications
You must be signed in to change notification settings - Fork 241
Streamer2 #967
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
Streamer2 #967
Changes from all commits
19419ac
02cddea
f097f3d
f5f829a
a17ec71
884fd20
1f34458
082dca5
909a6b0
cc48ad5
2fef426
7f5a61d
8829d1a
e3001c5
2374af5
e8e2692
7b38912
dc0a184
b8a8297
c28e784
04eec1c
2981836
10400f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #ifndef _WIN32 | ||
| #include "jamstreamer.h" | ||
|
|
||
| using namespace streamer; | ||
|
|
||
| CJamStreamer::CJamStreamer() : qproc ( NULL ) {} | ||
|
|
||
| void CJamStreamer::process( int iServerFrameSizeSamples, const CVector<int16_t>& data ) { | ||
| qproc->write ( reinterpret_cast<const char*> (&data[0]), sizeof (int16_t) * ( 2 * iServerFrameSizeSamples ) ); | ||
| } | ||
|
|
||
| void CJamStreamer::Init( const QString strStreamDest ) { | ||
| this->strStreamDest = strStreamDest; | ||
| } | ||
|
|
||
| void CJamStreamer::OnStarted() { | ||
| if ( !qproc ) | ||
| { | ||
| qproc = new QProcess; | ||
| QObject::connect ( qproc, &QProcess::errorOccurred, this, &CJamStreamer::onError ); | ||
| QObject::connect ( qproc, QOverload<int, QProcess::ExitStatus>::of( &QProcess::finished ), this, &CJamStreamer::onFinished ); | ||
| qproc->setStandardOutputFile ( QProcess::nullDevice() ); | ||
| } | ||
| QStringList argumentList = { "-loglevel", "error", | ||
| "-y", "-f", "s16le", | ||
| "-ar", "48000", "-ac", "2", | ||
| "-i", "-" }; | ||
| argumentList += strStreamDest.split( QRegExp("\\s+") ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Absolutely! I didn't know about that. What I did just fixed the immediate issue ( The only problem I see is that this function is only available as of Qt 5.15. As far as I can see, Jamulus is supposed to support earlier versions (5.9?). Therefore, a compromise might be a version check which uses Are you (@npostavs) going to continue with this? Or is @dingodoppelt? Personally, I currently have no need for this feature at all so I would prefer if one of you could continue. :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoffie
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, didn't realize it 5.15 specific.
The compromise sounds like a recipe for confusion to me. How necessary are the multiple arguments? E.g.,
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, my example was hypothetical. No idea why I added that. The help text talks about "ffmpeg arguments", but not sure if or in what circumstances this would be needed. If the requirement could be dropped, this would be the simplest fix. @dingodoppelt?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hoffie EDIT: This works fine, for example, and represents my usecase:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how we could move this forward.
I generally agree. However, we are talking about edge cases I think (e.g. filenames/urls with spaces). It seems like the half-broken hack I've implemented works for @dingodoppelt's use case. If we can improve that code to be less half-broken on modern Qt versions, I think that's a benefit. So I'd still vote for the compromise as I don't see any better alternatives?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, the other possibilities would be for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not sure I'm following. Do you mean repeated
Jamulus-wise, this would be the simplest form. @dingodoppelt Would that work for you as well?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I just noticed that the Qt docs seem to say the split functions are only available as of Qt 5.14, so it might be trouble as well? |
||
| // Note that program name is also repeated as first argument | ||
| qproc->start ( "ffmpeg", argumentList ); | ||
| } | ||
|
|
||
| void CJamStreamer::onError(QProcess::ProcessError error) | ||
| { | ||
| QString errDesc; | ||
| switch (error) { | ||
| case QProcess::FailedToStart: | ||
| errDesc = "failed to start"; | ||
| break; | ||
| case QProcess::Crashed: | ||
| errDesc = "crashed"; | ||
| break; | ||
| case QProcess::Timedout: | ||
| errDesc = "timed out"; | ||
| break; | ||
| case QProcess::WriteError: | ||
| errDesc = "write error"; | ||
| break; | ||
| case QProcess::ReadError: | ||
| errDesc = "read error"; | ||
| break; | ||
| case QProcess::UnknownError: | ||
| errDesc = "unknown error"; | ||
| break; | ||
| default: | ||
| errDesc = "UNKNOWN unknown error"; | ||
| break; | ||
| } | ||
| qWarning() << "QProcess Error: " << errDesc << "\n"; | ||
| } | ||
|
|
||
| void CJamStreamer::onFinished( int exitCode, QProcess::ExitStatus exitStatus ) | ||
| { | ||
| Q_UNUSED ( exitStatus ); | ||
| QByteArray stderr = qproc->readAllStandardError (); | ||
| qInfo() << "ffmpeg exited with exitCode" << exitCode << ", stderr:" << stderr; | ||
| } | ||
|
|
||
| void CJamStreamer::OnStopped() { | ||
| qproc->closeWriteChannel (); | ||
| } | ||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #ifndef _WIN32 | ||
| #include <QObject> | ||
| #include <QProcess> | ||
| #include "../util.h" | ||
|
|
||
| namespace streamer { | ||
|
|
||
| class CJamStreamer : public QObject { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| CJamStreamer(); | ||
| void Init( const QString strStreamDest ); | ||
|
|
||
| public slots: | ||
| void process( int iServerFrameSizeSamples, const CVector<int16_t>& data ); | ||
| void OnStarted(); | ||
| void OnStopped(); | ||
| private slots: | ||
| void onError(QProcess::ProcessError error); | ||
| void onFinished( int exitCode, QProcess::ExitStatus exitStatus ); | ||
|
|
||
| private: | ||
| QString strStreamDest; // stream destination to pass to ffmpeg as output part of arguments | ||
| QProcess* qproc; // ffmpeg subprocess | ||
| }; | ||
| } | ||
| #endif |
Uh oh!
There was an error while loading. Please reload this page.