// // Created by Bradley Austin Davis on 2015/11/13 // Copyright 2015 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_RecordingScriptingInterface_h #define hifi_RecordingScriptingInterface_h #include #include #include #include #include #include #include #include class QScriptEngine; class QScriptValue; class RecordingScriptingInterface : public QObject, public Dependency { Q_OBJECT public: RecordingScriptingInterface(); void setScriptEngine(QSharedPointer scriptEngine) { _scriptEngine = scriptEngine; } public slots: void loadRecording(const QString& url, QScriptValue callback = QScriptValue()); void startPlaying(); void pausePlayer(); void stopPlaying(); bool isPlaying() const; bool isPaused() const; float playerElapsed() const; float playerLength() const; void setPlayerVolume(float volume); void setPlayerAudioOffset(float audioOffset); void setPlayerTime(float time); void setPlayerLoop(bool loop); void setPlayerUseDisplayName(bool useDisplayName); void setPlayerUseAttachments(bool useAttachments); void setPlayerUseHeadModel(bool useHeadModel); void setPlayerUseSkeletonModel(bool useSkeletonModel); void setPlayFromCurrentLocation(bool playFromCurrentLocation); bool getPlayerUseDisplayName() { return _useDisplayName; } bool getPlayerUseAttachments() { return _useAttachments; } bool getPlayerUseHeadModel() { return _useHeadModel; } bool getPlayerUseSkeletonModel() { return _useSkeletonModel; } bool getPlayFromCurrentLocation() { return _playFromCurrentLocation; } void startRecording(); void stopRecording(); bool isRecording() const; float recorderElapsed() const; QString getDefaultRecordingSaveDirectory(); void saveRecording(const QString& filename); bool saveRecordingToAsset(QScriptValue getClipAtpUrl); void loadLastRecording(); protected: using Mutex = std::recursive_mutex; using Locker = std::unique_lock; using Flag = std::atomic; QSharedPointer _player; QSharedPointer _recorder; Flag _playFromCurrentLocation { true }; Flag _useDisplayName { false }; Flag _useHeadModel { false }; Flag _useAttachments { false }; Flag _useSkeletonModel { false }; recording::ClipPointer _lastClip; QSharedPointer _scriptEngine; QSet _clipLoaders; private: void playClip(recording::NetworkClipLoaderPointer clipLoader, const QString& url, QScriptValue callback); }; #endif // hifi_RecordingScriptingInterface_h