Hi,
My code now compile, but I have some warnings.
The first warning error I have is the following:
//--------
warning C4244: 'argument' : conversion from 'const std::allocator<_Ty>::value
_type' to 'char', possible loss of data
//------
The seconde warning I have in the same code is the following
//----------------
warning C4244: 'argument' : conversion from 'std::ctype<wchar_t>::_Ele
m' to 'char', possible loss of data
//----------------
The line incriminated is the following for the two warnings
ret += char_facet.widen(*it);
The line incriminated is between two lines like this //------------------------
----------
----------
-----
here's the whole code
//******************** BEGINNING OF THE CODE
#include "stdafx.h"
#include "cTimeCode.h"
#include "cEdlData.h"
#include "cToken.h"
#include "cLine.h"
#include "cEdl.h"
#include "cAafEdl.h"
#include "cCut.h"
#include "cDisolve.h"
#include "cWipe.h"
//#include "cEvent.h"
string narrow(const wstring & str) throw()
{
const ctype<wchar_t>& char_facet = _USE(locale(),ctype<wchar_
t>);
string ret;
ret.reserve(str.size());//
avoid incremental allocation
for(wstring::const_iterato
r it = str.begin(); it != str.end(); ++it)
{
//------------------------
----------
----------
---------
ret += char_facet.widen(*it);
//------------------------
----------
----------
--------
}
return ret;
}
cUnknownPtr<IAAFDataDef> cAafEdl::getDataDef(int track)
{
if(!track)return pPictureDataDef;
return pSoundDataDef;
}
void cAafEdl::initAaf()
{
cUnknownPtr<IAAFPluginMana
ger> pPluginMgr;
checkResult(AAFGetPluginMa
nager(&pPl
uginMgr));
checkResult(pPluginMgr->Re
gisterShar
edPlugins(
));
}
void cAafEdl::createAafFile(wst
ring filename)
{
wifstream test;
test.open(narrow(filename)
.c_str());
if(!test.fail())
{
throw AAFRESULT_FILE_EXISTS;
}
aafProductVersion_t version;
version.major = 1;
version.minor = 0;
version.tertiary = 0;
version.patchLevel = 0;
version.type = kAAFVersionDebug;
aafProductIdentification_t
ident;
ident.companyName = L"AAF example";
ident.productName = L"edlaaf";
ident.productVersionString
= L"1.0.0.0";
ident.productID.Data1 = 0x9438acfd;
ident.productID.Data2 = 0xd233;
ident.productID.Data3 = 0x41b0;
ident.productID.Data4[0] = 0x8a;
ident.productID.Data4[1] = 0x89;
ident.productID.Data4[2] = 0xb4;
ident.productID.Data4[3] = 0x48;
ident.productID.Data4[4] = 0x75;
ident.productID.Data4[5] = 0xdc;
ident.productID.Data4[6] = 0x48;
ident.productID.Data4[7] = 0x4;
ident.platform = L"MS Windows 2000";
ident.productVersion = &version;
// Open the file
checkResult(AAFFileOpenNew
Modify(fil
ename.c_st
r(), 0, &ident, &pFile));
// We can't really do anthing in AAF without the header.
checkResult(pFile->GetHead
er(&pHeade
r));
//The dictionary has information about the type of data that is in the file.
checkResult(pFile->GetDict
ionary(&pD
ictionary)
);
assert(pFile && pHeader && pDictionary);
}
cTimeCode getTimeCode(aafRational_t rate,bool dropFrame)
{
div_t d = div(rate.numerator,rate.de
nominator)
;
if(d.rem != 0) ++d.quot;
return cTimeCode(0,(eFps)d.quot,d
ropFrame);
}
void cAafEdl::saveEssence()
{
cUnknownPtr<IAAFEssenceDes
criptor> pEssenceDescriptor;
// save cassettes with tapeDescriptors
for(tCassIt cass = cassettes.begin(); cass != cassettes.end(); ++cass)
{
wstring cassName = cass->first;
aafRational_t rate = cass->second->Rate;
bool dropframe = cass->second->DropFrame;
if((L"BL" != cassName) && (L"BLK" != cassName) && (L"AX" != cassName)) //do not store blank as a master mob
{
cUnknownPtr<IAAFTapeDescri
ptor> pTapeDescriptor;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFTapeDesc
riptor,IID
_IAAFTapeD
escriptor,
(IUnknown **)&pTapeDescriptor));
// Objects must ALWAYS be initialised before use.
pTapeDescriptor->Initializ
e();
pTapeDescriptor.demandQI(I
ID_IAAFEss
enceDescri
ptor, (void **)&pEssenceDescriptor);
// create mobs
cTimeCode tc = getTimeCode(rate,dropframe
);
cTimeCode in = cTimeCode(0, tc.fps(), tc.isDropFrame()); // assume tape starts at midnight
cTimeCode out = cTimeCode(tc.getFramesPerD
ay()-1, tc.fps(), tc.isDropFrame()); // assume tape is 24 hours long
createEssenceMobs(cassName
, cassName, rate, dropframe, in, out, pEssenceDescriptor); // name mobs from tape name
}
}
}
void cAafEdl::createEssenceMobs
(wstring mobName, wstring cassName, aafRational_t rate, bool dropFrame, cTimeCode in, cTimeCode out, cUnknownPtr<IAAFEssenceDes
criptor> pEssenceDescriptor,bool V,const bool* pA)
{
// Get a Master MOB Interface
cUnknownPtr<IAAFMasterMob>
pMasterMob;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFMasterMo
b,IID_IAAF
MasterMob,
(IUnknown **)&pMasterMob));
//Objects must ALWAYS be initialised before use.
checkResult(pMasterMob->In
itialize()
);
// Get a Mob interface and set its variables.
cUnknownPtr<IAAFMob> pMobMast;
pMasterMob.demandQI(IID_IA
AFMob, (void **)&pMobMast);
// Set the master mob name
checkResult(pMobMast->SetN
ame(mobNam
e.c_str())
);
// Add it to the file
checkResult(pHeader->AddMo
b(pMobMast
));
// Get a Source MOB Interface
cUnknownPtr<IAAFSourceMob>
pSourceMob;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFSourceMo
b,IID_IAAF
SourceMob,
(IUnknown **)&pSourceMob));
//Objects must ALWAYS be initialised before use.
checkResult(pSourceMob->In
itialize()
);
// Get a Mob interface and set its variables.
cUnknownPtr<IAAFMob> pMobSrc;
pSourceMob.demandQI(IID_IA
AFMob, (void **)&pMobSrc);
// Set the master mob name
checkResult(pMobSrc->SetNa
me(mobName
.c_str()))
;
checkResult(pSourceMob->Se
tEssenceDe
scriptor(p
EssenceDes
criptor));
// Add it to the file
checkResult(pHeader->AddMo
b(pMobSrc)
);
saveEssenceVA(rate,in,out,
pSourceMob
,pMobSrc,p
MasterMob,
pMobMast);
saveEssenceTC(rate,dropFra
me,in,out,
pSourceMob
,pMobSrc);
bool channels[1+NUM_AUDIO_CHANN
ELS];
channels[0] = V;
for(int i = 0; i < NUM_AUDIO_CHANNELS; ++i)
{
channels[1+i] = pA?pA[i]:true;
}
tMobLookup::value_type val(cassName, pMobMast);
cassetteToMasterMob.insert
(val);
}
void cAafEdl::saveEssenceVA(aaf
Rational_t
rate, cTimeCode In, cTimeCode Out, cUnknownPtr<IAAFSourceMob>
pSourceMob, cUnknownPtr<IAAFMob> pMobSrc, cUnknownPtr<IAAFMasterMob>
pMasterMob, cUnknownPtr<IAAFMob> pMobMast)
{
for(unsigned long int channel = 0; channel <= NUM_AUDIO_CHANNELS; ++channel)
{
//even though alot of these numbers mathematically are related, they have separate semantics.
aafSlotID_t sourceSlotID = channel+1;
aafSlotID_t masterSlotID = sourceSlotID;
aafUInt32 physicalNum = channel; // count up from 1 for each slot type
if(0==channel) physicalNum = 1;
cUnknownPtr<IAAFTimelineMo
bSlot> pTimelineMobSlot;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFTimeline
MobSlot,II
D_IAAFTime
lineMobSlo
t,(IUnknow
n **)&pTimelineMobSlot));
//Objects must ALWAYS be initialised before use.
checkResult(pTimelineMobSl
ot->Initia
lize());
checkResult(pTimelineMobSl
ot->SetEdi
tRate(rate
));
checkResult(pTimelineMobSl
ot->SetOri
gin(0));
cUnknownPtr<IAAFSourceClip
> pSourceClip;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFSourceCl
ip,IID_IAA
FSourceCli
p,(IUnknow
n **)&pSourceClip));
aafLength_t length = Out.framesSinceMidnight() - In.framesSinceMidnight();
aafSourceRef_t srcRef;
memset(&srcRef,0,sizeof(sr
cRef));//n
o predecesor - AAF spec. says null aafSourceRef_t for this.
//Objects must ALWAYS be initialised before use.
checkResult(pSourceClip->I
nitialize(
getDataDef
(channel),
length,src
Ref));
cUnknownPtr<IAAFSegment> pSegment;
pSourceClip.demandQI(IID_I
AAFSegment
, (void **)&pSegment);
cUnknownPtr<IAAFMobSlot> pMobSlot;
pTimelineMobSlot.demandQI(
IID_IAAFMo
bSlot, (void **)&pMobSlot);
checkResult(pMobSlot->SetS
egment(pSe
gment));
checkResult(pMobSlot->SetP
hysicalNum
(physicalN
um));
checkResult(pMobSlot->SetN
ame(L""));
checkResult(pMobSlot->SetS
lotID(sour
ceSlotID))
;
checkResult(pMobSrc->Appen
dSlot(pMob
Slot));
checkResult(pMasterMob->Ad
dMasterSlo
t(getDataD
ef(channel
),sourceSl
otID,pSour
ceMob,mast
erSlotID,L
""));
cUnknownPtr<IAAFMobSlot> pMastMobSlot;
checkResult(pMobMast->Look
upSlot(mas
terSlotID,
&pMastMobS
lot));
checkResult(pMastMobSlot->
SetPhysica
lNum(physi
calNum));
}
}
void cAafEdl::saveEssenceTC(aaf
Rational_t
rate, bool dropFrame, cTimeCode In, cTimeCode Out, cUnknownPtr<IAAFSourceMob>
pSourceMob, cUnknownPtr<IAAFMob> pMobSrc)
{
//even though alot of these numbers mathematically are related, they have separate semantics.
aafSlotID_t channel = NUM_AUDIO_CHANNELS+1;
aafSlotID_t sourceSlotID = channel+1;
aafSlotID_t masterSlotID = sourceSlotID;
aafUInt32 physicalNum = 1; // count up from 1 for each slot type
//add a timecode object
cUnknownPtr<IAAFTimelineMo
bSlot> pTimelineMobSlot;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFTimeline
MobSlot,II
D_IAAFTime
lineMobSlo
t,(IUnknow
n **)&pTimelineMobSlot));
//Objects must ALWAYS be initialised before use.
checkResult(pTimelineMobSl
ot->Initia
lize());
checkResult(pTimelineMobSl
ot->SetEdi
tRate(rate
));
checkResult(pTimelineMobSl
ot->SetOri
gin(0));
cUnknownPtr<IAAFMobSlot> pMobSlot;
pTimelineMobSlot.demandQI(
IID_IAAFMo
bSlot, (void **)&pMobSlot);
cUnknownPtr<IAAFTimecode> pTimecode;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFTimecode
,IID_IAAFT
imecode,(I
Unknown **)&pTimecode));
//Objects must ALWAYS be initialised before use.
aafLength_t length = Out.framesSinceMidnight() - In.framesSinceMidnight();
cTimeCode timecode = getTimeCode(rate,dropFrame
);
aafTimecode_t tc;
tc.startFrame = In.framesSinceMidnight();
tc.drop = timecode.isDropFrame()?1:0
;
tc.fps = timecode.fps();
checkResult(pTimecode->Ini
tialize(le
ngth,&tc))
;
cUnknownPtr<IAAFSegment> pSegment;
pTimecode.demandQI(IID_IAA
FSegment, (void **)&pSegment);
checkResult(pMobSlot->SetS
egment(pSe
gment));
checkResult(pMobSlot->SetP
hysicalNum
(physicalN
um));
checkResult(pMobSlot->SetN
ame(L""));
checkResult(pMobSlot->SetS
lotID(sour
ceSlotID))
;
checkResult(pMobSrc->Appen
dSlot(pMob
Slot));
}
void cAafEdl::removeZeroLengthC
uts()
{
// first dissolve/wipe cannot appear before 3rd line of edl if unwanted zero length cut is present
{
for(cTimelineTrack::tList:
:iterator it = Video.Segments.begin(); it != Video.Segments.end(); ++it)
{
cTimelineTrack::tList::ite
rator next = it;
++next;
if(next != Video.Segments.end())
{
cTimelineTrack::tList::ite
rator nextnext = next;
++nextnext;
if(nextnext != Video.Segments.end())
{
bool removeElem;
removeElem = (*nextnext)->removeZeroLen
gthCut(*it
,*next);
if (removeElem) Video.Segments.erase(next)
;
}
}
}
}
for(int i = 0; i < NUM_AUDIO_CHANNELS; ++i)
{
for(cTimelineTrack::tList:
:iterator it = Audio[i].Segments.begin();
it != Audio[i].Segments.end(); ++it)
{
cTimelineTrack::tList::ite
rator next = it;
++next;
if(next != Audio[i].Segments.end())
{
cTimelineTrack::tList::ite
rator nextnext = next;
++nextnext;
if(nextnext != Audio[i].Segments.end())
{
bool removeElem;
removeElem = (*nextnext)->removeZeroLen
gthCut(*it
,*next);
if (removeElem) Audio[i].Segments.erase(ne
xt);
}
}
}
}
}
void cAafEdl::adjustComposition
()
{
// extend tail of segment before transition
{
for(cTimelineTrack::tList:
:iterator it = Video.Segments.begin(); it != Video.Segments.end(); ++it)
{
cTimelineTrack::tList::ite
rator next = it;
++next;
if(next != Video.Segments.end())
{
(*next)->adjust(*it,false)
;
}
}
}
for(int i = 0; i < NUM_AUDIO_CHANNELS; ++i)
{
for(cTimelineTrack::tList:
:iterator it = Audio[i].Segments.begin();
it != Audio[i].Segments.end(); ++it)
{
cTimelineTrack::tList::ite
rator next = it;
++next;
if(next != Audio[i].Segments.end())
{
(*next)->adjust(*it,true);
}
}
}
}
void cAafEdl::saveComposition()
{
// Get a Master MOB Interface
cUnknownPtr<IAAFCompositio
nMob> pCompositionMob;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFComposit
ionMob,IID
_IAAFCompo
sitionMob,
(IUnknown **)&pCompositionMob));
//Objects must ALWAYS be initialised before use.
checkResult(pCompositionMo
b->Initial
ize(Title.
c_str()));
//EDL title becomes the compositions title
// Get a Mob interface and set its variables.
cUnknownPtr<IAAFMob> pMobComp;
pCompositionMob.demandQI(I
ID_IAAFMob
, (void **)&pMobComp);
// Add it to the file
checkResult(pHeader->AddMo
b(pMobComp
));
aafRational_t rate = getFrameRate();
saveCompositionVA(pMobComp
, rate);
saveCompositionTC(pMobComp
, rate);
saveCompositionComments(pM
obComp, rate);
}
void cAafEdl::saveCompositionVA
(cUnknownP
tr<IAAFMob
> pMobComp, aafRational_t rate)
{
for(aafSlotID_t channel = 0; channel <= NUM_AUDIO_CHANNELS; ++channel)
{
//even though alot of these numbers mathematically are related, they have separate semantics.
aafSlotID_t compositionSlotID = channel + 1;
aafSlotID_t masterSlotID = compositionSlotID;
aafUInt32 physicalNum = channel; // count up from 1 for each slot type
if(0==channel) physicalNum = 1;
cUnknownPtr<IAAFSequence> pSequence;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFSequence
,IID_IAAFS
equence,(I
Unknown **)&pSequence));
//Objects must ALWAYS be initialised before use.
checkResult(pSequence->Ini
tialize(ge
tDataDef(c
hannel)));
cTimelineTrack* pTrack = 0;
if(0==channel) pTrack = &Video;
else pTrack = &Audio[channel-1];
if (pTrack->Segments.empty())
{
aafRational_t speedRatio = {1000, 1000};
cSegment::Ptr dummySeg = new cCut;
dummySeg->set(0,L"",cTimeC
ode(),Time
lineDestIn
,TimelineD
estOut,spe
edRatio);
dummySeg->createFiller(pDi
ctionary,g
etDataDef(
channel),p
Sequence);
delete dummySeg;
dummySeg = 0;
}
else
{
for(cTimelineTrack::tList:
:iterator it = pTrack->Segments.begin(); it != pTrack->Segments.end(); ++it)
{
cSegment::Ptr seg = *it;
if(L"BL" == seg->cassette() || L"BLK" == seg->cassette() || L"AX" == seg->cassette())
{
seg->createFiller(pDiction
ary,getDat
aDef(chann
el),pSeque
nce);
}
else
{
tMobLookup::iterator mob = cassetteToMasterMob.find(s
eg->casset
te());
assert(mob != cassetteToMasterMob.end())
;
seg->createComponent(mob->
second,mas
terSlotID,
pDictionar
y,getDataD
ef(channel
),pSequenc
e);
}
}
}
cUnknownPtr<IAAFSegment> pSegment;
pSequence.demandQI(IID_IAA
FSegment, (void **)&pSegment);
cUnknownPtr<IAAFTimelineMo
bSlot> pTimelineMobSlot;
checkResult(pMobComp->Appe
ndNewTimel
ineSlot(ra
te,pSegmen
t,composit
ionSlotID,
L"",0,&pTi
melineMobS
lot));
cUnknownPtr<IAAFMobSlot> pMobSlot;
pTimelineMobSlot.demandQI(
IID_IAAFMo
bSlot, (void **)&pMobSlot);
checkResult(pMobSlot->SetP
hysicalNum
(physicalN
um));
}
}
void cAafEdl::saveCompositionTC
(cUnknownP
tr<IAAFMob
> pMobComp, aafRational_t rate)
{
if(TimelineDestIn != TimelineDestOut) // add the destination timecode track
{
//even though alot of these numbers mathematically are related, they have separate semantics.
aafSlotID_t channel = NUM_AUDIO_CHANNELS + 1;
aafSlotID_t compositionSlotID = channel + 1;
aafUInt32 physicalNum = 1; // count up from 1 for each slot type
cUnknownPtr<IAAFTimecode> pTimecode;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFTimecode
,IID_IAAFT
imecode,(I
Unknown **)&pTimecode));
aafTimecode_t tc;
tc.startFrame = TimelineDestIn.framesSince
Midnight()
;
tc.fps = (aafUInt16)TimelineDestIn.
fps();
tc.drop = TimelineDestIn.isDropFrame
() ? 1 : 0;
checkResult(pTimecode->Ini
tialize(Ti
melineDest
Out.frames
SinceMidni
ght() - TimelineDestIn.framesSince
Midnight()
,&tc));
cUnknownPtr<IAAFSegment> pSegment;
pTimecode.demandQI(IID_IAA
FSegment, (void **)&pSegment);
cUnknownPtr<IAAFTimelineMo
bSlot> pTimelineMobSlot;
checkResult(pMobComp->Appe
ndNewTimel
ineSlot(ra
te,pSegmen
t,composit
ionSlotID,
L"Timecode
",0,&pTime
lineMobSlo
t));
cUnknownPtr<IAAFMobSlot> pMobSlot;
pTimelineMobSlot.demandQI(
IID_IAAFMo
bSlot, (void **)&pMobSlot);
checkResult(pMobSlot->SetP
hysicalNum
(physicalN
um));
}
}
void cAafEdl::saveCompositionCo
mments(cUn
knownPtr<I
AAFMob> pMobComp, aafRational_t rate)
{
if (CommentTrack.Events.size(
) > 0) // add comments
{
aafSlotID_t channel = NUM_AUDIO_CHANNELS + 2;
aafSlotID_t compositionSlotID = channel + 1;
aafUInt32 physicalNum = 1; // count up from 1 for each slot type
cUnknownPtr<IAAFSequence> pSequence;
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFSequence
,IID_IAAFS
equence,(I
Unknown **)&pSequence));
//Objects must ALWAYS be initialised before use.
checkResult(pSequence->Ini
tialize(pP
ictureData
Def));
std::greater<cEvent::Ptr> sortOrder;
CommentTrack.Events.sort(s
ortOrder);
//events MUST be sorted on timecode otherwise AAF SDK asserts.
for(cEventTrack::tList::it
erator it = CommentTrack.Events.begin(
); it != CommentTrack.Events.end();
++it)
{
cEvent::Ptr event = *it;
event->createComment(pDict
ionary,pPi
ctureDataD
ef,pSequen
ce);
}
cUnknownPtr<IAAFSegment> pSegment;
pSequence.demandQI(IID_IAA
FSegment, (void **)&pSegment);
cUnknownPtr<IAAFEventMobSl
ot> pEventMobSlot; // no initialise ???
checkResult(pDictionary->C
reateInsta
nce(AUID_A
AFEventMob
Slot,IID_I
AAFEventMo
bSlot,(IUn
known **)&pEventMobSlot));
checkResult(pEventMobSlot-
>SetEditRa
te(&rate))
;
cUnknownPtr<IAAFMobSlot> pMobSlot;
pEventMobSlot.demandQI(IID
_IAAFMobSl
ot, (void **)&pMobSlot);
checkResult(pMobSlot->SetN
ame(L"Comm
ents"));
checkResult(pMobSlot->SetP
hysicalNum
(physicalN
um));
checkResult(pMobSlot->SetS
lotID(comp
ositionSlo
tID));
checkResult(pMobSlot->SetS
egment(pSe
gment));
checkResult(pMobComp->Appe
ndSlot(pMo
bSlot));
}
}
void cAafEdl::closeFile()
{
checkResult(pFile->Save())
;
checkResult(pFile->Close()
);
}
void cAafEdl::createAaf(wstring
filename)
{
createAafFile(filename);
checkResult(pDictionary->L
ookupDataD
ef(DDEF_Pi
cture,&pPi
ctureDataD
ef));
checkResult(pDictionary->L
ookupDataD
ef(DDEF_So
und,&pSoun
dDataDef))
;
checkResult(pDictionary->L
ookupDataD
ef(DDEF_Ti
mecode,&pT
imecodeDat
aDef));
saveEssence();
removeZeroLengthCuts();
adjustComposition();
saveComposition();
closeFile();
}
//******************** END OF THE CODE
ANY CLUES???
Thanks in advance...
Start Free Trial