Example #1
0
bool GstPlayerBase::on_bus_Message(const Glib::RefPtr<Gst::Bus>& bus, const Glib::RefPtr<Gst::Message>& message)
{
	cout << "message" << endl;
	switch (message->get_message_type())
	{
	case Gst::MESSAGE_EOS:
		cout << "EOS" << endl;
		Stop();
		break;
	case Gst::MESSAGE_ERROR:
		{
			Glib::RefPtr<Gst::MessageError> msgError = Glib::RefPtr<Gst::MessageError>::cast_dynamic(message);
			if(msgError)
			{
				Glib::Error err;
				err = msgError->parse();
				std::cerr << "Error: " << err.what() << std::endl;
			}
			else
				std::cerr << "Error." << std::endl;

		Stop();
		return false;
		}
	default:
		break;
	}
	return true;
}
Example #2
0
bool JAMediaPlayer::on_bus_message(const Glib::RefPtr<Gst::Bus>& bus,
    const Glib::RefPtr<Gst::Message>& message){

    switch(message->get_message_type()){
        case Gst::MESSAGE_ELEMENT: {
            if (message->get_structure().has_name("prepare-xwindow-id")){
                Glib::RefPtr<Gst::Element> element =
                    Glib::RefPtr<Gst::Element>::cast_dynamic(message->get_source());
                Glib::RefPtr< Gst::ElementInterfaced<Gst::XOverlay> > xoverlay =
                    Gst::Interface::cast <Gst::XOverlay>(element);
                if (xoverlay){
                    xoverlay->set_xwindow_id(xid);}}
            break;}

        case Gst::MESSAGE_STATE_CHANGED:{
            Glib::RefPtr<Gst::MessageStateChanged> stateChangeMsg =
                Glib::RefPtr<Gst::MessageStateChanged>::cast_dynamic(message);
            if (stateChangeMsg){
                Gst::State oldState, newState, pendingState;
                stateChangeMsg->parse(oldState, newState, pendingState);
                if (estado != newState){
                    estado = newState;
                    if (estado == Gst::STATE_PLAYING){
                        signal_estado_update.emit("playing");
                        new_handler(true);}
                    else {signal_estado_update.emit("paused");
                        new_handler(false);}}}
            break;}

        case Gst::MESSAGE_EOS:{
            new_handler(false);
            signal_end.emit();
            return false;
            break;}

        case Gst::MESSAGE_ERROR:{
            Glib::RefPtr<Gst::MessageError> msgError =
                Glib::RefPtr<Gst::MessageError>::cast_static(message);
            if(msgError){
                Glib::Error err;
                err = msgError->parse();
                std::cerr << "Player Error: " << err.what() << std::endl;}
            else{
                std::cerr << "Player Error." << std::endl;}
            new_handler(false);
            return false;
            break;}

        case Gst::MESSAGE_TAG:{
            Glib::RefPtr<Gst::MessageTag> msg =
                Glib::RefPtr<Gst::MessageTag>::cast_static(message);
            Glib::ustring info = msg->get_structure().to_string();
            size_t found = info.find("video-codec");
            if (found!=std::string::npos){
                signal_video.emit();}
            signal_info_update.emit(info);
            break;}

        //elif message.type == gst.MESSAGE_BUFFERING:
        //    buf = int(message.structure["buffer-percent"])
        //    if buf < 100 and self.estado == gst.STATE_PLAYING:
        //        self.emit("loading-buffer", buf)
        //        self.__pause()
        //    elif buf > 99 and self.estado != gst.STATE_PLAYING:
        //        self.emit("loading-buffer", buf)
        //        self.play()

    }return true;}
Example #3
0
	std::string EE(const Glib::Error& error)
	{
		return error.what();
	}