"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../../../Class/Functional");
const MediaStream_1 = require("../../../../../../wrap/MediaStream");
const _ids_1 = require("../../../../../_ids");
class MediaStreamDestinationNode_ extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['node'],
            o: ['stream'],
        }, {
            input: {
                node: {
                    ref: true,
                },
            },
            output: {
                stream: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_MEDIA_STREAM_DESTINATION_NODE);
    }
    f({ node }, done) {
        this._source = node;
        const ctx = node.getContext();
        const node_ = ctx.createMediaStreamDestination();
        this._node = node_;
        const stream_ = node_.stream;
        node.connect(node_);
        const stream = (0, MediaStream_1.wrapMediaStream)(stream_, this.__system);
        done({
            stream,
        });
    }
    d() {
        if (this._source) {
            this._source.disconnect(this._node);
            this._node = undefined;
        }
    }
}
exports.default = MediaStreamDestinationNode_;
//# sourceMappingURL=index.js.map