Improved user message for stream discovery failure

This commit is contained in:
Bruno Herbelin
2022-01-01 10:13:46 +01:00
parent 28f9ed1d8d
commit 780a20689c
3 changed files with 9 additions and 4 deletions

View File

@@ -157,7 +157,8 @@ StreamInfo StreamDiscoverer(const std::string &description, guint w, guint h)
// wait for the callback_stream_discoverer to return, no more than 4 sec
std::mutex mtx;
std::unique_lock<std::mutex> lck(mtx);
info.discovered.wait_for(lck,std::chrono::seconds(TIMEOUT));
if ( info.discovered.wait_for(lck,std::chrono::seconds(TIMEOUT)) == std::cv_status::timeout)
info.message = "Time out.";
// stop and delete pipeline
GstStateChangeReturn ret = gst_element_set_state (_pipeline, GST_STATE_NULL);
@@ -166,6 +167,8 @@ StreamInfo StreamDiscoverer(const std::string &description, guint w, guint h)
gst_object_unref (_pipeline);
}
}
else
info.message = error->message;
}
// at this point, the info should be filled
return info;
@@ -631,7 +634,7 @@ void Stream::update()
}
// invalid info; fail
else
fail("Failed to determine resolution");
fail("Could not create stream: " + i.message);
}
}
// wait next frame to display

View File

@@ -15,13 +15,14 @@
class Visitor;
#define N_FRAME 3
#define TIMEOUT 4
#define TIMEOUT 5
struct StreamInfo {
guint width;
guint height;
std::condition_variable discovered;
std::string message;
StreamInfo(guint w=0, guint h=0) {
width = w;
@@ -31,6 +32,7 @@ struct StreamInfo {
StreamInfo(const StreamInfo& b) {
width = b.width;
height = b.height;
message = b.message;
}
inline bool valid() { return width > 0 && height > 0; }

View File

@@ -45,7 +45,7 @@ GenericStreamSource::GenericStreamSource(uint64_t id) : StreamSource(id)
void GenericStreamSource::setDescription(const std::string &desc)
{
gst_description_ = desc;
gst_description_ = BaseToolkit::unwrapped(desc);
gst_elements_ = BaseToolkit::splitted(desc, '!');
Log::Notify("Creating Source with Stream description '%s'", gst_description_.c_str());