コード例 #1
0
void 
Opal::Sip::EndPoint::OnPresenceInfoReceived (const PString & user,
                                             const PString & basic,
                                             const PString & note)
{
  PINDEX j;
  PCaselessString b = basic;
  PCaselessString s = note;

  std::string presence = "unknown";
  std::string status;

  if (!basic.IsEmpty () && !note.IsEmpty ()) {

    if (b.Find ("Open") != P_MAX_INDEX)
      presence = "online";
    else
      presence = "offline";
  
    if (s.Find ("Away") != P_MAX_INDEX)
      presence = "away";
    else if (s.Find ("On the phone") != P_MAX_INDEX
             || s.Find ("Ringing") != P_MAX_INDEX) 
      presence = "inacall";
    else if (s.Find ("dnd") != P_MAX_INDEX
             || s.Find ("Do Not Disturb") != P_MAX_INDEX) 
      presence = "dnd";
  
    else if (s.Find ("Free For Chat") != P_MAX_INDEX) 
      presence = "freeforchat";
  
    if ((j = s.Find (" - ")) != P_MAX_INDEX)
      status = (const char *) note.Mid (j + 3);
  }

  SIPURL sip_uri = SIPURL (user);
  sip_uri.Sanitise (SIPURL::ExternalURI);
  std::string _uri = sip_uri.AsString ();
  std::string old_presence = uri_presences[_uri].first;
  std::string old_status = uri_presences[_uri].second;
  
  // If first notification, and no information, then we are offline
  if (presence == "unknown" && old_presence.empty ())
    presence = "offline";

  // If presence change, then signal it to the various components
  // If presence is unknown (notification with empty body), and it is not the 
  // first notification, and we can conclude it is a ping back from the server 
  // to indicate the presence status did not change, hence we do nothing.
  if (presence != "unknown" && (old_presence != presence || old_status != status)) {
    uri_presences[_uri] = std::pair<std::string, std::string> (presence, status);
    runtime.run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, _uri, presence, status));
  }
}
コード例 #2
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
void SIDStil::ReadEntry(PFile *inFile, PString &buffer)
{
	PString line;
	PCharSet_MS_WIN_1252 charSet;

	try
	{
		do
		{
			line = inFile->ReadLine(&charSet);
			buffer += line;
			if (!line.IsEmpty())
				buffer += "\n";
		}
		while(!line.IsEmpty());
	}
	catch(PFileException e)
	{
		;
	}
}
コード例 #3
0
ファイル: misc.cpp プロジェクト: nightfly19/renyang-learn
PString
gnomemeeting_pstring_cut (PString s)
{
  PString s2 = s;

  if (s.IsEmpty ())
    return s2;

  PINDEX bracket = s2.Find('[');                                          
                                                                               
  if (bracket != P_MAX_INDEX)                                                
    s2 = s2.Left (bracket);                                            

  bracket = s2.Find('(');                                                 
                                                                               
  if (bracket != P_MAX_INDEX)                                                
    s2 = s2.Left (bracket);     

  return s2.Trim ();
}
コード例 #4
0
ファイル: MyPhoneEndPoint.cpp プロジェクト: cubemoon/myphone3
BOOL CMyPhoneEndPoint::FindGatekeeper()
{
	if (GetGatekeeper() != NULL) {
		if (gatekeeper->IsRegistered()) // If registered, then unregister
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKUNREGSTR), S_SYSTEM, (const char *)gatekeeper->GetName());	
		RemoveGatekeeper();
	}
	
	if (!config.GetBoolean(UseGatekeeperConfigKey, FALSE))
		return TRUE;
	
	SetGatekeeperPassword(config.GetString(GatekeeperPassConfigKey));
	
	PString gkHost = config.GetString(GatekeeperHostConfigKey, "");
	PString gkid = config.GetString(GatekeeperIdConfigKey, "");
	PString iface = "";
	int iMode = config.GetInteger(DiscoverGatekeeperConfigKey, -1);
	switch(iMode)
	{
	case -1:
		return TRUE;
		break;
	case 0:
		gkHost = "";
		gkid = "";
		iface = "";
		break;
	case 1:
		gkid = "";
		iface = "";
		break;
	case 2:
		gkHost = "";
		iface = "";
		break;
	}

	m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKSRCHSTR), S_SYSTEM);	
	m_dialog->m_cstatus.UpdateWindow();
	AfxGetApp()->DoWaitCursor(1);
	if (UseGatekeeper(gkHost, gkid, iface)) {
		m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKREGSTR), S_SYSTEM, (const char *)gatekeeper->GetName());	
	}
	AfxGetApp()->DoWaitCursor(0);
	
	BOOL gkRequired = config.GetBoolean(RequireGatekeeperConfigKey, FALSE);
	
	if (GetGatekeeper() != NULL)
	{
		unsigned reason = gatekeeper->GetRegistrationFailReason();
		switch (reason) {
		case H323Gatekeeper::InvalidListener :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRPORTSTR));
			break;
		case H323Gatekeeper::DuplicateAlias :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRALIASSTR));
			break;
		case H323Gatekeeper::SecurityDenied :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRSECSTR));
			break;
		case H323Gatekeeper::TransportError :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRTRNSTR));
			break;
		default :
			if ((reason&H323Gatekeeper::RegistrationRejectReasonMask) != 0)
			{
				CString strRes;
				strRes.Format((LPCTSTR)LoadStringLang(IDS_GKERRUNSTR),(int) reason&(H323Gatekeeper::RegistrationRejectReasonMask-1));
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR), S_SYSTEM, (LPCTSTR) strRes);
			}
			break;
		}
	}
	else
	{
		if (!gkHost.IsEmpty())
		{
			if (!gkid.IsEmpty())
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFINDSTR),
				S_SYSTEM, (const char *)gkid, (const char *)gkHost);
			else
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND1STR),
				S_SYSTEM, (const char *)gkHost);
		}
		else {
			if (!gkid.IsEmpty())
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND2STR),
				S_SYSTEM, (const char *)gkid);
			else
			{
				if (gkRequired)
					m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND3STR),
					S_SYSTEM);
				else
					m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND4STR),
					S_SYSTEM);
			}
		}
	}
	
	return !gkRequired; 
}
コード例 #5
0
ファイル: MyPhoneEndPoint.cpp プロジェクト: cubemoon/myphone3
BOOL CMyPhoneEndPoint::OpenVideoChannel(H323Connection & connection,
					BOOL isEncoding,
					H323VideoCodec & codec)
{

 PVideoChannel   * channel = new PVideoChannel;
 PVideoDevice * displayDevice = NULL;
	
 if (isEncoding) 
 {
  // Transmitter part
  if(!autoStartTransmitVideo) return FALSE;
		
  codec.SetTxQualityLevel(config.GetInteger(VideoQualityConfigKey,15));
  codec.SetBackgroundFill(2);

  int videoOutMaxBitRate = config.GetInteger(VideoOutMaxbandWidthKey, 320);
  videoOutMaxBitRate = 1024 * PMAX(16, PMIN(10240, videoOutMaxBitRate));

  H323Channel * lchannel = codec.GetLogicalChannel();
  const H323Capability & capability = lchannel->GetCapability();
  PString cname = capability.GetFormatName();
  PINDEX suffixPos = cname.Find("H.263");
  if(suffixPos == P_MAX_INDEX) suffixPos = cname.Find("H.261");

  int videoSize = config.GetInteger(VideoOutSizeConfigKey, 2);
  int width=352, height=288;

  suffixPos = P_MAX_INDEX;
  switch(videoSize)
  {
   case 0: //QCIF
    width = 176; height = 144; break;
   case 1: //QVGA
    if(suffixPos == P_MAX_INDEX) { width = 320; height = 240; break; }
   case 2: //CIF
    width = 352; height = 288; break;
   case 3: //VGA
    if(suffixPos == P_MAX_INDEX) { width = 640; height = 480; break; }
   case 5: //SVGA
    if(suffixPos == P_MAX_INDEX) { width = 800; height = 600; break; }
   case 6: //XVGA
    if(suffixPos == P_MAX_INDEX) { width = 1024; height = 768; break; }
   case 4: //4CIF
    width = 704; height = 576; break;
   case 7: //HD 720
    if(suffixPos == P_MAX_INDEX) { width = 1280; height = 720; break; }
   case 8: //SXGA
    if(suffixPos == P_MAX_INDEX) { width = 1280; height = 1024; break; }
   case 9: //16CIF
    width = 1408; height = 1152; break;
   case 10: //UXGA
    if(suffixPos == P_MAX_INDEX) { width = 1600; height = 1200; break; }
   case 11: //HD 1080
    if(suffixPos == P_MAX_INDEX) { width = 1920; height = 1080; break; }
   default:
    break;
  }

  PTRACE(1, "Video device videoSize=" << videoSize << " width=" << width << " height=" << height);

  codec.SetVideoSize(width, height);
  width = codec.GetWidth(); 
  height = codec.GetHeight();

  PTRACE(1, "Accepted video device width=" << width << " height=" << height);
  
  int curMBR = codec.GetMaxBitRate();
  if(curMBR > videoOutMaxBitRate) codec.SetMaxBitRate(videoOutMaxBitRate);

  int videoFramesPS = config.GetInteger(VideoFPSKey, 10);
  codec.SetGeneralCodecOption("Frame Rate",videoFramesPS);

  //Create grabber.
  bool NoDevice = false;
  PString deviceName = config.GetString(VideoDeviceConfigKey, deviceName);
  if (deviceName.IsEmpty()) 
  {
   PStringArray devices = PVideoInputDevice::GetDriversDeviceNames(VideoInputDriver);
   if (!devices.IsEmpty()) deviceName = devices[0];
   else NoDevice = true;
  }
		
  PVideoInputDevice * grabber = NULL;
  if (deviceName.Find("fake") == 0) NoDevice = true;
//  else if (deviceName.Find("screen") == 0) grabber = PVideoInputDevice::CreateDevice("ScreenVideo");
  else grabber = PVideoInputDevice::CreateDeviceByName(deviceName,VideoInputDriver);
		
  if (NoDevice || !grabber->Open(deviceName, FALSE) ||
      !grabber->SetFrameSize(width, height) || 
      !grabber->SetColourFormatConverter("YUV420P") || 
			!grabber->SetVFlipState(localFlip))
  {
   if(!NoDevice)
   {
    char sSrc[64];
    m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRVDEVSTR), S_SYSTEM, 
 			      (const char *) deviceName, 
				itoa(config.GetInteger(VideoSourceConfigKey,0), sSrc, 10));
    PTRACE(1, "Failed to open or configure the video device \"" << deviceName << '"');
   }

   if(grabber) delete grabber;
   grabber = PVideoInputDevice::CreateDevice("FakeVideo");
			grabber->SetColourFormat("YUV420P");
			grabber->SetVideoFormat(PVideoDevice::PAL);
			grabber->SetFrameSize(width, height);
			grabber->SetVFlipState(localFlip);
			grabber->SetChannel(4);
  }

  if(videoFramesPS >0 && videoFramesPS<30) 
   grabber->SetFrameRate(videoFramesPS);

  grabber->Start();

  channel->AttachVideoReader(grabber);
