public function endRecording($stream)
    {
        $parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']);
        $rtmp_app = end($parts);
        $success = $this->record(
            $this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'],
            $rtmp_app,
            $stream->getUniqID(),
            false
        );
        if ($success) {
            $stream->setTechnicalStatus(Stream::STATE_ENDED);
            $this->em->persist($stream);
            $this->em->flush();

            // $event = new EndRecordingStreamEvent($stream);
            // $this->dispatcher->dispatch(
            //     OktolabMediaEvent::STREAM_END_RECORDING,
            //     $event
            // );
            return true;
        }
        return false;
    }