SdkAudioStream::SdkAudioStream(sdk_audio_format_enum_t format,int maxpackets,int * pRunningBits) : m_Format(format), m_MaxPackets(maxpackets) , m_pRunningBits(pRunningBits) { GMI_RESULT gmiret; gmiret = m_Mutex.Create(NULL); SDK_ASSERT(gmiret == GMI_SUCCESS); #ifdef AUDIO_DUAL_FILE_EMULATE #else m_Initialized = 0; m_Registered = 0; #endif /*AUDIO_DUAL_FILE_EMULATE*/ /*ipc client will init itself*/ SDK_ASSERT(m_DataVec.size() == 0); SDK_ASSERT(m_DataLenVec.size() == 0); SDK_ASSERT(m_FrameNumVec.size() == 0); SDK_ASSERT(m_PtsVec.size() == 0); #ifdef AUDIO_PULL_MODE m_ThreadRunning =0 ; m_ThreadExited = 1; m_pThread = NULL; #endif }
SnpDocumentActionHelper::VPB::~VPB() { ASErr result = kNoErr; try { SDK_ASSERT(sAIActionManager); result = sAIActionManager->AIDeleteActionParamValue(fActionParamValueRef); SDK_ASSERT(!result); fActionParamValueRef = NULL; } catch (ai::Error) { } }
SnpDocumentActionHelper::VPB::VPB() : fActionParamValueRef(NULL) { ASErr result = kNoErr; try { SDK_ASSERT(sAIActionManager); result = sAIActionManager->AINewActionParamValue(&fActionParamValueRef); SDK_ASSERT(!result); SDK_ASSERT(fActionParamValueRef); } catch (ai::Error) { } }
int SdkServerBuffer::StartStream(sys_stream_info_t * pStreamInfo) { int ret; if (this->m_Started > 0) { return 0; } this->StopStream(); if (this->m_StreamId < 0 || this->m_StreamId >= MAX_STREAM_IDS || this->m_MaxPacks == 0) { return -EINVAL; } /*now ,first to change the stream*/ ret = this->__CopyStreamInfo(&(this->m_StreamInfo),pStreamInfo); if (ret < 0) { this->StopStream(); return ret; } SDK_ASSERT(this->m_pStream == NULL); this->m_pStream = new SdkServerStream(this->m_StreamId,this->m_StreamInfo.s_Compression); ret = this->m_pStream->StartStream(); if (ret < 0) { this->StopStream(); return ret; } SDK_ASSERT(this->m_pPacks == NULL); this->m_pPacks =(stream_pack_t**) calloc(sizeof(*(this->m_pPacks)),this->m_MaxPacks); if (this->m_pPacks == NULL) { this->StopStream(); return -ENOMEM; } this->m_StartIdx = 0; this->m_EndIdx = 0; this->m_PackSize = 0; SDK_ASSERT(this->m_pClientBuffers.size() == 0); /*started */ this->m_Started = 1; return 0; }
int SdkAudioStream::__PushStreamData(void * pData,uint32_t datalen,uint32_t idx,uint64_t pts) { GMI_RESULT gmiret; int ret = 1; void* pRemovePtr=NULL; uint32_t discardnum =0; gmiret = this->m_Mutex.Lock(TIMEOUT_INFINITE); SDK_ASSERT(gmiret == GMI_SUCCESS); VECTOR_EQUAL_ASSERT(); if(this->m_MaxPackets && this->m_DataVec.size() == this->m_MaxPackets) { /*we pick the most early one to get this packet*/ pRemovePtr = this->m_DataVec[0]; discardnum = this->m_FrameNumVec[0]; this->m_DataVec.erase(this->m_DataVec.begin()); this->m_DataLenVec.erase(this->m_DataLenVec.begin()); this->m_PtsVec.erase(this->m_PtsVec.begin()); this->m_FrameNumVec.erase(this->m_FrameNumVec.begin()); /*now to insert*/ this->m_DataVec.push_back(pData); this->m_DataLenVec.push_back(datalen); this->m_FrameNumVec.push_back(idx); this->m_PtsVec.push_back(pts); ret = 0; SDK_ASSERT(this->m_DataVec.size() == this->m_MaxPackets || this->m_MaxPackets == 0); } else { ret = 1; /*now to insert*/ this->m_DataVec.push_back(pData); this->m_DataLenVec.push_back(datalen); this->m_FrameNumVec.push_back(idx); this->m_PtsVec.push_back(pts); } this->m_Mutex.Unlock(); if(pRemovePtr) { DEBUG_INFO("discard frame number %d\n",discardnum); free(pRemovePtr); } pRemovePtr = NULL; return ret; }
void SdkServerStream::__ClearVectors() { GMI_RESULT gmiret; gmiret = this->m_Mutex.Lock(TIMEOUT_INFINITE); SDK_ASSERT(gmiret ==GMI_SUCCESS); SIZE_EQUAL_ASSERT(); while(this->m_DataVec.size() > 0) { void* pData=NULL; pData = this->m_DataVec[0]; this->m_DataVec.erase(this->m_DataVec.begin()); this->m_DataLen.erase(this->m_DataLen.begin()); this->m_DataType.erase(this->m_DataType.begin()); this->m_DataIdx.erase(this->m_DataIdx.begin()); this->m_DataPts.erase(this->m_DataPts.begin()); if(pData) { DEBUG_INFO("data %p\n",pData); free(pData); } pData = NULL; } SIZE_EQUAL_ASSERT(); this->m_Mutex.Unlock(); return ; }
ASErr SnpDocumentActionHelper::OpenDocument(const ai::UnicodeString& name) { ASErr result = kNoErr; try { SDK_ASSERT(sAIActionManager); // Stores action parameters. SnpDocumentActionHelper::VPB vpb; // Name parameter SnpDocumentHelper docHelper; ai::FilePath path = docHelper.GetAssetPath(name); SnippetRunnerLog::Instance()->Write(path.GetFullPath()); vpb.SetOpenDocumentName(path); // Color model parameter. SnpChooser chooser; AIDocumentColorModelValue colorModel = chooser.PickDocumentColorModel(); vpb.SetOpenDocumentColorModel(colorModel); // Play the action. result = this->OpenDocument(kDialogOff, vpb); aisdk::check_ai_error(result); } catch (ai::Error& ex) { result = ex; } return result; }
void SdkServerBuffer::__FreeResource() { unsigned int i; /*make sure that we should release all the client*/ SDK_ASSERT(this->m_pClientBuffers.size() == 0); if (this->m_pPacks) { for(i=0; i<this->m_MaxPacks; i++) { if (this->m_pPacks[i]) { DEBUG_INFO("pack %p data %p\n",this->m_pPacks[i],this->m_pPacks[i]->m_pData); } this->__FreeStreamPack(this->m_pPacks[i]); } free(this->m_pPacks); } this->m_pPacks = NULL; this->m_StartIdx = 0; this->m_EndIdx = 0; this->m_PackSize = 0; if (this->m_pStream) { delete this->m_pStream; } this->m_pStream = NULL; this->m_Started = 0; memset(&(this->m_StreamInfo),0,sizeof(this->m_StreamInfo)); return ; }
int SdkServerBuffer::__GetStreamDataPendingState(client_buffer_t * pCBuffer,struct iovec * pIoVec,int & iovlen,int & begin) { int ret; SDK_ASSERT(pCBuffer->m_State == cb_pending_state); if (pCBuffer->m_pBlock && pCBuffer->m_WriteLen < pCBuffer->m_TotalLen) { /*if we have data left*/ ret = this->__SetIov(pCBuffer,pIoVec,iovlen,begin); if (ret < 0) { return ret; } return 1; } /*we free until here ,for it will change for the next search ,and will not be cb_pending_state*/ this->__FreeStreamPack(pCBuffer->m_pBlock); /*now to change the state for cb_end_state ,start from */ this->__InitClientBuffer(pCBuffer,pCBuffer->m_Sock,pCBuffer->m_SesId); /*now we should get from the cb_end_state ,to do here*/ return this->__GetStreamDataEndState(pCBuffer,pIoVec,iovlen,begin); }
void SnpDocumentActionHelper::VPB::SetNewDocumentPreviewMode(AIPreviewMode previewMode) { SDK_ASSERT(sAIActionManager); ASUInt32 previewModeMask = 0x020; switch (previewMode) { default: case kAIPreviewModeDefault: { previewModeMask = 0x020; } break; case kAIPreviewModePixelPreview: { previewModeMask = 0x040; } break; case kAIPreviewModeOverprintPreview: { previewModeMask = 0x100; } break; } ASErr result = sAIActionManager->AIActionSetInteger(this->fActionParamValueRef, kAINewDocumentPreviewModeKey, previewModeMask); aisdk::check_ai_error(result); }
void SnpDocumentActionHelper::VPB::SetNewDocumentRasterResolution(AIRasterResolution rasterResolution) { SDK_ASSERT(sAIActionManager); ASUInt32 rasterResolutionPPI = 72; switch (rasterResolution) { default: case kAIRasterResolutionScreen: { rasterResolutionPPI = 72; } break; case kAIRasterResolutionMedium: { rasterResolutionPPI = 150; } break; case kAIRasterResolutionHigh: { rasterResolutionPPI = 300; } break; } ASErr result = sAIActionManager->AIActionSetInteger(this->fActionParamValueRef, kAINewDocumentRasterResolutionKey, rasterResolutionPPI); aisdk::check_ai_error(result); }
void SdkAudioStream::__ClearVectors() { #ifndef AUDIO_DUAL_FILE_EMULATE SDK_ASSERT(this->m_Initialized == 0 && this->m_Registered == 0); #endif /*AUDIO_DUAL_FILE_EMULATE*/ /*this is from the single threaded ,so we can do this*/ VECTOR_EQUAL_ASSERT(); while(this->m_DataVec.size() > 0) { void* pData = this->m_DataVec[0]; this->m_DataVec.erase(this->m_DataVec.begin()); this->m_DataLenVec.erase(this->m_DataLenVec.begin()); this->m_PtsVec.erase(this->m_PtsVec.begin()); this->m_FrameNumVec.erase(this->m_FrameNumVec.begin()); if(pData) { free(pData); } pData = NULL; VECTOR_EQUAL_ASSERT(); } return ; }
int SdkServerStream::PullStreamData(stream_pack_t* pPack) { GMI_RESULT gmiret; int ret = 0; gmiret = this->m_Mutex.Lock(TIMEOUT_INFINITE); SDK_ASSERT(gmiret == GMI_SUCCESS); SIZE_EQUAL_ASSERT(); if(this->m_DataIdx.size() > 0) { pPack->m_Idx = this->m_DataIdx[0]; pPack->m_Type = this->m_DataType[0]; pPack->m_pData = this->m_DataVec[0]; pPack->m_DataLen = this->m_DataLen[0]; pPack->m_Pts = this->m_DataPts[0]; this->m_DataIdx.erase(this->m_DataIdx.begin()); this->m_DataType.erase(this->m_DataType.begin()); this->m_DataVec.erase(this->m_DataVec.begin()); this->m_DataLen.erase(this->m_DataLen.begin()); this->m_DataPts.erase(this->m_DataPts.begin()); ret = 1; } this->m_Mutex.Unlock(); if(ret == 0 && this->m_ThreadExited) { ret= -EFAULT; } return ret; }
int SdkServerBuffer::__CopyBlock(client_buffer_t * pCBuffer,stream_pack_t * pPack,enum_cb_state_t state) { SDK_ASSERT(pCBuffer->m_pBlock == NULL); SDK_ASSERT(state == cb_block_state || state == cb_pending_state); pCBuffer->m_pBlock = this->__CopyPack(pPack); if(pCBuffer->m_pBlock == NULL) { /*set it is failed*/ pCBuffer->m_Failed = 1; return -ENOMEM; } SDK_ASSERT(pCBuffer->m_pBlock->m_Idx == pCBuffer->m_SourceIdx); this->__ChangeClientBufferState(pCBuffer,state,__FILE__,__LINE__); return 0; }
/*now first to initialize*/ for(i=0; i<100; i++) { gmiret = this->m_IPCClient.Initialize(startport + i,GM_STREAM_APPLICATION_ID); if(gmiret == GMI_SUCCESS) { DEBUG_INFO("Initialize Port (%d)\n",startport + i); break; } } if(gmiret != GMI_SUCCESS) { return -EFAULT; } this->m_Initialized = 1; serverport += this->m_StreamId; if(this->m_Type == SYS_COMP_H264) { type = MEDIA_VIDEO_H264; } else if(this->m_Type == SYS_COMP_MJPEG) { type = MEDIA_VIDEO_MJPEG; } else if(this->m_Type == SYS_COMP_MPEG4) { type = MEDIA_VIDEO_MPEG4; } else { this->__ClearIPC(); return -EFAULT; } #ifdef STREAM_PULL_MODE gmiret = this->m_IPCClient.Register(serverport,type,this->m_StreamId,true,NULL,NULL); #else gmiret = GMI_FAIL; #endif if(gmiret != GMI_SUCCESS) { ERROR_INFO("register port %d at streamid %d error 0x%08lx\n", serverport,this->m_StreamId,gmiret); this->__ClearIPC(); return -EFAULT; } this->m_Registered = 1; return 0; } #endif /*VIDEO_STREAM_EMULATE*/ #ifdef VIDEO_STREAM_EMULATE #ifdef STREAM_PULL_MODE #define THREAD_EXIT_ASSERT() \ do\ {\ SDK_ASSERT(this->m_ThreadRunning == 0);\ SDK_ASSERT(this->m_ThreadExited == 1);\ SDK_ASSERT(this->m_pThread == NULL);\ }\ while(0) #else #define THREAD_EXIT_ASSERT() \ do\ {\ ;\ }\ while(0) #endif /*STREAM_PULL_MODE*/ #else /*VIDEO_STREAM_EMULATE*/ #ifdef STREAM_PULL_MODE #define THREAD_EXIT_ASSERT() \ do\ {\ SDK_ASSERT(this->m_ThreadRunning == 0);\ SDK_ASSERT(this->m_ThreadExited == 1);\ SDK_ASSERT(this->m_pThread == NULL);\ SDK_ASSERT(this->m_Initialized == 0);\ SDK_ASSERT(this->m_Registered == 0);\ }\ while(0) #else #define THREAD_EXIT_ASSERT() \ do\ {\ SDK_ASSERT(this->m_Initialized == 0);\ SDK_ASSERT(this->m_Registered == 0);\ }\ while(0) #endif /*STREAM_PULL_MODE*/ #endif /*VIDEO_STREAM_EMULATE*/ int SdkServerStream::PauseStream() { #ifdef STREAM_PULL_MODE GMI_RESULT gmiret; if(this->m_pThread==NULL) { THREAD_EXIT_ASSERT(); return 0; } this->m_ThreadRunning = 0; while(this->m_ThreadExited == 0) { /*sleep for 100 milli seconds*/ usleep(100000); } /*now exited ,so we should destroy*/ gmiret = this->m_pThread->Destroy(); SDK_ASSERT(gmiret == GMI_SUCCESS); delete this->m_pThread ; this->m_pThread = NULL; #endif #ifdef VIDEO_STREAM_EMULATE #else this->__ClearIPC(); #endif /*VIDEO_STREAM_EMULATE*/ THREAD_EXIT_ASSERT(); return 1; }
int SdkServerBuffer::ResumeStream(sys_stream_info_t * pStreamInfo) { int ret; /*ok ,to make things ok ,when we from the very sure state*/ this->PauseStream(); if (this->m_StreamId < 0 || this->m_StreamId >= MAX_STREAM_IDS || this->m_MaxPacks == 0) { return -EINVAL; } ret = this->__CopyStreamInfo(&(this->m_StreamInfo),pStreamInfo); if (ret < 0) { this->PauseStream(); return ret; } /*now ,first to change the stream*/ SDK_ASSERT(this->m_pStream == NULL); this->m_pStream = new SdkServerStream(this->m_StreamId,this->m_StreamInfo.s_Compression); ret = this->m_pStream->StartStream(); if (ret < 0) { this->PauseStream(); return ret; } SDK_ASSERT(this->m_pPacks == NULL); this->m_pPacks = (stream_pack_t**)calloc(sizeof(*(this->m_pPacks)),this->m_MaxPacks); if (this->m_pPacks == NULL) { this->PauseStream(); return -ENOMEM; } this->m_StartIdx = 0; this->m_EndIdx = 0; this->m_PackSize = 0; /*started */ this->m_Started = 1; return 0; }
int SdkServerSession::__StartKeepAliveTimer() { float ftime = (float)this->m_KeepAliveTime; SDK_ASSERT(this->m_InsertKeepAliveTimer == 0); ev_timer_init(&(this->m_KeepAliveTimer),SdkServerSession::KeepAliveTimerFunc,ftime,0.0,this); ev_timer_start(EV_DEFAULT,&(this->m_KeepAliveTimer)); this->m_InsertKeepAliveTimer = 1; return 0; }
int SdkServerBuffer::__HandleClientInsert(client_buffer_t * pCBuffer,unsigned int insertidx) { stream_pack_t* pCBlock=NULL; int ret; SDK_ASSERT(this->m_PackSize == this->m_MaxPacks); if (pCBuffer->m_CurIdx != insertidx || pCBuffer->m_State == cb_pending_state || pCBuffer->m_State == cb_block_state || pCBuffer->m_State == cb_end_state) { return 0; } pCBlock = this->m_pPacks[insertidx]; SDK_ASSERT(pCBlock); /*it may be handled not the same index ,so it is the time pointed to it*/ if (pCBuffer->m_SourceIdx != pCBlock->m_Idx) { return 0; } /*this block does not the one ,we notify */ if ((pCBuffer->m_State == cb_i_frame_state && (pCBlock->m_Type != I_FRAME_TYPE)) || (pCBuffer->m_WriteLen == pCBuffer->m_TotalLen)) { /* maybe this will modify the pCBuffer->m_CurIdx and pCBuffer->m_SourceIdx but it will give the next one waken up to enter the function __GetStreamDataIFrameState, in that function will scan from m_StartIdx to m_EndIdx,so we handle the function there */ return 0; } DEBUG_INFO("DISCARD [%d] idx blockstate discarded\n",pCBuffer->m_Sock); SDK_ASSERT(pCBuffer->m_pBlock == NULL); ret = this->__CopyBlock(pCBuffer,pCBlock,cb_block_state); if (ret < 0) { return ret; } return 1; }
int SdkServerBuffer::ForwardStreamData(int sock,struct iovec * pIoVec,int iovlen,int forwardlen) { int ret; unsigned int i; client_buffer_t* pCBuffer=NULL,*pFindCBuffer=NULL; for (i=0; i<this->m_pClientBuffers.size(); i++) { pCBuffer = this->m_pClientBuffers[i]; if (sock == pCBuffer->m_Sock) { pFindCBuffer = pCBuffer; break; } } if (pFindCBuffer == NULL) { return -ENODEV; } pCBuffer = pFindCBuffer; switch(pCBuffer->m_State) { case cb_end_state: /*this can not be happend ,so we make bug*/ SDK_ASSERT(0!=0); ret = -EINVAL; break; case cb_i_frame_state: case cb_seq_state: case cb_block_state: case cb_pending_state: ret = this->__ForwardStreamDataInner(pCBuffer,pIoVec,iovlen,forwardlen); break; default: /*this can not be happend ,so we make bug*/ SDK_ASSERT(0!=0); ret = -EFAULT; break; } return ret; }
SdkAudioStream::~SdkAudioStream() { GMI_RESULT gmiret; this->StopStream(); gmiret = this->m_Mutex.Destroy(); SDK_ASSERT(gmiret == GMI_SUCCESS); this->m_pRunningBits = NULL; this->m_MaxPackets = 0; this->m_Format = audio_format_default; }
void SdkServerSession::__ReleaseResource() { /*we can not release when session has in the vector*/ SDK_ASSERT(this->m_pClients.size() == 0); this->__StopKeepAliveTimer(); #ifdef SESSION_EXPIRE_TIME this->__StopExpireTimer(); #endif /*SESSION_EXPIRE_TIME*/ this->m_Valid = 0; }
int SdkServerBuffer::GetStreamData(int sock,struct iovec * pIoVec,int & iovlen,int & begin) { int ret; unsigned int i; client_buffer_t *pCBuffer=NULL,*pFindCBuffer=NULL; for (i=0; i<this->m_pClientBuffers.size(); i++) { pCBuffer = this->m_pClientBuffers[i]; if (pCBuffer->m_Sock == sock) { pFindCBuffer = pCBuffer; break; } } if (pFindCBuffer == NULL) { ERROR_INFO("sock %d clientbuffers %d\n",sock, this->m_pClientBuffers.size()); return -ENODEV; } if(pFindCBuffer->m_Failed) { /*we have failed before ,so we should just return error*/ return -EFAULT; } pCBuffer = pFindCBuffer; switch(pCBuffer->m_State) { case cb_end_state: ret = this->__GetStreamDataEndState(pCBuffer,pIoVec,iovlen,begin); break; case cb_i_frame_state: ret = this->__GetStreamDataIFrameState(pCBuffer,pIoVec,iovlen,begin); break; case cb_seq_state: ret = this->__GetStreamDataSeqState(pCBuffer,pIoVec,iovlen,begin); break; case cb_block_state: ret = this->__GetStreamDataBlockState(pCBuffer,pIoVec,iovlen,begin); break; case cb_pending_state: ret = this->__GetStreamDataPendingState(pCBuffer,pIoVec,iovlen,begin); break; default: SDK_ASSERT(0!=0); ret = -EINVAL; break; } return ret; }
int SdkServerBuffer::__ForwardStreamDataInner(client_buffer_t * pCBuffer,struct iovec * pIoVec,int iovlen,int forwardlen) { int ret; /*now to test for the write len*/ SDK_ASSERT (pCBuffer->m_WriteLen < pCBuffer->m_TotalLen); ret = this->__ForwardAssert(pCBuffer,pIoVec,iovlen,forwardlen); if (ret < 0) { return ret; } /*now to test whether it is ok in the format*/ pCBuffer->m_WriteLen += forwardlen; SDK_ASSERT (pCBuffer->m_WriteLen <= pCBuffer->m_TotalLen); if (pCBuffer->m_WriteLen > (pCBuffer->m_FrameLen + pCBuffer->m_GsspLen)) { pCBuffer->m_Offset = (pCBuffer->m_WriteLen - (pCBuffer->m_FrameLen + pCBuffer->m_GsspLen)); } //DEBUG_INFO("writelen %d totallen %d\n",pCBuffer->m_WriteLen,pCBuffer->m_TotalLen); return pCBuffer->m_WriteLen == pCBuffer->m_TotalLen ? 1 : 0; }
ASErr SnpSelectionHelper::DeselectAll() { ASErr result = kNoErr; try { SDK_ASSERT(sAIMatchingArt); result = sAIMatchingArt->DeselectAll(); aisdk::check_ai_error(result); } catch (ai::Error& ex) { result = ex; } return result; }
ASErr SnpSelectionHelper::SelectArt(AIArtHandle art) { ASErr result = kNoErr; try { SDK_ASSERT(this->CanSelectArt(art)); result = sAIArt->SetArtUserAttr(art, kArtSelected, kArtSelected); aisdk::check_ai_error(result); } catch (ai::Error& ex) { result = ex; } return result; }
ASErr SnpDocumentActionHelper::NewDocument(ActionDialogStatus dialogStatus, AIActionParamValueRef parameters) { ASErr result = kNoErr; try { SDK_ASSERT(sAIActionManager); result = sAIActionManager->PlayActionEvent(kAINewDocumentAction, dialogStatus, parameters); aisdk::check_ai_error(result); } catch (ai::Error& ex) { result = ex; } return result; }
ASBoolean SnpSelectionHelper::CanSelectArt(AIArtHandle art) { ASBoolean result = false; try { SDK_ASSERT(sAIArt); long attr = 0; ASErr status = sAIArt->GetArtUserAttr(art, kArtLocked | kArtHidden, &attr); aisdk::check_ai_error(status); result = !(attr & kArtLocked) && !(attr & kArtHidden); } catch (ai::Error) { } return result; }
SdkServerBuffer::SdkServerBuffer(int streamid,int maxpacks,int* pRunningBits) : m_StreamId(streamid) ,m_MaxPacks(maxpacks) ,m_pRunningBits(pRunningBits) { m_Started = 0 ; memset(&m_StreamInfo,0,sizeof(m_StreamInfo)); m_pPacks = NULL; m_StartIdx = 0; m_EndIdx = 0; m_PackSize = 0; SDK_ASSERT(m_pClientBuffers.size() == 0); m_pStream = NULL; }
ASErr SnpDocumentActionHelper::NewDocument() { ASErr result = kNoErr; try { SDK_ASSERT(sAIActionManager); SnpDocumentActionHelper::VPB vpb; SnippetRunnerParameter* parameter = SnippetRunnerParameter::Instance(); ai::UnicodeString documentName = parameter->GetString(ai::UnicodeString("Document name"), ai::UnicodeString("MyDocument")); vpb.SetNewDocumentName(documentName); ai::FilePath profilesFolder; result = sAIFolders->FindFolder(kAIUserWritableStartupFileFolderType, false, profilesFolder); aisdk::check_ai_error(result); ai::FilePath defaultPresetFilePath = profilesFolder; defaultPresetFilePath.AddComponent(ai::FilePath(ai::UnicodeString("Print.ai"))); ai::FilePath presetFilePath = parameter->GetFilePath("New Document Profile", true, defaultPresetFilePath); vpb.SetNewDocumentSettingsFile(presetFilePath); SnpChooser chooser; AIDocumentColorModelValue documentColorModel = chooser.PickDocumentColorModel(); vpb.SetNewDocumentColorModel(documentColorModel); ASReal documentWidth = parameter->GetReal("Document width", 612.0); vpb.SetNewDocumentWidth(documentWidth); ASReal documentHeight = parameter->GetReal("Document height", 792.0); vpb.SetNewDocumentHeight(documentHeight); AIDocumentRulerUnitValue documentRulerUnit = chooser.PickDocumentRulerUnit(); vpb.SetNewDocumentRulerUnits(documentRulerUnit); AIRasterResolution rasterResolution = chooser.PickDocumentRasterResolution(); vpb.SetNewDocumentRasterResolution(rasterResolution); AIPreviewMode previewMode = chooser.PickPreviewMode(); vpb.SetNewDocumentPreviewMode(previewMode); result = this->NewDocument(kDialogOff, vpb); aisdk::check_ai_error(result); } catch (ai::Error& ex) { result = ex; } return result; }
int SdkAudioStream::PullStreamData(stream_pack_t * pPack) { int ret=0; GMI_RESULT gmiret; #ifdef AUDIO_DUAL_FILE_EMULATE #ifdef AUDIO_PULL_MODE if(this->m_pThread == NULL) { return 0; } #endif /*AUDIO_PULL_MODE*/ #else if(this->m_Initialized == 0) { /*nothing get */ return 0; } #endif /*AUDIO_DUAL_FILE_EMULATE*/ gmiret = this->m_Mutex.Lock(TIMEOUT_INFINITE); SDK_ASSERT(gmiret == GMI_SUCCESS); VECTOR_EQUAL_ASSERT(); if(this->m_DataVec.size() > 0) { /*now put the value*/ pPack->m_pData = this->m_DataVec[0]; pPack->m_DataLen = this->m_DataLenVec[0]; pPack->m_Idx = this->m_FrameNumVec[0]; pPack->m_Pts = this->m_PtsVec[0]; pPack->m_Type = 0; this->m_DataVec.erase(this->m_DataVec.begin()); this->m_DataLenVec.erase(this->m_DataLenVec.begin()); this->m_PtsVec.erase(this->m_PtsVec.begin()); this->m_FrameNumVec.erase(this->m_FrameNumVec.begin()); /*we have get one*/ ret = 1; } this->m_Mutex.Unlock(); return ret; }