|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if (defined(x64) || defined(__LP64__))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Toonz includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tfilepath.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "timageinfo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsound.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//tipc includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tipc.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "t32bitsrv_wrap.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qsharedmemory></qsharedmemory>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmutexlocker></qmutexlocker>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdatastream></qdatastream>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tiio_3gp_proxy.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
For a list of supported commands through the 32-bit background server,
|
|
Toshihiro Shimizu |
890ddd |
see the related "t32libserver" project.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Generic stuff implementation
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*NOT PRESENT: Inherits the MOV stuff*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TImageWriter3gp Proxy implementation
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TImageWriter3gpProxy : public TImageWriter
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter3gp *m_lw;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
int m_frameIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TImageWriter3gpProxy(const TFilePath &fp, int frameIndex, TLevelWriter3gp *lw);
|
|
Toshihiro Shimizu |
890ddd |
~TImageWriter3gpProxy();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool is64bitOutputSupported() { return false; }
|
|
Toshihiro Shimizu |
890ddd |
void save(const TImageP &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
//not implemented
|
|
Toshihiro Shimizu |
890ddd |
TImageWriter3gpProxy(const TImageWriter3gpProxy &);
|
|
Toshihiro Shimizu |
890ddd |
TImageWriter3gpProxy &operator=(const TImageWriter3gpProxy &src);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageWriter3gpProxy::TImageWriter3gpProxy(const TFilePath &fp, int frameIndex, TLevelWriter3gp *lw)
|
|
Toshihiro Shimizu |
890ddd |
: TImageWriter(fp), m_lw(lw), m_frameIndex(frameIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_lw->addRef();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageWriter3gpProxy::~TImageWriter3gpProxy()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_lw->release();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TImageWriter3gpProxy::save(const TImageP &img)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_lw->save(img, m_frameIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TLevelWriter3gp Proxy implementation
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter3gp::TLevelWriter3gp(const TFilePath &path, TPropertyGroup *winfo)
|
|
Toshihiro Shimizu |
890ddd |
: TLevelWriter(path, winfo)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static TAtomicVar count;
|
|
Toshihiro Shimizu |
890ddd |
unsigned int currCount = ++count;
|
|
Toshihiro Shimizu |
890ddd |
m_id = currCount;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString res, propsFp;
|
|
Toshihiro Shimizu |
890ddd |
if (winfo) {
|
|
Toshihiro Shimizu |
890ddd |
//Request a temporary file to store the infos to
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$tmpfile_request") << QString("initLW3") + QString::number(currCount));
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
goto err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg >> propsFp >> tipc::clr;
|
|
Toshihiro Shimizu |
890ddd |
assert(!propsFp.isEmpty());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath propsTfp(propsFp.toStdWString());
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TOStream os(propsTfp);
|
|
Toshihiro Shimizu |
890ddd |
winfo->saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Pass fp to the server
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$initLW3gp") << m_id << QString::fromStdWString(path.getWideString()) << propsFp);
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
goto err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (winfo) {
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << tipc::clr << QString("$tmpfile_release")
|
|
Toshihiro Shimizu |
890ddd |
<< QString("initLW3gp") + QString::number(currCount));
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
goto err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
err:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Unable to write file");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter3gp::~TLevelWriter3gp()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
QString res;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$closeLW3gp") << m_id);
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Unable to write file");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TLevelWriter3gp::setFrameRate(double fps)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TLevelWriter::setFrameRate(fps);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
QString res;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$LW3gpSetFrameRate") << m_id << fps);
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Unexpected error");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageWriterP TLevelWriter3gp::getFrameWriter(TFrameId fid)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (fid.getLetter() != 0)
|
|
Toshihiro Shimizu |
890ddd |
return TImageWriterP(0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int index = fid.getNumber() - 1;
|
|
Toshihiro Shimizu |
890ddd |
return new TImageWriter3gpProxy(m_path, index, this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TLevelWriter3gp::save(const TImageP &img, int frameIndex)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP ri(img);
|
|
Toshihiro Shimizu |
890ddd |
if (!img)
|
|
Toshihiro Shimizu |
890ddd |
throw TImageException(getFilePath(), "Unsupported image type");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterP ras(ri->getRaster());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int lx = ras->getLx(), ly = ras->getLy(), pixSize = ras->getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
if (pixSize != 4)
|
|
Toshihiro Shimizu |
890ddd |
throw TImageException(getFilePath(), "Unsupported pixel type");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int size = lx * ly * pixSize;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Send messages
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Send the write message.
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$LW3gpImageWrite") << m_id << frameIndex << lx << ly);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Send the data through a shared memory segment
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
t32bitsrv::RasterExchanger<tpixel32> exch(ras);</tpixel32>
|
|
Toshihiro Shimizu |
890ddd |
tipc::writeShMemBuffer(stream, msg << tipc::clr, size, &exch);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
throw TImageException(getFilePath(), "Couln't save image");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TLevelWriter3gp::saveSoundTrack(TSoundTrack *st)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (st == 0)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Prepare connection
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
unsigned int size = st->getSampleSize() * st->getSampleCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Send the saveSoundTract command to the server
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$LW3gpSaveSoundTrack") << m_id << st->getSampleRate() << st->getBitPerSample()
|
|
Toshihiro Shimizu |
890ddd |
<< st->getChannelCount() << st->getSampleCount() << st->getFormat().m_signedSample);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
t32bitsrv::BufferExchanger exch((UCHAR *)st->getRawData());
|
|
Toshihiro Shimizu |
890ddd |
tipc::writeShMemBuffer(stream, msg << tipc::clr, size, &exch);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString res(tipc::readMessage(stream, msg));
|
|
Toshihiro Shimizu |
890ddd |
assert(res == "ok");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TImageReaderMov Proxy implementation
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TImageReader3gpProxy : public TImageReader
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader3gp *m_lr;
|
|
Toshihiro Shimizu |
890ddd |
TImageInfo *m_info;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
int m_frameIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TImageReader3gpProxy(const TFilePath &fp, int frameIndex, TLevelReader3gp *lr, TImageInfo *info);
|
|
Toshihiro Shimizu |
890ddd |
~TImageReader3gpProxy() { m_lr->release(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP load();
|
|
Toshihiro Shimizu |
890ddd |
void load(const TRasterP &rasP, const TPoint &pos = TPoint(0, 0), int shrinkX = 1, int shrinkY = 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimension getSize() const { return m_lr->getSize(); }
|
|
Toshihiro Shimizu |
890ddd |
TRect getBBox() const { return m_lr->getBBox(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TImageInfo *getImageInfo() const { return m_info; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
//not implemented
|
|
Toshihiro Shimizu |
890ddd |
TImageReader3gpProxy(const TImageReader3gpProxy &);
|
|
Toshihiro Shimizu |
890ddd |
TImageReader3gpProxy &operator=(const TImageReader3gpProxy &src);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageReader3gpProxy::TImageReader3gpProxy(const TFilePath &fp, int frameIndex,
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader3gp *lr, TImageInfo *info)
|
|
Toshihiro Shimizu |
890ddd |
: TImageReader(fp), m_lr(lr), m_frameIndex(frameIndex), m_info(info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_lr->addRef();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageP TImageReader3gpProxy::load()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P ras(m_lr->getSize());
|
|
Toshihiro Shimizu |
890ddd |
m_lr->load(ras, m_frameIndex, TPointI(), 1, 1);
|
|
Toshihiro Shimizu |
890ddd |
return TRasterImageP(ras);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TImageReader3gpProxy::load(const TRasterP &rasP, const TPoint &pos, int shrinkX, int shrinkY)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//NOTE: The original implementation is different. But is also does not make sense...
|
|
Toshihiro Shimizu |
890ddd |
//I've substituted it with the lrm plain call.
|
|
Toshihiro Shimizu |
890ddd |
m_lr->load(rasP, m_frameIndex, pos, shrinkX, shrinkY);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TLevelReader3gp Proxy implementation
|
|
Toshihiro Shimizu |
890ddd |
//******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader3gp::TLevelReader3gp(const TFilePath &path)
|
|
Toshihiro Shimizu |
890ddd |
: TLevelReader(path)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static TAtomicVar count;
|
|
Toshihiro Shimizu |
890ddd |
unsigned int currCount = ++count;
|
|
Toshihiro Shimizu |
890ddd |
m_id = currCount;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$initLR3gp") << m_id << QString::fromStdWString(path.getWideString()));
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
throw TImageException(path, "Couldn't open file");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double frameRate;
|
|
Toshihiro Shimizu |
890ddd |
msg >> m_lx >> m_ly >> frameRate >> tipc::clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_info = new TImageInfo;
|
|
Toshihiro Shimizu |
890ddd |
m_info->m_lx = m_lx;
|
|
Toshihiro Shimizu |
890ddd |
m_info->m_ly = m_ly;
|
|
Toshihiro Shimizu |
890ddd |
m_info->m_frameRate = frameRate;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelReader3gp::~TLevelReader3gp()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$closeLR3gp") << m_id);
|
|
Toshihiro Shimizu |
890ddd |
QString res(tipc::readMessage(stream, msg));
|
|
Toshihiro Shimizu |
890ddd |
assert(res == "ok");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TImageReaderP TLevelReader3gp::getFrameReader(TFrameId fid)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (fid.getLetter() != 0)
|
|
Toshihiro Shimizu |
890ddd |
return TImageReaderP(0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int index = fid.getNumber() - 1;
|
|
Toshihiro Shimizu |
890ddd |
return new TImageReader3gpProxy(m_path, index, this, m_info);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelP TLevelReader3gp::loadInfo()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TLevelP level;
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString shMemId(tipc::uniqueId());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Send the appropriate command
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$LR3gpLoadInfo") << m_id << shMemId);
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
goto err;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int frameCount;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg >> frameCount >> tipc::clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Read the data in the shared memory segment
|
|
Toshihiro Shimizu |
890ddd |
QSharedMemory shmem(shMemId);
|
|
Toshihiro Shimizu |
890ddd |
shmem.attach();
|
|
Toshihiro Shimizu |
890ddd |
shmem.lock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int *f, *fBegin = (int *)shmem.data(), *fEnd = fBegin + frameCount;
|
|
Toshihiro Shimizu |
890ddd |
assert(fBegin);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (f = fBegin; f < fEnd; ++f)
|
|
Toshihiro Shimizu |
890ddd |
level->setFrame(*f, TImageP());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
shmem.unlock();
|
|
Toshihiro Shimizu |
890ddd |
shmem.detach();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Release the shared memory segment
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$shmem_release") << shMemId);
|
|
Toshihiro Shimizu |
890ddd |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Toshihiro Shimizu |
890ddd |
goto err;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return level;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
err:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Couldn't read movie data");
|
|
Toshihiro Shimizu |
890ddd |
return TLevelP();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TLevelReader3gp::enableRandomAccessRead(bool enable)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$LR3gpEnableRandomAccessRead") << m_id << QString(enable ? "true" : "false"));
|
|
Toshihiro Shimizu |
890ddd |
QString res(tipc::readMessage(stream, msg));
|
|
Toshihiro Shimizu |
890ddd |
assert(res == "ok");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TLevelReader3gp::load(const TRasterP &ras, int frameIndex, const TPoint &pos,
|
|
Toshihiro Shimizu |
890ddd |
int shrinkX, int shrinkY)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLocalSocket socket;
|
|
Toshihiro Shimizu |
890ddd |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
tipc::Stream stream(&socket);
|
|
Toshihiro Shimizu |
890ddd |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
unsigned int size = ras->getLx() * ras->getLy() * ras->getPixelSize();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Send the appropriate command to the 32-bit server
|
|
Toshihiro Shimizu |
890ddd |
stream << (msg << QString("$LR3gpImageRead") << m_id << ras->getLx() << ras->getLy() << ras->getPixelSize()
|
|
Toshihiro Shimizu |
890ddd |
<< frameIndex << pos.x << pos.y << shrinkX << shrinkY);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
t32bitsrv::RasterExchanger<tpixel32> exch(ras);</tpixel32>
|
|
Toshihiro Shimizu |
890ddd |
if (!tipc::readShMemBuffer(stream, msg << tipc::clr, &exch))
|
|
Toshihiro Shimizu |
890ddd |
throw TException("Couldn't load image");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif //x64
|