/*
  if (localVideo)
		{
			BOOL curVFlip = config.GetBoolean(VideoOutVFlipConfigKey, FALSE);
			BOOL curHFlip = config.GetBoolean(VideoOutHFlipConfigKey, FALSE);
			displayDevice = new CVideoOutputDevice(m_dialog, 
				connection.GetLocalPartyName(), curVFlip, curHFlip, TRUE, FALSE);
		}
  else 
*/
   displayDevice = PVideoOutputDevice::CreateDevice("NULLOutput");
 }
 else
 {
  // Receiver part
  if(!autoStartReceiveVideo) return FALSE;
  BOOL curVFlip = config.GetBoolean(VideoInVFlipConfigKey, FALSE);
  BOOL curHFlip = config.GetBoolean(VideoInHFlipConfigKey, FALSE);

  displayDevice = new CVideoOutputDevice( 
		m_vdlg, (LPCTSTR)m_dialog->FindContactName(connection), curVFlip,
		curHFlip, FALSE, localVideo);
 }
	
 if(displayDevice)
 {
  int width = codec.GetWidth();
  int height = codec.GetHeight();
//  if( m_dialog->autohideVideoPan && !m_dialog->showVideoPan)
//   m_dialog->ShowVideoPanels(TRUE);  // show Video panel if it's hiden
  displayDevice->SetColourFormat("RGB32");
  displayDevice->SetColourFormatConverter("YUV420P");
  displayDevice->SetFrameSize(width, height);
  //Give the video window refreshing class to the channel.
  channel->AttachVideoPlayer((PVideoOutputDevice *)displayDevice);
 }

 return codec.AttachChannel(channel,TRUE);
}
コード例 #6
0
ファイル: MyPhoneEndPoint.cpp プロジェクト: cubemoon/myphone3
void CMyPhoneEndPoint::LoadCapabilities()
{

 BOOL sizeChange = FALSE;

 capabilities.RemoveAll();
	
// Add the codecs we know about
 AddAllCapabilities(0, 0, "*"); 

// Удаляю не поддерживаемые видео кодеки из реестра
 PINDEX videoNum = 0;
 for (;;)
 {
  PString key = psprintf("%u", ++videoNum);
  PString name = config.GetString(VideoCodecsConfigSection, key, "");
  if (name.IsEmpty()) break;

  PINDEX suffixPos = name.Find(OnCodecSuffix);
  if (suffixPos != P_MAX_INDEX) 
   name.Delete(suffixPos, P_MAX_INDEX);
  else 
  {
   suffixPos = name.Find(OffCodecSuffix);
   name.Delete(suffixPos, P_MAX_INDEX);
  }

  int res = 0;
  for (PINDEX i = 0; i < capabilities.GetSize(); i++)
  {
   if (capabilities[i].GetMainType() == H323Capability::e_Video)
   {
    if(capabilities[i].GetFormatName() == name)
     { res = 1; break; }
   }
  }
  if(res == 0) 
  {
   PINDEX j = videoNum; videoNum--;
   for (;;)
   {
    PString key1 = psprintf("%u", ++j);
    PString name1 = config.GetString(VideoCodecsConfigSection, key1, "");
    if (name1.IsEmpty()) break;

    config.SetString(VideoCodecsConfigSection, psprintf("%u", j-2), name1);
   }
   config.DeleteKey(VideoCodecsConfigSection, psprintf("%u", j-1));
  }
 }

// добавляю новые видео кодеки если их нет в конфигурации
 for (PINDEX i = 0; i < capabilities.GetSize(); i++)
 {
  if (capabilities[i].GetMainType() == H323Capability::e_Video)
  {
   PINDEX codecNum=0;
   int res = 0;
   int suffix = 0;
   for (;;)
   {
    PString key = psprintf("%u", ++codecNum);
    PString name = config.GetString(VideoCodecsConfigSection, key, "");
    if (name.IsEmpty()) break;   

    suffix = 0;
    PINDEX suffixPos = name.Find(OnCodecSuffix);
    if (suffixPos != P_MAX_INDEX)
     name.Delete(suffixPos, P_MAX_INDEX);
    else
    {
     suffix = 1;
     suffixPos = name.Find(OffCodecSuffix);
     name.Delete(suffixPos, P_MAX_INDEX);
    }
  
    if(capabilities[i].GetFormatName() == name) { res = 1; break; }
   }
   if(res == 0)
   {
    config.SetString(VideoCodecsConfigSection,
        psprintf("%u", codecNum),
        capabilities[i].GetFormatName() + ((suffix==0)?OnCodecSuffix:OffCodecSuffix));
   }
  }
 }

 PINDEX audioNum = 0;
 for (;;)
 {
  PString key = psprintf("%u", ++audioNum);
  PString name = config.GetString(CodecsConfigSection, key, "");
  if (name.IsEmpty()) break;

  PINDEX suffixPos = name.Find(OnCodecSuffix);
  if (suffixPos != P_MAX_INDEX) 
   name.Delete(suffixPos, P_MAX_INDEX);
  else 
  {
   suffixPos = name.Find(OffCodecSuffix);
   name.Delete(suffixPos, P_MAX_INDEX);
  }

  int res = 0;
  for (PINDEX i = 0; i < capabilities.GetSize(); i++)
  {
   if (capabilities[i].GetMainType() == H323Capability::e_Audio)
   {
    if(capabilities[i].GetFormatName() == name)
     { res = 1; break; }
   }
  }
  if(res == 0) 
  {
   PINDEX j = audioNum; audioNum--;
   for (;;)
   {
    PString key1 = psprintf("%u", ++j);
    PString name1 = config.GetString(CodecsConfigSection, key1, "");
    if (name1.IsEmpty()) break;

    config.SetString(CodecsConfigSection, psprintf("%u", j-2), name1);
   }
   config.DeleteKey(CodecsConfigSection, psprintf("%u", j-1));
  }
 }

 for (PINDEX i = 0; i < capabilities.GetSize(); i++)
 {
  if (capabilities[i].GetMainType() == H323Capability::e_Audio)
  {
   PINDEX codecNum=0;
   int res = 0;
   int suffix = 0;
   for (;;)
   {
    PString key = psprintf("%u", ++codecNum);
    PString name = config.GetString(CodecsConfigSection, key, "");
    if (name.IsEmpty()) break;   

    suffix = 0;
    PINDEX suffixPos = name.Find(OnCodecSuffix);
    if (suffixPos != P_MAX_INDEX)
     name.Delete(suffixPos, P_MAX_INDEX);
    else
    {
     suffix = 1;
     suffixPos = name.Find(OffCodecSuffix);
     name.Delete(suffixPos, P_MAX_INDEX);
    }
  
    if(capabilities[i].GetFormatName() == name) { res = 1; break; }
   }
   if(res == 0)
   {
    config.SetString(CodecsConfigSection,
        psprintf("%u", codecNum),
        capabilities[i].GetFormatName() + ((suffix==0)?OnCodecSuffix:OffCodecSuffix));
   }
  }
 }

// Add all the UserInput capabilities
 AddAllUserInputCapabilities(0, 1);

 int videoSizeRx = config.GetInteger(VideoInSizeConfigKey, 2);
 int videoSizeTx = config.GetInteger(VideoOutSizeConfigKey, 2);

 RemoveCapability(H323Capability::e_ExtendVideo);

 autoStartTransmitVideo = config.GetBoolean(AutoTransmitVideoConfigKey, TRUE);
 autoStartReceiveVideo = config.GetBoolean(AutoReceiveVideoConfigKey, TRUE);
	
 localVideo = config.GetBoolean(VideoLocalConfigKey, FALSE);
 localFlip = config.GetBoolean(VideoFlipLocalConfigKey, FALSE);
	
 int videoInMaxBitRate = config.GetInteger(VideoInMaxbandWidthKey, 320);
 videoInMaxBitRate = 1024 * PMAX(16, PMIN(10240, videoInMaxBitRate));

// changing audio codecs
 PStringArray enabledCodecs;
 PINDEX codecNum = 0;
 for (;;) 
 {
  PString key = psprintf("%u", ++codecNum);
  PString name = config.GetString(CodecsConfigSection, key, "");
  if (name.IsEmpty()) break;
		
  PINDEX suffixPos = name.Find(OffCodecSuffix);
  if (suffixPos != P_MAX_INDEX) 
  {
   capabilities.Remove(name(0, suffixPos-1));
   continue;
  }
		
  suffixPos = name.Find(OnCodecSuffix);
  if (suffixPos != P_MAX_INDEX)	name.Delete(suffixPos, P_MAX_INDEX);
  enabledCodecs.AppendString(name);
 }

 codecNum = 0;
 for (;;) 
 {
  PString key = psprintf("%u", ++codecNum);
  PString name = config.GetString(VideoCodecsConfigSection, key, "");
  if (name.IsEmpty()) break;
 }

 int tvNum = 0;
// if(tvCaps==NULL)  this generates error in free
 tvCaps = (char **)calloc(codecNum+1,sizeof(char *));
// while(tvCaps[tvNum]!=NULL) { free(tvCaps[tvNum]); tvCaps[tvNum]=NULL; tvNum++; }

 tvNum = 0;
 codecNum = 0;
 for (;;) 
 {
  PString key = psprintf("%u", ++codecNum);
  PString name = config.GetString(VideoCodecsConfigSection, key, "");
  if (name.IsEmpty()) break;

// удаление отключенных кодеков		
  PINDEX suffixPos = name.Find(OffCodecSuffix);
  if (suffixPos != P_MAX_INDEX) 
  {
   capabilities.Remove(name(0, suffixPos-1)); continue;
  }
// удаление суффикса on из имени кодека
  suffixPos = name.Find(OnCodecSuffix);
  if (suffixPos != P_MAX_INDEX)	name.Delete(suffixPos, P_MAX_INDEX);

// проверка кодека на соответствие размеру принимаемой картинки
// (меньше можно, больше нельзя) и удаление из списка локальных кодеков
  suffixPos = P_MAX_INDEX;
  switch(videoSizeRx)
  {
   case 0: //QCIF
    suffixPos = name.Find("-CIF");   if(suffixPos != P_MAX_INDEX) break;
   case 1: //QVGA
   case 2: //CIF
    suffixPos = name.Find("-4CIF");  if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-480P");    if(suffixPos != P_MAX_INDEX) break;
   case 3: //VGA
   case 4: //4CIF
    suffixPos = name.Find("-SD");    if(suffixPos != P_MAX_INDEX) break;
   case 5: //SVGA
    suffixPos = name.Find("-720P");    if(suffixPos != P_MAX_INDEX) break;
   case 6: //XVGA
    suffixPos = name.Find("-HD");    if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-16CIF"); if(suffixPos != P_MAX_INDEX) break;
   case 7: //SXGA
    suffixPos = name.Find("-FHD"); if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-16CIF"); if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-1080P"); if(suffixPos != P_MAX_INDEX) break;
   case 8: //16CIF
   default:
    break;
  }
  if(suffixPos == P_MAX_INDEX) enabledCodecs.AppendString(name);
  else capabilities.Remove(name);

// проверка кодека на соответствие размеру отправляемой картинки
// (меньше можно, больше нельзя) и создание списка допустимых кодеков
  suffixPos = P_MAX_INDEX;
  switch(videoSizeTx)
  {
   case 0: //QCIF
    suffixPos = name.Find("-CIF");   if(suffixPos != P_MAX_INDEX) break;
   case 1: //QVGA
   case 2: //CIF
    suffixPos = name.Find("-4CIF");  if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-480P");    if(suffixPos != P_MAX_INDEX) break;
   case 3: //VGA
   case 4: //4CIF
    suffixPos = name.Find("-SD");    if(suffixPos != P_MAX_INDEX) break;
   case 5: //SVGA
   case 6: //XVGA
    suffixPos = name.Find("-HD");    if(suffixPos != P_MAX_INDEX) break;
   case 7: //HD 720
    suffixPos = name.Find("-720P");    if(suffixPos != P_MAX_INDEX) break;
   case 8: //SXGA
    suffixPos = name.Find("-16CIF"); if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-FHD"); if(suffixPos != P_MAX_INDEX) break;
    suffixPos = name.Find("-1080P"); if(suffixPos != P_MAX_INDEX) break;
   case 9: //16CIF
   default:
    break;
  }
  if(suffixPos == P_MAX_INDEX) // добавляю в список допустимых
  {
   const char *p2pstr=name;
   tvCaps[tvNum]=strdup(p2pstr);
   tvNum++;
  }
 }

