MPD*
nsDASHWebMODParser::Parse()
{
  LOG("Parsing DOM into MPD objects");
  nsAutoPtr<MPD> mpd(new MPD());

  nsresult rv = VerifyMPDAttributes();
  NS_ENSURE_SUCCESS(rv, nullptr);

  rv = SetMPDBaseUrls(mpd);
  NS_ENSURE_SUCCESS(rv, nullptr);

  rv = SetPeriods(mpd);
  NS_ENSURE_SUCCESS(rv, nullptr);

  return mpd.forget();
}
Example #2
0
//---------------------------------------------------------------------------
//метод стрельб
double strelba(double y1, double y2, double a){
	double yp, k=y1, ks, kn=y1;
	int d=0;

	do{
		ks=k;
		k=kn;

		yp=kutt(y1, k, a);

		if(yp>y2)
			if(d!=2){kn-=h; d=1;}else d=3;

		if((yp<y2)&&(d!=3))
			if(d!=1){kn+=h; d=2;}else d=3;
	}while(d!=3);

	k=mpd(k, ks, y2);

	return k;
}
Example #3
0
QuviMedia::QuviMedia(std::wstring&& url)
	: QuviMediaInfo(std::move(url))
	, m_curlsh(curl_share_init())
{
	assert(m_curlsh); // TODO: throw exception
	curl_share_setopt(m_curlsh, CURLSHOPT_LOCKFUNC, CurlShareLockFunction);
	curl_share_setopt(m_curlsh, CURLSHOPT_UNLOCKFUNC, CurlShareUnlockFunction);
	curl_share_setopt(m_curlsh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
	curl_share_setopt(m_curlsh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
	curl_share_setopt(m_curlsh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
	curl_share_setopt(m_curlsh, CURLSHOPT_USERDATA, &m_curlshLock);

	curl_easy_setopt(m_curl, CURLOPT_SHARE, m_curlsh);
	// TODO: ensure that cookies are properly inherited

	if (GetContentType() == "video/vnd.mpeg.dash.mpd") {
		std::string murl = GetMultibyteUrl();
		if (murl.empty())
			throw 1; // TODO: replace with some sensible exception
		std::unique_ptr<dash::IDASHManager> manager(CreateDashManager());
		if (!manager)
			throw 1; // TODO: replace with some sensible exception
		std::unique_ptr<dash::mpd::IMPD> mpd(manager->Open(&murl[0]));
		if (!mpd)
			throw 1; // TODO: replace with some sensible exception

		const auto& period = mpd->GetPeriods().front();

		for (const auto& adaptationSet : period->GetAdaptationSets()) {
			const auto& representation = adaptationSet->GetRepresentation().back();

			enum class DashRepresentationType {
				Base,
				Template,
				List,
			};

			auto determineType = [](const dash::mpd::IPeriod* period,
				const dash::mpd::IAdaptationSet* adaptationSet,
				const dash::mpd::IRepresentation* representation) -> DashRepresentationType {
				assert(representation && adaptationSet && period);
				if (representation->GetSegmentList())
					return DashRepresentationType::List;
				if (representation->GetSegmentTemplate())
					return DashRepresentationType::Template;
				if (representation->GetSegmentBase() || !representation->GetBaseURLs().empty())
					return DashRepresentationType::Base;

				if (adaptationSet->GetSegmentList())
					return DashRepresentationType::List;
				if (adaptationSet->GetSegmentTemplate())
					return DashRepresentationType::Template;
				if (adaptationSet->GetSegmentBase())
					return DashRepresentationType::Base;

				if (period->GetSegmentList())
					return DashRepresentationType::List;
				if (period->GetSegmentTemplate())
					return DashRepresentationType::Template;
				if (period->GetSegmentBase())
					return DashRepresentationType::Base;

				throw 1; // TODO: replace with some sensible exception
			};

			const DashRepresentationType type = determineType(period, adaptationSet, representation);

			if (type != DashRepresentationType::Base) // TODO: support other stream types
				throw 1; // TODO: replace with some sensible exception

			// TODO: support compound urls
			std::unique_ptr<dash::network::IChunk> chunk(representation->GetBaseURLs()[0]->ToMediaSegment({}));
			if (!chunk)
				throw 1; // TODO: replace with some sensible exception

			auto& uri = chunk->AbsoluteURI();
			if (uri.empty())
				throw 1; // TODO: replace with some sensible exception

			curl_easy_setopt(m_curl, CURLOPT_URL, &uri[0]);
			curl_easy_setopt(m_curl, CURLOPT_NOBODY, 1L);

			CURLcode cc = curl_easy_perform(m_curl);
			if (cc != CURLE_OK)
				throw 1; // TODO: replace with some sensible exception

			// TODO: use return codes
			long code = 0, proxycode = 0;
			curl_easy_getinfo(m_curl, CURLINFO_RESPONSE_CODE, &code);
			curl_easy_getinfo(m_curl, CURLINFO_HTTP_CONNECTCODE, &proxycode);

			double size = 0;
			curl_easy_getinfo(m_curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &size);

			curl_easy_setopt(m_curl, CURLOPT_HTTPGET, 1L);
			m_backends.emplace_back(std::make_unique<QuviSimpleStreamBackend>((uint64_t)size, m_curl, m_curlsh));
		}
	} else {
		assert(m_backends.empty());
		m_backends.emplace_back(std::make_unique<QuviSimpleStreamBackend>(GetContentLength(), m_curl, m_curlsh));
	}
}
Example #4
0
void MenuItem::mountItem(){
  //Mount the device
  
  //Create the full path to the mountpoint
  QString deviceName = devLabel->text();
  QString mntpoint = MOUNTDIR + deviceName.replace(" ","-"); //take into account spaces in the name

  //Create the fileystem specific command for mounting
  QString tmpFileSystem;
  QString cmd;
  if(filesystem=="UNKNOWN"){
    //prompt for filesystem
    bool selected = false;
    tmpFileSystem = QInputDialog::getItem(0, deviceName+"("+devType+")", tr("Mount as:"), DEVCHECK->AvailableFS(), 0, false, &selected);
    if( !selected || tmpFileSystem.isEmpty() ){ return; } //cancelled
    //Now get the mount command
    cmd = DEVCHECK->getMountCommand(tmpFileSystem, device, mntpoint);
  }else{
    cmd = DEVCHECK->getMountCommand(filesystem, device, mntpoint);
  }

  //Make sure the mntpoint is available
  QDir mpd(mntpoint);
  if(mpd.exists() && !rootRequired){
    //Remove the existing directory (will work only if it is empty)
    mpd.cdUp();
    mpd.rmdir(mntpoint);
  }
  //Prepare the mount command to run
  //QString cmd = fstype + " " +fsopts + " " + device + " " + mntpoint;
  qDebug() << "Mounting device" << device << "on" << mntpoint << "("<<filesystem<<")";
  if(DEBUG_MODE){ qDebug() << " - command:" << cmd; }
  //Generate the run script
  QString runscript = createRunScript( mntpoint, cmd);
  //Now run the script 
  bool ok = !runscript.isEmpty();
  bool tryroot = false;
  QStringList outL("ERROR:SCRIPT");
  //Run the mounting commands
  if(ok && !rootRequired){
    outL.clear();
    outL = systemCMD(runscript);
    //qDebug() << "Mount return code 1:" << outL;
    //if it could not mount device with permissions issues - try as root
    if( !outL.filter("Permission denied").isEmpty() || !outL.filter("not permitted").isEmpty() ){ 
      qDebug() << " - Permissions issue, try as root";
      tryroot = true; 
    } 
  }
  if( (ok && rootRequired) || tryroot ){
    outL.clear();
    outL = systemCMD("pc-su "+runscript);
    //qDebug() << "Mount return code 2:" << outL;
  }
  //Now parse the return code
  QString result, title;
  mountedHere = true; //need to set this before running isMounted to update icons right
  ok = isMounted();
  mountedHere = ok; //now make sure it is the proper value
  if( ok ){
	title = tr("Success");
	result = QString( tr("%1 mounted at %2") ).arg(deviceName).arg(mntpoint);
	if(tryroot){ rootRequired = true; } //flag this as requiring root for later
  }else if( !outL.filter("ERROR:MOUNTPOINT").isEmpty() ){
	title = tr("Failure");
	result = QString( tr("Could not create mountpoint: %1") ).arg(mntpoint);
  }else if( !outL.filter("ERROR:MOUNTING").isEmpty() ){
	title = tr("Failure");
	result = QString( tr("Could not mount device %1 on %2 (%3)") ).arg(deviceName, mntpoint, filesystem);
  }else{
	QString tmp = outL.join("");
	  tmp.remove("password:"******"General Error output:" << outL;
	  title = tr("General Error");
	  result = tr("Could not create/run the device mounting script");
	}
  }
  qDebug() << "pc-mounttray: "<<title << result;
  if(DEBUG_MODE){ qDebug() << " - output:" << outL; }
  
  //Output the proper signals depending upon success
  if(ok){
    emit itemMounted(mntpoint);
    mountpoint = mntpoint;
    if( !tmpFileSystem.isEmpty() ){ filesystem = tmpFileSystem; } //this one worked - use it in the future
  }else{
    mountpoint.clear();
  }
  if( !checkAutomount->isChecked()  && !(title.isEmpty() && result.isEmpty()) ){
    emit newMessage(title, result); //suppress the output message if it was automounted
  }
  //Now remove the runscript
  //if(ok)  //only for testing purposes
    QFile::remove(runscript);
  
}