TEST_F(OsgScreenSpaceQuadRenderTests, InitTest) { std::shared_ptr<OsgScreenSpaceQuadRepresentation> quad = std::make_shared<OsgScreenSpaceQuadRepresentation>("Screen Quad"); viewElement->addComponent(quad); /// Run the thread runtime->start(); EXPECT_TRUE(graphicsManager->isInitialized()); EXPECT_TRUE(viewElement->isInitialized()); quad->setSize(100, 100); boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); auto dimensions = viewElement->getView()->getDimensions(); SurgSim::Math::Vector3d startPosition(0.0, 0.0, 0.0); SurgSim::Math::Vector3d endPosition(dimensions[0], dimensions[1], 0.0); SurgSim::Math::Vector2d startSize(0.0, 0.0); SurgSim::Math::Vector2d endSize(200, 200); int numSteps = 100; for (int i = 0; i < numSteps; ++i) { /// Calculate t in [0.0, 1.0] double t = static_cast<double>(i) / numSteps; RigidTransform3d currentPose = SurgSim::Testing::interpolatePose( Vector3d::Identity(), Vector3d::Identity(), startPosition, endPosition, t); quad->setLocalPose(currentPose); SurgSim::Math::Vector2d size = SurgSim::Testing::interpolate(startSize, endSize, t); quad->setSize(size.x(), size.y()); boost::this_thread::sleep(boost::posix_time::milliseconds(1000 / numSteps)); } }
VlcVideoWidget::VlcVideoWidget(const QList<QByteArray> &args) : QFrame(0), vlcInstance_(0), vlcPlayer_(0), vlcMedia_(0), hasVideoOut_(false) { /// Convert the arguments into a proper form QVarLengthArray<const char*, 64> vlcArgs(args.size()); for (int i = 0; i < args.size(); ++i) vlcArgs[i] = args.at(i).constData(); // Create new libvlc instance vlcInstance_ = libvlc_new(vlcArgs.size(), vlcArgs.constData()); // Check if instance is running if (!vlcInstance_) { std::string errorMsg; if (libvlc_errmsg()) errorMsg = std::string("VlcVideoWidget: Failed to create VLC instance: ") + libvlc_errmsg(); else errorMsg = "VlcVideoWidget: Failed to create VLC instance"; LogError(errorMsg); return; } libvlc_set_user_agent(vlcInstance_, "realXtend Tundra Media Player 1.0", "Tundra/1.0"); /// Create the vlc player and set event callbacks vlcPlayer_ = libvlc_media_player_new(vlcInstance_); libvlc_event_manager_t *em = libvlc_media_player_event_manager(vlcPlayer_); libvlc_event_attach(em, libvlc_MediaPlayerMediaChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerOpening, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerBuffering, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPlaying, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPaused, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerStopped, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerEncounteredError, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerTimeChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPositionChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerSeekableChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPausableChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerTitleChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerLengthChanged, &VlcEventHandler, this); /// register callbacks so that we can implement custom drawing of video frames libvlc_video_set_callbacks( vlcPlayer_, &CallBackLock, &CallBackUnlock, &CallBackDisplay, this); // Initialize rendering //idleLogo_ = QImage(":/images/vlc-cone.png"); idleLogo_ = QImage(":/images/play-video.png"); idleLogo_ = idleLogo_.convertToFormat(QImage::Format_ARGB32); //audioLogo_ = QImage(":/images/audio.png"); audioLogo_ = QImage(":/images/play-audio.png"); audioLogo_ = audioLogo_.convertToFormat(QImage::Format_ARGB32); pausePixmap_ = QPixmap(":/images/pause-big.png"); bufferingPixmap_ = QPixmap(":/images/buffering.png"); QSize startSize(600, 360); renderPixmap_ = QImage(startSize.width(), startSize.height(), QImage::Format_RGB32); libvlc_video_set_format(vlcPlayer_, "RV32", renderPixmap_.width(), renderPixmap_.height(), renderPixmap_.bytesPerLine()); // Initialize widget properties setMinimumSize(startSize); resize(startSize); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setStyleSheet("background-color: black;"); // Connect and start status poller connect(&pollTimer_, SIGNAL(timeout()), SLOT(StatusPoller())); pollTimer_.start(10); }