1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
|
/*
* recordQT.cpp
* GEM_darwin
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "recordQT.h"
#include "plugins/PluginFactory.h"
#include "Gem/Exception.h"
#include "Gem/RTE.h"
#include "Utils/wstring.h"
using namespace gem::plugins;
#ifdef __APPLE__
# include <sys/types.h>
# include <unistd.h>
# include <fcntl.h>
#elif defined _WIN32
//apparently on OSX there is no member portPixMap in a GWorld so a function is used instead
# define GetPortPixMap(x) (x)->portPixMap
#endif
#ifdef _MSC_VER /* This is only for Microsoft's compiler, not cygwin, e.g. */
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#endif
#include <stdio.h>
/* for post() and error() */
#include "Gem/RTE.h"
static char* FourCC2Str(int code, char*char5) {
char5[0] = (code >> 24) & 0xFF;
char5[1] = (code >> 16) & 0xFF;
char5[2] = (code >> 8) & 0xFF;
char5[3] = (code >> 0) & 0xFF;
char5[4] = 0;
return char5;
}
static bool touch(const std::string&filename)
{
#ifdef __APPLE__
int fd;
fd = open(filename.c_str(), O_CREAT | O_RDWR, 0600);
if (fd < 0) {
return false;
}
write(fd, " ", 1);
close(fd);
return true;
#elif defined _WIN32
FILE*outfile=fopen(filename.c_str(), "");
if(NULL==outfile) {
return false;
}
fclose(outfile);
return true;
#endif
return false;
}
REGISTER_RECORDFACTORY("QT", recordQT);
/////////////////////////////////////////////////////////
//
// recordQT
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
recordQT :: recordQT(void)
: m_recordSetup(false)
, m_recordStart(false)
, m_recordStop(false)
, m_width(-1), m_height(-1)
, m_prevWidth(0), m_prevHeight(0)
, m_compressImage(NULL)
, seconds(0.f)
, m_ticks(20)
, m_firstRun(true)
, m_rowBytes(0)
, dataSize(0)
, m_depth(0)
, m_frameRate(0), m_keyFrameRate(0)
, m_spatialQuality(codecNormalQuality)
, nFileRefNum(0), nResID(0)
{
static bool firsttime=true;
if(firsttime) {
OSErr err = noErr;
#ifdef _WIN32
// Initialize QuickTime Media Layer
if ((err = InitializeQTML(0))) {
throw(GemException("unable to initialize QuickTime"));
}
#endif // WINDOWS
// start QuickTime
if (err = EnterMovies()) {
throw(GemException("unable to initialize QuickTime/Movies"));
}
verbose(1, "[GEM:recordQT] QT init done");
firsttime=false;
}
//get list of codecs installed -- useful later
CodecNameSpecListPtr codecList;
CodecNameSpec codecName;
int i;
int count;
GetCodecNameList(&codecList,1);
count=codecList->count;
codecContainer.clear();
verbose(0, "[GEM:recordQT] %i codecs installed",codecList->count);
for (i = 0; i < count; i++) {
codecName = codecList->list[i];
std::string typeName = std::string((char*)codecName.typeName + 1, ((char*)codecName.typeName)[0]);
codecListStorage cod = {i, codecName.cType, typeName, codecName.codec};
codecContainer.push_back(cod);
}
//initialize member variables
stdComponent = NULL;
hImageDesc = NULL;
nResID = movieInDataForkResID;
m_codecType = kJPEGCodecType;
for(i = 0; i < count; i++) {
if (codecContainer[i].ctype == kJPEGCodecType) {
m_codec = codecContainer[i].codec;
verbose(1, "[GEM:recordQT] found pjpeg codec %i %lu %p ctype",
i, m_codecType, m_codec);
break;
}
}
stdComponent = OpenDefaultComponent(StandardCompressionType,
StandardCompressionSubType);
if (stdComponent == NULL) {
verbose(0, "[GEM:recordQT] failed to open compressor component");
}
}
////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
recordQT :: ~recordQT(void)
{
ComponentResult compErr = noErr;
if (stdComponent != NULL) {
compErr = CloseComponent(stdComponent);
if (compErr != noErr) {
verbose(0, "[GEM:recordQT] CloseComponent failed with error %ld", compErr);
}
}
}
////////////////////////////////////////////////////////
// Prepares QT for recording
//
/////////////////////////////////////////////////////////
void recordQT :: setupQT(
void) //this only needs to be done when codec info changes
{
FSSpec theFSSpec;
OSErr err = noErr;
FSRef ref;
OSType colorspace;
ComponentResult compErr = noErr;
m_recordSetup = false; //if it fails then there is no setup
//this mess should create and open a file for QT to use
//probably should be a separate function
if (m_filename.empty()) {
error("[GEM:recordQT] no filename passed");
return;
}
std::string filename = gem::string::utf8string_to_nativestring(m_filename);
if (!m_compressImage) {
error("[GEM:recordQT] no image to record");
return;
}
touch (filename);
#ifdef __APPLE__
do {
const UInt8*filename8=reinterpret_cast<const UInt8*>(filename.c_str());
err = ::FSPathMakeRef(filename8, &ref, NULL);
if (err) {
error("[GEM:recordQT] Unable to make file ref from filename %s",
m_filename.c_str());
return ;
}
err = FSGetCatalogInfo(&ref, kFSCatInfoNodeFlags, NULL, NULL, &theFSSpec,
NULL);
if (err != noErr) {
error("[GEM:recordQT] error#%d in FSGetCatalogInfo()", err);
return ;
}
err = FSMakeFSSpec(theFSSpec.vRefNum, theFSSpec.parID, filename8,
&theFSSpec);
if (err != noErr && err != -37) { /* -37: invalid filename (e.g. non-existant) */
error("[GEM:recordQT] error#%d in FSMakeFSSpec()", err);
return;
}
} while(0);
#elif defined _WIN32
do {
err = ::NativePathNameToFSSpec (const_cast<char*>(filename.c_str()), &theFSSpec, 0);
if (err != noErr && err != -37) {
error("[GEM:recordQT] error#%d in NativePathNameToFSSpec()", err);
return;
}
err = CreateMovieFile( &theFSSpec,
FOUR_CHAR_CODE('TVOD'),
smSystemScript,
createMovieFileDeleteCurFile |
createMovieFileDontCreateResFile,
&nFileRefNum,
&m_movie);
err = CloseMovieFile(nFileRefNum);
err = ::NativePathNameToFSSpec (const_cast<char*>(filename.c_str()), &theFSSpec, 0);
} while(0);
#endif /* OS */
//create the movie from the file
err = CreateMovieFile( &theFSSpec,
FOUR_CHAR_CODE('TVOD'),
smSystemScript,
createMovieFileDeleteCurFile |
createMovieFileDontCreateResFile,
&nFileRefNum,
&m_movie);
switch(err) {
case noErr:
break;
case -37:
error("[GEM:recordQT] invalid filename '%s'", m_filename.c_str());
return;
default:
error("[GEM:recordQT] CreateMovieFile failed with error %d",err);
return;
}
//give QT the dimensions of the image to compress
m_srcRect.top = 0;
m_srcRect.left = 0;
m_srcRect.bottom = m_height;
m_srcRect.right = m_width;
if (m_compressImage->format == GEM_YUV) {
verbose(0, "[GEM:recordQT] using YUV");
colorspace = k422YpCbCr8CodecType;
}
if (m_compressImage->format == GEM_RGBA) {
verbose(0, "[GEM:recordQT] using BGRA");
colorspace = k32ARGBPixelFormat;
}
#ifdef _WIN32
colorspace = k32RGBAPixelFormat;
#endif
char char5[5];
switch(colorspace) {
case k32ARGBPixelFormat:
case k32BGRAPixelFormat:
case k32RGBAPixelFormat:
m_rowBytes = m_width * 4;
break;
case k422YpCbCr8CodecType:
m_rowBytes = m_width * 2;
break;
default:
error("[GEM:recordQT] unknown colorspace '%s'", FourCC2Str(colorspace, char5));
m_rowBytes = m_width;
break;
}
//give QT the length of each pixel row in bytes (2 for 4:2:2 YUV)
err = QTNewGWorldFromPtr(&m_srcGWorld,
colorspace,
&m_srcRect,
NULL,
NULL,
0,
m_compressImage->data,
m_rowBytes);
if (err != noErr) {
error("[GEM:recordQT] QTNewGWorldFromPtr failed with error %d",err);
return;
}
SetMovieGWorld(m_movie,m_srcGWorld,GetGWorldDevice(m_srcGWorld));
#ifdef __APPLE__
//there is a discrepency between what is really upside down and not.
//since QT has flipped Y compared to GL it is upside down to GL but not to itself
//so while the upsidedown flag is set for QT images sent to GL it is not correct for pix_ processing.
//this is a hack on OSX since the native is YUV for pix_ and the only BGRA will usually be from pix_snap
if (m_compressImage->upsidedown && m_compressImage->format == GEM_RGBA) {
MatrixRecord aMatrix;
GetMovieMatrix(m_movie,&aMatrix);
verbose(1, "[GEM:recordQT] upside down");
ScaleMatrix(&aMatrix,Long2Fix(1),Long2Fix(-1),0,0);
SetMovieMatrix(m_movie,&aMatrix);
}
#elif defined _WIN32
MatrixRecord aMatrix;
GetMovieMatrix(m_movie,&aMatrix);
ScaleMatrix(&aMatrix,Long2Fix(1),Long2Fix(-1),0,0);
SetMovieMatrix(m_movie,&aMatrix);
#endif
track = NewMovieTrack(m_movie,FixRatio(m_srcRect.right, 1),
FixRatio(m_srcRect.bottom, 1),kNoVolume);
media = NewTrackMedia(track,VideoMediaType,600,nil,0);
SpatialSettings.codecType = m_codecType;
SpatialSettings.codec = m_codec;
SpatialSettings.depth = m_depth;
SpatialSettings.spatialQuality = m_spatialQuality;
TemporalSettings.temporalQuality = m_spatialQuality;
TemporalSettings.frameRate = m_frameRate;
TemporalSettings.keyFrameRate = m_keyFrameRate;
datarate.frameDuration = 33;
compErr = SCSetInfo(stdComponent, scTemporalSettingsType,
&TemporalSettings);
compErr = SCSetInfo(stdComponent, scSpatialSettingsType, &SpatialSettings);
compErr = SCSetInfo(stdComponent, scDataRateSettingsType, &datarate);
if (compErr != noErr) {
error("[GEM:recordQT] SCSetInfo failed with error#%ld", compErr);
}
compErr = SCCompressSequenceBegin(stdComponent,GetPortPixMap(m_srcGWorld),
&m_srcRect,&hImageDesc);
if (compErr != noErr) {
error("[GEM:recordQT] SCCompressSequenceBegin failed with error#%ld",
compErr);
return;
}
err = BeginMediaEdits(media);
if (err != noErr) {
error("[GEM:recordQT] BeginMediaEdits failed with error#%d",err);
return;
}
//this will show that everything is OK for recording
m_recordSetup = true;
//set the previous dimensions for the sanity check during compression
m_prevWidth = m_width;
m_prevHeight = m_height;
//reset frame counter for new movie file
}
//
// stops recording into the QT movie
//
void recordQT :: stop(void)
{
ComponentResult compErr = noErr;
OSErr err;
m_recordStart = false; //just to be sure
err = EndMediaEdits(media);
if (err != noErr) {
error("[GEM:recordQT] EndMediaEdits failed with error %d",err);
return; //no sense in crashing after this
}
err = InsertMediaIntoTrack(track,0,0,GetMediaDuration(media),0x00010000);
if (err != noErr) {
error("[GEM:recordQT] InsertMediaIntoTrack failed with error %d", err);
}
err = AddMovieResource(m_movie,nFileRefNum,&nResID,NULL);
if (err != noErr) {
error("[GEM:recordQT] AddMovieResource failed with error %d", err);
}
err = CloseMovieFile(nFileRefNum);
if (err != noErr) {
error("[GEM:recordQT] CloseMovieFile failed with error %d", err);
}
DisposeMovie(m_movie);
DisposeGWorld(m_srcGWorld);
m_srcGWorld = NULL;
compErr = SCCompressSequenceEnd(stdComponent);
if (compErr != noErr) {
error("[GEM:recordQT] SCCompressSequenceEnd failed with error %ld",
compErr);
}
m_recordStop = false;
m_recordSetup = false;
m_firstRun = 1;
verbose(0, "[GEM:recordQT] movie written to %s",m_filename.c_str());
m_filename.clear();
}
void recordQT :: compressFrame(void)
{
OSErr err;
Handle compressedData; //data to put in QT mov
ComponentResult compErr = noErr;
short syncFlag; //flag for keyframes
#ifdef __APPLE__
//fakes the first run time
if (m_firstRun) {
::Microseconds(&startTime);
m_firstRun = 0;
}
::Microseconds(&endTime);
seconds = static_cast<float>(endTime.lo - startTime.lo) / 1000000.f;
m_ticks = static_cast<int>(600 * seconds);
if (m_ticks < 20) {
m_ticks = 20;
}
#endif //timers
#ifdef _WIN32
static float countFreq = 0;
if (m_firstRun) {
// LARGE_INTEGER freq;
if (!QueryPerformanceFrequency(&freq)) {
countFreq = 0;
} else {
countFreq = static_cast<float>(freq.QuadPart);
}
QueryPerformanceCounter(&startTime);//fakes the time of the first frame
m_ticks = 20;
m_firstRun = 0;
} else {
QueryPerformanceCounter(&endTime);
float fps = 1000 / (static_cast<float>(endTime.QuadPart -
startTime.QuadPart)/countFreq * 1000.f);
seconds = (static_cast<float>(endTime.QuadPart -
startTime.QuadPart)/countFreq * 1.f);
verbose(1,
"[GEM:recordQT] freq %f countFreq %f startTime %d endTime %d fps %f seconds %f",
freq, countFreq, static_cast<int>(startTime.QuadPart),
static_cast<int>(endTime.QuadPart), fps, seconds);
m_ticks = static_cast<int>(600 * seconds);
if (m_ticks < 20) {
m_ticks = 20;
}
}
#endif
compErr = SCCompressSequenceFrame(stdComponent,
GetPortPixMap(m_srcGWorld),
&m_srcRect,
&compressedData,
&dataSize,
&syncFlag);
if (compErr != noErr) {
error("[GEM:recordQT] SCCompressSequenceFrame failed with error %ld",
compErr);
}
err = AddMediaSample(media,
compressedData,
0,
dataSize,
m_ticks, //this should not be a fixed value but vary with framerate
reinterpret_cast<SampleDescriptionHandle>(hImageDesc),
1,
syncFlag,
NULL);
if (err != noErr) {
error("[GEM:recordQT] AddMediaSample failed with error %d",err);
}
#ifdef __APPLE__
::Microseconds(&startTime);
#endif //timer
#ifdef _WIN32
QueryPerformanceCounter(&startTime);
#endif
}
/////////////////////////////////////////////////////////
// render
//
/////////////////////////////////////////////////////////
bool recordQT :: write(imageStruct*img)
{
//check if state exists
if(!img) {
return false;
}
m_compressImage = img;
m_height = img->ysize;
m_width = img->xsize;
//record
if (m_recordStart) {
//if setupQT() has not been run do that first
if (!m_recordSetup) {
setupQT();
if(!m_recordSetup) {
/* failed! */
m_recordStop = true;
return false;
}
}
//should check if the size has changed or else we will freak the compressor's trip out
if (m_width == m_prevWidth && m_height == m_prevHeight) {
//go ahead and grab a frame if everything is ready to go
if (m_recordSetup) {
compressFrame();
}
} else {
error("[GEM:recordQT] movie dimensions changed prev %dx%d now %dx%d stopping recording",
m_prevWidth,m_prevHeight,m_width,m_height);
m_recordStop = true;
m_prevWidth = m_width;
m_prevHeight = m_height; //go ahead and change dimensions
}
}
//if recording is stopped and everything is setup then stop recording
if (m_recordStop) {
//guard against someone not setting up QT beforehand
if (!m_recordSetup) {
return false;
}
stop();
}
return true;
}
/////////////////////////////////////////////////////////
// dialogMess
//
/////////////////////////////////////////////////////////
bool recordQT :: dialog(void)
{
//if recording is going, do not open the dialog
if (!m_recordStart) {
ComponentResult compErr = noErr;
//close the component if already open
if (stdComponent) {
compErr = CloseComponent(stdComponent);
}
if (compErr != noErr) {
verbose(0, "[GEM:recordQT] CloseComponent failed with error %ld", compErr);
}
//open a new component from scratch
stdComponent = OpenDefaultComponent(StandardCompressionType,
StandardCompressionSubType);
if (stdComponent == NULL) {
error("[GEM:recordQT] failed to open compressor component");
return false;
}
compErr = SCRequestSequenceSettings(stdComponent);
if (compErr != noErr) {
verbose(0, "[GEM:recordQT] SCRequestSequenceSettings failed with error %ld",
compErr);
}
compErr = SCGetInfo(stdComponent, scTemporalSettingsType,
&TemporalSettings);
compErr = SCGetInfo(stdComponent, scSpatialSettingsType, &SpatialSettings);
if (compErr != noErr) {
verbose(0, "[GEM:recordQT] SCGetInfo failed with error %ld", compErr);
}
m_codecType = SpatialSettings.codecType;
m_depth = SpatialSettings.depth;
m_spatialQuality = SpatialSettings.spatialQuality;
m_codec = SpatialSettings.codec;
m_frameRate = TemporalSettings.frameRate;
m_keyFrameRate = TemporalSettings.keyFrameRate;
verbose(1, "[GEM:recordQT] Dialog returned SpatialSettings\n"
"\tcodecType %lX\n"
"\tcodec %p\n"
"\tdepth %d\n"
"\tspatialQuality %ld",
SpatialSettings.codecType, SpatialSettings.codec, SpatialSettings.depth,
SpatialSettings.spatialQuality);
verbose(1, "[GEM:recordQT] Dialog returned TemporalSettings\n"
"\ttemporalQualitye %ld\n"
"\tframeRate %ld\n"
"\tkeyFrameRate %ld",
TemporalSettings.temporalQuality, TemporalSettings.frameRate,
TemporalSettings.keyFrameRate);
return(true);
}
error("[GEM:recordQT] recording is running; refusing to show up dialog...!");
return(false);
}
/////////////////////////////////////////////////////////
// spits out a list of installed codecs and stores them
//
/////////////////////////////////////////////////////////
int recordQT :: getNumCodecs(void)
{
//get list of codecs installed -- useful later
return(codecContainer.size());
}
const char*recordQT :: getCodecName(int i)
{
if(i<0 || i>codecContainer.size()) {
return NULL;
}
return (codecContainer[i].name.c_str());
}
std::vector<std::string>recordQT::getCodecs(void)
{
std::vector<std::string>result;
int i;
for(i=0; i<codecContainer.size(); i++) {
result.push_back(codecContainer[i].name);
}
return result;
}
const std::string recordQT::getCodecDescription(const std::string&codec)
{
return(codec);
}
bool recordQT::enumProperties(gem::Properties&props)
{
props.clear();
return false;
}
/////////////////////////////////////////////////////////
// deals with the name of a codec
//
/////////////////////////////////////////////////////////
bool recordQT :: setCodec(int num)
{
if(num<0 || num>codecContainer.size()) {
return false;
}
resetCodecSettings();
m_codecType = codecContainer[num].ctype;
m_codec = codecContainer[num].codec;
return true;
}
bool recordQT :: setCodec(const std::string&codecName)
{
int i;
int requestedCodec=0;
if(codecName=="pjpeg") {
requestedCodec=1;
} else if(codecName=="aic") {
requestedCodec=2;
} else if(codecName=="anim") {
requestedCodec=3;
} else if(codecName=="dvntsc") {
requestedCodec=4;
} else if(codecName=="dvpal") {
requestedCodec=5;
}
for(i=0; i < codecContainer.size(); i++) {
switch(requestedCodec) {
case 1: /* PJPEG */
if (codecContainer[i].ctype == kJPEGCodecType) {
verbose(0, "[GEM:recordQT] found Photo Jpeg");
resetCodecSettings();
m_codecType = codecContainer[i].ctype;
m_codec = codecContainer[i].codec;
return true;
}
break;
case 2: /* AIC */
if (static_cast<int>(codecContainer[i].ctype) == 'icod') {
verbose(0, "[GEM:recordQT] found Apple Intermediate Codec");
resetCodecSettings();
m_codecType = codecContainer[i].ctype;
m_codec = codecContainer[i].codec;
return true;
}
break;
case 3: /* Animation */
if (codecContainer[i].ctype == kAnimationCodecType) {
verbose(0, "[GEM:recordQT] found Animation");
resetCodecSettings();
m_codecType = codecContainer[i].ctype;
m_codec = codecContainer[i].codec;
return true;
}
break;
case 4: /* DV NTSC */
if (codecContainer[i].ctype == kDVCNTSCCodecType) {
verbose(0, "[GEM:recordQT] found DV NTSC");
resetCodecSettings();
m_codecType = codecContainer[i].ctype;
m_codec = codecContainer[i].codec;
return true;
}
break;
case 5: /* DV PAL */
if (codecContainer[i].ctype == kDVCPALCodecType) {
verbose(0, "[GEM:recordQT] found DV PAL");
resetCodecSettings();
m_codecType = codecContainer[i].ctype;
m_codec = codecContainer[i].codec;
return true;
}
break;
default:
/* hmmm... */
if(gensym(codecName.c_str())==gensym(codecContainer[i].name.c_str())) {
verbose(0, "[GEM:recordQT] found '%s'", codecName.c_str());
resetCodecSettings();
m_codecType = codecContainer[i].ctype;
m_codec = codecContainer[i].codec;
return true;
}
break;
}
}
//no codec found
return false;
}
bool recordQT :: start(const std::string&filename, gem::Properties&props)
{
// if recording is going, do not accept a new file name
// on OSX changing the name while recording won't have any effect
// but it will give the wrong message at the end if recording
if (m_recordStart) {
error("[GEM:recordQT] cannot set filename while recording is running!");
return false;
}
m_filename = filename;
m_recordStart=true;
return true;
}
void recordQT :: resetCodecSettings(void)
{
m_codecType = 0;
m_codec = 0;
m_depth = 0;
m_spatialQuality = codecNormalQuality;
m_frameRate = 0;
m_keyFrameRate = 0;
}
|