FIX: [STUDIO-2340] [STUDIO-2297] handle linux gstreamer error
Change-Id: Iadc6dcb9d7a9f2c5d1ce9cf979bbbfbd0f805d19
This commit is contained in:
parent
0e3364a415
commit
a401c0fa2e
|
@ -27,9 +27,6 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
|||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
m_media_ctrl->Bind(wxEVT_MEDIA_STATECHANGED, &MediaPlayCtrl::onStateChanged, this);
|
||||
#if wxUSE_GSTREAMER_PLAYER
|
||||
m_media_ctrl->Bind(wxEVT_MEDIA_LOADED, &MediaPlayCtrl::onStateChanged, this);
|
||||
#endif
|
||||
|
||||
m_button_play = new Button(this, "", "media_play", wxBORDER_NONE);
|
||||
m_button_play->SetCanFocus(false);
|
||||
|
@ -365,11 +362,11 @@ void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
|
|||
Stop();
|
||||
return;
|
||||
}
|
||||
if (last_state == MEDIASTATE_LOADING && (state == wxMEDIASTATE_STOPPED || state == wxMEDIASTATE_PAUSED || event.GetEventType() == wxEVT_MEDIA_LOADED)) {
|
||||
if (last_state == MEDIASTATE_LOADING && (state == wxMEDIASTATE_STOPPED || state == wxMEDIASTATE_PAUSED)) {
|
||||
wxSize size = m_media_ctrl->GetVideoSize();
|
||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::onStateChanged: size: " << size.x << "x" << size.y;
|
||||
m_failed_code = m_media_ctrl->GetLastError();
|
||||
if (size.GetWidth() > 1000 || (event.GetEventType() == wxEVT_MEDIA_LOADED)) {
|
||||
if (size.GetWidth() > 1000) {
|
||||
m_last_state = state;
|
||||
SetStatus(_L("Playing..."), false);
|
||||
m_failed_retry = 0;
|
||||
|
|
|
@ -259,6 +259,8 @@ gst_bambusrc_get_property (GObject * object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
int gst_bambu_last_error = 0;
|
||||
|
||||
static GstFlowReturn
|
||||
gst_bambusrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
||||
{
|
||||
|
@ -286,7 +288,8 @@ gst_bambusrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
|||
}
|
||||
|
||||
if (rv != Bambu_success) {
|
||||
return GST_FLOW_ERROR;
|
||||
gst_bambu_last_error = rv;
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,68,0)
|
||||
|
@ -316,7 +319,7 @@ gst_bambusrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
|||
//if (GST_CLOCK_TIME_NONE == src->sttime)
|
||||
// src->sttime
|
||||
GST_DEBUG_OBJECT(src,
|
||||
"sttime init to %llu.",
|
||||
"sttime init to %lu.",
|
||||
src->sttime);
|
||||
}
|
||||
//GST_BUFFER_DTS(*outbuf) = gst_element_get_current_clock_time((GstElement *)psrc) - src->sttime;
|
||||
|
@ -325,7 +328,7 @@ gst_bambusrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
|||
GST_BUFFER_DURATION(*outbuf) = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
GST_DEBUG_OBJECT(src,
|
||||
"sttime:%llu, DTS:%llu, PTS: %llu~",
|
||||
"sttime:%lu, DTS:%lu, PTS: %lu~",
|
||||
src->sttime, GST_BUFFER_DTS(*outbuf), GST_BUFFER_PTS(*outbuf));
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
@ -377,6 +380,7 @@ gst_bambusrc_start (GstBaseSrc * bsrc)
|
|||
BAMBULIB(Bambu_Close)(src->tnl);
|
||||
BAMBULIB(Bambu_Destroy)(src->tnl);
|
||||
src->tnl = NULL;
|
||||
gst_bambu_last_error = rv;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
|
||||
void SetIdleImage(wxString const & image);
|
||||
|
||||
int GetLastError() const { return m_error; }
|
||||
int GetLastError() const;
|
||||
|
||||
wxSize GetVideoSize() const;
|
||||
|
||||
|
@ -83,6 +83,7 @@ protected:
|
|||
private:
|
||||
wxString m_idle_image;
|
||||
int m_error = 0;
|
||||
bool m_loaded = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue