本文整理汇总了C++中DataSourceRef::getUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ DataSourceRef::getUrl方法的具体用法?C++ DataSourceRef::getUrl怎么用?C++ DataSourceRef::getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSourceRef
的用法示例。
在下文中一共展示了DataSourceRef::getUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFileQuartzRef
///////////////////////////////////////////////////////////////////////////////
// ImageSourceFileQuartz
ImageSourceFileQuartzRef ImageSourceFileQuartz::createFileQuartzRef( DataSourceRef dataSourceRef, ImageSource::Options options )
{
std::shared_ptr<CGImageSource> sourceRef;
std::shared_ptr<CGImage> imageRef;
::CFStringRef keys[1] = { kCGImageSourceShouldAllowFloat };
::CFBooleanRef values[1] = { kCFBooleanTrue };
const std::shared_ptr<__CFDictionary> optionsDict( (__CFDictionary*)CFDictionaryCreate( kCFAllocatorDefault, (const void **)&keys, (const void **)&values, 1, NULL, NULL ), cocoa::safeCfRelease );
if( dataSourceRef->isFilePath() ) {
::CFStringRef pathString = cocoa::createCfString( dataSourceRef->getFilePath().string() );
::CFURLRef urlRef = ::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString, kCFURLPOSIXPathStyle, false );
sourceRef = std::shared_ptr<CGImageSource>( ::CGImageSourceCreateWithURL( urlRef, optionsDict.get() ), cocoa::safeCfRelease );
::CFRelease( pathString );
::CFRelease( urlRef );
}
else if( dataSourceRef->isUrl() ) {
::CFURLRef urlRef = cocoa::createCfUrl( dataSourceRef->getUrl() );
if( ! urlRef )
throw ImageIoExceptionFailedLoad();
sourceRef = std::shared_ptr<CGImageSource>( ::CGImageSourceCreateWithURL( urlRef, optionsDict.get() ), cocoa::safeCfRelease );
::CFRelease( urlRef );
}
else { // last ditch, we'll use a dataref from the buffer
::CFDataRef dataRef = cocoa::createCfDataRef( dataSourceRef->getBuffer() );
if( ! dataRef )
throw ImageIoExceptionFailedLoad();
sourceRef = std::shared_ptr<CGImageSource>( ::CGImageSourceCreateWithData( dataRef, optionsDict.get() ), cocoa::safeCfRelease );
::CFRelease( dataRef );
}
if( sourceRef ) {
imageRef = std::shared_ptr<CGImage>( ::CGImageSourceCreateImageAtIndex( sourceRef.get(), options.getIndex(), optionsDict.get() ), CGImageRelease );
if( ! imageRef )
throw ImageIoExceptionFailedLoad();
}
else
throw ImageIoExceptionFailedLoad();
const std::shared_ptr<__CFDictionary> imageProperties( (__CFDictionary*)::CGImageSourceCopyProperties( sourceRef.get(), NULL ), ::CFRelease );
const std::shared_ptr<__CFDictionary> imageIndexProperties( (__CFDictionary*)::CGImageSourceCopyPropertiesAtIndex( sourceRef.get(), options.getIndex(), NULL ), ::CFRelease );
return ImageSourceFileQuartzRef( new ImageSourceFileQuartz( imageRef.get(), options, imageProperties, imageIndexProperties ) );
}
示例2: createFileQuartzRef
///////////////////////////////////////////////////////////////////////////////
// ImageSourceFileQuartz
ImageSourceFileQuartzRef ImageSourceFileQuartz::createFileQuartzRef( DataSourceRef dataSourceRef )
{
::CGImageSourceRef sourceRef = NULL;
::CGImageRef imageRef = NULL;
::CFStringRef keys[1] = { kCGImageSourceShouldAllowFloat };
::CFBooleanRef values[1] = { kCFBooleanTrue };
::CFDictionaryRef optionsDict = ::CFDictionaryCreate( kCFAllocatorDefault, (const void **)&keys, (const void **)&values, 1, NULL, NULL );
if( dataSourceRef->isFilePath() ) {
::CFStringRef pathString = cocoa::createCfString( dataSourceRef->getFilePath() );
::CFURLRef urlRef = ::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString, kCFURLPOSIXPathStyle, false );
sourceRef = ::CGImageSourceCreateWithURL( urlRef, optionsDict );
::CFRelease( pathString );
::CFRelease( urlRef );
}
else if( dataSourceRef->isUrl() ) {
::CFURLRef urlRef = cocoa::createCfUrl( dataSourceRef->getUrl() );
if( ! urlRef )
throw ImageIoExceptionFailedLoad();
sourceRef = ::CGImageSourceCreateWithURL( urlRef, optionsDict );
::CFRelease( urlRef );
}
else { // last ditch, we'll use a dataref from the buffer
::CFDataRef dataRef = cocoa::createCfDataRef( dataSourceRef->getBuffer() );
if( ! dataRef )
throw ImageIoExceptionFailedLoad();
sourceRef = ::CGImageSourceCreateWithData( dataRef, optionsDict );
::CFRelease( dataRef );
}
if( sourceRef ) {
imageRef = ::CGImageSourceCreateImageAtIndex( sourceRef, 0, optionsDict );
::CFRelease( sourceRef );
if( ! imageRef )
throw ImageIoExceptionFailedLoad();
}
else
throw ImageIoExceptionFailedLoad();
return ImageSourceFileQuartzRef( new ImageSourceFileQuartz( imageRef ) );
}
示例3: initFromDataSource
void MovieBase::initFromDataSource( DataSourceRef dataSourceRef, const std::string &mimeTypeHint )
{
startQuickTime();
if( dataSourceRef->isFilePath() ) { // try to use quicktime's native file handling if possible
getObj()->mMovie = openMovieFromPath( dataSourceRef->getFilePath() );
// no need to retain the data source
}
else if( dataSourceRef->isUrl() ) { // try to use quicktime's native Url handling if possible
// Create a loader for this Url and then wait on it
MovieLoader loader( dataSourceRef->getUrl() );
loader.waitForLoaded();
getObj()->mMovie = loader.transferMovieHandle();
// no need to retain the data source
}
else { // we'll need to load from memory; and we'll rer to the data source to make sure it doesn't go away before the movie does
Buffer buffer( dataSourceRef->getBuffer() );
getObj()->mMovie = openMovieFromMemory( buffer.getData(), buffer.getDataSize(), dataSourceRef->getFilePathHint(), mimeTypeHint );
getObj()->mDataSource = dataSourceRef; // retain a reference to the dataSource so that it doesn't go away before we do
}
init();
}
示例4: IoExceptionSourceNotFound
SourceFile::SourceFile( DataSourceRef dataSourceRef )
: Source()
{
OSStatus err = noErr;
AudioFileID aFileRef;
if( dataSourceRef->isFilePath() ) {
::CFStringRef pathString = cocoa::createCfString( dataSourceRef->getFilePath() );
::CFURLRef urlRef = ::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString, kCFURLPOSIXPathStyle, false );
err = AudioFileOpenURL( urlRef, kAudioFileReadPermission/*fsRdPerm*/, 0, &aFileRef );
::CFRelease( pathString );
::CFRelease( urlRef );
if( err ) {
#if defined(CINDER_MAC)
//TODO: find iphone equivalent of fnfErr
if( err == fnfErr ) {
throw IoExceptionSourceNotFound();
}
#endif
throw IoExceptionFailedLoad();
}
} else if( dataSourceRef->isUrl() ) {
::CFURLRef urlRef = cocoa::createCfUrl( dataSourceRef->getUrl() );
err = AudioFileOpenURL( urlRef, kAudioFileReadPermission/*fsRdPerm*/, 0, &aFileRef );
::CFRelease( urlRef );
if( err ) {
throw IoExceptionFailedLoad();
}
}
mFileRef = shared_ptr<OpaqueAudioFileID>( aFileRef, AudioFileClose );
//load header info
AudioStreamBasicDescription nativeFormatDescription;
UInt32 size = sizeof( AudioStreamBasicDescription );
err = AudioFileGetProperty( aFileRef, kAudioFilePropertyDataFormat, &size, &nativeFormatDescription );
if( err ) {
throw IoExceptionFailedLoad();
}
loadFromCaAudioStreamBasicDescription( this, &nativeFormatDescription );
size = sizeof( uint64_t );
err = AudioFileGetProperty( aFileRef, kAudioFilePropertyAudioDataPacketCount, &size, &mPacketCount );
if( err ) {
throw IoExceptionFailedLoad();
}
size = sizeof( uint64_t );
err = AudioFileGetProperty( aFileRef, kAudioFilePropertyAudioDataByteCount, &size, &mByteCount );
if( err ) {
throw IoExceptionFailedLoad();
}
size = sizeof( uint32_t );
err = AudioFileGetProperty( aFileRef, kAudioFilePropertyMaximumPacketSize, &size, &mMaxPacketSize );
if( err ) {
throw IoExceptionFailedLoad();
}
size = sizeof( double );
err = AudioFileGetProperty( aFileRef, kAudioFilePropertyEstimatedDuration, &size, &mDuration );
if( err ) {
throw IoExceptionFailedLoad();
}
}