diff options
author | Sven Hesse | 2010-08-08 00:34:33 +0000 |
---|---|---|
committer | Sven Hesse | 2010-08-08 00:34:33 +0000 |
commit | f8a43ee35f4ca2a409558fbb6bf978cc2ae54ab4 (patch) | |
tree | b5ca6120a37f2709c42b5544a9b338abe956ba8a | |
parent | a802e1e64f56b5c6b0534a481e84418078b2699f (diff) | |
download | scummvm-rg350-f8a43ee35f4ca2a409558fbb6bf978cc2ae54ab4.tar.gz scummvm-rg350-f8a43ee35f4ca2a409558fbb6bf978cc2ae54ab4.tar.bz2 scummvm-rg350-f8a43ee35f4ca2a409558fbb6bf978cc2ae54ab4.zip |
GOB: Stub the new VideoPlayer interface
This is will be the new, less convoluted interface for playing videos
within the gob engine. No actual functionality is implemented yet, and
old functions are mostly commented out for now.
svn-id: r51851
-rw-r--r-- | engines/gob/demos/demoplayer.cpp | 4 | ||||
-rw-r--r-- | engines/gob/scenery.cpp | 6 | ||||
-rw-r--r-- | engines/gob/videoplayer.cpp | 512 | ||||
-rw-r--r-- | engines/gob/videoplayer.h | 127 |
4 files changed, 400 insertions, 249 deletions
diff --git a/engines/gob/demos/demoplayer.cpp b/engines/gob/demos/demoplayer.cpp index d6c3ac73a5..bd29e6b780 100644 --- a/engines/gob/demos/demoplayer.cpp +++ b/engines/gob/demos/demoplayer.cpp @@ -215,7 +215,7 @@ void DemoPlayer::playVideoNormal() { } void DemoPlayer::playVideoDoubled() { - Common::String fileNameOpened = _vm->_vidPlayer->getPrimaryFileName(); + Common::String fileNameOpened = _vm->_vidPlayer->getFileName(); _vm->_vidPlayer->primaryClose(); int16 x = _rebase0 ? 0 : -1; @@ -223,7 +223,7 @@ void DemoPlayer::playVideoDoubled() { if (_vm->_vidPlayer->primaryOpen(fileNameOpened.c_str(), x, y, VideoPlayer::kFlagScreenSurface)) { - for (int i = 0; i < _vm->_vidPlayer->getFrameCount(); i++) { + for (uint i = 0; i < _vm->_vidPlayer->getFrameCount(); i++) { _vm->_vidPlayer->playFrame(i); Graphics::CoktelDecoder::State state;// = _vm->_vidPlayer->getState(); diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp index 6b5982ec3e..edd2051f1a 100644 --- a/engines/gob/scenery.cpp +++ b/engines/gob/scenery.cpp @@ -616,19 +616,19 @@ void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, return; } - if (frame >= _vm->_vidPlayer->getFrameCount(obj.videoSlot - 1)) + if (frame >= ((int16)_vm->_vidPlayer->getFrameCount(obj.videoSlot - 1))) frame = _vm->_vidPlayer->getFrameCount(obj.videoSlot - 1) - 1; // Seek to frame if (_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) < 256) { - while (_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) <= frame) + while (((int32)_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1)) <= frame) _vm->_vidPlayer->slotPlay(obj.videoSlot - 1); } else { int16 curFrame = _vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1); uint8 frameWrap = curFrame / 256; frame = (frame + 1) % 256; - while (_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) < (frameWrap * 256 + frame)) + while (((int32)_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1)) < (frameWrap * 256 + frame)) _vm->_vidPlayer->slotPlay(obj.videoSlot - 1); } diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index d6de1cb652..bdab7fcac1 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -38,98 +38,301 @@ namespace Gob { +VideoPlayer::Properties::Properties() : type(kVideoTypeTry), sprite(20), + x(-1), y(-1), width(-1), height(-1), flags(kFlagFrontSurface), + startFrame(-1), lastFrame(-1), breakKey(kShortKeyEscape), + palCmd(8), palStart(0), palEnd(255), palFrame(-1), fade(false) { + +} + + +VideoPlayer::Video::Video() : decoder(0) { +} + +bool VideoPlayer::Video::isEmpty() const { + return decoder == 0; +} + +void VideoPlayer::Video::close() { + delete decoder; + + decoder = 0; + fileName.clear(); +} + + const char *VideoPlayer::_extensions[] = { "IMD", "IMD", "VMD", "RMD", "SMD" }; -VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm), _primaryVideo(0), +VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm), _ownSurf(false), _backSurf(false), _needBlit(false), _noCursorSwitch(false), _woodruffCohCottWorkaround(false) { - - for (int i = 0; i < kVideoSlotCount; i++) - _videoSlots[i] = 0; } VideoPlayer::~VideoPlayer() { - delete _primaryVideo; for (int i = 0; i < kVideoSlotCount; i++) - delete _videoSlots[i]; + _videoSlots[i].close(); } -bool VideoPlayer::findFile(char *fileName, Type &which) { - char *extStart = strrchr(fileName, '.'); - // There's no empty extension, Or the filename with its current extension is not found - if ((extStart) && ((extStart == (fileName + strlen(fileName) - 1)) || (!_vm->_dataIO->existData(fileName)))) { - *extStart = 0; - extStart = 0; +int VideoPlayer::openVideo(bool primary, const Common::String &file, Properties &properties) { + int slot = 0; + + Video *video = 0; + if (!primary) { + slot = getNextFreeSlot(); + if (slot < 0) { + warning("VideoPlayer::openVideo(): Can't open video \"%s\": No free slot", file.c_str()); + return -1; + } + + video = &_videoSlots[slot]; + } else + video = &_videoSlots[0]; + + // Different video already in the slot => close that video + if (!video->isEmpty() && (video->fileName.compareToIgnoreCase(file) != 0)) + video->close(); + + // No video => load the requested file + if (video->isEmpty()) { + // Open the video + if (!(video->decoder = openVideo(file, properties))) + return -1; + + // Set the filename + video->fileName = file; } - if (extStart) { - // The requested file already has an extension. Verifying. + // TODO + + return -1; // slot +} + +bool VideoPlayer::closeVideo(int slot) { + Video *video = getVideoBySlot(slot); + if (!video) + return false; + + video->close(); + return true; +} + +bool VideoPlayer::play(int slot, const Properties &properties) { + Video *video = getVideoBySlot(slot); + if (!video) + return false; + + // TODO + + return false; +} + +bool VideoPlayer::slotIsOpen(int slot) const { + return getVideoBySlot(slot) != 0; +} + +Common::String VideoPlayer::getFileName(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return ""; + + return video->fileName; +} + +uint16 VideoPlayer::getFlags(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return 0; // video->decoder->getFlags(); +} + +uint32 VideoPlayer::getFrameCount(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return video->decoder->getFrameCount(); +} + +uint32 VideoPlayer::getCurrentFrame(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return video->decoder->getCurFrame(); +} +uint16 VideoPlayer::getWidth(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return video->decoder->getWidth(); +} + +uint16 VideoPlayer::getHeight(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return video->decoder->getHeight(); +} + +uint16 VideoPlayer::getDefaultX(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return 0; // video->decoder->getDefaultX(); +} + +uint16 VideoPlayer::getDefaultY(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return 0; // video->decoder->getDefaultY(); +} + +uint32 VideoPlayer::getFeatures(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return 0; // video->decoder->getFeatures(); +} + +void VideoPlayer::getState(int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return; + + return; // video->decoder->getState(); +} + +bool VideoPlayer::hasExtraData(const Common::String &fileName, int slot) const { + const Video *video = getVideoBySlot(slot); + if (!video) + return false; + + return false; // video->decoder->hasExtraData(fileName); +} + +Common::MemoryReadStream *VideoPlayer::getExtraData(const Common::String &fileName, int slot) { + const Video *video = getVideoBySlot(slot); + if (!video) + return 0; + + return 0; // video->decoder->getExtraData(fileName); +} + +const VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) const { + if ((slot < 0) || (slot >= kVideoSlotCount)) + return 0; + + if (_videoSlots[slot].isEmpty()) + return 0; + + return &_videoSlots[slot]; +} + +VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) { + if ((slot < 0) || (slot >= kVideoSlotCount)) + return 0; + + if (_videoSlots[slot].isEmpty()) + return 0; + + return &_videoSlots[slot]; +} + +int VideoPlayer::getNextFreeSlot() { + // Starting with 1, since 0 is reserved for the "primary" video + for (int i = 1; i < kVideoSlotCount; i++) + if (_videoSlots[i].isEmpty()) + return i; + + return -1; +} + +Common::String VideoPlayer::findFile(const Common::String &file, Properties &properties) { + + bool hasExtension = false; + + Common::String base = file; + Common::String fileName = file; + + const char *posDot = strrchr(base.c_str(), '.'); + if (posDot) { + hasExtension = true; + base = Common::String(base.c_str(), posDot); + posDot++; + } + + if (hasExtension) { int i; for (i = 0; i < ARRAYSIZE(_extensions); i++) { - if (!scumm_stricmp(extStart + 1, _extensions[i])) { - if ((which != kVideoTypeTry) && (which == ((Type) i))) { - warning("Attempted to open video \"%s\", " - "but requested a different type", fileName); - return false; + if (!scumm_stricmp(posDot, _extensions[i])) { + if ((properties.type != kVideoTypeTry) && (properties.type == ((Type) i))) { + warning("Attempted to open video \"%s\", but requested a different type", fileName.c_str()); + return ""; } - which = (Type) i; + properties.type = (Type) i; break; } } if (i >= ARRAYSIZE(_extensions)) - extStart = 0; - + hasExtension = false; } - if (!extStart) { + if (!hasExtension) { // No or unrecognized extension. Probing. - int len = strlen(fileName); - int i; for (i = 0; i < ARRAYSIZE(_extensions); i++) { - if ((which == kVideoTypeTry) || (which == ((Type) i))) { - fileName[len] = '.'; - fileName[len + 1] = 0; - strcat(fileName, _extensions[i]); + if ((properties.type == kVideoTypeTry) || (properties.type == ((Type) i))) { + fileName = base + "." + _extensions[i]; - if (_vm->_dataIO->existData(fileName)) { - which = (Type) i; + if (_vm->_dataIO->existData(fileName.c_str())) { + properties.type = (Type) i; break; } } } - if ((i >= ARRAYSIZE(_extensions)) || (which == kVideoTypeTry)) { - fileName[len] = 0; - warning("Couldn't open video \"%s\"", fileName); - return false; + if ((i >= ARRAYSIZE(_extensions)) || (properties.type == kVideoTypeTry)) { + warning("Couldn't open video \"%s\"", file.c_str()); + return ""; } } - return true; + return fileName; } -Graphics::CoktelDecoder *VideoPlayer::openVideo(const char *fileName, Type which, uint16 width, uint16 height) { - Common::SeekableReadStream *stream = _vm->_dataIO->getDataStream(fileName); +Graphics::CoktelDecoder *VideoPlayer::openVideo(const Common::String &file, Properties &properties) { + Common::String fileName = findFile(file, properties); + if (fileName.empty()) + return 0; + + Common::SeekableReadStream *stream = _vm->_dataIO->getDataStream(fileName.c_str()); if (!stream) return 0; Graphics::CoktelDecoder *video = 0; - if (which == kVideoTypeIMD) + if (properties.type == kVideoTypeIMD) warning("TODO: IMD"); //_video = new Graphics::Imd(); - else if (which == kVideoTypePreIMD) - video = new Graphics::PreIMDDecoder(width, height, *_vm->_mixer, Audio::Mixer::kSFXSoundType); - else if (which == kVideoTypeVMD) + else if (properties.type == kVideoTypePreIMD) { + warning("PreIMDDecoder \"%s\" %dx%d", fileName.c_str(), properties.width, properties.height); + video = new Graphics::PreIMDDecoder(properties.width, properties.height, *_vm->_mixer, Audio::Mixer::kSFXSoundType); + } else if (properties.type == kVideoTypeVMD) warning("TODO: VMD"); //_video = new Graphics::Vmd(_vm->_video->_palLUT); - else if (which == kVideoTypeRMD) + else if (properties.type == kVideoTypeRMD) warning("TODO: RMD"); //_video = new Graphics::Vmd(_vm->_video->_palLUT); else - warning("Couldn't open video \"%s\": Invalid video Type", fileName); + warning("Couldn't open video \"%s\": Invalid video Type", fileName.c_str()); if (!video) { delete stream; @@ -144,9 +347,17 @@ Graphics::CoktelDecoder *VideoPlayer::openVideo(const char *fileName, Type which return video; } + + + +// Obsolete, to be deleted + bool VideoPlayer::primaryOpen(const char *videoFile, int16 x, int16 y, int32 flags, Type which, int16 width, int16 height) { + return false; + +#if 0 char fileName[256]; strncpy0(fileName, videoFile, 250); @@ -230,12 +441,19 @@ bool VideoPlayer::primaryOpen(const char *videoFile, int16 x, int16 y, WRITE_VAR(7, _primaryVideo->getFrameCount()); return true; + +#endif + } bool VideoPlayer::primaryPlay(int16 startFrame, int16 lastFrame, int16 breakKey, uint16 palCmd, int16 palStart, int16 palEnd, int16 palFrame, int16 endFrame, bool fade, int16 reverseTo, bool forceSeek) { + return false; + +#if 0 + if (!_primaryVideo) return false; @@ -312,16 +530,24 @@ bool VideoPlayer::primaryPlay(int16 startFrame, int16 lastFrame, int16 breakKey, evalBgShading(video); return canceled; + +#endif } void VideoPlayer::primaryClose() { +#if 0 delete _primaryVideo; _primaryVideo = 0; _primaryFileName.clear(); +#endif } int VideoPlayer::slotOpen(const char *videoFile, Type which, int16 width, int16 height) { + return -1; + +#if 0 + int slot = getNextFreeSlot(); if (slot == -1) return -1; @@ -346,18 +572,11 @@ int VideoPlayer::slotOpen(const char *videoFile, Type which, int16 width, int16 WRITE_VAR(7, video->getFrameCount()); return slot; -} - -int VideoPlayer::getNextFreeSlot() { - for (int i = 0; i < kVideoSlotCount; i++) - if (!_videoSlots[i]) - return i; - - warning("VideoPlayer::getNextFreeSlot(): No free video slot"); - return -1; +#endif } void VideoPlayer::slotPlay(int slot, int16 frame) { +#if 0 if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot]) return; @@ -376,35 +595,43 @@ void VideoPlayer::slotPlay(int slot, int16 frame) { WRITE_VAR(11, frame); evalBgShading(video); +#endif } void VideoPlayer::slotClose(int slot) { +#if 0 if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot]) return; delete _videoSlots[slot]; _videoSlots[slot] = 0; +#endif } void VideoPlayer::slotCopyFrame(int slot, byte *dest, uint16 left, uint16 top, uint16 width, uint16 height, uint16 x, uint16 y, uint16 pitch, int16 transp) { +#if 0 if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot]) return; /*_videoSlots[slot]->getVideo()->copyCurrentFrame(dest, left, top, width, height, x, y, pitch, transp);*/ +#endif } void VideoPlayer::slotCopyPalette(int slot, int16 palStart, int16 palEnd) { +#if 0 if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot]) return; //copyPalette(*(_videoSlots[slot]->getVideo()), palStart, palEnd); +#endif } void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) { +#if 0 Graphics::CoktelDecoder *video = getVideoBySlot(slot); if (video) { @@ -415,154 +642,20 @@ void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) { cVideo.waitEndFrame(); */ } -} - -bool VideoPlayer::slotIsOpen(int slot) const { - if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot]) - return true; - - return false; +#endif } void VideoPlayer::slotSetDoubleMode(int slot, bool doubleMode) { - /* - Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - video->getVideo()->setDoubleMode(doubleMode); - */ -} - -const Graphics::CoktelDecoder *VideoPlayer::getVideoBySlot(int slot) const { - if (slot < 0) { - if (_primaryVideo) - return _primaryVideo; - } else if ((slot < kVideoSlotCount) && _videoSlots[slot]) - return _videoSlots[slot]; - - return 0; -} - -Graphics::CoktelDecoder *VideoPlayer::getVideoBySlot(int slot) { - if (slot < 0) { - if (_primaryVideo) - return _primaryVideo; - } else if ((slot < kVideoSlotCount) && _videoSlots[slot]) - return _videoSlots[slot]; - - return 0; -} - -const Common::String &VideoPlayer::getPrimaryFileName() const { - return _primaryFileName; } -uint16 VideoPlayer::getFlags(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return 0;//return video->getVideo()->getFlags(); - - return 0; -} - -int16 VideoPlayer::getFrameCount(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return video->getFrameCount(); - - return 0; -} - -int16 VideoPlayer::getCurrentFrame(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return video->getCurFrame(); - - return 0; -} - -int16 VideoPlayer::getWidth(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return video->getWidth(); - - return 0; -} - -int16 VideoPlayer::getHeight(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return video->getHeight(); - - return 0; -} - -int16 VideoPlayer::getDefaultX(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return 0;//return video->getDefaultX(); - - return 0; -} - -int16 VideoPlayer::getDefaultY(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return 0;//return video->getDefaultY(); - - return 0; -} -uint32 VideoPlayer::getFeatures(int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return 0;//return video->getFeatures(); - - return 0; -} - -void VideoPlayer::getState(int slot) const { - /* - const Video *video = getVideoBySlot(slot); - Graphics::CoktelVideo::State state; - - if (video) - state = video->getState(); - - return state; - */ -} - -bool VideoPlayer::hasExtraData(const char *fileName, int slot) const { - const Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return false;//return video->hasExtraData(fileName); - return false; -} - -Common::MemoryReadStream *VideoPlayer::getExtraData(const char *fileName, int slot) { - Graphics::CoktelDecoder *video = getVideoBySlot(slot); - - if (video) - return 0;//return video->getExtraData(fileName); - - return 0; -} void VideoPlayer::playFrame(int16 frame, int16 breakKey, uint16 palCmd, int16 palStart, int16 palEnd, int16 palFrame, int16 endFrame, bool noRetrace) { +#if 0 if (!_primaryVideo) return; @@ -648,12 +741,16 @@ void VideoPlayer::playFrame(int16 frame, int16 breakKey, if (modifiedPal && ((palCmd == 2) || (palCmd == 4))) _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); +#endif } bool VideoPlayer::doPlay(int16 frame, int16 breakKey, uint16 palCmd, int16 palStart, int16 palEnd, int16 palFrame, int16 endFrame, bool noRetrace) { + return false; +#if 0 + playFrame(frame, breakKey, palCmd, palStart, palEnd, palFrame, endFrame, noRetrace); _vm->_util->processInput(); @@ -677,6 +774,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey, } return false; +#endif } void VideoPlayer::copyPalette(Graphics::CoktelDecoder &video, int16 palStart, int16 palEnd) { @@ -697,36 +795,38 @@ void VideoPlayer::copyPalette(Graphics::CoktelDecoder &video, int16 palStart, in */ } -void VideoPlayer::writeVideoInfo(const char *videoFile, int16 varX, int16 varY, +void VideoPlayer::writeVideoInfo(const Common::String &file, int16 varX, int16 varY, int16 varFrames, int16 varWidth, int16 varHeight) { - if (primaryOpen(videoFile)) { + Properties properties; + + int slot = openVideo(false, file, properties); + if (slot >= 0) { + Video &video = _videoSlots[slot]; + int16 x = -1, y = -1, width = -1, height = -1; - /* - x = _primaryVideo->getVideo()->getX(); - y = _primaryVideo->getVideo()->getY(); - width = _primaryVideo->getVideo()->getWidth(); - height = _primaryVideo->getVideo()->getHeight(); - */ + // x = video.decoder->getX(); + // y = video.decoder->getY(); + width = video.decoder->getWidth(); + width = video.decoder->getHeight(); /* if (VAR_OFFSET(varX) == 0xFFFFFFFF) - _primaryVideo->getVideo()->getFrameCoords(1, x, y, width, height); + video.decoder->getFrameCoords(1, x, y, width, height); */ - WRITE_VAR_OFFSET(varX, x); - WRITE_VAR_OFFSET(varY, y); - WRITE_VAR_OFFSET(varFrames, _primaryVideo->getFrameCount()); - WRITE_VAR_OFFSET(varWidth, width); + WRITE_VAR_OFFSET(varX , x); + WRITE_VAR_OFFSET(varY , y); + WRITE_VAR_OFFSET(varFrames, video.decoder->getFrameCount()); + WRITE_VAR_OFFSET(varWidth , width); WRITE_VAR_OFFSET(varHeight, height); - primaryClose(); } else { - WRITE_VAR_OFFSET(varX, (uint32) -1); - WRITE_VAR_OFFSET(varY, (uint32) -1); + WRITE_VAR_OFFSET(varX , (uint32) -1); + WRITE_VAR_OFFSET(varY , (uint32) -1); WRITE_VAR_OFFSET(varFrames, (uint32) -1); - WRITE_VAR_OFFSET(varWidth, (uint32) -1); + WRITE_VAR_OFFSET(varWidth , (uint32) -1); WRITE_VAR_OFFSET(varHeight, (uint32) -1); } } diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index f885e96428..b79b92084c 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -41,25 +41,83 @@ class DataStream; class VideoPlayer { public: enum Flags { - kFlagNone = 0, - kFlagUseBackSurfaceContent = 0x40, - kFlagFrontSurface = 0x80, - kFlagNoVideo = 0x100, - kFlagOtherSurface = 0x800, - kFlagScreenSurface = 0x400000 + kFlagNone = 0x000000, + kFlagUseBackSurfaceContent = 0x000040, ///< Use the back surface as a video "base". + kFlagFrontSurface = 0x000080, ///< Draw directly into the front surface. + kFlagNoVideo = 0x000100, ///< Only sound. + kFlagOtherSurface = 0x000800, ///< Draw into a specific sprite. + kFlagScreenSurface = 0x400000 ///< Draw into a newly created sprite of screen dimensions. }; + /** Video format. */ enum Type { - kVideoTypeTry = -1, - kVideoTypeIMD = 0, - kVideoTypePreIMD = 1, - kVideoTypeVMD = 2, - kVideoTypeRMD = 3 + kVideoTypeTry = -1, ///< Try any format. + kVideoTypeIMD = 0, + kVideoTypePreIMD = 1, ///< Early IMD format found in Fascination. + kVideoTypeVMD = 2, + kVideoTypeRMD = 3 ///< VMD containing "reversed" video. + }; + + struct Properties { + Type type; ///< Type of the video to open. + + int sprite; ///< The sprite onto which to draw the video. + + int32 x; ///< X coordinate of the video. + int32 y; ///< Y coordinate of the video. + int32 width; ///< Width of the video. + int32 height; ///< Height of the video. + + uint32 flags; ///< Video flags. + + int16 startFrame; ///< Frame to start playback from. + int16 lastFrame; ///< Frame to stop playback at. + + int16 breakKey; ///< Keycode of the break/abort key. + + uint16 palCmd; ///< Palette command. + uint16 palStart; ///< Palette entry to start with. + uint16 palEnd; ///< Palette entry to end at. + int16 palFrame; ///< Frame to apply the palette command at. + + bool fade; ///< Fade in? + + Properties(); }; VideoPlayer(GobEngine *vm); ~VideoPlayer(); + int openVideo(bool primary, const Common::String &file, Properties &properties); + bool closeVideo(int slot); + + bool play(int slot, const Properties &properties); + + bool slotIsOpen(int slot = 0) const; + + Common::String getFileName(int slot = 0) const; + + uint16 getFlags (int slot = 0) const; + uint32 getFrameCount (int slot = 0) const; + uint32 getCurrentFrame(int slot = 0) const; + uint16 getWidth (int slot = 0) const; + uint16 getHeight (int slot = 0) const; + uint16 getDefaultX (int slot = 0) const; + uint16 getDefaultY (int slot = 0) const; + uint32 getFeatures (int slot = 0) const; + + void getState(int slot = 0) const; + + bool hasExtraData(const Common::String &fileName, int slot = 0) const; + Common::MemoryReadStream *getExtraData(const Common::String &fileName, int slot = 0); + + void writeVideoInfo(const Common::String &file, int16 varX, int16 varY, + int16 varFrames, int16 varWidth, int16 varHeight); + + + + // Obsolete, to be deleted + bool primaryOpen(const char *videoFile, int16 x = -1, int16 y = -1, int32 flags = kFlagFrontSurface, Type which = kVideoTypeTry, int16 width = -1, int16 height = -1); @@ -86,37 +144,26 @@ public: void slotSetDoubleMode(int slot, bool doubleMode); - bool slotIsOpen(int slot) const; - - const Common::String &getPrimaryFileName() const; - uint16 getFlags(int slot = -1) const; - int16 getFrameCount(int slot = -1) const; - int16 getCurrentFrame(int slot = -1) const; - int16 getWidth(int slot = -1) const; - int16 getHeight(int slot = -1) const; - int16 getDefaultX(int slot = -1) const; - int16 getDefaultY(int slot = -1) const; - void getState(int slot = -1) const; - uint32 getFeatures(int slot = -1) const; +private: + struct Video { + Graphics::CoktelDecoder *decoder; + Common::String fileName; - bool hasExtraData(const char *fileName, int slot = -1) const; - Common::MemoryReadStream *getExtraData(const char *fileName, int slot = -1); + Video(); - void writeVideoInfo(const char *videoFile, int16 varX, int16 varY, - int16 varFrames, int16 varWidth, int16 varHeight); + bool isEmpty() const; + void close(); + }; -private: static const int kVideoSlotCount = 32; static const char *_extensions[]; GobEngine *_vm; - Graphics::CoktelDecoder *_primaryVideo; - Graphics::CoktelDecoder *_videoSlots[kVideoSlotCount]; - - Common::String _primaryFileName; + // _videoSlots[0] is reserved for the "primary" video + Video _videoSlots[kVideoSlotCount]; bool _ownSurf; bool _backSurf; @@ -125,20 +172,24 @@ private: bool _woodruffCohCottWorkaround; - bool findFile(char *fileName, Type &which); - - const Graphics::CoktelDecoder *getVideoBySlot(int slot = -1) const; - Graphics::CoktelDecoder *getVideoBySlot(int slot = -1); + const Video *getVideoBySlot(int slot) const; + Video *getVideoBySlot(int slot); int getNextFreeSlot(); + Common::String findFile(const Common::String &file, Properties &properties); + + Graphics::CoktelDecoder *openVideo(const Common::String &file, Properties &properties); + + + + // Obsolete, to be deleted + void copyPalette(Graphics::CoktelDecoder &video, int16 palStart = -1, int16 palEnd = -1); bool doPlay(int16 frame, int16 breakKey, uint16 palCmd, int16 palStart, int16 palEnd, int16 palFrame, int16 endFrame, bool noRetrace = false); void evalBgShading(Graphics::CoktelDecoder &video); - - Graphics::CoktelDecoder *openVideo(const char *fileName, Type which, uint16 width, uint16 height); }; } // End of namespace Gob |