// Reorder the codecs we have
 capabilities.Reorder(enabledCodecs);

 for (PINDEX i = 0; i < capabilities.GetSize(); i++) 
 {
  if (capabilities[i].GetMainType() == H323Capability::e_Video)
  {
   capabilities[i].SetMediaFormatOptionInteger(OpalVideoFormat::MaxBitRateOption, videoInMaxBitRate);
   if((capabilities[i].GetFormatName().Find("H.264")!=P_MAX_INDEX) || (capabilities[i].GetFormatName().Find("VP8-")==0))
   {

    H323GenericVideoCapability *h264cap = (H323GenericVideoCapability *) &capabilities[i];
    h264cap->SetMaxBitRate(videoInMaxBitRate/100);
   }
  }
 }

/*	
	PINDEX audioNum = 1;
	PINDEX videoNum = 1;
	for (PINDEX i = 0; i < capabilities.GetSize(); i++) 
	{
		if (capabilities[i].GetMainType() == H323Capability::e_Audio)
		{
			config.SetString(CodecsConfigSection,
				psprintf("%u", audioNum++),
				capabilities[i].GetFormatName() + OnCodecSuffix);
		} 
		else if (capabilities[i].GetMainType() == H323Capability::e_Video)
		{
			config.SetString(VideoCodecsConfigSection,
				psprintf("%u", videoNum++),
				capabilities[i].GetFormatName() + OnCodecSuffix);
		}
	}
*/

	PTRACE(1, "MyPhone\tCapability Table:\n" << setprecision(4) << capabilities);
}
コード例 #7
0
ファイル: APModuleLoader.cpp プロジェクト: pulkomandy/APlayer
bool APModuleLoader::LoadModule(PString fileName, bool changeType, PString &errorStr)
{
	APAgent_DecrunchFile decrunchInfo;
	APAgent_ConvertModule convInfo;
	APMRSWList<AddOnInfo *> *infoList;
	bool modConverted = false;
	bool foundType = false;
	bool result = false;
	ap_result apResult;

	// Allocate the file object
	file = new PCacheFile();
	if (file == NULL)
		throw PMemoryException();

	try
	{
		// Initialize the converter structure
		convInfo.moduleFile         = NULL;
		convInfo.newModuleFile      = NULL;

		// Initialize the decruncher structure
		decrunchInfo.file           = file;
		decrunchInfo.decrunchedFile = NULL;

		// Open the module
		decrunchInfo.file->Open(fileName, PFile::pModeReadWrite | PFile::pModeShareRead | PFile::pModeNoTruncate);

		// Get the original length of the file
		fileLength = decrunchInfo.file->GetLength();

		// Decrunch the file
		DecrunchFile(&decrunchInfo);

		// Copy the file used for decrunching into the converter structure
		convInfo.moduleFile = decrunchInfo.file;

		// Well, lock the player list
		infoList = &GetApp()->playerInfo;
		infoList->WaitToRead();

		try
		{
			// Check to see if we can find a player via
			// the file type
			if (!FindPlayerViaFileType(convInfo.moduleFile))
			{
				// No player could be found via the file type.
				// Now try to convert the module
				modConverted = ConvertModule(&convInfo);

				// Try all the players to see if we can find
				// one that understand the file format
				if (FindPlayer(convInfo.moduleFile))
					result = true;
			}
			else
			{
				foundType = true;
				result    = true;
			}

			// Did we found a player?
			if (result)
			{
				PString typeString;
				PString playerError;

				// Yap, change the file type
				if (changeType && !foundType)
				{
					try
					{
						// Change the module type on the file
						if (modConverted)
						{
							if (convInfo.fileType.IsEmpty())
								typeString = player->GetModTypeString(playerInfo->index);
							else
								typeString = convInfo.fileType;
						}
						else
							typeString = player->GetModTypeString(playerInfo->index);

						if (!typeString.IsEmpty())
							file->SetFileType(typeString);
					}
					catch(PFileException e)
					{
						// If we can't set the file type, we ignore the error.
						// An error will occure on e.g. CD-ROM disks
						;
					}
				}

				// Yap, load the module
				convInfo.moduleFile->SeekToBegin();
				apResult = player->LoadModule(playerInfo->index, convInfo.moduleFile, playerError);

				if (apResult != AP_OK)
				{
					// Well, something went wrong when loading the file
					//
					// Build the error string
					errorStr.Format_S3(GetApp()->resource, IDS_CMDERR_LOAD_MODULE, fileName, playerInfo->addOnName, playerError);

					// Delete the player
					playerInfo->loader->DeleteInstance(player);
					player     = NULL;
					playerInfo = NULL;

					result = false;
				}
				else
				{
					// Get module information
					playerName = playerInfo->addOnName;

					if (modConverted)
					{
						moduleFormat = convInfo.modKind;
						if (moduleFormat.IsEmpty())
							moduleFormat = playerInfo->addOnName;
					}
					else
						moduleFormat = playerInfo->addOnName;

					// Should the file still be open?
					if (player->GetSupportFlags(playerInfo->index) & appDontCloseFile)
					{
						// Yes, remember the file pointer
						if (modConverted)
						{
							usingFile = convInfo.newModuleFile;
							convInfo.newModuleFile = NULL;
						}
						else
						{
							usingFile = file;
							file      = NULL;
						}
					}
				}
			}
			else
			{
				// Nup, send an error back
				errorStr.Format_S1(GetApp()->resource, IDS_CMDERR_UNKNOWN_MODULE, fileName);
			}
		}
		catch(...)
		{
			infoList->DoneReading();
			throw;
		}

		// Done with the list
		infoList->DoneReading();
	}
	catch(PFileException e)
	{
		PString err;
		char *fileStr, *errStr;

		// Build error message
		err = PSystem::GetErrorString(e.errorNum);
		errorStr.Format(GetApp()->resource, IDS_CMDERR_FILE, (fileStr = fileName.GetString()), e.errorNum, (errStr = err.GetString()));
		err.FreeBuffer(errStr);
		fileName.FreeBuffer(fileStr);
		result = false;
	}
	catch(...)
	{
		;
	}

	// Close the files again
	delete convInfo.newModuleFile;
	delete file;
	file = NULL;

	return (result);
}
コード例 #8
0
ファイル: VisualPage.cpp プロジェクト: Cavsle/myphone3
void CVisualPage::OnCamSetupButton()
{
  CComboBox * box = (CComboBox*)(GetDlgItem(IDC_RECORDING_COMBO));
  int i = box->GetCurSel();
  int n = box->GetLBTextLen(i);
  CString s;
  box->GetLBText(i, s.GetBuffer(n));
  PString setupDeviceName = s;
  s.ReleaseBuffer();

  if (setupDeviceName.IsEmpty()) return;
  if (setupDeviceName.Find("fake") == 0) return;
  if (setupDeviceName.Find("monitor") == 0) return;
  if (setupDeviceName.Find("zmonitor") == 0) return;
  PTRACE(4,"PVidDirectShow\tCurrent device: " << setupDeviceName);

  HRESULT hr;
  IBaseFilter * pFilter = NULL;
  IMoniker *pMoniker =NULL;
  ICreateDevEnum *pDevEnum =NULL;
  IEnumMoniker *pClassEnum = NULL;
  ULONG cFetched;

  ::CoInitialize(NULL);

  // Create the system device enumerator
  hr = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, IID_ICreateDevEnum, (void **) &pDevEnum);
  if (FAILED(hr)) { ::CoUninitialize(); return; }

  // Create an enumerator for the video capture devices
  hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pClassEnum, 0);
  if (FAILED(hr)) { ::CoUninitialize(); return; }

  if (pClassEnum == NULL) { ::CoUninitialize(); return; }

  PTRACE(4,"PVidDirectShow\tEntering device enumeration loop...");
  while (1)
  { // Get the next device
    hr = pClassEnum->Next(1, &pMoniker, &cFetched);
    if (hr != S_OK) { PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() No more video capture device"); break; }

    // Get the property bag
    IPropertyBag *pPropBag;

    hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag));
    if (FAILED(hr))
    { PTRACE(4,"PVidDerectShow\tBindToStorage failed, continue");
      pMoniker->Release();
      continue;
    }

    // Find the description or friendly name.
    VARIANT DeviceName;
    DeviceName.vt = VT_BSTR;
    hr = pPropBag->Read(L"Description", &DeviceName, NULL);
    if (FAILED(hr)) hr = pPropBag->Read(L"FriendlyName", &DeviceName, NULL);
    if (SUCCEEDED(hr))
    { char *pDeviceName = BSTR_to_ANSI(DeviceName.bstrVal);
      if (pDeviceName)
      { PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() Found this capture device '"<< pDeviceName <<"'");
        if(PString(pDeviceName) == setupDeviceName)
        {
          PTRACE(4, "PVidDirectShow\tCamera Setup: device found");
          pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**) &pFilter);
          ISpecifyPropertyPages *p_spec; CAUUID cauuid;
          HRESULT hr = pFilter->QueryInterface( IID_ISpecifyPropertyPages, (void **)&p_spec );
          if( !FAILED(hr) )
          if( SUCCEEDED(p_spec->GetPages( &cauuid )) )
          { if( cauuid.cElems > 0 )
            { HWND hwnd_desktop = ::GetDesktopWindow();
              OleCreatePropertyFrame( hwnd_desktop, 30, 30, NULL, 1, (LPUNKNOWN *)(&pFilter), cauuid.cElems, cauuid.pElems, 0, 0, NULL );
              CoTaskMemFree( cauuid.pElems );
            }
            p_spec->Release();
          }
        }
        free(pDeviceName);
      }
    }
    pPropBag->Release();
    pMoniker->Release();
  }

  ::CoUninitialize();
}
コード例 #9
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
bool SIDStil::SetBaseDir(PString pathToHVSC)
{
	PString tempName;
	PDirectory dir;
	PList<DirList *> tempStilDirs, tempBugDirs;
	float tempStilVersion;

	// Temporary placeholder for STIL.txt's version number
	tempStilVersion = stilVersion;

	// Sanity check the length
	if (pathToHVSC.IsEmpty())
		return (false);

	try
	{
		// Attempt to open STIL
		dir.SetDirectory(pathToHVSC);
		dir.Append("DOCUMENTS");

		stilFile = new PCacheFile(dir.GetDirectory() + "STIL.txt", PFile::pModeRead | PFile::pModeShareRead);
		if (stilFile == NULL)
			throw PMemoryException();

		// Attempt to open BUGList
		try
		{
			bugFile = new PCacheFile(dir.GetDirectory() + "BUGlist.txt", PFile::pModeRead | PFile::pModeShareRead);
			if (bugFile == NULL)
				throw PMemoryException();
		}
		catch(PFileException e)
		{
			// This is not a critical error - some earlier versions of HVSC did
			// not have a BUGlist.txt file at all
			bugFile = NULL;
		}

		// This is necessary so the version number gets scanned in from the
		// new file, too
		stilVersion = 0.0f;

		if (GetDirs(stilFile, tempStilDirs, true) != true)
			throw PUserException();

		if (bugFile != NULL)
		{
			if (GetDirs(bugFile, tempBugDirs, false) != true)
			{
				// This is not a critical error - it is possible that the
				// BUGlist.txt file has no entries in it at all (in fact, that's
				// good!)
				;
			}
		}
	}
	catch(...)
	{
		// Close the files
		delete bugFile;
		bugFile = NULL;

		delete stilFile;
		stilFile = NULL;

		// Delete the directory lists
		DeleteDirList(tempStilDirs);
		DeleteDirList(tempBugDirs);

		// Copy back the original version
		stilVersion = tempStilVersion;

		return (false);
	}

	// Close the files
	stilFile->Close();
	bugFile->Close();

	// Now we can copy the stuff into private data.
	// NOTE: At this point, stilVersion should contain the new info!
	//
	// Remember the base directory
	baseDir = pathToHVSC;

	// First, delete whatever may have been there previously
	DeleteDirList(stilDirs);
	DeleteDirList(bugDirs);

	// Now proceed with copy
	CopyDirList(stilDirs, tempStilDirs);
	CopyDirList(bugDirs, tempBugDirs);

	// Clear the buffers (caches)
	entryBuf.MakeEmpty();
	globalBuf.MakeEmpty();
	bugBuf.MakeEmpty();

	// Cleanup
	DeleteDirList(tempStilDirs);
	DeleteDirList(tempBugDirs);

	return (true);
}
コード例 #10
0
ファイル: SIDStil.cpp プロジェクト: pulkomandy/APlayer
bool SIDStil::PositionToEntry(PString entryStr, PFile *inFile, PList<DirList *> &dirs)
{
	DirList *item = NULL;
	int32 slashIndex;
	int32 startPos;
	int32 i, count;
	int32 pathLen, entryStrLen;
	PString line;
	bool foundIt = false;
	bool globComm = false;
	bool temp;
	PCharSet_MS_WIN_1252 charSet;

	try
	{
		// Seek to the start of the file
		inFile->SeekToBegin();

		// Get the dirpath
		slashIndex = entryStr.ReverseFind('/');

		// If no slash was found, something is screwed up in the entryStr
		if (slashIndex == -1)
			return (false);

		pathLen = slashIndex + 1;

		// Determine whether a section-global comment is asked for
		entryStrLen = entryStr.GetLength();
		if (pathLen == entryStrLen)
			globComm = true;

		// Find it in the table
		count = dirs.CountItems();
		for (i = 0; i < count; i++)
		{
			item = dirs.GetItem(i);
			if (entryStr.Left(pathLen) == item->dirName)
			{
				foundIt = true;
				break;
			}
		}

		if (!foundIt)
		{
			// The directory was not found
			return (false);
		}

		// Jump to the first entry of this section
		inFile->Seek(item->position, PFile::pSeekBegin);
		foundIt = false;

		// Now find the desired entry
		do
		{
			startPos = inFile->GetPosition();
			line     = inFile->ReadLine(&charSet);

			if (inFile->IsEOF())
				break;

			// Check if it is the start of an entry
			if (!line.IsEmpty() && (line.GetAt(0) == '/'))
			{
				if (line.Left(pathLen) != item->dirName)
				{
					// We are outside the section - get out of the loop,
					// which will fail the search
					break;
				}

				// Check whether we need to find a section-global comment or
				// a specific entry
				if (globComm || (stilVersion > 2.59f))
					temp = (line == entryStr);
				else
				{
					// To be compatible with older versions of STIL, which may have
					// the tune designation on the first line of a STIL entry
					// together with the pathname
					temp = (line.Left(entryStrLen) == entryStr);
				}

				if (temp)
				{
					// Found it!
					foundIt = true;
				}
			}
		}
		while (!foundIt);

		if (foundIt)
		{
			// Reposition the file pointer back to the start of the entry
			inFile->Seek(startPos, PFile::pSeekBegin);
			return (true);
		}
	}
	catch(PFileException e)
	{
		;
	}

	return (false);
}