觉得没什么比代码更清楚了。直接“翠花,上代码”.
int VideoPublisher_T::publishVideo(long lw,long lh,ACE_UINT8 * dibData, long size)
{
ACE_UINT8* jpgImageData = 0;
long jpgImageDataSize = 0;
CxImage image;
Video::FrameDataWriter_var dw =
Video::FrameDataWriter::_narrow(this->dataWriter_.in());
if (CORBA::is_nil(dw.in()))
{
ACE_ERROR_RETURN((LM_ERROR,"(%t|%T) narrow frame data writer/n"),-1);
}
// bytes alignment
ACE_UINT32 bytesPerLine = 4 * ((lw * 24 + 31)/32);
// Convert original RGB data to Image
image.CreateFromArray(
(unsigned char *)dibData,
lw,
lh,
24,
bytesPerLine,
false);
image.Encode(jpgImageData,jpgImageDataSize,CXIMAGE_FORMAT_JPG);
image.SetJpegQuality(24);
Video::Frame frame;
frame.frameId = 0;
frame.timestamp = ::getTimestamp();
frame.deviceId = OPTIONS::instance()->getDeviceId();
frame.type = Video::IT_JPG;
frame.deviceInfo = CORBA::string_dup(this->statMsg_);
frame.image.length(jpgImageDataSize);
ACE_OS::memcpy(frame.image.get_buffer(),(const void*)jpgImageData,jpgImageDataSize);
image.FreeMemory(jpgImageData);
DDS::ReturnCode_t ret = dw->write(frame, DDS::HANDLE_NIL);
if (ret != DDS::RETCODE_OK)
{
ACE_ERROR_RETURN((LM_ERROR,"(%t|%T) data writer/n"),-1);
}
return 0;
}