Guest User

Untitled

a guest
Nov 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. bool DtVideoStreamDriver::buildPipeline()
  2. {
  3.    std::string piplineDescription=myInitializer->findData<std::string>("pipeline");
  4.    GError* error=NULL;
  5.    myPipeline = gst_parse_launch(piplineDescription.c_str(), &error);
  6.    
  7.    if(error!=NULL)
  8.    {
  9.       DtWarn << "Error: " << error->message << std::endl;
  10.       return false;
  11.    }
  12.  
  13.    if(myPipeline==NULL)
  14.    {
  15.       DtWarn << "Error creating pipeline" << std::endl;
  16.       return false;
  17.    }
  18.  
  19.    myAppSrc= gst_bin_get_by_name (GST_BIN(myPipeline), "myAppSrc");
  20.    if(myAppSrc==NULL || !(GST_IS_APP_SRC(myAppSrc)))
  21.    {
  22.       DtWarn << "pipeline description must have an AppSrc element named myAppSrc" << std::endl;
  23.       return false;
  24.    }
  25.  
  26.  
  27.    //get the current channels width and height to set the caps on the appsrc
  28.    DtChannel* c=myAgentManager.de().driverManager().inputDriver().currentChannel();
  29.    DtOsgChannel* oc=dynamic_cast<DtOsgChannel*>(c);
  30.    if(!oc)
  31.    {
  32.       DtWarn << "Need an OSG Channel for this to work!" << std::endl;
  33.       return false;
  34.    }
  35.  
  36.    int x,y;
  37.    oc->getViewport(x,y, myWidth, myHeight);
  38.    GstCaps* caps = gst_caps_new_simple (
  39.       "video/x-raw-rgb",
  40.       "bpp",G_TYPE_INT,24,
  41.       "depth",G_TYPE_INT,24,
  42.       "width", G_TYPE_INT, myWidth,
  43.       "height", G_TYPE_INT, myHeight,
  44.       "red_mask",   G_TYPE_INT, 0x000000ff,
  45.       "green_mask", G_TYPE_INT, 0x0000ff00,
  46.       "blue_mask",  G_TYPE_INT, 0x00ff0000,
  47.       "framerate", GST_TYPE_FRACTION, 25, 1,
  48.       "endianness", G_TYPE_INT, G_BIG_ENDIAN,
  49.       NULL);
  50.    gst_app_src_set_caps(GST_APP_SRC(myAppSrc), caps);
  51.  
  52.    return true;
  53. }
Add Comment
Please, Sign In to add comment