Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 10 files). Show all
Unified · Split
| @@ -15,11 +15,11 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <recording/Clip.h> |
| 16 | 16 | #include <recording/Frame.h> |
| 17 | 17 | #include <NumericalConstants.h> |
| 18 | +// FiXME | |
| 18 | 19 | //#include <AudioClient.h> |
| 19 | 20 | #include <AudioConstants.h> |
| 20 | 21 | #include <Transform.h> |
| 21 | −//#include "avatar/AvatarManager.h" | |
| 22 | −//#include "Application.h" | |
| 22 | + | |
| 23 | 23 | #include "ScriptEngineLogging.h" |
| 24 | 24 | |
| 25 | 25 | typedef int16_t AudioSample; |
| @@ -45,6 +45,7 @@ RecordingScriptingInterface::RecordingScriptingInterface() { · 19 unmodified lines | ||
| 45 | 45 | _player = DependencyManager::get<Deck>(); |
| 46 | 46 | _recorder = DependencyManager::get<Recorder>(); |
| 47 | 47 | |
| 48 | + // FIXME : Disabling Sound | |
| 48 | 49 | // auto audioClient = DependencyManager::get<AudioClient>(); |
| 49 | 50 | // connect(audioClient.data(), &AudioClient::inputReceived, this, &RecordingScriptingInterface::processAudioInput); |
| 50 | 51 | } |
| @@ -53,19 +54,19 @@ void RecordingScriptingInterface::setControlledAvatar(AvatarData* avatar) { · 2 unmodified lines | ||
| 53 | 54 | _controlledAvatar = avatar; |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | −bool RecordingScriptingInterface::isPlaying() { | |
| 57 | +bool RecordingScriptingInterface::isPlaying() const { | |
| 57 | 58 | return _player->isPlaying(); |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | −bool RecordingScriptingInterface::isPaused() { | |
| 61 | +bool RecordingScriptingInterface::isPaused() const { | |
| 61 | 62 | return _player->isPaused(); |
| 62 | 63 | } |
| 63 | 64 | |
| 64 | −float RecordingScriptingInterface::playerElapsed() { | |
| 65 | +float RecordingScriptingInterface::playerElapsed() const { | |
| 65 | 66 | return _player->position(); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | −float RecordingScriptingInterface::playerLength() { | |
| 69 | +float RecordingScriptingInterface::playerLength() const { | |
| 69 | 70 | return _player->length(); |
| 70 | 71 | } |
| 71 | 72 | |
| @@ -90,11 +91,10 @@ void RecordingScriptingInterface::startPlaying() { · 18 unmodified lines | ||
| 90 | 91 | QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection); |
| 91 | 92 | return; |
| 92 | 93 | } |
| 93 | − //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 94 | − auto myAvatar = _controlledAvatar; | |
| 94 | + | |
| 95 | 95 | // Playback from the current position |
| 96 | − if (_playFromCurrentLocation) { | |
| 97 | − _dummyAvatar.setRecordingBasis(std::make_shared<Transform>(myAvatar->getTransform())); | |
| 96 | + if (_playFromCurrentLocation && _controlledAvatar) { | |
| 97 | + _dummyAvatar.setRecordingBasis(std::make_shared<Transform>(_controlledAvatar->getTransform())); | |
| 98 | 98 | } else { |
| 99 | 99 | _dummyAvatar.clearRecordingBasis(); |
| 100 | 100 | } |
| @@ -110,6 +110,10 @@ void RecordingScriptingInterface::setPlayerAudioOffset(float audioOffset) { · 9 unmodified lines | ||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | void RecordingScriptingInterface::setPlayerTime(float time) { |
| 113 | + if (QThread::currentThread() != thread()) { | |
| 114 | + QMetaObject::invokeMethod(this, "setPlayerTime", Qt::BlockingQueuedConnection, Q_ARG(float, time)); | |
| 115 | + return; | |
| 116 | + } | |
| 113 | 117 | _player->seek(time); |
| 114 | 118 | } |
| 115 | 119 | |
| @@ -137,23 +141,27 @@ void RecordingScriptingInterface::setPlayerUseSkeletonModel(bool useSkeletonMode · 21 unmodified lines | ||
| 137 | 141 | _useSkeletonModel = useSkeletonModel; |
| 138 | 142 | } |
| 139 | 143 | |
| 140 | −void RecordingScriptingInterface::play() { | |
| 141 | − _player->play(); | |
| 142 | −} | |
| 143 | − | |
| 144 | 144 | void RecordingScriptingInterface::pausePlayer() { |
| 145 | + if (QThread::currentThread() != thread()) { | |
| 146 | + QMetaObject::invokeMethod(this, "pausePlayer", Qt::BlockingQueuedConnection); | |
| 147 | + return; | |
| 148 | + } | |
| 145 | 149 | _player->pause(); |
| 146 | 150 | } |
| 147 | 151 | |
| 148 | 152 | void RecordingScriptingInterface::stopPlaying() { |
| 153 | + if (QThread::currentThread() != thread()) { | |
| 154 | + QMetaObject::invokeMethod(this, "stopPlaying", Qt::BlockingQueuedConnection); | |
| 155 | + return; | |
| 156 | + } | |
| 149 | 157 | _player->stop(); |
| 150 | 158 | } |
| 151 | 159 | |
| 152 | −bool RecordingScriptingInterface::isRecording() { | |
| 160 | +bool RecordingScriptingInterface::isRecording() const { | |
| 153 | 161 | return _recorder->isRecording(); |
| 154 | 162 | } |
| 155 | 163 | |
| 156 | −float RecordingScriptingInterface::recorderElapsed() { | |
| 164 | +float RecordingScriptingInterface::recorderElapsed() const { | |
| 157 | 165 | return _recorder->position(); |
| 158 | 166 | } |
| 159 | 167 | |
| @@ -170,29 +178,21 @@ void RecordingScriptingInterface::startRecording() { · 10 unmodified lines | ||
| 170 | 178 | |
| 171 | 179 | _recordingEpoch = Frame::epochForFrameTime(0); |
| 172 | 180 | |
| 173 | − //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 174 | − //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 175 | − auto myAvatar = _controlledAvatar; | |
| 176 | − myAvatar->setRecordingBasis(); | |
| 181 | + if (_controlledAvatar) { | |
| 182 | + _controlledAvatar->setRecordingBasis(); | |
| 183 | + } | |
| 184 | + | |
| 177 | 185 | _recorder->start(); |
| 178 | 186 | } |
| 179 | 187 | |
| 180 | 188 | void RecordingScriptingInterface::stopRecording() { |
| 181 | 189 | _recorder->stop(); |
| 182 | − | |
| 183 | 190 | _lastClip = _recorder->getClip(); |
| 184 | − // post-process the audio into discreet chunks based on times of received samples | |
| 185 | − _lastClip->seek(0); | |
| 186 | − Frame::ConstPointer frame; | |
| 187 | − while (frame = _lastClip->nextFrame()) { | |
| 188 | − qDebug() << "Frame time " << frame->timeOffset << " size " << frame->data.size(); | |
| 189 | − } | |
| 190 | 191 | _lastClip->seek(0); |
| 191 | 192 | |
| 192 | − //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 193 | − //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 194 | − auto myAvatar = _controlledAvatar; | |
| 195 | − myAvatar->clearRecordingBasis(); | |
| 193 | + if (_controlledAvatar) { | |
| 194 | + _controlledAvatar->clearRecordingBasis(); | |
| 195 | + } | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | void RecordingScriptingInterface::saveRecording(const QString& filename) { |
| @@ -228,28 +228,32 @@ void RecordingScriptingInterface::loadLastRecording() { · 29 unmodified lines | ||
| 228 | 228 | void RecordingScriptingInterface::processAvatarFrame(const Frame::ConstPointer& frame) { |
| 229 | 229 | Q_ASSERT(QThread::currentThread() == thread()); |
| 230 | 230 | |
| 231 | + if (!_controlledAvatar) { | |
| 232 | + return; | |
| 233 | + } | |
| 234 | + | |
| 231 | 235 | AvatarData::fromFrame(frame->data, _dummyAvatar); |
| 232 | 236 | |
| 233 | − //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | |
| 234 | − auto myAvatar = _controlledAvatar; | |
| 237 | + | |
| 238 | + | |
| 235 | 239 | if (_useHeadModel && _dummyAvatar.getFaceModelURL().isValid() && |
| 236 | − (_dummyAvatar.getFaceModelURL() != myAvatar->getFaceModelURL())) { | |
| 240 | + (_dummyAvatar.getFaceModelURL() != _controlledAvatar->getFaceModelURL())) { | |
| 237 | 241 | // FIXME |
| 238 | 242 | //myAvatar->setFaceModelURL(_dummyAvatar.getFaceModelURL()); |
| 239 | 243 | } |
| 240 | 244 | |
| 241 | 245 | if (_useSkeletonModel && _dummyAvatar.getSkeletonModelURL().isValid() && |
| 242 | − (_dummyAvatar.getSkeletonModelURL() != myAvatar->getSkeletonModelURL())) { | |
| 246 | + (_dummyAvatar.getSkeletonModelURL() != _controlledAvatar->getSkeletonModelURL())) { | |
| 243 | 247 | // FIXME |
| 244 | 248 | //myAvatar->useFullAvatarURL() |
| 245 | 249 | } |
| 246 | 250 | |
| 247 | − if (_useDisplayName && _dummyAvatar.getDisplayName() != myAvatar->getDisplayName()) { | |
| 248 | − myAvatar->setDisplayName(_dummyAvatar.getDisplayName()); | |
| 251 | + if (_useDisplayName && _dummyAvatar.getDisplayName() != _controlledAvatar->getDisplayName()) { | |
| 252 | + _controlledAvatar->setDisplayName(_dummyAvatar.getDisplayName()); | |
| 249 | 253 | } |
| 250 | 254 | |
| 251 | − myAvatar->setPosition(_dummyAvatar.getPosition()); | |
| 252 | − myAvatar->setOrientation(_dummyAvatar.getOrientation()); | |
| 255 | + _controlledAvatar->setPosition(_dummyAvatar.getPosition()); | |
| 256 | + _controlledAvatar->setOrientation(_dummyAvatar.getOrientation()); | |
| 253 | 257 | |
| 254 | 258 | // FIXME attachments |
| 255 | 259 | // FIXME joints |