Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 12 files). Show all
Unified · Split
| @@ -15,43 +15,16 @@ · 14 unmodified lines | |||
| 15 | #include <recording/Clip.h> | 15 | #include <recording/Clip.h> |
| 16 | #include <recording/Frame.h> | 16 | #include <recording/Frame.h> |
| 17 | #include <NumericalConstants.h> | 17 | #include <NumericalConstants.h> |
| 18 | // FiXME | ||
| 19 | //#include <AudioClient.h> | ||
| 20 | #include <AudioConstants.h> | ||
| 21 | #include <Transform.h> | 18 | #include <Transform.h> |
| 22 | 19 | ||
| 23 | #include "ScriptEngineLogging.h" | 20 | #include "ScriptEngineLogging.h" |
| 24 | 21 | ||
| 25 | typedef int16_t AudioSample; | ||
| 26 | |||
| 27 | |||
| 28 | using namespace recording; | 22 | using namespace recording; |
| 29 | 23 | ||
| 30 | // FIXME move to somewhere audio related? | ||
| 31 | static const QString AUDIO_FRAME_NAME = "com.highfidelity.recording.Audio"; | ||
| 32 | 24 | ||
| 33 | RecordingScriptingInterface::RecordingScriptingInterface() { | 25 | RecordingScriptingInterface::RecordingScriptingInterface() { |
| 34 | static const recording::FrameType AVATAR_FRAME_TYPE = recording::Frame::registerFrameType(AvatarData::FRAME_NAME); | ||
| 35 | // FIXME how to deal with driving multiple avatars locally? | ||
| 36 | Frame::registerFrameHandler(AVATAR_FRAME_TYPE, [this](Frame::ConstPointer frame) { | ||
| 37 | processAvatarFrame(frame); | ||
| 38 | }); | ||
| 39 | |||
| 40 | static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AUDIO_FRAME_NAME); | ||
| 41 | Frame::registerFrameHandler(AUDIO_FRAME_TYPE, [this](Frame::ConstPointer frame) { | ||
| 42 | processAudioFrame(frame); | ||
| 43 | }); | ||
| 44 | |||
| 45 | _player = DependencyManager::get<Deck>(); | 26 | _player = DependencyManager::get<Deck>(); |
| 46 | _recorder = DependencyManager::get<Recorder>(); | 27 | _recorder = DependencyManager::get<Recorder>(); |
| 47 | |||
| 48 | // FIXME : Disabling Sound | ||
| 49 | // auto audioClient = DependencyManager::get<AudioClient>(); | ||
| 50 | // connect(audioClient.data(), &AudioClient::inputReceived, this, &RecordingScriptingInterface::processAudioInput); | ||
| 51 | } | ||
| 52 | |||
| 53 | void RecordingScriptingInterface::setControlledAvatar(AvatarData* avatar) { | ||
| 54 | _controlledAvatar = avatar; | ||
| 55 | } | 28 | } |
| 56 | 29 | ||
| 57 | bool RecordingScriptingInterface::isPlaying() const { | 30 | bool RecordingScriptingInterface::isPlaying() const { |
| @@ -92,12 +65,6 @@ void RecordingScriptingInterface::startPlaying() { · 34 unmodified lines | |||
| 92 | return; | 65 | return; |
| 93 | } | 66 | } |
| 94 | 67 | ||
| 95 | // Playback from the current position | ||
| 96 | if (_playFromCurrentLocation && _controlledAvatar) { | ||
| 97 | _dummyAvatar.setRecordingBasis(std::make_shared<Transform>(_controlledAvatar->getTransform())); | ||
| 98 | } else { | ||
| 99 | _dummyAvatar.clearRecordingBasis(); | ||
| 100 | } | ||
| 101 | _player->play(); | 68 | _player->play(); |
| 102 | } | 69 | } |
| 103 | 70 | ||
| @@ -176,12 +143,6 @@ void RecordingScriptingInterface::startRecording() { · 72 unmodified lines | |||
| 176 | return; | 143 | return; |
| 177 | } | 144 | } |
| 178 | 145 | ||
| 179 | _recordingEpoch = Frame::epochForFrameTime(0); | ||
| 180 | |||
| 181 | if (_controlledAvatar) { | ||
| 182 | _controlledAvatar->setRecordingBasis(); | ||
| 183 | } | ||
| 184 | |||
| 185 | _recorder->start(); | 146 | _recorder->start(); |
| 186 | } | 147 | } |
| 187 | 148 | ||
| @@ -189,10 +150,6 @@ void RecordingScriptingInterface::stopRecording() { · 1 unmodified line | |||
| 189 | _recorder->stop(); | 150 | _recorder->stop(); |
| 190 | _lastClip = _recorder->getClip(); | 151 | _lastClip = _recorder->getClip(); |
| 191 | _lastClip->seek(0); | 152 | _lastClip->seek(0); |
| 192 | |||
| 193 | if (_controlledAvatar) { | ||
| 194 | _controlledAvatar->clearRecordingBasis(); | ||
| 195 | } | ||
| 196 | } | 153 | } |
| 197 | 154 | ||
| 198 | void RecordingScriptingInterface::saveRecording(const QString& filename) { | 155 | void RecordingScriptingInterface::saveRecording(const QString& filename) { |
| @@ -225,50 +182,3 @@ void RecordingScriptingInterface::loadLastRecording() { · 26 unmodified lines | |||
| 225 | _player->play(); | 182 | _player->play(); |
| 226 | } | 183 | } |
| 227 | 184 | ||
| 228 | void RecordingScriptingInterface::processAvatarFrame(const Frame::ConstPointer& frame) { | ||
| 229 | Q_ASSERT(QThread::currentThread() == thread()); | ||
| 230 | |||
| 231 | if (!_controlledAvatar) { | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | |||
| 235 | AvatarData::fromFrame(frame->data, _dummyAvatar); | ||
| 236 | |||
| 237 | |||
| 238 | |||
| 239 | if (_useHeadModel && _dummyAvatar.getFaceModelURL().isValid() && | ||
| 240 | (_dummyAvatar.getFaceModelURL() != _controlledAvatar->getFaceModelURL())) { | ||
| 241 | // FIXME | ||
| 242 | //myAvatar->setFaceModelURL(_dummyAvatar.getFaceModelURL()); | ||
| 243 | } | ||
| 244 | |||
| 245 | if (_useSkeletonModel && _dummyAvatar.getSkeletonModelURL().isValid() && | ||
| 246 | (_dummyAvatar.getSkeletonModelURL() != _controlledAvatar->getSkeletonModelURL())) { | ||
| 247 | // FIXME | ||
| 248 | //myAvatar->useFullAvatarURL() | ||
| 249 | } | ||
| 250 | |||
| 251 | if (_useDisplayName && _dummyAvatar.getDisplayName() != _controlledAvatar->getDisplayName()) { | ||
| 252 | _controlledAvatar->setDisplayName(_dummyAvatar.getDisplayName()); | ||
| 253 | } | ||
| 254 | |||
| 255 | _controlledAvatar->setPosition(_dummyAvatar.getPosition()); | ||
| 256 | _controlledAvatar->setOrientation(_dummyAvatar.getOrientation()); | ||
| 257 | |||
| 258 | // FIXME attachments | ||
| 259 | // FIXME joints | ||
| 260 | // FIXME head lean | ||
| 261 | // FIXME head orientation | ||
| 262 | } | ||
| 263 | |||
| 264 | void RecordingScriptingInterface::processAudioInput(const QByteArray& audio) { | ||
| 265 | if (_recorder->isRecording()) { | ||
| 266 | static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AUDIO_FRAME_NAME); | ||
| 267 | _recorder->recordFrame(AUDIO_FRAME_TYPE, audio); | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | void RecordingScriptingInterface::processAudioFrame(const recording::FrameConstPointer& frame) { | ||
| 272 | // auto audioClient = DependencyManager::get<AudioClient>(); | ||
| 273 | // audioClient->handleRecordedAudioInput(frame->data); | ||
| 274 | } | ||