Control the FTP Jobs¶
Transfer content in media to other devices using an FTP Server.
Only movie content for which information can be obtained with GetMediaProfile() can be transferred via FTP; Create a CrFTPJobSetting class instance using the content information obtained by GetMediaProfile().
Prepare one CrFTPJobSetting class instance per movie content. Some movie content can be trimmed in-camera and edited to a smaller file size before transfer. Trimming availability can be checked with the isTrimmingAvailable variable in the CrMediaProfileInfo class. Some fields must always be specified for trimmed transfers. Check the CrFTPJobSetting table for the fields that must be specified.
Example:
CrInt32u numOfList= 0;
SCRSDK:: CrMediaProfileInfo* mediaList;
CrError err = SCRSDK:: GetMediaProfile (
handle,
SCRSDK::CrMediaProfile_Slot1,
&mediaList,
&numOfList);
if (CR_SUCCEEDED(err) && 0 < numOfList) {
std::vector<SCRSDK::CrFTPJobSetting*> ftpAddJobList;
CrInt32u tempSvID = 1; // using CrDeviceProperty_SelectFTPServerID current value
CrInt16u strSize = 0;
for(CrInt32u i=0 ; i<numOfList ; ++i) {
SCRSDK::CrFTPJobSetting* ftpJob = new SCRSDK::CrFTPJobSetting();
ftpJob->trimType = SCRSDK::CrFTPJobTrimType_NoTrim;
ftpJob->serverId = tempSvID;
ftpJob->slotId = SCRSDK::CrFTPJobSlotId_Slot1; // same CrMediaProfile_Slot1
strSize = (CrInt16u)strlen((char*)mediaList[i].contentUrl);
strSize += (sizeof(CrInt16u) + 1); // +1 = null-terminate
ftpJob->clipPath = new CrInt8u[strSize];
memset(ftpJob->clipPath, 0, strSize);
// The first 2bytes are string length. include null-terminate
memcpy(&ftpJob->clipPath[0], &strSize, sizeof(strSize));
memcpy(&ftpJob->clipPath[2], &mediaList[i].contentUrl, strSize - 2);
ftpJobList.push_back(ftpJob);
}
CrError errJob = SCRSDK::ControlFTPJobList(
handle,
SCRSDK::CrFTPJobControlType_Add,
(void*)&ftpAddJobList,
numOfList);
if (CR_FAILED(errJob) {
// memory release, etc.
To transfer a proxy movie content, specify proxyUrl in clipPath.
Example:
strSize = (CrInt16u)strlen((char*)mediaList[i].proxyUrl);
...
memcpy(&ftpJob->clipPath[2], &mediaList[i].proxyUrl, strSize - 2);
The following is an example of trimming transfer.
Among the variables that must be specified during trimming transfer, there are three pieces of information determined by the user: inFrame, outFrame, and destClipName.
The destClipName is required, but the contentUrl may be used as is. When transferred under an alias, it can exist at the same time as the original content.
Example:
...
ftpJob->trimType = SCRSDK::CrFTPJobTrimType_Trim;
// 0 < inFrame < outFrame
ftpJob->inFrame = 1; // user decides
ftpJob->outFrame = 10; // user decides
ftpJob->duration = mediaList[i].duration; // copy
// umid
memcpy(ftpJob->umid, &mediaList[i].umid, sizeof(ftpJob->umid)); // copy
// videoType
strSize = (CrInt16u)strlen((char*)mediaList[i].contentVideoType);
strSize += (sizeof(CrInt16u) + 1); // +1 = null-terminate
ftpJob->videoType = new CrInt8u[strSize]; // copy
memset(ftpJob->videoType, 0, strSize);
// The first 2bytes are string length. include null-terminate
memcpy(&ftpJob->videoType[0], &strSize, sizeof(strSize));
memcpy(&ftpJob->videoType[2], &mediaList[i].contentVideoType, strSize - 2);
// Give a new name
char newName[256] = {0};
strcpy(newName, "trim_"); // 5 byte prefix
strcpy(&newName[5], (char*)&mediaList[0].contentName); // copy
strSize = strlen(newName);
strcpy(&newName[strSize], ".MXF"); // append extension
strSize += (strlen(newName) + sizeof(strSize) + 1);
ftpJob->destClipName = new CrInt8u[strSize];
memcpy(&ftpJob->destClipName[0], &strSize, sizeof(strSize));
memcpy(&ftpJob->destClipName[2], newName, strSize - 2);
...
FTP Jobs registered with the camera are transferred by FTP as appropriate. Use GetFTPJobList() to know the content transfer progress status.
Example:
std::vector<SCRSDK::CrFTPJobInfo*> ctrlJobList;
SCRSDK::CrFTPJobInfo* getJobInfoList = nullptr;
CrInt32u numOfList = 0;
CrError ret = SCRSDK::GetFTPJobList(handle, &getJobInfoList, &numOfList);
if (CR_SUCCEEDED(ret) && 0 < numOfList) {
for (CrInt32u i = 0; i < numOfList; i++) {
SCRSDK::CrFTPJobInfo* info = new SCRSDK::CrFTPJobInfo(getJobInfoList[i]);
// printf("ID=%d, Status=%d\n", info->jobId, info->jobStatus);
ctrlJobList.push_back(info);
}
SCRSDK::ReleaseFTPJobList(handle, getJobInfoList);
Control the suspend, resume, and deletion of the content transfer jobs. FTP Jobs that have been transferred should be deleted.
Example:
// Suspend multiple jobs
CrInt32u jobIdList[SCRSDK::CrFTPJOBLIST_MAX] = { 0 };
CrInt32u susCount = 0;
for (CrInt32u i = 0; i < ctrlJobList.size(); ++i) {
if (SCRSDK::CrFTPJobStatus_Waiting == ctrlJobList[i]->jobStatus) {
jobIdList[i] = ctrlJobList[i]->jobId;
susCount++;
}
}
CrError ret = SCRSDK::ControlFTPJobList(
handle,
SCRSDK::CrFTPJobControlType_Suspend,
&jobIdList,
susCount);
Example:
// Delete finished jobs
CrInt32u jobIdList[SCRSDK::CrFTPJOBLIST_MAX] = { 0 };
for (CrInt32u i = 0; i < ctrlJobList.size(); ++i) {
jobIdList[i] = ctrlJobList[i]->jobId;
}
CrError ret = SCRSDK::ControlFTPJobList(
handle,
SCRSDK::CrFTPJobControlType_Delete,
&jobIdList,
ctrlJobList.size(),
SCRSDK::CrFTPJobDeleteType_FinishedAll);