FIX: [STUDIO-2340] [STUDIO-2297] handle linux gstreamer error

Change-Id: Iadc6dcb9d7a9f2c5d1ce9cf979bbbfbd0f805d19
This commit is contained in:
chunmao.guo 2023-03-06 16:02:57 +08:00 committed by Lane.Wei
parent 0e3364a415
commit a401c0fa2e
4 changed files with 37 additions and 10 deletions

View file

@ -31,6 +31,9 @@ wxMediaCtrl2::wxMediaCtrl2(wxWindow *parent)
#ifdef __LINUX__
/* Register only after we have created the wxMediaCtrl, since only then are we guaranteed to have fired up Gstreamer's plugin registry. */
gstbambusrc_register();
Bind(wxEVT_MEDIA_LOADED, [this](auto & e) {
m_loaded = true;
});
#endif
}
@ -138,22 +141,44 @@ void wxMediaCtrl2::Load(wxURI url)
wxPostEvent(this, event);
return;
}
wxLog::EnableLogging(false);
#endif
m_error = 0;
m_loaded = false;
wxMediaCtrl::Load(url);
#ifdef __WXGTK3__
wxMediaEvent event(wxEVT_MEDIA_STATECHANGED);
event.SetId(GetId());
event.SetEventObject(this);
wxPostEvent(this, event);
#endif
}
void wxMediaCtrl2::Play() { wxMediaCtrl::Play(); }
void wxMediaCtrl2::Stop() { wxMediaCtrl::Stop(); }
#ifdef __LINUX__
extern int gst_bambu_last_error;
#endif
int wxMediaCtrl2::GetLastError() const
{
#ifdef __LINUX__
return gst_bambu_last_error;
#else
return m_error;
#endif
}
wxSize wxMediaCtrl2::GetVideoSize() const
{
#ifdef __LINUX__
// Gstreamer doesn't give us a VideoSize until we're playing, which
// confuses the MediaPlayCtrl into claiming that it is stuck
// "Loading...". Fake it out for now.
return wxSize(1280, 720);
return m_loaded ? wxSize(1280, 720) : wxSize{};
#else
return m_imp ? m_imp->GetVideoSize() : wxSize(0, 0);
#endif