bool ossimGeneralRasterWriter::writeToBip()
{
   ossimEndian endian;
   static const char* const MODULE = "ossimGeneralRasterWriter::writeToBip";
   
   if (traceDebug()) CLOG << " Entered." << std::endl;
   
   
   //---
   // Get an arbitrary tile just to get the size in bytes!
   // This should be changed later... An ossimImageSource should know
   // this.
   //---
   ossimRefPtr<ossimImageData> id;
   
   // Start the sequence at the first tile.
   theInputConnection->setToStartOfSequence();
   
   ossim_uint64 bands     = theInputConnection->getNumberOfOutputBands();
   ossim_uint64 tilesWide =  theInputConnection->getNumberOfTilesHorizontal();
   ossim_uint64 tilesHigh     = theInputConnection->getNumberOfTilesVertical();
   ossim_uint64 tileHeight    = theInputConnection->getTileHeight();
   ossim_uint64 numberOfTiles = theInputConnection->getNumberOfTiles();
   ossim_uint64 width         = theAreaOfInterest.width();

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "\nossimGeneralRasterWriter::writeToBip DEBUG:"
         << "\nbands:          " << bands
         << "\ntilesWide:      " << tilesWide
         << "\ntilesHigh:      " << tilesHigh
         << "\ntileHeight:     " << tileHeight
         << "\nnumberOfTiles:  " << numberOfTiles
         << "\nwidth:          " << width
         << std::endl;
   }
   
   //---
   // Buffer to hold one line x tileHeight
   //---
   ossim_uint64 bufferSizeInBytes = 0;
   ossim_uint64 bytesInLine       = 0;
   unsigned char* buffer = NULL;
   
   theMinPerBand.clear();
   theMaxPerBand.clear();
   ossim_uint64 tileNumber = 0;
   bool wroteSomethingOut = false;
   ossimScalarType scalarType = theInputConnection->getOutputScalarType();
   for(ossim_uint64 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
   {
      // Clear the buffer.
      if(buffer)
      {
	 memset(buffer, 0, bufferSizeInBytes);
      }
      
      ossimIrect bufferRect(theAreaOfInterest.ul().x,
			    theAreaOfInterest.ul().y + i*tileHeight,
			    theAreaOfInterest.ul().x + (width - 1),
			    theAreaOfInterest.ul().y + i*tileHeight + (tileHeight - 1));
      // Tile loop in the sample (width) direction.
      for(ossim_uint64 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
      {
         // Get the tile and copy it to the buffer.
         id = theInputConnection->getNextTile();
	 if(id.valid())
         {
            id->computeMinMaxPix(theMinPerBand, theMaxPerBand);
            if(!buffer)
            {
               bytesInLine     = id->getScalarSizeInBytes() * width * bands;
               
               //---
               // Buffer to hold one line x tileHeight
               //---
               bufferSizeInBytes = bytesInLine * tileHeight;
               buffer = new unsigned char[bufferSizeInBytes];
               memset(buffer, 0, bufferSizeInBytes);
            }
            id->unloadTile(buffer,
                           bufferRect,
                           OSSIM_BIP);
         }
         ++tileNumber;
      }
      
      // Get the number of lines to write from the buffer.
      ossim_uint64 linesToWrite =
         min(tileHeight,
             static_cast<ossim_uint64>(theAreaOfInterest.lr().y -
                                       bufferRect.ul().y + 1));
      // Write the buffer out to disk.  
      ossim_uint8* buf = buffer;
      if(buf)
      {
         for (ossim_uint64 ii=0; ((ii<linesToWrite)&&(!needsAborting())); ++ii)
         {
            std::streamsize lineBytes = bytesInLine;
            wroteSomethingOut = true;

            if(endian.getSystemEndianType() != theOutputByteOrder)
            {
               endian.swap(scalarType,
                           buf,
                           lineBytes/ossim::scalarSizeInBytes(scalarType));
            }
            theOutputStream->write((char*)buf, lineBytes);
            if (theOutputStream->fail())
            {
               ossimNotify(ossimNotifyLevel_FATAL)
                  << MODULE << " ERROR:"
                  << "Error returned writing line!" << std::endl;
               setErrorStatus();
               if(buffer)
               {
                  // Free the memory.
                  delete [] buffer;
               }
               return false;
            }
	    
            buf += bytesInLine;
	    
         } // End of loop to write lines from buffer to tiff file.
      }
      double tile = tileNumber;
      double numTiles = numberOfTiles;
      setPercentComplete(tile / numTiles * 100);
      if(needsAborting())
      {
         setPercentComplete(100.0);
      }
      
   } // End of loop in the line (height) direction.
   if(buffer)
   {
      // Free the memory.
      delete [] buffer;
   }
   
   if (traceDebug()) CLOG << " Exited." << std::endl;
   
   return wroteSomethingOut;
}
bool ossimGeneralRasterWriter::writeToBsq()
{
   ossimEndian endian;
   static const char* const MODULE = "ossimGeneralRasterWriter::writeToBsq";

   if (traceDebug()) CLOG << " Entered." << std::endl;

   //***
   // Get an arbitrary tile just to get the size in bytes!
   // This should be changed later... An ossimImageSource should know
   // this.
   //***
   ossimRefPtr<ossimImageData> id;

   // Start the sequence at the first tile.
   theInputConnection->setToStartOfSequence();

   ossim_uint64 bands     = theInputConnection->getNumberOfOutputBands();
   ossim_uint64 tilesWide = theInputConnection->getNumberOfTilesHorizontal();
   ossim_uint64 tilesHigh = theInputConnection->getNumberOfTilesVertical();
   ossim_uint64 tileHeight      = theInputConnection->getTileHeight();
   ossim_uint64 numberOfTiles   = theInputConnection->getNumberOfTiles();
   ossim_uint64 width           = theAreaOfInterest.width();
   ossim_uint64 height          = theAreaOfInterest.height();

   ossim_uint64 bytesInLine     = 0;
   ossim_uint64 buf_band_offset = 0;
   
   // Use the system "streampos" typedef for future 64 bit seeks (long long).
   streampos file_band_offset = 0;
   
   //***
   // Buffer to hold one line x tileHeight
   //***
   ossim_uint64 bufferSizeInBytes = 0;
   unsigned char* buffer = NULL;
      
   theMinPerBand.clear();
   theMaxPerBand.clear();

   ossim_uint64 tileNumber = 0;
   bool wroteSomethingOut = false;
   ossimScalarType scalarType = theInputConnection->getOutputScalarType();
   for(ossim_uint64 i = 0; ((i < tilesHigh)&&(!needsAborting())); ++i)
   {
      if(buffer)
      {
	 // Clear the buffer.
	 memset(buffer, 0, bufferSizeInBytes);
      }
      
      ossimIrect bufferRect(theAreaOfInterest.ul().x,
			    theAreaOfInterest.ul().y + i*tileHeight,
			    theAreaOfInterest.ul().x + (width - 1),
			    theAreaOfInterest.ul().y + i *
                            tileHeight + (tileHeight - 1));
      
      // Tile loop in the sample (width) direction.
      for(ossim_uint64 j = 0; ((j < tilesWide)&&(!needsAborting())); ++j)
      {
         // Get the tile and copy it to the buffer.
         id = theInputConnection->getNextTile();
	 if(id.valid())
         {
            id->computeMinMaxPix(theMinPerBand, theMaxPerBand);
            if(!buffer)
            {
               bytesInLine     = id->getScalarSizeInBytes() * width;
               buf_band_offset = bytesInLine * tileHeight;
               file_band_offset = height * bytesInLine;
               bufferSizeInBytes = bytesInLine * tileHeight * bands;
               buffer = new unsigned char[bufferSizeInBytes];
               memset(buffer, 0, bufferSizeInBytes);
            }
            id->unloadTile(buffer,
                           bufferRect,
                           OSSIM_BSQ);
         }
         ++tileNumber;
      }
      
      // Get the number of lines to write from the buffer.
      ossim_uint64 linesToWrite =
         min(tileHeight,
             static_cast<ossim_uint64>(theAreaOfInterest.lr().y -
                                       bufferRect.ul().y + 1));
      
      // Write the buffer out to disk.  
      ossim_uint64 start_line =
         static_cast<ossim_uint64>(bufferRect.ul().y -
                                   theAreaOfInterest.ul().y);
      for (ossim_uint64 band = 0; ((band < bands)&&(!needsAborting())); ++band)
      {
         ossim_uint8* buf = buffer;
         buf += buf_band_offset * band;
         
         // Put the file pointer in the right spot.
         streampos pos = file_band_offset * band + start_line * bytesInLine;
         theOutputStream->seekp(pos, ios::beg);
         if (theOutputStream->fail())
         {
            ossimNotify(ossimNotifyLevel_FATAL) << MODULE << " ERROR:"
                 << "Error returned seeking to image data position!" << std::endl;
            setErrorStatus();
            return false;
         }
         
         for (ossim_uint64 ii=0; ((ii<linesToWrite)&&(!needsAborting())); ++ii)
         {
            wroteSomethingOut = true;
            if(endian.getSystemEndianType() != theOutputByteOrder)
            {
               endian.swap(scalarType,
                           buf,
                           bytesInLine/ossim::scalarSizeInBytes(scalarType));
            }

            theOutputStream->write((char*)buf, bytesInLine);
            
            if (theOutputStream->fail())
            {
               ossimNotify(ossimNotifyLevel_FATAL) << MODULE << " ERROR:"
                    << "Error returned writing line!" << std::endl;
               setErrorStatus();
               return false;
            }
            
            buf += bytesInLine;
         }
         
      } // End of loop to write lines from buffer to tiff file.
      
      double tile = tileNumber;
      double numTiles = numberOfTiles;
      setPercentComplete(tile / numTiles * 100);

      if(needsAborting())
      {
         setPercentComplete(100.0);
      }
      
   } // End of loop in the line (height) direction.
   
   // Free the memory.
   delete [] buffer;
   
   if (traceDebug()) CLOG << " Exited." << std::endl;
   
   return wroteSomethingOut;
}
bool ossimGeneralRasterTileSource::getTile(ossimImageData* result,
                                           ossim_uint32 resLevel)
{
   bool status = false;
   
   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel)  &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);
      if (status)
      {
         if(getOutputScalarType() == OSSIM_USHORT11)
         {
            //---
            // Temp fix:
            // The overview handler could return a tile of OSSIM_UINT16 if
            // the max sample value was not set to 2047.
            //---
            result->setScalarType(OSSIM_USHORT11);
         }
      }
      
      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         //---
         // Subtract any sub image offset to get the zero based image space
         // rectangle.
         //---
         ossimIrect tile_rect = result->getImageRectangle();
         
         // This should be the zero base image rectangle for this res level.
         ossimIrect image_rect = getImageRectangle(resLevel);
         
         //---
         // See if any point of the requested tile is in the image.
         //---
         if ( tile_rect.intersects(image_rect) )
         {
            // Make the tile rectangle zero base.
            result->setImageRectangle(tile_rect);

            // Initialize the tile if needed as we're going to stuff it.
            if (result->getDataObjectStatus() == OSSIM_NULL)
            {
               result->initialize();
            }

            ossimIrect clip_rect = tile_rect.clipToRect(image_rect);

            if ( ! tile_rect.completely_within(m_bufferRect) )
            {
               // A new buffer must be loaded.
               if ( !tile_rect.completely_within(clip_rect) )
               {
                  //---
                  // Start with a blank tile since the whole tile buffer will
                  // not be
                  // filled.
                  //---
                  result->makeBlank();
               }

               // Reallocate the buffer if needed.
               if ( m_bufferSizeInPixels != result->getSize() )
               {
                  allocateBuffer( result );
               }

               ossimIpt size(static_cast<ossim_int32>(result->getWidth()),
                             static_cast<ossim_int32>(result->getHeight()));

               if( !fillBuffer(clip_rect.ul(), size) )
               {
                  ossimNotify(ossimNotifyLevel_WARN)
                     << "Error from fill buffer..."
                     << std::endl;
                  //---
                  // Error in filling buffer.
                  //---
                  setErrorStatus();
                  status = false;
               }
            }
            
            result->loadTile(m_buffer,
                             m_bufferRect,
                             clip_rect,
                             m_bufferInterleave);
            result->validate();

            // Set the rectangle back.
            result->setImageRectangle(tile_rect);
            
         }
         else // No intersection.
         {
            result->makeBlank();
         }
      }
   }
   return status;
}
Exemplo n.º 4
0
bool ossimNitfRpcModel::parseImageHeader(const ossimNitfImageHeader* ih)
{
   // Do this first so we don't waste time if not rpc image.
   if (getRpcData(ih) == false)
   {
      if (traceDebug())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimNitfRpcModel::parseFile DEBUG:"
         << "\nError parsing rpc tags.  Aborting with error."
         << std::endl;
      }
      setErrorStatus();
      return false;
   }
   
   
   //---
   // Get the decimation if any from the header "IMAG" field.
   // 
   // Look for string like:
   // "/2" = 1/2
   // "/4  = 1/4
   // ...
   // "/16 = 1/16
   // If it is full resolution it should be "1.0"
   //---
   ossimString os = ih->getImageMagnification();
   if ( os.contains("/") )
   {
      os = os.after("/");
      ossim_float64 d = os.toFloat64();
      if (d)
      {
         theDecimation = 1.0 / d;
      }
   }
   
   //***
   // Fetch Image ID:
   //***
   theImageID = ih->getImageId();
   
   ossimIrect imageRect = ih->getImageRect();
   
   //---
   // Fetch Image Size:
   //---
   theImageSize.line =
   static_cast<ossim_int32>(imageRect.height() / theDecimation);
   theImageSize.samp =
   static_cast<ossim_int32>(imageRect.width() / theDecimation);
   
   // Search for the STDID Tag to fetch mission (satellite) name:
   getSensorID(ih);
   
   //***
   // Assign other data members:
   //***
   theRefImgPt.line = theImageSize.line/2.0;
   theRefImgPt.samp = theImageSize.samp/2.0;
   theRefGndPt.lat  = theLatOffset;
   theRefGndPt.lon  = theLonOffset;
   theRefGndPt.hgt  = theHgtOffset;
   
   //***
   // Assign the bounding image space rectangle:
   //***
   theImageClipRect = ossimDrect(0.0, 0.0,
                                 theImageSize.samp-1, theImageSize.line-1);
   
   //---
   // Assign the bounding ground polygon:
   //
   // NOTE:  We will use the base ossimRpcModel for transformation since all
   // of our calls are in full image space (not decimated).
   //---
   ossimGpt v0, v1, v2, v3;
   ossimDpt ip0 (0.0, 0.0);
   ossimRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0);
   ossimDpt ip1 (theImageSize.samp-1.0, 0.0);
   ossimRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1);
   ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0);
   ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2);
   ossimDpt ip3 (0.0, theImageSize.line-1.0);
   ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3);
   
   theBoundGndPolygon
   = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3));
   
   updateModel();
   
   // Set the ground reference point.
   ossimRpcModel::lineSampleHeightToWorld(theRefImgPt,
                                          theHgtOffset,
                                          theRefGndPt);
   if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() )
   {
      if (traceDebug())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:"
         << "\nGround Reference Point not valid." 
         << " Aborting with error..."
         << std::endl;
      }
      setErrorStatus();
      return false;
   }
   
   //---
   // This will set theGSD and theMeanGSD.  This model doesn't need these but
   // others do.
   //---
   try
   {
      computeGsd();
   }
   catch (const ossimException& e)
   {
      if (traceDebug())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n"
         << e.what() << std::endl;
      }
   }
   
   if (traceExec())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
      << "DEBUG ossimNitfRpcModel::parseFile: returning..."
      << std::endl;
   }
   
   return true;
}
Exemplo n.º 5
0
void CRego6XXSerial::Do_Work()
{
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		if (m_stoprequested)
			break;

		sec_counter++;

		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}

		if (!isOpen())
		{
			if (m_retrycntr==0)
			{
				_log.Log(LOG_STATUS,"Rego6XX: serial retrying in %d seconds...", Rego6XX_RETRY_DELAY);
			}
			m_retrycntr++;
			if (m_retrycntr>=Rego6XX_RETRY_DELAY)
			{
				m_retrycntr=0;
				m_pollcntr = 0;
				m_pollDelaycntr = 0;
				m_readBufferHead = 0;
				m_readBufferTail = 0;
				OpenSerialDevice();
			}
		}
		else if(m_errorcntr > Rego6XX_MAX_ERRORS_UNITL_RESTART)
        {
            // Reopen the port and clear the error counter.
		    try {
			    clearReadCallback();
			    close();
			    doClose();
			    setErrorStatus(true);
		    } catch(...)
		    {
			    //Don't throw from a Stop command
		    }

		    _log.Log(LOG_ERROR,"Rego6XX: Reopening serial port");
		    sleep_seconds(2);

			m_retrycntr=0;
			m_pollcntr = 0;
			m_pollDelaycntr = 0;
			m_readBufferHead = 0;
			m_readBufferTail = 0;
            m_errorcntr = 0;

		    OpenSerialDevice();
        }
        else
		{
			m_pollDelaycntr++;

			if (m_pollDelaycntr>=Rego6XX_COMMAND_DELAY)
			{
                // Before issueing a new command, the recieve buffer must be empty.
                // It seems that there are errors sometimes and this will take care
                // of any problems even if it bypasses the circular buffer concept.
                // There should not be any data left to recieve anyway since commands
                // are sent with 5 seconds in between.
				m_readBufferHead = 0;
				m_readBufferTail = 0;

   				m_pollDelaycntr = 0;
				if(g_allRegisters[m_pollcntr].type != REGO_TYPE_NONE)
				{
					RegoCommand cmd;
					cmd.data.address = 0x81;
					cmd.data.command = 0x02;
                    switch(m_regoType)
                    {
                    case 0:
                        cmd.data.regNum[0] = (g_allRegisters[m_pollcntr].regNum_type1 & 0xC000) >> 14 ;
					    cmd.data.regNum[1] = (g_allRegisters[m_pollcntr].regNum_type1 & 0x3F80) >> 7 ;
					    cmd.data.regNum[2] = g_allRegisters[m_pollcntr].regNum_type1 & 0x007F;
                        break;
                    case 1:
                        cmd.data.regNum[0] = (g_allRegisters[m_pollcntr].regNum_type2 & 0xC000) >> 14 ;
					    cmd.data.regNum[1] = (g_allRegisters[m_pollcntr].regNum_type2 & 0x3F80) >> 7 ;
					    cmd.data.regNum[2] = g_allRegisters[m_pollcntr].regNum_type2 & 0x007F;
                        break;
                    case 2:
                        cmd.data.regNum[0] = (g_allRegisters[m_pollcntr].regNum_type3 & 0xC000) >> 14 ;
					    cmd.data.regNum[1] = (g_allRegisters[m_pollcntr].regNum_type3 & 0x3F80) >> 7 ;
					    cmd.data.regNum[2] = g_allRegisters[m_pollcntr].regNum_type3 & 0x007F;
                        break;
                    default:
		                _log.Log(LOG_ERROR,"Rego6XX: Unknown type!");
                        break;
                    }
					cmd.data.value[0] = 0;
					cmd.data.value[1] = 0;
					cmd.data.value[2] = 0;
					cmd.data.crc = 0;

					for ( int i = 2; i < 8; i++ )
						cmd.data.crc ^= cmd.raw[ i ];

					WriteToHardware((char*)cmd.raw, sizeof(cmd.raw));
				}
				else
				{
					m_pollcntr = 0;
				}
			}
Exemplo n.º 6
0
void CRFLink::Do_Work()
{
	int msec_counter = 0;
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		sleep_milliseconds(200);
		if (m_stoprequested)
			break;

		msec_counter++;
		if (msec_counter == 5)
		{
			msec_counter = 0;
			sec_counter++;

			if (sec_counter % 12 == 0) {
				m_LastHeartbeat = mytime(NULL);
			}
			if (isOpen())
			{
				if (sec_counter % 10 == 0)
				{
					//Send ping (keep alive)
					time_t atime = mytime(NULL);
					if (atime - m_LastReceivedTime > 15)
					{
						//Timeout
						_log.Log(LOG_ERROR, "RFLink: Not received anything for more then 15 seconds, restarting...");
						m_retrycntr = (RFLINK_RETRY_DELAY-3) * 5;
						m_LastReceivedTime = atime;
						try {
							clearReadCallback();
							close();
							doClose();
							setErrorStatus(true);
						}
						catch (...)
						{
							//Don't throw from a Stop command
						}
					}
					else
						write("10;PING;\n");
				}
			}
		}

		if (!isOpen())
		{
			if (m_retrycntr==0)
			{
				_log.Log(LOG_STATUS,"RFLink: serial retrying in %d seconds...", RFLINK_RETRY_DELAY);
			}
			m_retrycntr++;
			if (m_retrycntr/5>=RFLINK_RETRY_DELAY)
			{
				m_retrycntr=0;
				m_rfbufferpos=0;
				OpenSerialDevice();
			}
		}
		/*
		if (m_sendqueue.size()>0)
		{
			boost::lock_guard<boost::mutex> l(m_sendMutex);

			std::vector<std::string>::iterator itt=m_sendqueue.begin();
			if (itt!=m_sendqueue.end())
			{
				std::string sBytes=*itt;
				write(sBytes.c_str(),sBytes.size());
				m_sendqueue.erase(itt);
			}
		}
		*/
	}
	_log.Log(LOG_STATUS,"RFLink: Serial Worker stopped...");
}
Exemplo n.º 7
0
void eMoviePlayer::gotMessage(const Message &msg )
{
	eString mrl;
	eString restmp = "";
	eString command = ""; 

	eDebug("[MOVIEPLAYER] message %d coming in...", msg.type);
	switch (msg.type)
	{
		case Message::start:
		case Message::start2:
		{
			status.STAT = PLAY;
			killThreads();
			if (msg.filename)
			{
				mrl = eString(msg.filename);
				eDebug("[MOVIEPLAYER] mrl = %s", mrl.c_str());
				free((char*)msg.filename);
				
				eDebug("[MOVIEPLAYER] Server IP: %s", server.serverIP.c_str());
				eDebug("[MOVIEPLAYER] Server Port: %d", atoi(server.streamingPort.c_str()));
				
				if (msg.type == Message::start2)
				{
					// stop vlc, just to check whether vlc is up and running
					if (int res = sendRequest2VLC("?control=stop") < 0)
					{
						eDebug("[MOVIEPLAYER] couldn't communicate with vlc, streaming server ip address may be wrong in settings. Errno: %d",res);
						setErrorStatus();
						break;
					}
					usleep(200000);
					// empty vlc's playlist
					if (sendRequest2VLC("?control=empty") < 0)
					{
						setErrorStatus();
						break;
					}
					usleep(200000);
					// vlc: set sout...
					if (sendRequest2VLC("?sout=" + httpEscape(sout(mrl))) < 0)
					{
						setErrorStatus();
						break;
					}
					usleep(200000);
					// vlc: add mrl to playlist
					if (sendRequest2VLC("?control=add&mrl=" + httpEscape(mrl)) < 0)
					{
						setErrorStatus();
						break;
					}
					if(mrl.left(3) != "dvd" && mrl.left(3) != "vcd" )
					{
						usleep(200000);
						// vlc: play (circumvention for vlc deficiency)
						if (sendRequest2VLC("?control=play") < 0)
						{
							setErrorStatus();
							break;
						}
						usleep(200000);
						// vlc: stop (circumvention for vlc deficiency)
						if (sendRequest2VLC("?control=stop") < 0)
						{
							setErrorStatus();
							break;
						}
					}
					usleep(200000);
					// vlc: start playback of first item in playlist
					if (sendRequest2VLC("?control=play") < 0)
					{
						setErrorStatus();
						break;
					}
				}
				usleep(200000);
				// receive and play ts stream
				// initialBuffer = INITIALBUFFER;  // for future for plugin 
				if (playStream(mrl) < 0)
				{
					setErrorStatus();
					break;
				}
			}
			break;
		}
		case Message::pause:
			status.STAT = PAUSE;
			break;
		case Message::play:
			status.STAT = PLAY;
			break;
		case Message::forward:
			break;
		case Message::rewind:
			break;
		case Message::async:
		        status.A_SYNC=false;
			break;
		case Message::subtitles:
		        status.SUBT=false;
			break;
		case Message::nsf:
		        status.NSF=true;
			break;
		case Message::dvbon:
		        status.DVB=false;
			break;
		case Message::dvboff:
		        status.DVB=true;
			break;
		case Message::runplg:
		        status.PLG=true;
			break;
		case Message::endplg:
		        status.PLG=false;
			break;
		case Message::bufsize:
		{
				percBuffer = atoi(msg.filename);
			eDebug("### percBuffer %d", percBuffer);
			initialBuffer = (int)( INITIALBUFFER/100. * percBuffer );
			break;
		}
		case Message::jump:
		{
			int jump = atoi(eString(msg.filename).c_str());
			eDebug("[MOVIEPLAYER] jump: %d seconds", jump);
			break;
		}
		case Message::quit:
		{
			quit(0);
			break;
		}
		default:
			eDebug("unhandled thread message");
	}
	eDebug("[MOVIEPLAYER] message %d handled.", msg.type);
}